diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java index 82f08c7f9..71812d4ef 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEcoBlockListener.java @@ -3,7 +3,6 @@ package com.earth2me.essentials; import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.craftbukkit.block.CraftSign; -import org.bukkit.craftbukkit.inventory.CraftInventory; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockListener; import org.bukkit.event.block.SignChangeEvent; @@ -142,8 +141,8 @@ public class EssentialsEcoBlockListener extends BlockListener else { ItemStack i2 = ItemDb.get(l2[1], r2); - if (!InventoryWorkaround.containsItem((CraftInventory)user.getInventory(), true, i2)) throw new Exception("You do not have " + r2 + "x " + l2[1] + "."); - InventoryWorkaround.removeItem((CraftInventory)user.getInventory(), true, i2); + if (!InventoryWorkaround.containsItem(user.getInventory(), true, i2)) throw new Exception("You do not have " + r2 + "x " + l2[1] + "."); + InventoryWorkaround.removeItem(user.getInventory(), true, i2); user.updateInventory(); } diff --git a/Essentials/src/com/earth2me/essentials/EssentialsEcoPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsEcoPlayerListener.java index 9908a960d..502517615 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsEcoPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsEcoPlayerListener.java @@ -4,7 +4,6 @@ import java.util.Map; import org.bukkit.Material; import org.bukkit.block.Sign; import org.bukkit.craftbukkit.block.CraftSign; -import org.bukkit.craftbukkit.inventory.CraftInventory; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerListener; @@ -54,9 +53,9 @@ public class EssentialsEcoPlayerListener extends PlayerListener int amount = Integer.parseInt(sign.getLine(1)); ItemStack item = ItemDb.get(sign.getLine(2), amount); int cost = Integer.parseInt(sign.getLine(3).substring(1)); - if (!InventoryWorkaround.containsItem((CraftInventory)user.getInventory(), true, item)) throw new Exception("You do not have enough items to sell."); + if (!InventoryWorkaround.containsItem(user.getInventory(), true, item)) throw new Exception("You do not have enough items to sell."); user.giveMoney(cost); - InventoryWorkaround.removeItem((CraftInventory)user.getInventory(), true, item); + InventoryWorkaround.removeItem(user.getInventory(), true, item); user.updateInventory(); } catch (Throwable ex) @@ -109,7 +108,7 @@ public class EssentialsEcoPlayerListener extends PlayerListener } else { - if (!InventoryWorkaround.containsItem((CraftInventory)user.getInventory(), true, qi1)) + if (!InventoryWorkaround.containsItem(user.getInventory(), true, qi1)) throw new Exception("You do not have " + q1 + "x " + l1[1] + "."); } @@ -118,7 +117,7 @@ public class EssentialsEcoPlayerListener extends PlayerListener if (m1) user.takeMoney(q1); else - InventoryWorkaround.removeItem((CraftInventory)user.getInventory(), true, qi1); + InventoryWorkaround.removeItem(user.getInventory(), true, qi1); if (m2) user.giveMoney(q2); diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 3dd087d5f..b04ada85a 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -1,14 +1,12 @@ package com.earth2me.essentials; import java.util.List; -import java.util.logging.Level; import java.util.logging.Logger; import net.minecraft.server.InventoryPlayer; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.Sign; import org.bukkit.craftbukkit.block.CraftSign; -import org.bukkit.craftbukkit.inventory.CraftInventory; import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer; import org.bukkit.event.block.Action; import org.bukkit.event.player.*; @@ -315,10 +313,10 @@ public class EssentialsPlayerListener extends PlayerListener else { ItemStack i = ItemDb.get(l1[1], q1); - if (!InventoryWorkaround.containsItem((CraftInventory)user.getInventory(), true, i)) { + if (!InventoryWorkaround.containsItem(user.getInventory(), true, i)) { throw new Exception("You do not have " + q1 + "x " + l1[1] + "."); } - InventoryWorkaround.removeItem((CraftInventory)user.getInventory(), true, i); + InventoryWorkaround.removeItem(user.getInventory(), true, i); user.updateInventory(); } } @@ -363,10 +361,10 @@ public class EssentialsPlayerListener extends PlayerListener else { ItemStack i = ItemDb.get(l1[1], q1); - if (!InventoryWorkaround.containsItem((CraftInventory)user.getInventory(), true, i)) { + if (!InventoryWorkaround.containsItem(user.getInventory(), true, i)) { throw new Exception("You do not have " + q1 + "x " + l1[1] + "."); } - InventoryWorkaround.removeItem((CraftInventory)user.getInventory(), true, i); + InventoryWorkaround.removeItem(user.getInventory(), true, i); user.updateInventory(); } } diff --git a/Essentials/src/com/earth2me/essentials/InventoryWorkaround.java b/Essentials/src/com/earth2me/essentials/InventoryWorkaround.java index fc207f5de..dd1051159 100644 --- a/Essentials/src/com/earth2me/essentials/InventoryWorkaround.java +++ b/Essentials/src/com/earth2me/essentials/InventoryWorkaround.java @@ -1,8 +1,7 @@ package com.earth2me.essentials; import java.util.HashMap; -import org.bukkit.craftbukkit.inventory.CraftInventory; -import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; /* @@ -12,11 +11,11 @@ import org.bukkit.inventory.ItemStack; */ public class InventoryWorkaround { - public static int first(CraftInventory ci, ItemStack item, boolean forceDurability, boolean forceAmount) { + public static int first(Inventory ci, ItemStack item, boolean forceDurability, boolean forceAmount) { return next(ci, item, 0, forceDurability, forceAmount); } - public static int next(CraftInventory ci, ItemStack item, int start, boolean forceDurability, boolean forceAmount) { + public static int next(Inventory ci, ItemStack item, int start, boolean forceDurability, boolean forceAmount) { ItemStack[] inventory = ci.getContents(); for (int i = start; i < inventory.length; i++) { ItemStack cItem = inventory[i]; @@ -27,7 +26,7 @@ public class InventoryWorkaround { return -1; } - public static HashMap removeItem(CraftInventory ci, boolean forceDurability, ItemStack... items) { + public static HashMap removeItem(Inventory ci, boolean forceDurability, ItemStack... items) { HashMap leftover = new HashMap(); // TODO: optimization @@ -74,7 +73,7 @@ public class InventoryWorkaround { return leftover; } - public static boolean containsItem(CraftInventory ci, boolean forceDurability, ItemStack... items) { + public static boolean containsItem(Inventory ci, boolean forceDurability, ItemStack... items) { HashMap leftover = new HashMap(); // TODO: optimization diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java index 4f94c0935..c3a90a646 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java @@ -3,7 +3,6 @@ package com.earth2me.essentials.commands; import com.earth2me.essentials.Essentials; import com.earth2me.essentials.User; import org.bukkit.Server; -import org.bukkit.craftbukkit.inventory.CraftInventory; public class Commandinvsee extends EssentialsCommand { @@ -22,7 +21,7 @@ public class Commandinvsee extends EssentialsCommand { invUser = getPlayer(server, args, 0); } if (invUser == user && user.savedInventory != null) { - ((CraftInventory)invUser.getInventory()).setContents(user.savedInventory); + invUser.getInventory().setContents(user.savedInventory); user.savedInventory = null; user.sendMessage("Your inventory has been restored."); return; @@ -32,7 +31,7 @@ public class Commandinvsee extends EssentialsCommand { if (user.savedInventory == null) { user.savedInventory = user.getInventory().getContents(); } - ((CraftInventory)user.getInventory()).setContents(((CraftInventory)invUser.getInventory()).getContents()); + user.getInventory().setContents(invUser.getInventory().getContents()); user.sendMessage("You see the inventory of "+invUser.getDisplayName()+"."); user.sendMessage("Use /invsee to restore your inventory."); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java index 9263db0f5..1540e049c 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java @@ -8,7 +8,6 @@ import java.util.List; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.Server; -import org.bukkit.craftbukkit.inventory.CraftInventory; import org.bukkit.inventory.ItemStack; public class Commandunlimited extends EssentialsCommand @@ -79,7 +78,7 @@ public class Commandunlimited extends EssentialsCommand user.sendMessage("§7Giving unlimited amount of " + itemname + " to " + target.getDisplayName() + "."); } target.sendMessage("§7Giving unlimited amount of " + itemname + " to " + target.getDisplayName() + "."); - if (!InventoryWorkaround.containsItem((CraftInventory)target.getInventory(), true, stack)) { + if (!InventoryWorkaround.containsItem(target.getInventory(), true, stack)) { target.getInventory().addItem(stack); } target.setUnlimited(stack, true);