diff --git a/README.md b/README.md index 226abf6..ea7a708 100644 --- a/README.md +++ b/README.md @@ -149,12 +149,13 @@ You could use `/droppergroupswap Sea Savanna` to change the order to: ### Parkour -| Name | Type | Default | Description | -|-----------------------------------|------------|--------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| mustDoGroupedInSequence | true/false | true | Whether grouped dropper arenas must be played in the correct sequence | -| ignoreRecordsUntilGroupBeatenOnce | true/false | false | Whether records won't be registered unless the player has already beaten all arenas in a group. That means players are required to do a second play-through to register a record for a grouped arena. | -| makePlayersInvisible | true/false | false | Whether players should be made invisible while playing in a dropper arena | -| killPlaneBlocks | list | [see this](#killplaneblocks-default) | The types of blocks compromising parkour arenas' kill planes. Add any materials you want to use for the "bottom" of your parkour arenas. +WOOL and other block tags are supported. | +| Name | Type | Default | Description | +|-----------------------------------|------------|--------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| enforceCheckpointOrder | true/false | false | Whether to enforce the order in which a player must reach checkpoints. Enabling this ensures that a player cannot trigger a previous checkpoint by accident. It also ensures players cannot skip a checkpoint, even if the arena layout makes it possible. | +| mustDoGroupedInSequence | true/false | true | Whether grouped dropper arenas must be played in the correct sequence | +| ignoreRecordsUntilGroupBeatenOnce | true/false | false | Whether records won't be registered unless the player has already beaten all arenas in a group. That means players are required to do a second play-through to register a record for a grouped arena. | +| makePlayersInvisible | true/false | false | Whether players should be made invisible while playing in a dropper arena | +| killPlaneBlocks | list | [see this](#killplaneblocks-default) | The types of blocks compromising parkour arenas' kill planes. Add any materials you want to use for the "bottom" of your parkour arenas. +WOOL and other block tags are supported. | #### blockWhitelist default: diff --git a/src/main/java/net/knarcraft/minigames/MiniGames.java b/src/main/java/net/knarcraft/minigames/MiniGames.java index 00eaaa7..f26726a 100644 --- a/src/main/java/net/knarcraft/minigames/MiniGames.java +++ b/src/main/java/net/knarcraft/minigames/MiniGames.java @@ -238,7 +238,7 @@ public final class MiniGames extends JavaPlugin { PluginManager pluginManager = getServer().getPluginManager(); pluginManager.registerEvents(new DamageListener(), this); - pluginManager.registerEvents(new MoveListener(this.dropperConfiguration), this); + pluginManager.registerEvents(new MoveListener(this.dropperConfiguration, this.parkourConfiguration), this); pluginManager.registerEvents(new PlayerLeaveListener(), this); pluginManager.registerEvents(new CommandListener(), this); diff --git a/src/main/java/net/knarcraft/minigames/arena/parkour/ParkourArena.java b/src/main/java/net/knarcraft/minigames/arena/parkour/ParkourArena.java index 212ebff..2494e02 100644 --- a/src/main/java/net/knarcraft/minigames/arena/parkour/ParkourArena.java +++ b/src/main/java/net/knarcraft/minigames/arena/parkour/ParkourArena.java @@ -393,6 +393,10 @@ public class ParkourArena implements Arena { * @return
True if successfully cleared
*/ public boolean clearCheckpoints() { + if (checkpoints.isEmpty()) { + return false; + } + this.checkpoints.clear(); this.parkourArenaHandler.saveArenas(); return true; diff --git a/src/main/java/net/knarcraft/minigames/config/ParkourConfiguration.java b/src/main/java/net/knarcraft/minigames/config/ParkourConfiguration.java index 16497ee..eb8703d 100644 --- a/src/main/java/net/knarcraft/minigames/config/ParkourConfiguration.java +++ b/src/main/java/net/knarcraft/minigames/config/ParkourConfiguration.java @@ -13,6 +13,7 @@ public class ParkourConfiguration extends MiniGameConfiguration { private final static String rootNode = "parkour."; + private boolean enforceCheckpointOrder; private boolean mustDoGroupedInSequence; private boolean ignoreRecordsUntilGroupBeatenOnce; private boolean makePlayersInvisible; @@ -27,6 +28,15 @@ public class ParkourConfiguration extends MiniGameConfiguration { super(configuration); } + /** + * Gets whether all checkpoints must be triggered in the order they are set when configuring the parkour arena + * + * @returnWhether checkpoints must be triggered in order
+ */ + public boolean enforceCheckpointOrder() { + return this.enforceCheckpointOrder; + } + /** * Gets whether grouped arenas must be done in the set sequence * @@ -65,6 +75,7 @@ public class ParkourConfiguration extends MiniGameConfiguration { @Override protected void load() { + this.enforceCheckpointOrder = configuration.getBoolean(rootNode + "enforceCheckpointOrder", false); this.mustDoGroupedInSequence = configuration.getBoolean(rootNode + "mustDoGroupedInSequence", true); this.ignoreRecordsUntilGroupBeatenOnce = configuration.getBoolean(rootNode + "ignoreRecordsUntilGroupBeatenOnce", false); this.makePlayersInvisible = configuration.getBoolean(rootNode + "makePlayersInvisible", false); diff --git a/src/main/java/net/knarcraft/minigames/listener/CommandListener.java b/src/main/java/net/knarcraft/minigames/listener/CommandListener.java index 4a89d85..05391d8 100644 --- a/src/main/java/net/knarcraft/minigames/listener/CommandListener.java +++ b/src/main/java/net/knarcraft/minigames/listener/CommandListener.java @@ -26,6 +26,8 @@ public class CommandListener implements Listener { ListThe configuration to use
+ * @param dropperConfigurationThe dropper configuration to use
+ * @param parkourConfigurationThe parkour configuration to use
*/ - public MoveListener(DropperConfiguration configuration) { - this.configuration = configuration; + public MoveListener(DropperConfiguration dropperConfiguration, ParkourConfiguration parkourConfiguration) { + this.dropperConfiguration = dropperConfiguration; + this.parkourConfiguration = parkourConfiguration; } @EventHandler @@ -70,9 +76,19 @@ public class MoveListener implements Listener { } // Check if the player reached one of the checkpoints for the arena - for (Location checkpoint : arenaSession.getArena().getCheckpoints()) { - if (checkpoint.getBlock().equals(event.getTo().getBlock()) && - !checkpoint.equals(arenaSession.getRegisteredCheckpoint())) { + ParkourArena arena = arenaSession.getArena(); + List