mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 19:49:35 +01:00
SPIGOT-678: Fix the particles flag being ignored in hashCode, equals and serialization
By: Thinkofdeath <thinkofdeath@spigotmc.org>
This commit is contained in:
parent
0693d6c758
commit
1b8726b2b5
1 changed files with 8 additions and 5 deletions
|
@ -22,6 +22,7 @@ public class PotionEffect implements ConfigurationSerializable {
|
||||||
private static final String DURATION = "duration";
|
private static final String DURATION = "duration";
|
||||||
private static final String TYPE = "effect";
|
private static final String TYPE = "effect";
|
||||||
private static final String AMBIENT = "ambient";
|
private static final String AMBIENT = "ambient";
|
||||||
|
private static final String PARTICLES = "has-particles";
|
||||||
private final int amplifier;
|
private final int amplifier;
|
||||||
private final int duration;
|
private final int duration;
|
||||||
private final PotionEffectType type;
|
private final PotionEffectType type;
|
||||||
|
@ -77,7 +78,7 @@ public class PotionEffect implements ConfigurationSerializable {
|
||||||
* @param map the map to deserialize from
|
* @param map the map to deserialize from
|
||||||
*/
|
*/
|
||||||
public PotionEffect(Map<String, Object> map) {
|
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) {
|
private static PotionEffectType getEffectType(Map<?,?> map) {
|
||||||
|
@ -97,12 +98,12 @@ public class PotionEffect implements ConfigurationSerializable {
|
||||||
throw new NoSuchElementException(map + " does not contain " + key);
|
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);
|
Object bool = map.get(key);
|
||||||
if (bool instanceof Boolean) {
|
if (bool instanceof Boolean) {
|
||||||
return (Boolean) bool;
|
return (Boolean) bool;
|
||||||
}
|
}
|
||||||
throw new NoSuchElementException(map + " does not contain " + key);
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> serialize() {
|
public Map<String, Object> serialize() {
|
||||||
|
@ -110,7 +111,8 @@ public class PotionEffect implements ConfigurationSerializable {
|
||||||
TYPE, type.getId(),
|
TYPE, type.getId(),
|
||||||
DURATION, duration,
|
DURATION, duration,
|
||||||
AMPLIFIER, amplifier,
|
AMPLIFIER, amplifier,
|
||||||
AMBIENT, ambient
|
AMBIENT, ambient,
|
||||||
|
PARTICLES, particles
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +137,7 @@ public class PotionEffect implements ConfigurationSerializable {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PotionEffect that = (PotionEffect) obj;
|
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 + amplifier;
|
||||||
hash = hash * 31 + duration;
|
hash = hash * 31 + duration;
|
||||||
hash ^= 0x22222222 >> (ambient ? 1 : -1);
|
hash ^= 0x22222222 >> (ambient ? 1 : -1);
|
||||||
|
hash ^= 0x22222222 >> (particles ? 1 : -1);
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue