diff options
author | mbax <matt@phozop.net> | 2013-11-04 07:07:38 -0600 |
---|---|---|
committer | Wesley Wolfe <weswolf@aol.com> | 2013-11-30 19:26:12 -0600 |
commit | 2726696652179a5ead7dc07dd39edf7dfda687f7 (patch) | |
tree | ff78e22fdd4fc01889a5f6cc482b599f965cd93a /src/test/java/org | |
parent | ff8b70fbb7a96b9d2ff078afcf3b3ff90f200981 (diff) | |
download | craftbukkit-2726696652179a5ead7dc07dd39edf7dfda687f7.tar craftbukkit-2726696652179a5ead7dc07dd39edf7dfda687f7.tar.gz craftbukkit-2726696652179a5ead7dc07dd39edf7dfda687f7.tar.lz craftbukkit-2726696652179a5ead7dc07dd39edf7dfda687f7.tar.xz craftbukkit-2726696652179a5ead7dc07dd39edf7dfda687f7.zip |
Update CraftBukkit to Minecraft 1.7.2
Diffstat (limited to 'src/test/java/org')
6 files changed, 58 insertions, 26 deletions
diff --git a/src/test/java/org/bukkit/AchievementTest.java b/src/test/java/org/bukkit/AchievementTest.java index b8695ccd..813568e3 100644 --- a/src/test/java/org/bukkit/AchievementTest.java +++ b/src/test/java/org/bukkit/AchievementTest.java @@ -7,26 +7,26 @@ import java.util.Collections; import java.util.List; import net.minecraft.server.AchievementList; -import net.minecraft.server.Statistic; +import org.bukkit.craftbukkit.CraftAchievement; +import org.bukkit.support.AbstractTestingBase; import org.bukkit.support.Util; import org.junit.Test; import com.google.common.collect.Lists; -public class AchievementTest { +public class AchievementTest extends AbstractTestingBase { @Test @SuppressWarnings("unchecked") public void verifyMapping() throws Throwable { List<Achievement> achievements = Lists.newArrayList(Achievement.values()); for (net.minecraft.server.Achievement statistic : (List<net.minecraft.server.Achievement>) AchievementList.e) { - int id = statistic.e; + String name = statistic.e; - String name = Util.getInternalState(Statistic.class, statistic, "a"); - String message = String.format("org.bukkit.Achievement is missing id: %d named: '%s'", id - Achievement.STATISTIC_OFFSET, name); + String message = String.format("org.bukkit.Achievement is missing: '%s'", name); - Achievement subject = Achievement.getById(id); + Achievement subject = CraftAchievement.getAchievement(name); assertNotNull(message, subject); assertTrue(name, achievements.remove(subject)); diff --git a/src/test/java/org/bukkit/MaterialTest.java b/src/test/java/org/bukkit/MaterialTest.java index dbb60de0..a63c0f4d 100644 --- a/src/test/java/org/bukkit/MaterialTest.java +++ b/src/test/java/org/bukkit/MaterialTest.java @@ -12,6 +12,8 @@ import org.bukkit.support.AbstractTestingBase; import org.junit.Test; import com.google.common.collect.Maps; +import java.util.Iterator; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; public class MaterialTest extends AbstractTestingBase { @@ -19,14 +21,21 @@ public class MaterialTest extends AbstractTestingBase { public void verifyMapping() { Map<Integer, Material> materials = Maps.newHashMap(); for (Material material : Material.values()) { + if (INVALIDATED_MATERIALS.contains(material)) { + continue; + } + materials.put(material.getId(), material); } materials.remove(0); // Purge air. - for (Item item : Item.byId) { + Iterator<Item> items = Item.REGISTRY.iterator(); + + while (items.hasNext()) { + Item item = items.next(); if (item == null) continue; - int id = item.id; + int id = CraftMagicNumbers.getId(item); String name = item.getName(); Material material = materials.remove(id); diff --git a/src/test/java/org/bukkit/PerMaterialTest.java b/src/test/java/org/bukkit/PerMaterialTest.java index ab4333c3..a33fcbff 100644 --- a/src/test/java/org/bukkit/PerMaterialTest.java +++ b/src/test/java/org/bukkit/PerMaterialTest.java @@ -5,12 +5,11 @@ import static org.hamcrest.Matchers.*; import java.util.List; -import net.minecraft.server.Block; +import net.minecraft.server.BlockFalling; import net.minecraft.server.BlockFire; import net.minecraft.server.Item; import net.minecraft.server.ItemFood; import net.minecraft.server.ItemRecord; -import net.minecraft.server.BlockSand; import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.inventory.ItemStack; @@ -24,6 +23,8 @@ import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; import com.google.common.collect.Lists; +import net.minecraft.server.Blocks; +import org.bukkit.craftbukkit.util.CraftMagicNumbers; @RunWith(Parameterized.class) public class PerMaterialTest extends AbstractTestingBase { @@ -31,13 +32,17 @@ public class PerMaterialTest extends AbstractTestingBase { @BeforeClass public static void getFireValues() { - fireValues = Util.getInternalState(BlockFire.class, Block.FIRE, "a"); + fireValues = Util.getInternalState(BlockFire.class, Blocks.FIRE, "a"); } @Parameters(name= "{index}: {0}") public static List<Object[]> data() { List<Object[]> list = Lists.newArrayList(); for (Material material : Material.values()) { + if (INVALIDATED_MATERIALS.contains(material)) { + continue; + } + list.add(new Object[] {material}); } return list; @@ -50,7 +55,7 @@ public class PerMaterialTest extends AbstractTestingBase { if (material == Material.AIR) { assertFalse(material.isSolid()); } else if (material.isBlock()) { - assertThat(material.isSolid(), is(Block.byId[material.getId()].material.isSolid())); + assertThat(material.isSolid(), is(CraftMagicNumbers.getBlock(material).getMaterial().isSolid())); } else { assertFalse(material.isSolid()); } @@ -58,20 +63,21 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void isEdible() { - assertThat(material.isEdible(), is(Item.byId[material.getId()] instanceof ItemFood)); + assertThat(material.isEdible(), is(CraftMagicNumbers.getItem(material) instanceof ItemFood)); } @Test public void isRecord() { - assertThat(material.isRecord(), is(Item.byId[material.getId()] instanceof ItemRecord)); + assertThat(material.isRecord(), is(CraftMagicNumbers.getItem(material) instanceof ItemRecord)); } @Test public void maxDurability() { if (material == Material.AIR) { assertThat((int) material.getMaxDurability(), is(0)); - } else { - assertThat((int) material.getMaxDurability(), is(Item.byId[material.getId()].getMaxDurability())); + } else if (material.isBlock()){ + Item item = CraftMagicNumbers.getItem(material); + assertThat((int) material.getMaxDurability(), is(item.getMaxDurability())); } } @@ -85,7 +91,7 @@ public class PerMaterialTest extends AbstractTestingBase { assertThat(bukkit.getMaxStackSize(), is(MAX_AIR_STACK)); assertThat(craft.getMaxStackSize(), is(MAX_AIR_STACK)); } else { - assertThat(material.getMaxStackSize(), is(Item.byId[material.getId()].getMaxStackSize())); + assertThat(material.getMaxStackSize(), is(CraftMagicNumbers.getItem(material).getMaxStackSize())); assertThat(bukkit.getMaxStackSize(), is(material.getMaxStackSize())); assertThat(craft.getMaxStackSize(), is(material.getMaxStackSize())); } @@ -96,7 +102,7 @@ public class PerMaterialTest extends AbstractTestingBase { if (material == Material.AIR) { assertTrue(material.isTransparent()); } else if (material.isBlock()) { - assertThat(material.isTransparent(), is(not(Block.byId[material.getId()].material.blocksLight()))); + assertThat(material.isTransparent(), is(not(CraftMagicNumbers.getBlock(material).getMaterial().blocksLight()))); } else { assertFalse(material.isTransparent()); } @@ -105,7 +111,7 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void isFlammable() { if (material != Material.AIR && material.isBlock()) { - assertThat(material.isFlammable(), is(Block.byId[material.getId()].material.isBurnable())); + assertThat(material.isFlammable(), is(CraftMagicNumbers.getBlock(material).getMaterial().isBurnable())); } else { assertFalse(material.isFlammable()); } @@ -123,7 +129,7 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void isOccluding() { if (material.isBlock()) { - assertThat(material.isOccluding(), is(Block.l(material.getId()))); + assertThat(material.isOccluding(), is(CraftMagicNumbers.getBlock(material).r())); } else { assertFalse(material.isOccluding()); } @@ -132,7 +138,7 @@ public class PerMaterialTest extends AbstractTestingBase { @Test public void hasGravity() { if (material.isBlock()) { - assertThat(material.hasGravity(), is(Block.byId[material.getId()] instanceof BlockSand)); + assertThat(material.hasGravity(), is(CraftMagicNumbers.getBlock(material) instanceof BlockFalling)); } else { assertFalse(material.hasGravity()); } diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/FactoryItemMaterialTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/FactoryItemMaterialTest.java index 885964dd..1e5c3ef2 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/FactoryItemMaterialTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/FactoryItemMaterialTest.java @@ -5,6 +5,7 @@ import static org.hamcrest.Matchers.*; import java.util.ArrayList; import java.util.List; +import org.apache.commons.lang.ArrayUtils; import org.bukkit.Material; import org.bukkit.inventory.ItemFactory; @@ -21,7 +22,20 @@ import org.junit.runners.Parameterized.Parameters; public class FactoryItemMaterialTest extends AbstractTestingBase { static final ItemFactory factory = CraftItemFactory.instance(); static final StringBuilder buffer = new StringBuilder(); - static final Material[] materials = Material.values(); + static final Material[] materials; + + static { + Material[] local_materials = Material.values(); + List<Material> list = new ArrayList<Material>(local_materials.length); + for (Material material : local_materials) { + if (INVALIDATED_MATERIALS.contains(material)) { + continue; + } + + list.add(material); + } + materials = list.toArray(new Material[list.size()]); + } static String name(Enum<?> from, Enum<?> to) { if (from.getClass() == to.getClass()) { diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java index be1ffcf6..a1838437 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/NMSCraftItemStackTest.java @@ -13,7 +13,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.Item.POTION); + net.minecraft.server.ItemStack nmsItemStack = new net.minecraft.server.ItemStack(net.minecraft.server.Items.POTION); nmsItemStack.addEnchantment(Enchantment.DAMAGE_ALL, 1); ItemStack itemStack = CraftItemStack.asCraftMirror(nmsItemStack); ItemStack clone = itemStack.clone(); diff --git a/src/test/java/org/bukkit/support/AbstractTestingBase.java b/src/test/java/org/bukkit/support/AbstractTestingBase.java index e04158d6..7c4484f0 100644 --- a/src/test/java/org/bukkit/support/AbstractTestingBase.java +++ b/src/test/java/org/bukkit/support/AbstractTestingBase.java @@ -1,7 +1,9 @@ package org.bukkit.support; -import net.minecraft.server.StatisticList; - +import com.google.common.collect.ImmutableList; +import java.util.List; +import net.minecraft.server.DispenserRegistry; +import org.bukkit.Material; import org.junit.BeforeClass; /** @@ -13,10 +15,11 @@ import org.junit.BeforeClass; * extend this class to solve it. */ public abstract class AbstractTestingBase { + public static final List<Material> INVALIDATED_MATERIALS = ImmutableList.<Material>builder().add(Material.BREWING_STAND, Material.BED_BLOCK, Material.NETHER_WARTS, Material.CAULDRON, Material.FLOWER_POT, Material.CROPS, Material.SUGAR_CANE_BLOCK, Material.CAKE_BLOCK, Material.SKULL, Material.PISTON_EXTENSION, Material.PISTON_MOVING_PIECE, Material.GLOWING_REDSTONE_ORE, Material.DIODE_BLOCK_ON, Material.PUMPKIN_STEM, Material.SIGN_POST, Material.REDSTONE_COMPARATOR_ON, Material.TRIPWIRE, Material.REDSTONE_LAMP_ON, Material.MELON_STEM, Material.REDSTONE_TORCH_OFF, Material.REDSTONE_COMPARATOR_OFF, Material.REDSTONE_WIRE, Material.WALL_SIGN, Material.DIODE_BLOCK_OFF, Material.IRON_DOOR_BLOCK, Material.WOODEN_DOOR).add(Material.LOCKED_CHEST).build(); @BeforeClass public static void setup() { - StatisticList.a(); + DispenserRegistry.b(); DummyServer.setup(); DummyPotions.setup(); DummyEnchantments.setup(); |