Added can-toggle-with-combat, added two more toggle-on-move options

This commit is contained in:
Esophose 2020-04-19 16:14:54 -06:00
parent 5d55eb05c2
commit 826f37330b
5 changed files with 33 additions and 4 deletions

View file

@ -1,4 +1,6 @@
=== v7.9 ===
+ Added options DISPLAY_NORMAL and DISPLAY_OVERHEAD to toggle-on-move
+ Added setting in each style setting file for can-toggle-on-combat
* Fixed performance issues with toggle-on-move setting
* Fixed possible concurrency deadlock with arrows and fishing styles
=== v7.8 ===

View file

@ -41,9 +41,9 @@ 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", "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("toggle-on-move", "NONE", "Valid values: DISPLAY_FEET, DISPLAY_NORMAL, DISPLAY_OVERHEAD, HIDE, NONE", "DISPLAY_FEET will display particles using the feet style while moving", "DISPLAY_NORMAL will display particles using the normal style while moving", "DISPLAY_OVERHEAD will display particles using the overhead style 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("toggle-on-combat", false, "If true, particles will be completely disabled while the player is in combat", "Note: You can change what styles follow this setting in their individual setting files"),
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"),
DISABLED_WORLDS("disabled-worlds", Collections.singletonList("disabled_world_name"), "A list of worlds that the plugin is disabled in"),
MAX_PARTICLES("max-particles", 3, "The maximum number of particles a player can apply at once", "The GUI will only display up to 21, don't set this any higher than that"),

View file

@ -172,7 +172,7 @@ public class ParticleManager extends Manager implements Listener, Runnable {
*/
private void displayParticles(PPlayer pplayer, ParticlePair particle, Location location) {
if (!this.playerParticles.getManager(ParticleStyleManager.class).isEventHandled(particle.getStyle())) {
if (Setting.TOGGLE_ON_COMBAT.getBoolean() && pplayer.isInCombat())
if (Setting.TOGGLE_ON_COMBAT.getBoolean() && particle.getStyle().canToggleWithCombat() && pplayer.isInCombat())
return;
if (particle.getStyle().canToggleWithMovement() && pplayer.isMoving()) {
@ -182,6 +182,14 @@ public class ParticleManager extends Manager implements Listener, Runnable {
for (PParticle pparticle : DefaultStyles.FEET.getParticles(particle, location))
ParticleEffect.display(particle, pparticle, particle.getStyle().hasLongRangeVisibility(), pplayer.getPlayer());
return;
case "DISPLAY_NORMAL":
for (PParticle pparticle : DefaultStyles.NORMAL.getParticles(particle, location))
ParticleEffect.display(particle, pparticle, particle.getStyle().hasLongRangeVisibility(), pplayer.getPlayer());
return;
case "DISPLAY_OVERHEAD":
for (PParticle pparticle : DefaultStyles.OVERHEAD.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;

View file

@ -17,12 +17,14 @@ public abstract class DefaultParticleStyle implements ParticleStyle {
private String internalStyleName;
private boolean canBeFixedByDefault;
private boolean canToggleWithMovementByDefault;
private boolean canToggleWithCombatByDefault;
private double fixedEffectOffsetByDefault;
private String styleName;
private boolean enabled;
private boolean canBeFixed;
private boolean canToggleWithMovement;
private boolean canToggleWithCombat;
private double fixedEffectOffset;
private Material guiIconMaterial;
@ -30,6 +32,7 @@ public abstract class DefaultParticleStyle implements ParticleStyle {
this.internalStyleName = internalStyleName;
this.canBeFixedByDefault = canBeFixedByDefault;
this.canToggleWithMovementByDefault = canToggleWithMovementByDefault;
this.canToggleWithCombatByDefault = true;
this.fixedEffectOffsetByDefault = fixedEffectOffsetByDefault;
this.playerParticles = PlayerParticles.getInstance();
@ -52,6 +55,7 @@ public abstract class DefaultParticleStyle implements ParticleStyle {
this.setIfNotExists("enabled", true, "If the style is enabled or not");
this.setIfNotExists("can-be-fixed", this.canBeFixedByDefault, "If the style can be used in /pp fixed");
this.setIfNotExists("can-toggle-with-movement", this.canToggleWithMovementByDefault, "If the style will only be shown at the player's feet while moving");
this.setIfNotExists("can-toggle-with-combat", this.canToggleWithCombatByDefault, "If particles for this style will be hidden if the player is in combat");
this.setIfNotExists("fixed-effect-offset", this.fixedEffectOffsetByDefault, "How far vertically to offset the style position for fixed effects");
this.setIfNotExists("gui-icon-material", this.getGuiIconMaterialNames(), "The material of the icon to display in the GUI");
@ -74,6 +78,7 @@ public abstract class DefaultParticleStyle implements ParticleStyle {
this.enabled = this.config.getBoolean("enabled");
this.canBeFixed = this.config.getBoolean("can-be-fixed");
this.canToggleWithMovement = this.config.getBoolean("can-toggle-with-movement");
this.canToggleWithCombat = this.config.getBoolean("can-toggle-with-combat");
this.fixedEffectOffset = this.config.getDouble("fixed-effect-offset");
this.guiIconMaterial = ParticleUtils.closestMatchWithFallback(true, this.config.getStringList("gui-icon-material").toArray(new String[0]));
@ -132,6 +137,11 @@ public abstract class DefaultParticleStyle implements ParticleStyle {
return this.canToggleWithMovement;
}
@Override
public final boolean canToggleWithCombat() {
return this.canToggleWithCombat;
}
@Override
public final double getFixedEffectOffset() {
return this.fixedEffectOffset;

View file

@ -59,13 +59,22 @@ public interface ParticleStyle {
boolean canBeFixed();
/**
* Gets if the style can be replaced with DefaultStyles.FEET when the player is moving
* Gets if the style can be displayed differently based on the toggle-on-move setting when the player is moving
*
* @return True if it can be, otherwise False
*/
default boolean canToggleWithMovement() {
return true;
}
/**
* Gets if the style can be hidden if the player is in combat with the toggle-on-combat setting
*
* @return True if it can be, otherwise False
*/
default boolean canToggleWithCombat() {
return true;
}
/**
* The Y-axis offset to be applied when using '/pp fixed create looking'