Change how toggle-on-move setting works

This commit is contained in:
Esophose 2020-04-15 12:52:34 -06:00
parent b2a5aa2eab
commit 6936e516d7
4 changed files with 23 additions and 15 deletions

View file

@ -1,5 +1,8 @@
=== v7.8 ===
* Moved GUI icon settings from the config.yml to the effects/ and styles/ files. You will need to set these again.
* Fixed the messages-enabled setting not working at all
* Changed toggle-on-move to have three different setting values (DISPLAY_MOVE, HIDE, NONE)
* Changed how particle styles are registered
=== v7.7 ===
* Fixed an error with the style 'blockplace'
=== v7.6 ===

View file

@ -41,7 +41,7 @@ public class ConfigurationManager extends Manager {
GUI_PRESETS_ONLY("gui-presets-only", false, "If true, only the preset groups will be available in the GUI", "Permissions to open the GUI will change to only open if the user has any preset groups available"),
GUI_CLOSE_AFTER_GROUP_SELECTED("gui-close-after-group-selected", true, "If true, the GUI will close after selecting a group (either saved or preset)"),
GUI_BUTTON_SOUND("gui-button-sound", true, "If clicking a GUI button should make a noise"),
TOGGLE_ON_MOVE("toggle-on-move", false, "If true, styles will not display while the player is moving", "They will instead have the effect displayed at their feet", "Note: Not all styles abide by this rule, but most will"),
TOGGLE_ON_MOVE("toggle-on-move", "NONE", "Valid values: DISPLAY_FEET, HIDE, NONE", "DISPLAY_FEET will display particles under the player while moving", "HIDE will hide particles while moving", "NONE will make this setting do nothing", "Note: You can change what styles follow this setting in their individual setting files"),
TOGGLE_ON_MOVE_DELAY("toggle-on-move-delay", 9, "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"),
TOGGLE_ON_COMBAT("toggle-on-combat", false, "If true, particles will be completely disabled while the player is in combat"),
TOGGLE_ON_COMBAT_DELAY("toggle-on-combat-delay", 15, "The time (in seconds) a player has to not be damaged/attacked to be considered out of combat", "This setting has no effect if toggle-on-combat is set to false", "The value must be a positive whole number"),
@ -149,7 +149,7 @@ public class ConfigurationManager extends Manager {
*/
public String getString() {
this.loadValue();
return (String) this.value;
return String.valueOf(this.value);
}
private double getNumber() {

View file

@ -175,13 +175,23 @@ public class ParticleManager extends Manager implements Listener, Runnable {
if (Setting.TOGGLE_ON_COMBAT.getBoolean() && pplayer.isInCombat())
return;
if (Setting.TOGGLE_ON_MOVE.getBoolean() && particle.getStyle().canToggleWithMovement() && pplayer.isMoving()) {
for (PParticle pparticle : DefaultStyles.FEET.getParticles(particle, location))
ParticleEffect.display(particle, pparticle, particle.getStyle().hasLongRangeVisibility(), pplayer.getPlayer());
} else {
for (PParticle pparticle : particle.getStyle().getParticles(particle, location))
ParticleEffect.display(particle, pparticle, particle.getStyle().hasLongRangeVisibility(), pplayer.getPlayer());
if (particle.getStyle().canToggleWithMovement() && pplayer.isMoving()) {
switch (Setting.TOGGLE_ON_MOVE.getString().toUpperCase()) {
case "DISPLAY_FEET":
case "TRUE": // Old default value, keep here for legacy config compatibility
for (PParticle pparticle : DefaultStyles.FEET.getParticles(particle, location))
ParticleEffect.display(particle, pparticle, particle.getStyle().hasLongRangeVisibility(), pplayer.getPlayer());
return;
case "NONE":
case "FALSE": // Old default value, keep here for legacy config compatibility
break;
default:
return;
}
}
for (PParticle pparticle : particle.getStyle().getParticles(particle, location))
ParticleEffect.display(particle, pparticle, particle.getStyle().hasLongRangeVisibility(), pplayer.getPlayer());
}
}

View file

@ -19,15 +19,13 @@ import org.bukkit.event.player.PlayerMoveEvent;
public class PPlayerMovementListener implements Listener {
private static final int CHECK_INTERVAL = 3;
private Map<UUID, Integer> timeSinceLastMovement = new HashMap<>();
private Map<UUID, Integer> timeSinceLastMovement;
public PPlayerMovementListener() {
DataManager dataManager = PlayerParticles.getInstance().getManager(DataManager.class);
this.timeSinceLastMovement = new HashMap<>();
Bukkit.getScheduler().runTaskTimer(PlayerParticles.getInstance(), () -> {
if (!Setting.TOGGLE_ON_MOVE.getBoolean())
return;
List<UUID> toRemove = new ArrayList<>();
for (UUID uuid : this.timeSinceLastMovement.keySet()) {
@ -54,9 +52,6 @@ public class PPlayerMovementListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerMove(PlayerMoveEvent event) {
if (!Setting.TOGGLE_ON_MOVE.getBoolean())
return;
Location to = event.getTo();
Location from = event.getFrom();
if (to == null || (to.getBlockX() == from.getBlockX() && to.getBlockY() == from.getBlockY() && to.getBlockZ() == from.getBlockZ()))