diff options
Diffstat (limited to 'src/test')
9 files changed, 79 insertions, 19 deletions
diff --git a/src/test/java/org/bukkit/BiomeTest.java b/src/test/java/org/bukkit/BiomeTest.java new file mode 100644 index 00000000..8c6d40ae --- /dev/null +++ b/src/test/java/org/bukkit/BiomeTest.java @@ -0,0 +1,24 @@ +package org.bukkit; + +import net.minecraft.server.BiomeBase; +import org.bukkit.block.Biome; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.junit.Assert; +import org.junit.Test; + +public class BiomeTest { + + @Test + public void testBukkitToMinecraft() { + for (Biome biome : Biome.values()) { + Assert.assertNotNull("No NMS mapping for " + biome, CraftBlock.biomeToBiomeBase(biome)); + } + } + + @Test + public void testMinecraftToBukkit() { + for (BiomeBase biome : BiomeBase.REGISTRY_ID) { + Assert.assertNotNull("No Bukkit mapping for " + biome, CraftBlock.biomeBaseToBiome(biome)); + } + } +} diff --git a/src/test/java/org/bukkit/ParticleTest.java b/src/test/java/org/bukkit/ParticleTest.java new file mode 100644 index 00000000..c00869ba --- /dev/null +++ b/src/test/java/org/bukkit/ParticleTest.java @@ -0,0 +1,19 @@ +package org.bukkit; + +import net.minecraft.server.EnumParticle; +import org.bukkit.craftbukkit.CraftParticle; +import org.junit.Assert; +import org.junit.Test; + +public class ParticleTest { + + @Test + public void verifyMapping() { + for (Particle bukkit : Particle.values()) { + Assert.assertNotNull("Missing Bukkit->NMS particle mapping", CraftParticle.toNMS(bukkit)); + } + for (EnumParticle nms : EnumParticle.values()) { + Assert.assertNotNull("Missing NMS->Bukkit particle mapping", CraftParticle.toBukkit(nms)); + } + } +} diff --git a/src/test/java/org/bukkit/PerMaterialTest.java b/src/test/java/org/bukkit/PerMaterialTest.java index 2cbf4ecb..b727d1d4 100644 --- a/src/test/java/org/bukkit/PerMaterialTest.java +++ b/src/test/java/org/bukkit/PerMaterialTest.java @@ -53,7 +53,7 @@ public class PerMaterialTest extends AbstractTestingBase { if (material == Material.AIR) { assertFalse(material.isSolid()); } else if (material.isBlock()) { - assertThat(material.isSolid(), is(CraftMagicNumbers.getBlock(material).getMaterial().isSolid())); + assertThat(material.isSolid(), is(CraftMagicNumbers.getBlock(material).getBlockData().getMaterial().isSolid())); } else { assertFalse(material.isSolid()); } @@ -104,7 +104,7 @@ public class PerMaterialTest extends AbstractTestingBase { if (material == Material.AIR) { assertTrue(material.isTransparent()); } else if (material.isBlock()) { - assertThat(material.isTransparent(), is(not(CraftMagicNumbers.getBlock(material).getMaterial().blocksLight()))); + assertThat(material.isTransparent(), is(not(CraftMagicNumbers.getBlock(material).getBlockData().getMaterial().blocksLight()))); } else { assertFalse(material.isTransparent()); } @@ -113,7 +113,7 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void isFlammable() { if (material != Material.AIR && material.isBlock()) { - assertThat(material.isFlammable(), is(CraftMagicNumbers.getBlock(material).getMaterial().isBurnable())); + assertThat(material.isFlammable(), is(CraftMagicNumbers.getBlock(material).getBlockData().getMaterial().isBurnable())); } else { assertFalse(material.isFlammable()); } @@ -132,7 +132,7 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void isOccluding() { if (material.isBlock()) { - assertThat(material.isOccluding(), is(CraftMagicNumbers.getBlock(material).isOccluding())); + assertThat(material.isOccluding(), is(CraftMagicNumbers.getBlock(material).isOccluding(CraftMagicNumbers.getBlock(material).getBlockData()))); } else { assertFalse(material.isOccluding()); } diff --git a/src/test/java/org/bukkit/SoundTest.java b/src/test/java/org/bukkit/SoundTest.java index c9865fa0..2b00b4bf 100644 --- a/src/test/java/org/bukkit/SoundTest.java +++ b/src/test/java/org/bukkit/SoundTest.java @@ -1,12 +1,14 @@ package org.bukkit; +import net.minecraft.server.MinecraftKey; +import net.minecraft.server.SoundEffect; + import static org.junit.Assert.*; import static org.hamcrest.Matchers.*; import org.bukkit.craftbukkit.CraftSound; import org.junit.Test; - public class SoundTest { @Test @@ -15,4 +17,11 @@ public class SoundTest { assertThat(sound.name(), CraftSound.getSound(sound), is(not(nullValue()))); } } + + @Test + public void testReverse() { + for (MinecraftKey effect : SoundEffect.a.keySet()) { + assertNotNull(effect + "", Sound.valueOf(effect.a().replace('.', '_').toUpperCase())); + } + } } diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java index a1838437..1f5a6a32 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java @@ -3,7 +3,7 @@ package org.bukkit.craftbukkit.inventory; import static org.junit.Assert.*; import static org.hamcrest.Matchers.*; -import net.minecraft.server.Enchantment; +import net.minecraft.server.Enchantments; import org.bukkit.inventory.ItemStack; import org.bukkit.support.AbstractTestingBase; @@ -14,7 +14,7 @@ public class NMSCraftItemStackTest extends AbstractTestingBase { @Test public void testCloneEnchantedItem() throws Exception { net.minecraft.server.ItemStack nmsItemStack = new net.minecraft.server.ItemStack(net.minecraft.server.Items.POTION); - nmsItemStack.addEnchantment(Enchantment.DAMAGE_ALL, 1); + nmsItemStack.addEnchantment(Enchantments.DAMAGE_ALL, 1); ItemStack itemStack = CraftItemStack.asCraftMirror(nmsItemStack); ItemStack clone = itemStack.clone(); assertThat(clone.getType(), is(itemStack.getType())); diff --git a/src/test/java/org/bukkit/potion/PotionTest.java b/src/test/java/org/bukkit/potion/PotionTest.java index a9df7d19..691c3e50 100644 --- a/src/test/java/org/bukkit/potion/PotionTest.java +++ b/src/test/java/org/bukkit/potion/PotionTest.java @@ -4,10 +4,13 @@ import static org.junit.Assert.*; import static org.hamcrest.Matchers.*; import java.util.EnumMap; +import java.util.List; import java.util.Map; +import net.minecraft.server.MobEffect; +import net.minecraft.server.MobEffectList; +import net.minecraft.server.PotionRegistry; import org.bukkit.support.AbstractTestingBase; -import org.bukkit.support.Util; import org.junit.Test; public class PotionTest extends AbstractTestingBase { @@ -26,20 +29,20 @@ public class PotionTest extends AbstractTestingBase { @Test public void testEffectCompleteness() throws Throwable { - Map<Integer, ?> effectDurations = Util.getInternalState(net.minecraft.server.PotionBrewer.class, null, "effectDurations"); - Map<PotionType, String> effects = new EnumMap(PotionType.class); - for (int id : effectDurations.keySet()) { + for (PotionRegistry reg : PotionRegistry.a) { + List<MobEffect> eff = reg.a(); + if (eff.size() != 1) continue; + int id = MobEffectList.getId(eff.get(0).getMobEffect()); PotionEffectType type = PotionEffectType.getById(id); assertNotNull(String.valueOf(id), PotionEffectType.getById(id)); PotionType enumType = PotionType.getByEffect(type); assertNotNull(type.getName(), enumType); - assertThat(enumType.name(), effects.put(enumType, enumType.name()), is(nullValue())); + effects.put(enumType, enumType.name()); } - assertThat(effects.entrySet(), hasSize(effectDurations.size())); - assertThat(effectDurations.entrySet(), hasSize(PotionType.values().length - /* WATER */ 1)); + assertEquals(effects.entrySet().size(), PotionType.values().length - /* WATER */ 1); } } diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java index 3a362b75..37869feb 100644 --- a/src/test/java/org/bukkit/support/AbstractTestingBase.java +++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java @@ -64,7 +64,12 @@ public abstract class AbstractTestingBase { Material.BIRCH_DOOR, Material.JUNGLE_DOOR, Material.ACACIA_DOOR, - Material.DARK_OAK_DOOR + Material.DARK_OAK_DOOR, + Material.PURPUR_DOUBLE_SLAB, + Material.BEETROOT_BLOCK, + Material.END_GATEWAY, + Material.STRUCTURE_BLOCK, + Material.BURNING_FURNACE ).build(); @BeforeClass diff --git a/src/test/java/org/bukkit/support/DummyEnchantments.java b/src/test/java/org/bukkit/support/DummyEnchantments.java index ac34a438..f3cc27e7 100644 --- a/src/test/java/org/bukkit/support/DummyEnchantments.java +++ b/src/test/java/org/bukkit/support/DummyEnchantments.java @@ -1,10 +1,10 @@ package org.bukkit.support; -import net.minecraft.server.Enchantment; +import net.minecraft.server.Enchantments; public class DummyEnchantments { static { - Enchantment.getEffects(); + Enchantments.DAMAGE_ALL.getClass(); org.bukkit.enchantments.Enchantment.stopAcceptingRegistrations(); } diff --git a/src/test/java/org/bukkit/support/DummyPotions.java b/src/test/java/org/bukkit/support/DummyPotions.java index 30666abd..9c5cdec2 100644 --- a/src/test/java/org/bukkit/support/DummyPotions.java +++ b/src/test/java/org/bukkit/support/DummyPotions.java @@ -1,6 +1,6 @@ package org.bukkit.support; -import net.minecraft.server.MobEffectList; +import net.minecraft.server.MobEffects; import org.bukkit.craftbukkit.potion.CraftPotionBrewer; import org.bukkit.potion.Potion; @@ -9,7 +9,7 @@ import org.bukkit.potion.PotionEffectType; public class DummyPotions { static { Potion.setPotionBrewer(new CraftPotionBrewer()); - MobEffectList.BLINDNESS.getClass(); + MobEffects.BLINDNESS.getClass(); PotionEffectType.stopAcceptingRegistrations(); } |