[Bleeding] Fixed some issues with no-effect potions, and added more potion tests. Fixes BUKKIT-1251

By: Celtic Minstrel <celtic.minstrel.ca@some.place>
This commit is contained in:
Bukkit/Spigot
2012-03-04 18:58:18 -05:00
parent 82f7680bd0
commit da44559df3
2 changed files with 60 additions and 29 deletions

View File

@@ -31,6 +31,9 @@ public class Potion {
if (type != null) {
this.name = type.getDamageValue();
}
if (type == null || type == PotionType.WATER) {
this.level = 0;
}
}
/** @deprecated In favour of {@link #Potion(PotionType, int)} */
@@ -104,7 +107,7 @@ public class Potion {
public Potion(int name) {
this(PotionType.getByDamageValue(name & POTION_BIT));
this.name = name & NAME_BIT;
if (name == 0) {
if ((name & POTION_BIT) == 0) {
// If it's 0 it would've become PotionType.WATER, but it should actually be mundane potion
this.type = null;
}
@@ -363,7 +366,7 @@ public class Potion {
public static Potion fromDamage(int damage) {
PotionType type = PotionType.getByDamageValue(damage & POTION_BIT);
Potion potion;
if (type == null) {
if (type == null || (type == PotionType.WATER && damage != 0)) {
potion = new Potion(damage & NAME_BIT);
} else {
int level = (damage & TIER_BIT) >> TIER_SHIFT;
@@ -406,4 +409,8 @@ public class Potion {
throw new IllegalArgumentException("brewer can only be set internally");
brewer = other;
}
public int getNameId() {
return name;
}
}