Add setting 'toggle-on-move-delay'

This commit is contained in:
Esophose 2019-01-27 21:15:03 -07:00
parent a0826ae06c
commit c14f76e611
4 changed files with 15 additions and 3 deletions

View file

@ -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),

View file

@ -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;
}

View file

@ -19,7 +19,6 @@ import com.esophose.playerparticles.manager.SettingManager.PSetting;
public class PPlayerMovementListener implements Listener {
private static Map<UUID, Integer> timeSinceLastMovement = new HashMap<UUID, Integer>();
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);
}
}

View file

@ -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: []