diff options
author | Thinkofdeath <thinkofdeath@spigotmc.org> | 2015-03-11 11:53:20 +0000 |
---|---|---|
committer | Thinkofdeath <thinkofdeath@spigotmc.org> | 2015-03-11 11:53:20 +0000 |
commit | 8f84f08506c18b46f3975d9c0192664e4fff1822 (patch) | |
tree | 32bb3ee84b2da7f91965fe7a80259db365f64f33 | |
parent | 82f9df99196967fd21216fdc211f0e2ec3255ffd (diff) | |
download | bukkit-8f84f08506c18b46f3975d9c0192664e4fff1822.tar bukkit-8f84f08506c18b46f3975d9c0192664e4fff1822.tar.gz bukkit-8f84f08506c18b46f3975d9c0192664e4fff1822.tar.lz bukkit-8f84f08506c18b46f3975d9c0192664e4fff1822.tar.xz bukkit-8f84f08506c18b46f3975d9c0192664e4fff1822.zip |
SPIGOT-678: Fix the particles flag being ignored in hashCode, equals and serialization
-rw-r--r-- | src/main/java/org/bukkit/potion/PotionEffect.java | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main/java/org/bukkit/potion/PotionEffect.java b/src/main/java/org/bukkit/potion/PotionEffect.java index 01503f49..75bfa27a 100644 --- a/src/main/java/org/bukkit/potion/PotionEffect.java +++ b/src/main/java/org/bukkit/potion/PotionEffect.java @@ -22,6 +22,7 @@ public class PotionEffect implements ConfigurationSerializable { private static final String DURATION = "duration"; private static final String TYPE = "effect"; private static final String AMBIENT = "ambient"; + private static final String PARTICLES = "has-particles"; private final int amplifier; private final int duration; private final PotionEffectType type; @@ -77,7 +78,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)); + this(getEffectType(map), getInt(map, DURATION), getInt(map, AMPLIFIER), getBool(map, AMBIENT, false), getBool(map, PARTICLES, true)); } private static PotionEffectType getEffectType(Map<?,?> map) { @@ -97,12 +98,12 @@ public class PotionEffect implements ConfigurationSerializable { throw new NoSuchElementException(map + " does not contain " + key); } - private static boolean getBool(Map<?,?> map, Object key) { + private static boolean getBool(Map<?,?> map, Object key, boolean def) { Object bool = map.get(key); if (bool instanceof Boolean) { return (Boolean) bool; } - throw new NoSuchElementException(map + " does not contain " + key); + return def; } public Map<String, Object> serialize() { @@ -110,7 +111,8 @@ public class PotionEffect implements ConfigurationSerializable { TYPE, type.getId(), DURATION, duration, AMPLIFIER, amplifier, - AMBIENT, ambient + AMBIENT, ambient, + PARTICLES, particles ); } @@ -135,7 +137,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; + return this.type.equals(that.type) && this.ambient == that.ambient && this.amplifier == that.amplifier && this.duration == that.duration && this.particles == that.particles; } /** @@ -191,6 +193,7 @@ public class PotionEffect implements ConfigurationSerializable { hash = hash * 31 + amplifier; hash = hash * 31 + duration; hash ^= 0x22222222 >> (ambient ? 1 : -1); + hash ^= 0x22222222 >> (particles ? 1 : -1); return hash; } |