From bf771c192d4a859ae59891a6258d49176883ae86 Mon Sep 17 00:00:00 2001 From: Celtic Minstrel Date: Sun, 4 Mar 2012 18:58:18 -0500 Subject: [Bleeding] Fixed some issues with no-effect potions, and added more potion tests. Fixes BUKKIT-1251 --- src/main/java/org/bukkit/potion/Potion.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/main/java/org') diff --git a/src/main/java/org/bukkit/potion/Potion.java b/src/main/java/org/bukkit/potion/Potion.java index 18a03ae2..0320bc7d 100644 --- a/src/main/java/org/bukkit/potion/Potion.java +++ b/src/main/java/org/bukkit/potion/Potion.java @@ -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; + } } \ No newline at end of file -- cgit v1.2.3