From c14f76e611a804ea67c4929e59dd8ad45f3ad7cb Mon Sep 17 00:00:00 2001 From: Esophose Date: Sun, 27 Jan 2019 21:15:03 -0700 Subject: [PATCH] Add setting 'toggle-on-move-delay' --- .../esophose/playerparticles/manager/SettingManager.java | 2 ++ src/com/esophose/playerparticles/particles/PPlayer.java | 5 +++++ .../playerparticles/particles/PPlayerMovementListener.java | 5 ++--- src/config.yml | 6 ++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/com/esophose/playerparticles/manager/SettingManager.java b/src/com/esophose/playerparticles/manager/SettingManager.java index 47fe57d..47d61da 100644 --- a/src/com/esophose/playerparticles/manager/SettingManager.java +++ b/src/com/esophose/playerparticles/manager/SettingManager.java @@ -33,7 +33,9 @@ public class SettingManager { CHECK_UPDATES(PSettingType.BOOLEAN), GUI_ENABLED(PSettingType.BOOLEAN), GUI_BUTTON_SOUND(PSettingType.BOOLEAN), + TOGGLE_ON_MOVE(PSettingType.BOOLEAN), + TOGGLE_ON_MOVE_DELAY(PSettingType.INTEGER), PARTICLE_RENDER_RANGE_PLAYER(PSettingType.INTEGER), PARTICLE_RENDER_RANGE_FIXED_EFFECT(PSettingType.INTEGER), diff --git a/src/com/esophose/playerparticles/particles/PPlayer.java b/src/com/esophose/playerparticles/particles/PPlayer.java index fb646fd..2da3a16 100644 --- a/src/com/esophose/playerparticles/particles/PPlayer.java +++ b/src/com/esophose/playerparticles/particles/PPlayer.java @@ -118,6 +118,11 @@ public class PPlayer { this.isMoving = isMoving; } + /** + * Gets if a player is moving + * + * @return True if the player is moving + */ public boolean isMoving() { return this.isMoving; } diff --git a/src/com/esophose/playerparticles/particles/PPlayerMovementListener.java b/src/com/esophose/playerparticles/particles/PPlayerMovementListener.java index 21cfa31..f086596 100644 --- a/src/com/esophose/playerparticles/particles/PPlayerMovementListener.java +++ b/src/com/esophose/playerparticles/particles/PPlayerMovementListener.java @@ -19,7 +19,6 @@ import com.esophose.playerparticles.manager.SettingManager.PSetting; public class PPlayerMovementListener implements Listener { private static Map timeSinceLastMovement = new HashMap(); - private static final int STANDING_TIME = 9; private static final int CHECK_INTERVAL = 3; public PPlayerMovementListener() { @@ -35,8 +34,8 @@ public class PPlayerMovementListener implements Listener { toRemove.add(uuid); } else { int standingTime = timeSinceLastMovement.get(uuid); - pplayer.setMoving(standingTime < STANDING_TIME); - if (standingTime < STANDING_TIME) + pplayer.setMoving(standingTime < PSetting.TOGGLE_ON_MOVE_DELAY.getInt()); + if (standingTime < PSetting.TOGGLE_ON_MOVE_DELAY.getInt()) timeSinceLastMovement.replace(uuid, standingTime + CHECK_INTERVAL); } } diff --git a/src/config.yml b/src/config.yml index e89991e..c134fa8 100644 --- a/src/config.yml +++ b/src/config.yml @@ -51,6 +51,12 @@ gui-button-sound: true # Default: false toggle-on-move: false +# The time (in ticks) a player has to be standing still before they are considered to be stopped +# This setting has no effect if toggle-on-move is set to false +# The value must be a positive whole number +# Default: 9 +toggle-on-move-delay: 9 + # The worlds which this plugin is disabled in # Remove the [] before you enter world names # Default: []