summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/bukkit/potion/PotionEffect.java13
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;
}