SPIGOT-4727: Fix CraftEvil for legacy plugins

This commit is contained in:
md_5 2019-04-24 09:40:42 +10:00
parent 364b6fbb73
commit 93ad381a68
2 changed files with 27 additions and 0 deletions

View File

@ -22,6 +22,10 @@ public class CraftEvil {
static {
for (Material material : Material.values()) {
if (!material.isLegacy()) {
continue;
}
Preconditions.checkState(!byId.containsKey(material.getId()), "Duplicate material ID for", material);
byId.put(material.getId(), material);
}

View File

@ -0,0 +1,23 @@
package org.bukkit;
import org.bukkit.craftbukkit.util.CraftEvil;
import org.junit.Assert;
import org.junit.Test;
public class EvilTest {
@Test
public void testFrom() {
Assert.assertEquals(Material.LEGACY_STONE, CraftEvil.getMaterial(1));
}
@Test
public void testTo() {
Assert.assertEquals(1, CraftEvil.getId(Material.LEGACY_STONE));
}
@Test(expected = IllegalArgumentException.class)
public void testIllegal() {
Material.STONE.getId();
}
}