summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorCeltic Minstrel <celtic.minstrel.ca@some.place>2012-03-04 18:58:18 -0500
committerEvilSeph <evilseph@gmail.com>2012-03-21 12:31:21 -0400
commitbf771c192d4a859ae59891a6258d49176883ae86 (patch)
treeaef5d5226ed30738ff87a6497d5ecf62648c2246 /src/main/java/org
parent132ee0454229477f2403d445758594c3566405bc (diff)
downloadbukkit-bf771c192d4a859ae59891a6258d49176883ae86.tar
bukkit-bf771c192d4a859ae59891a6258d49176883ae86.tar.gz
bukkit-bf771c192d4a859ae59891a6258d49176883ae86.tar.lz
bukkit-bf771c192d4a859ae59891a6258d49176883ae86.tar.xz
bukkit-bf771c192d4a859ae59891a6258d49176883ae86.zip
[Bleeding] Fixed some issues with no-effect potions, and added more potion tests. Fixes BUKKIT-1251
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/potion/Potion.java11
1 files changed, 9 insertions, 2 deletions
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