From fad52760f6f231c0040604685e6915a5d1b3e6ed Mon Sep 17 00:00:00 2001 From: A5H73Y Date: Sat, 23 Dec 2023 15:29:31 +0000 Subject: [PATCH] Added "ParkourKit.BypassPotionCooldown" setting Tidied up ParkourKit config Fix HideAll not applying to Player join afterwards Fixed config upgrade not working --- .github/workflows/maven-build.yml | 2 +- README.md | 4 ++-- docs/changelogs.md | 10 ++++++++-- docs/tutorials/parkour-config.md | 15 ++++++++------- pom.xml | 2 +- .../java/io/github/a5h73y/parkour/Parkour.java | 4 ++-- .../parkour/commands/ParkourCommands.java | 3 +++ .../configuration/impl/DefaultConfig.java | 7 ++++--- .../parkour/listener/PlayerListener.java | 12 ++++++++++++ .../listener/move/ParkourBlockListener.java | 18 +++++++++++------- .../parkour/upgrade/ParkourUpgrader.java | 5 +++-- .../upgrade/minor/ConfigMinorUpgradeTask.java | 7 +++++-- 12 files changed, 60 insertions(+), 29 deletions(-) diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml index 1609acba..00cb7208 100644 --- a/.github/workflows/maven-build.yml +++ b/.github/workflows/maven-build.yml @@ -1,7 +1,7 @@ name: Build env: - artifact_name: 'Parkour-7.2.1' + artifact_name: 'Parkour-7.2.2' release_type: '-RELEASE' on: push diff --git a/README.md b/README.md index 6e36ed06..7e3798a6 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ For the list of known supported plugins and tutorials on how to set them up, [cl com.github.A5H73Y Parkour - 7.2.1 + 7.2.2 jar provided @@ -48,5 +48,5 @@ repositories { ``` ``` -compile 'com.github.A5H73Y:Parkour:7.2.1' +compile 'com.github.A5H73Y:Parkour:7.2.2' ``` diff --git a/docs/changelogs.md b/docs/changelogs.md index 6fa8b6fd..53b2cdda 100644 --- a/docs/changelogs.md +++ b/docs/changelogs.md @@ -3,9 +3,15 @@ Changelogs Please note that each version of Parkour is backwards compatible with the previous version and will automatically upgrade your config upon server start up. There will be no manual intervention, unless stated in breaking changes. +## 7.2.2 + +* Added "ParkourKit.BypassPotionCooldown" setting +* Tidied up ParkourKit config +* Fix HideAll not applying to Player join afterwards + ## 7.2.1 -* Added option to disable "OnCourse.ParkourKit.FloatingClosestBlock" +* Added option to disable "ParkourKit.FloatingClosestBlock" * Improvement to use centre of each block when calculating closest block * Fixed various Challenge bugs * Fix NPE with placeholders @@ -18,7 +24,7 @@ Please note that each version of Parkour is backwards compatible with the previo * Added "Other.Display.CurrencyName" to show or hide currency name in messages * Added Throwables to be ParkourTools * Ability to disable nested parkour commands -* Added ability to affect vehicles with ParkourKit (OnCourse.ParkourKit.IncludeVehicles) +* Added ability to affect vehicles with ParkourKit (ParkourKit.IncludeVehicles) * Added ability to return items achieved while on Course (OnFinish.GiveGainedItemsBack & OnLeave.GiveGainedItemsBack) * Fixed decimal rewarddelay not working * Fixed teleporting away from a Course detection diff --git a/docs/tutorials/parkour-config.md b/docs/tutorials/parkour-config.md index c687269c..298f1120 100644 --- a/docs/tutorials/parkour-config.md +++ b/docs/tutorials/parkour-config.md @@ -92,13 +92,6 @@ OnCourse: SneakToInteractItems: true # Should achieving the final Checkpoint trigger the Course finish for the Player TreatLastCheckpointAsFinish: false - # Should ParkourKits be enabled. If this is set to false, finish blocks will no longer work and Courses must be finished using a Finish Sign or other means. - ParkourKit: - Enabled: true - # Should Vehicles be affected by ParkourKits when driven upon (excludes repulse and climb blocks) - IncludeVehicles: false - # Detect the closest block to the Player while floating on a solid block - FloatingClosestBlock: true # Should the Player be prevented from using non-Parkour commands EnforceParkourCommands: Enabled: true @@ -392,6 +385,12 @@ ParkourGUI: # ParkourKit settings ParkourKit: + # Should ParkourKits be enabled. If this is set to false, finish blocks will no longer work and Courses must be finished using a Finish Sign or other means. + Enabled: true + # Should Vehicles be affected by ParkourKits when driven upon (excludes repulse and climb blocks) + IncludeVehicles: false + # Detect the closest block to the Player while floating on a solid block + FloatingClosestBlock: true # When a Kit is requested, should it replace the Player's inventory ReplaceInventory: true # When a Kit is requested, should a Sign be included in the Kit @@ -399,6 +398,8 @@ ParkourKit: # Should the plugin use the legacy ground detection. # This will always check what is below the Player, for example when standing on a LILYPAD on WATER will consider the Material WATER, similar for CARPET. LegacyGroundDetection: false + # Should the Potion be re-applied to the Player when they already have it applied + BypassPotionCooldown: false # ParkourRank Chat settings ParkourRankChat: diff --git a/pom.xml b/pom.xml index d854829b..5c966b32 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 io.github.a5h73y Parkour - 7.2.1 + 7.2.2 jar Parkour diff --git a/src/main/java/io/github/a5h73y/parkour/Parkour.java b/src/main/java/io/github/a5h73y/parkour/Parkour.java index b97d201f..bbe8719f 100644 --- a/src/main/java/io/github/a5h73y/parkour/Parkour.java +++ b/src/main/java/io/github/a5h73y/parkour/Parkour.java @@ -249,10 +249,10 @@ private void registerEvents() { if (getDefaultConfig().getBoolean("AutoStart.Enabled")) { pluginManager.registerEvents(new AutoStartListener(this), this); } - if (getDefaultConfig().getBoolean("OnCourse.ParkourKit.Enabled")) { + if (getDefaultConfig().getBoolean("ParkourKit.Enabled")) { pluginManager.registerEvents(new ParkourBlockListener(this), this); } - if (getDefaultConfig().getBoolean("OnCourse.ParkourKit.IncludeVehicles")) { + if (getDefaultConfig().getBoolean("ParkourKit.IncludeVehicles")) { pluginManager.registerEvents(new VehicleMoveListener(this), this); } } diff --git a/src/main/java/io/github/a5h73y/parkour/commands/ParkourCommands.java b/src/main/java/io/github/a5h73y/parkour/commands/ParkourCommands.java index f030fcda..8dfde223 100644 --- a/src/main/java/io/github/a5h73y/parkour/commands/ParkourCommands.java +++ b/src/main/java/io/github/a5h73y/parkour/commands/ParkourCommands.java @@ -277,6 +277,9 @@ public boolean onCommand(@NotNull CommandSender sender, } else if (!ValidationUtils.validateArgs(player, args, 2, 100)) { return false; + + } else if (!parkour.getParkourConfig().getBoolean("ParkourKit.Enabled")) { + TranslationUtils.sendMessage(player, "&4ParkourKits have been disabled in the config."); } parkour.getParkourKitManager().processParkourKitCommand(player, args[1], diff --git a/src/main/java/io/github/a5h73y/parkour/configuration/impl/DefaultConfig.java b/src/main/java/io/github/a5h73y/parkour/configuration/impl/DefaultConfig.java index dd7542fc..1c99ab3e 100644 --- a/src/main/java/io/github/a5h73y/parkour/configuration/impl/DefaultConfig.java +++ b/src/main/java/io/github/a5h73y/parkour/configuration/impl/DefaultConfig.java @@ -96,9 +96,6 @@ public DefaultConfig(File file) { this.setDefault("OnCourse.SequentialCheckpoints.AlertPlayer", true); this.setDefault("OnCourse.SneakToInteractItems", true); this.setDefault("OnCourse.TreatLastCheckpointAsFinish", false); - this.setDefault("OnCourse.ParkourKit.Enabled", true); - this.setDefault("OnCourse.ParkourKit.IncludeVehicles", false); - this.setDefault("OnCourse.ParkourKit.FloatingClosestBlock", true); this.setDefault("OnCourse.EnforceParkourCommands.Enabled", true); this.setDefault("OnCourse.EnforceParkourCommands.Whitelist", Collections.singletonList("login")); this.setDefault("OnCourse.ManualCheckpointAnyPressurePlate", true); @@ -259,9 +256,13 @@ public DefaultConfig(File file) { this.setDefault("ParkourGUI.Material", "BOOK"); this.setDefault("ParkourGUI.FillerMaterial", XMaterial.CYAN_STAINED_GLASS_PANE.parseMaterial().name()); + this.setDefault("ParkourKit.Enabled", true); + this.setDefault("ParkourKit.IncludeVehicles", false); + this.setDefault("ParkourKit.FloatingClosestBlock", true); this.setDefault("ParkourKit.ReplaceInventory", true); this.setDefault("ParkourKit.GiveSign", true); this.setDefault("ParkourKit.LegacyGroundDetection", false); + this.setDefault("ParkourKit.BypassPotionCooldown", false); this.setDefault("ParkourRankChat.Enabled", false); this.setDefault("ParkourRankChat.OverrideChat", true); diff --git a/src/main/java/io/github/a5h73y/parkour/listener/PlayerListener.java b/src/main/java/io/github/a5h73y/parkour/listener/PlayerListener.java index 559fdea9..8f99c686 100644 --- a/src/main/java/io/github/a5h73y/parkour/listener/PlayerListener.java +++ b/src/main/java/io/github/a5h73y/parkour/listener/PlayerListener.java @@ -4,6 +4,7 @@ import io.github.a5h73y.parkour.other.AbstractPluginReceiver; import io.github.a5h73y.parkour.type.player.PlayerConfig; import io.github.a5h73y.parkour.type.player.session.ParkourSession; +import io.github.a5h73y.parkour.utility.PlayerUtils; import io.github.a5h73y.parkour.utility.TranslationUtils; import org.bukkit.GameMode; import org.bukkit.World; @@ -238,6 +239,17 @@ public void onPlayerJoin(PlayerJoinEvent event) { } } + /** + * Handle Players joining while Players have HideAll mode. + * @param event PlayerJoinEvent + */ + @EventHandler + public void onPlayerJoinRestoreHideall(PlayerJoinEvent event) { + parkour.getParkourSessionManager().getOnlineParkourPlayers().stream() + .filter(player -> parkour.getParkourSessionManager().hasHiddenPlayers(player)) + .forEach(player -> PlayerUtils.hidePlayer(player, event.getPlayer())); + } + /** * Handle Player Quitting Server. * Teardown the Player to remove any of their references before leaving. diff --git a/src/main/java/io/github/a5h73y/parkour/listener/move/ParkourBlockListener.java b/src/main/java/io/github/a5h73y/parkour/listener/move/ParkourBlockListener.java index ecb9e219..ee5e8099 100644 --- a/src/main/java/io/github/a5h73y/parkour/listener/move/ParkourBlockListener.java +++ b/src/main/java/io/github/a5h73y/parkour/listener/move/ParkourBlockListener.java @@ -8,9 +8,6 @@ import io.github.a5h73y.parkour.type.player.session.ParkourSession; import io.github.a5h73y.parkour.utility.MaterialUtils; import io.github.a5h73y.parkour.utility.PlayerUtils; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -21,16 +18,22 @@ import org.bukkit.potion.PotionEffectType; import org.bukkit.util.Vector; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; + public class ParkourBlockListener extends AbstractPluginReceiver implements Listener { public static final List BLOCK_FACES = Arrays.asList(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST); private final boolean floatingClosestBlock; + private final boolean bypassPotionCooldown; public ParkourBlockListener(final Parkour parkour) { super(parkour); - this.floatingClosestBlock = parkour.getParkourConfig().getBoolean("OnCourse.ParkourKit.FloatingClosestBlock"); + this.floatingClosestBlock = parkour.getParkourConfig().getBoolean("ParkourKit.FloatingClosestBlock"); + this.bypassPotionCooldown = parkour.getParkourConfig().getBoolean("ParkourKit.BypassPotionCooldown"); } /** @@ -130,14 +133,14 @@ private void performFloorAction(Player player, ParkourKitAction kitAction) { break; case BOUNCE: - if (!player.hasPotionEffect(PotionEffectType.JUMP)) { + if (!player.hasPotionEffect(PotionEffectType.JUMP) || bypassPotionCooldown) { PlayerUtils.applyPotionEffect(PotionEffectType.JUMP, kitAction.getDuration(), (int) kitAction.getStrength(), player); } break; case SPEED: - if (!player.hasPotionEffect(PotionEffectType.SPEED)) { + if (!player.hasPotionEffect(PotionEffectType.SPEED) || bypassPotionCooldown) { PlayerUtils.applyPotionEffect(PotionEffectType.SPEED, kitAction.getDuration(), (int) kitAction.getStrength(), player); } @@ -145,7 +148,8 @@ private void performFloorAction(Player player, ParkourKitAction kitAction) { case POTION: PotionEffectType effect = PotionEffectType.getByName(kitAction.getEffect()); - if (effect != null) { + + if (effect != null && (!player.hasPotionEffect(effect) || bypassPotionCooldown)) { PlayerUtils.applyPotionEffect(effect, kitAction.getDuration(), (int) kitAction.getStrength(), player); } diff --git a/src/main/java/io/github/a5h73y/parkour/upgrade/ParkourUpgrader.java b/src/main/java/io/github/a5h73y/parkour/upgrade/ParkourUpgrader.java index 0de4f198..35d86ad7 100644 --- a/src/main/java/io/github/a5h73y/parkour/upgrade/ParkourUpgrader.java +++ b/src/main/java/io/github/a5h73y/parkour/upgrade/ParkourUpgrader.java @@ -33,7 +33,7 @@ public class ParkourUpgrader extends AbstractPluginReceiver { private final File economyFile; private final File parkourKitFile; - private final FileConfiguration defaultConfig; + private FileConfiguration defaultConfig; private final FileConfiguration stringsConfig; private final FileConfiguration playerConfig; private final FileConfiguration inventoryConfig; @@ -95,7 +95,6 @@ public boolean beginUpgrade() { success = performPartialUpgrade(); } } else { - // nothing to partially upgrade yet success = performPartialUpgrade(); } @@ -165,6 +164,8 @@ private boolean performPartialUpgrade() { return false; } + // reload the local config + defaultConfig = YamlConfiguration.loadConfiguration(defaultFile); return new PlayerMinorUpgradeTask(this).start(); } diff --git a/src/main/java/io/github/a5h73y/parkour/upgrade/minor/ConfigMinorUpgradeTask.java b/src/main/java/io/github/a5h73y/parkour/upgrade/minor/ConfigMinorUpgradeTask.java index 93ea7040..dd9f9b9a 100644 --- a/src/main/java/io/github/a5h73y/parkour/upgrade/minor/ConfigMinorUpgradeTask.java +++ b/src/main/java/io/github/a5h73y/parkour/upgrade/minor/ConfigMinorUpgradeTask.java @@ -17,8 +17,11 @@ protected String getTitle() { @Override protected boolean doWork() { updateConfigEntry("ParkourModes.Rockets.SecondCooldown", "ParkourTool.Rockets.SecondCooldown"); - updateConfigEntry("OnCourse.UseParkourKit", "OnCourse.ParkourKit.Enabled"); - + updateConfigEntry("OnCourse.UseParkourKit", "ParkourKit.Enabled"); + updateConfigEntry("OnCourse.ParkourKit.Enabled", "ParkourKit.Enabled"); + updateConfigEntry("OnCourse.ParkourKit.IncludeVehicles", "ParkourKit.IncludeVehicles"); + updateConfigEntry("OnCourse.ParkourKit.FloatingClosestBlock", "ParkourKit.FloatingClosestBlock"); + this.config.forceReload(); return true; } }