From dd45c978c2a5894323ee25594a10332d55c3af90 Mon Sep 17 00:00:00 2001 From: rutgerkok Date: Thu, 12 May 2016 20:28:15 +0200 Subject: [PATCH] Update to Spigot 1.9.4. Fixes #19. Remove usages of deprecated methods --- pom.xml | 6 +-- .../BetterEnderChestPlugin.java | 3 +- .../rutgerkok/betterenderchest/ChestDrop.java | 3 +- .../nms/SimpleNMSHandler.java | 42 +++++++++---------- .../betterenderchest/nms/TestJSON.java | 2 +- 5 files changed, 29 insertions(+), 27 deletions(-) diff --git a/pom.xml b/pom.xml index bbc7e6d..a94afca 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 nl.rutgerkok.betterenderchest BetterEnderChest - 2.4.2 + 2.4.3 BetterEnderChest CraftBukkit plugin that adds functionality for both players and admins to the Ender Chest. https://github.com/rutgerkok/BetterEnderChest @@ -54,13 +54,13 @@ org.spigotmc spigot-api - 1.9-R0.1-SNAPSHOT + 1.9.4-R0.1-SNAPSHOT provided org.spigotmc spigot - 1.9-R0.1-SNAPSHOT + 1.9.4-R0.1-SNAPSHOT provided diff --git a/src/main/java/nl/rutgerkok/betterenderchest/BetterEnderChestPlugin.java b/src/main/java/nl/rutgerkok/betterenderchest/BetterEnderChestPlugin.java index 58b4ac3..9458ed6 100644 --- a/src/main/java/nl/rutgerkok/betterenderchest/BetterEnderChestPlugin.java +++ b/src/main/java/nl/rutgerkok/betterenderchest/BetterEnderChestPlugin.java @@ -143,7 +143,8 @@ public ChestDrop getChestDropForPlayer(Player player) { // Creative mode return chestDropCreative; } - if (player.getItemInHand().getEnchantments().containsKey(Enchantment.SILK_TOUCH)) { + ItemStack inHand = player.getInventory().getItemInMainHand(); + if (inHand.getEnchantments().containsKey(Enchantment.SILK_TOUCH)) { // Silk touch return chestDropSilkTouch; } diff --git a/src/main/java/nl/rutgerkok/betterenderchest/ChestDrop.java b/src/main/java/nl/rutgerkok/betterenderchest/ChestDrop.java index 6d08653..f2d82b1 100644 --- a/src/main/java/nl/rutgerkok/betterenderchest/ChestDrop.java +++ b/src/main/java/nl/rutgerkok/betterenderchest/ChestDrop.java @@ -22,7 +22,8 @@ public void drop(BlockBreakEvent event, BetterEnderChest plugin) { dropCreative(event, plugin); return; } - if (event.getPlayer().getItemInHand().getEnchantments().containsKey(Enchantment.SILK_TOUCH)) { + ItemStack inHand = event.getPlayer().getInventory().getItemInMainHand(); + if (inHand.getEnchantments().containsKey(Enchantment.SILK_TOUCH)) { // Silk touch dropSilkTouch(event); return; diff --git a/src/main/java/nl/rutgerkok/betterenderchest/nms/SimpleNMSHandler.java b/src/main/java/nl/rutgerkok/betterenderchest/nms/SimpleNMSHandler.java index d431971..04819c6 100644 --- a/src/main/java/nl/rutgerkok/betterenderchest/nms/SimpleNMSHandler.java +++ b/src/main/java/nl/rutgerkok/betterenderchest/nms/SimpleNMSHandler.java @@ -19,8 +19,8 @@ import org.bukkit.Location; import org.bukkit.Material; -import org.bukkit.craftbukkit.v1_9_R1.CraftWorld; -import org.bukkit.craftbukkit.v1_9_R1.inventory.CraftItemStack; +import org.bukkit.craftbukkit.v1_9_R2.CraftWorld; +import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.json.simple.JSONObject; @@ -28,21 +28,21 @@ import com.google.common.collect.ImmutableMap; -import net.minecraft.server.v1_9_R1.BlockPosition; -import net.minecraft.server.v1_9_R1.MinecraftServer; -import net.minecraft.server.v1_9_R1.NBTBase; -import net.minecraft.server.v1_9_R1.NBTBase.NBTNumber; -import net.minecraft.server.v1_9_R1.NBTCompressedStreamTools; -import net.minecraft.server.v1_9_R1.NBTTagByteArray; -import net.minecraft.server.v1_9_R1.NBTTagCompound; -import net.minecraft.server.v1_9_R1.NBTTagDouble; -import net.minecraft.server.v1_9_R1.NBTTagInt; -import net.minecraft.server.v1_9_R1.NBTTagIntArray; -import net.minecraft.server.v1_9_R1.NBTTagList; -import net.minecraft.server.v1_9_R1.NBTTagLong; -import net.minecraft.server.v1_9_R1.NBTTagString; -import net.minecraft.server.v1_9_R1.TileEntity; -import net.minecraft.server.v1_9_R1.TileEntityEnderChest; +import net.minecraft.server.v1_9_R2.BlockPosition; +import net.minecraft.server.v1_9_R2.Blocks; +import net.minecraft.server.v1_9_R2.NBTBase; +import net.minecraft.server.v1_9_R2.NBTBase.NBTNumber; +import net.minecraft.server.v1_9_R2.NBTCompressedStreamTools; +import net.minecraft.server.v1_9_R2.NBTTagByteArray; +import net.minecraft.server.v1_9_R2.NBTTagCompound; +import net.minecraft.server.v1_9_R2.NBTTagDouble; +import net.minecraft.server.v1_9_R2.NBTTagInt; +import net.minecraft.server.v1_9_R2.NBTTagIntArray; +import net.minecraft.server.v1_9_R2.NBTTagList; +import net.minecraft.server.v1_9_R2.NBTTagLong; +import net.minecraft.server.v1_9_R2.NBTTagString; +import net.minecraft.server.v1_9_R2.TileEntity; +import net.minecraft.server.v1_9_R2.TileEntityEnderChest; public class SimpleNMSHandler extends NMSHandler { static class JSONSimpleTypes { @@ -323,7 +323,7 @@ public void closeEnderChest(Location loc) { BlockPosition blockPos = toBlockPosition(loc); TileEntity tileEntity = ((CraftWorld) loc.getWorld()).getHandle().getTileEntity(blockPos); if (tileEntity instanceof TileEntityEnderChest) { - ((TileEntityEnderChest) tileEntity).d(); // .close() + ((TileEntityEnderChest) tileEntity).e(); // .close() } } @@ -367,7 +367,7 @@ private int getRows(ChestOwner chestOwner, NBTTagCompound baseTag, NBTTagList in public boolean isAvailable() { try { // Test whether nms access works. - MinecraftServer.getServer(); + Blocks.WOOL.getName(); return true; } catch (Throwable t) { return false; @@ -418,7 +418,7 @@ private Inventory loadNBTInventoryFromTag(NBTTagCompound baseTag, ChestOwner che NBTTagCompound item = inventoryTag.get(i); int slot = item.getByte("Slot") & 255; inventory.setItem(slot, - CraftItemStack.asCraftMirror(net.minecraft.server.v1_9_R1.ItemStack.createStack(item))); + CraftItemStack.asCraftMirror(net.minecraft.server.v1_9_R2.ItemStack.createStack(item))); } // Return the inventory @@ -430,7 +430,7 @@ public void openEnderChest(Location loc) { BlockPosition blockPos = toBlockPosition(loc); TileEntity tileEntity = ((CraftWorld) loc.getWorld()).getHandle().getTileEntity(blockPos); if (tileEntity instanceof TileEntityEnderChest) { - ((TileEntityEnderChest) tileEntity).b(); // .open() + ((TileEntityEnderChest) tileEntity).d(); // .open() } } diff --git a/src/test/java/nl/rutgerkok/betterenderchest/nms/TestJSON.java b/src/test/java/nl/rutgerkok/betterenderchest/nms/TestJSON.java index fc4b83e..d1b307b 100644 --- a/src/test/java/nl/rutgerkok/betterenderchest/nms/TestJSON.java +++ b/src/test/java/nl/rutgerkok/betterenderchest/nms/TestJSON.java @@ -12,7 +12,7 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import net.minecraft.server.v1_9_R1.NBTTagCompound; +import net.minecraft.server.v1_9_R2.NBTTagCompound; @RunWith(JUnit4.class) public class TestJSON {