From 3057b72c7d4033d241a257752206149393583970 Mon Sep 17 00:00:00 2001 From: md_5 Date: Tue, 7 May 2019 09:22:45 +1000 Subject: [PATCH] SPIGOT-4880: Potion effects with unknown names. --- .../potion/CraftPotionEffectType.java | 4 ++++ src/test/java/org/bukkit/potion/PotionTest.java | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java index 6edfff3a01..082b0fdf90 100644 --- a/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java +++ b/src/main/java/org/bukkit/craftbukkit/potion/CraftPotionEffectType.java @@ -84,6 +84,10 @@ public class CraftPotionEffectType extends PotionEffectType { return "CONDUIT_POWER"; case 30: return "DOLPHINS_GRACE"; + case 31: + return "BAD_OMEN"; + case 32: + return "HERO_OF_THE_VILLAGE"; default: return "UNKNOWN_EFFECT_TYPE_" + getId(); } diff --git a/src/test/java/org/bukkit/potion/PotionTest.java b/src/test/java/org/bukkit/potion/PotionTest.java index a7e276f9ab..d310ffcc47 100644 --- a/src/test/java/org/bukkit/potion/PotionTest.java +++ b/src/test/java/org/bukkit/potion/PotionTest.java @@ -5,6 +5,7 @@ import java.util.EnumMap; import java.util.List; import java.util.Map; import net.minecraft.server.IRegistry; +import net.minecraft.server.MinecraftKey; import net.minecraft.server.MobEffect; import net.minecraft.server.MobEffectList; import net.minecraft.server.PotionRegistry; @@ -30,4 +31,20 @@ public class PotionTest extends AbstractTestingBase { assertEquals(effects.entrySet().size(), PotionType.values().length - /* PotionTypes with no/shared Effects */ 6); } + + @Test + public void testEffectType() { + for (MobEffectList nms : IRegistry.MOB_EFFECT) { + MinecraftKey key = IRegistry.MOB_EFFECT.getKey(nms); + + int id = MobEffectList.getId(nms); + PotionEffectType bukkit = PotionEffectType.getById(id); + + assertNotNull("No Bukkit type for " + key, bukkit); + assertFalse("No name for " + key, bukkit.getName().contains("UNKNOWN")); + + PotionEffectType byName = PotionEffectType.getByName(bukkit.getName()); + assertEquals("Same type not returned by name " + key, bukkit, byName); + } + } }