summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2018-08-03 19:57:02 +1000
committermd_5 <git@md-5.net>2018-08-03 19:57:02 +1000
commite07c38325891cfaf6915881b4998c39b830ab6ea (patch)
treedf0a515254f6c6935723d7e53b843a97c9442868 /src/main/java/org
parent14527e6623aa40fa6fbb74013cb16e8a6bfff737 (diff)
downloadbukkit-e07c38325891cfaf6915881b4998c39b830ab6ea.tar
bukkit-e07c38325891cfaf6915881b4998c39b830ab6ea.tar.gz
bukkit-e07c38325891cfaf6915881b4998c39b830ab6ea.tar.lz
bukkit-e07c38325891cfaf6915881b4998c39b830ab6ea.tar.xz
bukkit-e07c38325891cfaf6915881b4998c39b830ab6ea.zip
SPIGOT-4217: Account for ShowIcon to allow custom tipped arrows to merge
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/potion/PotionEffect.java42
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;
}