Denies playing hardcore in a no-checkpoint arena

This commit is contained in:
Kristian Knarvik 2023-04-28 15:32:51 +02:00
parent e039840e89
commit fc1902e86a
4 changed files with 21 additions and 1 deletions

View File

@ -222,6 +222,15 @@ public class ParkourArena implements Arena {
return copy; return copy;
} }
/**
* Gets whether this arena has no checkpoints
*
* @return <p>True if this arena has no checkpoints</p>
*/
public boolean hasNoCheckpoints() {
return this.checkpoints.isEmpty();
}
/** /**
* Gets this arena's sanitized name * Gets this arena's sanitized name
* *

View File

@ -18,7 +18,7 @@ public enum ParkourArenaGameMode implements ConfigurationSerializable, ArenaGame
DEFAULT, DEFAULT,
/** /**
* A hard-core game mode where no checkpoints are allowed * A hardcore game mode where no checkpoints are allowed
*/ */
HARDCORE, HARDCORE,
; ;

View File

@ -71,6 +71,12 @@ public class JoinParkourArenaCommand implements CommandExecutor {
gameMode = ParkourArenaGameMode.DEFAULT; gameMode = ParkourArenaGameMode.DEFAULT;
} }
// Don't allow joining the hardcore game-mode if there are no checkpoints to skip
if (specifiedArena.hasNoCheckpoints() && gameMode == ParkourArenaGameMode.HARDCORE) {
player.sendMessage(Message.ERROR_HARDCORE_NO_CHECKPOINTS.getMessage());
return false;
}
// Make sure the player has beaten the necessary levels // Make sure the player has beaten the necessary levels
ParkourArenaGroup arenaGroup = MiniGames.getInstance().getParkourArenaHandler().getGroup(specifiedArena.getArenaId()); ParkourArenaGroup arenaGroup = MiniGames.getInstance().getParkourArenaHandler().getGroup(specifiedArena.getArenaId());
if (arenaGroup != null && !doGroupChecks(specifiedArena, arenaGroup, gameMode, player)) { if (arenaGroup != null && !doGroupChecks(specifiedArena, arenaGroup, gameMode, player)) {

View File

@ -135,6 +135,11 @@ public enum Message {
*/ */
ERROR_ILLEGAL_COMMAND("&cYou cannot use that command while in an arena!"), ERROR_ILLEGAL_COMMAND("&cYou cannot use that command while in an arena!"),
/**
* The message displayed if the player is trying to join a parkour arena on hardcore which has no checkpoints
*/
ERROR_HARDCORE_NO_CHECKPOINTS("&cThis arena cannot be played in hardcore mode as it has no checkpoints!"),
/* **************** * /* **************** *
* Success messages * * Success messages *
* **************** */ * **************** */