geforkt von Mirrors/Paper
SPIGOT-2039: Correctly check Potion Tags both with or without the "minecraft:" prefix, and default to UNCRAFTABLE if there is a completely garbage value.
Dieser Commit ist enthalten in:
Ursprung
712213dacc
Commit
0ff499cf03
@ -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) {
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren