SPIGOT-4880: Potion effects with unknown names.

This commit is contained in:
md_5 2019-05-07 09:22:45 +10:00
parent fe1199caa5
commit 3057b72c7d
2 changed files with 21 additions and 0 deletions

View File

@ -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();
}

View File

@ -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);
}
}
}