diff options
author | t00thpick1 <t00thpick1dirko@gmail.com> | 2016-03-23 23:42:15 -0500 |
---|---|---|
committer | md_5 <git@md-5.net> | 2016-03-24 15:05:10 +1100 |
commit | 0ff499cf03a013e8999042d6e758ecab6ddf41b6 (patch) | |
tree | bf49a0ce556ed8bf24ebf57b445e9d372cfccd42 | |
parent | 712213daccc731620ae5651bec7fd48ffe201a25 (diff) | |
download | craftbukkit-0ff499cf03a013e8999042d6e758ecab6ddf41b6.tar craftbukkit-0ff499cf03a013e8999042d6e758ecab6ddf41b6.tar.gz craftbukkit-0ff499cf03a013e8999042d6e758ecab6ddf41b6.tar.lz craftbukkit-0ff499cf03a013e8999042d6e758ecab6ddf41b6.tar.xz craftbukkit-0ff499cf03a013e8999042d6e758ecab6ddf41b6.zip |
SPIGOT-2039: Correctly check Potion Tags both with or without the "minecraft:" prefix, and default to UNCRAFTABLE if there is a completely garbage value.
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java | 83 |
1 files changed, 45 insertions, 38 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java index 6126c0a9..b7341d66 100644 --- a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java +++ b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionUtil.java @@ -14,47 +14,47 @@ import org.bukkit.potion.PotionData; public class CraftPotionUtil { private static final BiMap<PotionType, String> regular = ImmutableBiMap.<PotionType, String>builder() - .put(PotionType.UNCRAFTABLE, "minecraft:empty") - .put(PotionType.WATER, "minecraft:water") - .put(PotionType.MUNDANE, "minecraft:mundane") - .put(PotionType.THICK, "minecraft:thick") - .put(PotionType.AWKWARD, "minecraft:awkward") - .put(PotionType.NIGHT_VISION, "minecraft:night_vision") - .put(PotionType.INVISIBILITY, "minecraft:invisibility") - .put(PotionType.JUMP, "minecraft:leaping") - .put(PotionType.FIRE_RESISTANCE, "minecraft:fire_resistance") - .put(PotionType.SPEED, "minecraft:swiftness") - .put(PotionType.SLOWNESS, "minecraft:slowness") - .put(PotionType.WATER_BREATHING, "minecraft:water_breathing") - .put(PotionType.INSTANT_HEAL, "minecraft:healing") - .put(PotionType.INSTANT_DAMAGE, "minecraft:harming") - .put(PotionType.POISON, "minecraft:poison") - .put(PotionType.REGEN, "minecraft:regeneration") - .put(PotionType.STRENGTH, "minecraft:strength") - .put(PotionType.WEAKNESS, "minecraft:weakness") - .put(PotionType.LUCK, "minecraft:luck") + .put(PotionType.UNCRAFTABLE, "empty") + .put(PotionType.WATER, "water") + .put(PotionType.MUNDANE, "mundane") + .put(PotionType.THICK, "thick") + .put(PotionType.AWKWARD, "awkward") + .put(PotionType.NIGHT_VISION, "night_vision") + .put(PotionType.INVISIBILITY, "invisibility") + .put(PotionType.JUMP, "leaping") + .put(PotionType.FIRE_RESISTANCE, "fire_resistance") + .put(PotionType.SPEED, "swiftness") + .put(PotionType.SLOWNESS, "slowness") + .put(PotionType.WATER_BREATHING, "water_breathing") + .put(PotionType.INSTANT_HEAL, "healing") + .put(PotionType.INSTANT_DAMAGE, "harming") + .put(PotionType.POISON, "poison") + .put(PotionType.REGEN, "regeneration") + .put(PotionType.STRENGTH, "strength") + .put(PotionType.WEAKNESS, "weakness") + .put(PotionType.LUCK, "luck") .build(); private static final BiMap<PotionType, String> upgradeable = ImmutableBiMap.<PotionType, String>builder() - .put(PotionType.JUMP, "minecraft:strong_leaping") - .put(PotionType.SPEED, "minecraft:strong_swiftness") - .put(PotionType.INSTANT_HEAL, "minecraft:strong_healing") - .put(PotionType.INSTANT_DAMAGE, "minecraft:strong_harming") - .put(PotionType.POISON, "minecraft:strong_poison") - .put(PotionType.REGEN, "minecraft:strong_regeneration") - .put(PotionType.STRENGTH, "minecraft:strong_strength") + .put(PotionType.JUMP, "strong_leaping") + .put(PotionType.SPEED, "strong_swiftness") + .put(PotionType.INSTANT_HEAL, "strong_healing") + .put(PotionType.INSTANT_DAMAGE, "strong_harming") + .put(PotionType.POISON, "strong_poison") + .put(PotionType.REGEN, "strong_regeneration") + .put(PotionType.STRENGTH, "strong_strength") .build(); private static final BiMap<PotionType, String> extendable = ImmutableBiMap.<PotionType, String>builder() - .put(PotionType.NIGHT_VISION, "minecraft:long_night_vision") - .put(PotionType.INVISIBILITY, "minecraft:long_invisibility") - .put(PotionType.JUMP, "minecraft:long_leaping") - .put(PotionType.FIRE_RESISTANCE, "minecraft:long_fire_resistance") - .put(PotionType.SPEED, "minecraft:long_swiftness") - .put(PotionType.SLOWNESS, "minecraft:long_slowness") - .put(PotionType.WATER_BREATHING, "minecraft:long_water_breathing") - .put(PotionType.POISON, "minecraft:long_poison") - .put(PotionType.REGEN, "minecraft:long_regeneration") - .put(PotionType.STRENGTH, "minecraft:long_strength") - .put(PotionType.WEAKNESS, "minecraft:long_weakness") + .put(PotionType.NIGHT_VISION, "long_night_vision") + .put(PotionType.INVISIBILITY, "long_invisibility") + .put(PotionType.JUMP, "long_leaping") + .put(PotionType.FIRE_RESISTANCE, "long_fire_resistance") + .put(PotionType.SPEED, "long_swiftness") + .put(PotionType.SLOWNESS, "long_slowness") + .put(PotionType.WATER_BREATHING, "long_water_breathing") + .put(PotionType.POISON, "long_poison") + .put(PotionType.REGEN, "long_regeneration") + .put(PotionType.STRENGTH, "long_strength") + .put(PotionType.WEAKNESS, "long_weakness") .build(); public static String fromBukkit(PotionData data) { @@ -68,6 +68,9 @@ public class CraftPotionUtil { } public static PotionData toBukkit(String type) { + if (type.startsWith("minecraft:")) { + type = type.substring(10); + } PotionType potionType = null; potionType = extendable.inverse().get(type); if (potionType != null) { @@ -77,7 +80,11 @@ public class CraftPotionUtil { if (potionType != null) { return new PotionData(potionType, false, true); } - return new PotionData(regular.inverse().get(type), false, false); + potionType = regular.inverse().get(type); + if (potionType != null) { + return new PotionData(potionType, false, true); + } + return new PotionData(PotionType.UNCRAFTABLE, false, false); } public static MobEffect fromBukkit(PotionEffect effect) { |