summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit
diff options
context:
space:
mode:
authorThinkofdeath <thinkofdeath@spigotmc.org>2015-04-15 15:02:34 +0100
committerThinkofdeath <thinkofdeath@spigotmc.org>2015-04-15 15:02:34 +0100
commit5b2764148d517587ccb570d9743e6834dbd710ac (patch)
tree1929bbd7d6a029e736152aac0b13e8e31f3d513e /src/main/java/org/bukkit
parente4ca2af9c46471723d804c7745159964f01d369a (diff)
downloadcraftbukkit-5b2764148d517587ccb570d9743e6834dbd710ac.tar
craftbukkit-5b2764148d517587ccb570d9743e6834dbd710ac.tar.gz
craftbukkit-5b2764148d517587ccb570d9743e6834dbd710ac.tar.lz
craftbukkit-5b2764148d517587ccb570d9743e6834dbd710ac.tar.xz
craftbukkit-5b2764148d517587ccb570d9743e6834dbd710ac.zip
SPIGOT-798: Allow for CustomPotionEffects to be empty
Diffstat (limited to 'src/main/java/org/bukkit')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java
index 553fcdfa..5b2d12bb 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaPotion.java
@@ -47,18 +47,16 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta {
if (tag.hasKey(POTION_EFFECTS.NBT)) {
NBTTagList list = tag.getList(POTION_EFFECTS.NBT, 10);
int length = list.size();
- if (length > 0) {
- customEffects = new ArrayList<PotionEffect>(length);
-
- for (int i = 0; i < length; i++) {
- NBTTagCompound effect = list.get(i);
- PotionEffectType type = PotionEffectType.getById(effect.getByte(ID.NBT));
- int amp = effect.getByte(AMPLIFIER.NBT);
- int duration = effect.getInt(DURATION.NBT);
- boolean ambient = effect.getBoolean(AMBIENT.NBT);
- boolean particles = effect.getBoolean(SHOW_PARTICLES.NBT);
- customEffects.add(new PotionEffect(type, duration, amp, ambient, particles));
- }
+ customEffects = new ArrayList<PotionEffect>(length);
+
+ for (int i = 0; i < length; i++) {
+ NBTTagCompound effect = list.get(i);
+ PotionEffectType type = PotionEffectType.getById(effect.getByte(ID.NBT));
+ int amp = effect.getByte(AMPLIFIER.NBT);
+ int duration = effect.getInt(DURATION.NBT);
+ boolean ambient = effect.getBoolean(AMBIENT.NBT);
+ boolean particles = effect.getBoolean(SHOW_PARTICLES.NBT);
+ customEffects.add(new PotionEffect(type, duration, amp, ambient, particles));
}
}
}
@@ -82,7 +80,7 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta {
@Override
void applyToItem(NBTTagCompound tag) {
super.applyToItem(tag);
- if (hasCustomEffects()) {
+ if (customEffects != null) {
NBTTagList effectList = new NBTTagList();
tag.set(POTION_EFFECTS.NBT, effectList);
@@ -127,7 +125,7 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta {
}
public boolean hasCustomEffects() {
- return !(customEffects == null || customEffects.isEmpty());
+ return customEffects != null;
}
public List<PotionEffect> getCustomEffects() {
@@ -177,6 +175,9 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta {
changed = true;
}
}
+ if (customEffects.isEmpty()) {
+ customEffects = null;
+ }
return changed;
}