SPIGOT-798: Allow for CustomPotionEffects to be empty
This commit is contained in:
parent
e4ca2af9c4
commit
5b2764148d
@ -47,7 +47,6 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta {
|
|||||||
if (tag.hasKey(POTION_EFFECTS.NBT)) {
|
if (tag.hasKey(POTION_EFFECTS.NBT)) {
|
||||||
NBTTagList list = tag.getList(POTION_EFFECTS.NBT, 10);
|
NBTTagList list = tag.getList(POTION_EFFECTS.NBT, 10);
|
||||||
int length = list.size();
|
int length = list.size();
|
||||||
if (length > 0) {
|
|
||||||
customEffects = new ArrayList<PotionEffect>(length);
|
customEffects = new ArrayList<PotionEffect>(length);
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
@ -61,7 +60,6 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
CraftMetaPotion(Map<String, Object> map) {
|
CraftMetaPotion(Map<String, Object> map) {
|
||||||
super(map);
|
super(map);
|
||||||
@ -82,7 +80,7 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta {
|
|||||||
@Override
|
@Override
|
||||||
void applyToItem(NBTTagCompound tag) {
|
void applyToItem(NBTTagCompound tag) {
|
||||||
super.applyToItem(tag);
|
super.applyToItem(tag);
|
||||||
if (hasCustomEffects()) {
|
if (customEffects != null) {
|
||||||
NBTTagList effectList = new NBTTagList();
|
NBTTagList effectList = new NBTTagList();
|
||||||
tag.set(POTION_EFFECTS.NBT, effectList);
|
tag.set(POTION_EFFECTS.NBT, effectList);
|
||||||
|
|
||||||
@ -127,7 +125,7 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasCustomEffects() {
|
public boolean hasCustomEffects() {
|
||||||
return !(customEffects == null || customEffects.isEmpty());
|
return customEffects != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PotionEffect> getCustomEffects() {
|
public List<PotionEffect> getCustomEffects() {
|
||||||
@ -177,6 +175,9 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta {
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (customEffects.isEmpty()) {
|
||||||
|
customEffects = null;
|
||||||
|
}
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user