diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/potion/PotionEffect.java | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/src/main/java/org/bukkit/potion/PotionEffect.java b/src/main/java/org/bukkit/potion/PotionEffect.java index e7b86f85..86616f1b 100644 --- a/src/main/java/org/bukkit/potion/PotionEffect.java +++ b/src/main/java/org/bukkit/potion/PotionEffect.java @@ -24,12 +24,13 @@ public class PotionEffect implements ConfigurationSerializable { private static final String TYPE = "effect"; private static final String AMBIENT = "ambient"; private static final String PARTICLES = "has-particles"; + private static final String ICON = "has-icon"; private final int amplifier; private final int duration; private final PotionEffectType type; private final boolean ambient; private final boolean particles; - private final Color color; + private final boolean icon; /** * Creates a potion effect. @@ -39,16 +40,16 @@ public class PotionEffect implements ConfigurationSerializable { * @param amplifier the amplifier, see {@link PotionEffect#getAmplifier()} * @param ambient the ambient status, see {@link PotionEffect#isAmbient()} * @param particles the particle status, see {@link PotionEffect#hasParticles()} - * @param color the particle color, see {@link PotionEffect#getColor()} + * @param icon the icon status, see {@link PotionEffect#hasIcon()} */ - public PotionEffect(PotionEffectType type, int duration, int amplifier, boolean ambient, boolean particles, Color color) { + public PotionEffect(PotionEffectType type, int duration, int amplifier, boolean ambient, boolean particles, boolean icon) { Validate.notNull(type, "effect type cannot be null"); this.type = type; this.duration = duration; this.amplifier = amplifier; this.ambient = ambient; this.particles = particles; - this.color = color; + this.icon = icon; } /** @@ -62,7 +63,7 @@ public class PotionEffect implements ConfigurationSerializable { * @param particles the particle status, see {@link PotionEffect#hasParticles()} */ public PotionEffect(PotionEffectType type, int duration, int amplifier, boolean ambient, boolean particles) { - this(type, duration, amplifier, ambient, particles, null); + this(type, duration, amplifier, ambient, particles, particles); } /** @@ -96,7 +97,7 @@ public class PotionEffect implements ConfigurationSerializable { * @param map the map to deserialize from */ public PotionEffect(Map<String, Object> map) { - this(getEffectType(map), getInt(map, DURATION), getInt(map, AMPLIFIER), getBool(map, AMBIENT, false), getBool(map, PARTICLES, true)); + this(getEffectType(map), getInt(map, DURATION), getInt(map, AMPLIFIER), getBool(map, AMBIENT, false), getBool(map, PARTICLES, true), getBool(map, ICON, getBool(map, PARTICLES, true))); } private static PotionEffectType getEffectType(Map<?, ?> map) { @@ -125,13 +126,14 @@ public class PotionEffect implements ConfigurationSerializable { } public Map<String, Object> serialize() { - return ImmutableMap.<String, Object>of( - TYPE, type.getId(), - DURATION, duration, - AMPLIFIER, amplifier, - AMBIENT, ambient, - PARTICLES, particles - ); + return ImmutableMap.<String, Object>builder() + .put(TYPE, type.getId()) + .put(DURATION, duration) + .put(AMPLIFIER, amplifier) + .put(AMBIENT, ambient) + .put(PARTICLES, particles) + .put(ICON, icon) + .build(); } /** @@ -155,7 +157,7 @@ public class PotionEffect implements ConfigurationSerializable { return false; } PotionEffect that = (PotionEffect) obj; - return this.type.equals(that.type) && this.ambient == that.ambient && this.amplifier == that.amplifier && this.duration == that.duration && this.particles == that.particles; + return this.type.equals(that.type) && this.ambient == that.ambient && this.amplifier == that.amplifier && this.duration == that.duration && this.particles == that.particles && this.icon == that.icon; } /** @@ -206,9 +208,18 @@ public class PotionEffect implements ConfigurationSerializable { /** * @return color of this potion's particles. May be null if the potion has no particles or defined color. + * @deprecated color is not part of potion effects */ + @Deprecated public Color getColor() { - return color; + return null; + } + + /** + * @return whether this effect has an icon or not + */ + public boolean hasIcon() { + return icon; } @Override @@ -219,6 +230,7 @@ public class PotionEffect implements ConfigurationSerializable { hash = hash * 31 + duration; hash ^= 0x22222222 >> (ambient ? 1 : -1); hash ^= 0x22222222 >> (particles ? 1 : -1); + hash ^= 0x22222222 >> (icon ? 1 : -1); return hash; } |