Skip to content

Commit

Permalink
Added "ParkourKit.BypassPotionCooldown" setting
Browse files Browse the repository at this point in the history
Tidied up ParkourKit config
Fix HideAll not applying to Player join afterwards
Fixed config upgrade not working
  • Loading branch information
A5H73Y committed Dec 23, 2023
1 parent 3a0395e commit fad5276
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build

env:
artifact_name: 'Parkour-7.2.1'
artifact_name: 'Parkour-7.2.2'
release_type: '-RELEASE'

on: push
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ For the list of known supported plugins and tutorials on how to set them up, [cl
<dependency>
<groupId>com.github.A5H73Y</groupId>
<artifactId>Parkour</artifactId>
<version>7.2.1</version>
<version>7.2.2</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
Expand All @@ -48,5 +48,5 @@ repositories {
```

```
compile 'com.github.A5H73Y:Parkour:7.2.1'
compile 'com.github.A5H73Y:Parkour:7.2.2'
```
10 changes: 8 additions & 2 deletions docs/changelogs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
15 changes: 8 additions & 7 deletions docs/tutorials/parkour-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -392,13 +385,21 @@ 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
GiveSign: true
# 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:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.a5h73y</groupId>
<artifactId>Parkour</artifactId>
<version>7.2.1</version>
<version>7.2.2</version>
<packaging>jar</packaging>

<name>Parkour</name>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/io/github/a5h73y/parkour/Parkour.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<BlockFace> 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");
}

/**
Expand Down Expand Up @@ -130,22 +133,23 @@ 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);
}
break;

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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -95,7 +95,6 @@ public boolean beginUpgrade() {
success = performPartialUpgrade();
}
} else {
// nothing to partially upgrade yet
success = performPartialUpgrade();
}

Expand Down Expand Up @@ -165,6 +164,8 @@ private boolean performPartialUpgrade() {
return false;
}

// reload the local config
defaultConfig = YamlConfiguration.loadConfiguration(defaultFile);
return new PlayerMinorUpgradeTask(this).start();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit fad5276

Please sign in to comment.