summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java3
-rw-r--r--Essentials/src/com/earth2me/essentials/InventoryWorkaround.java21
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandenchant.java3
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java5
-rw-r--r--Essentials/src/com/earth2me/essentials/craftbukkit/EnchantmentFix.java66
5 files changed, 7 insertions, 91 deletions
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
index ad7a396d7..fcec9a2d0 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java
@@ -1,6 +1,5 @@
package com.earth2me.essentials;
-import com.earth2me.essentials.craftbukkit.EnchantmentFix;
import com.earth2me.essentials.craftbukkit.SetBed;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.textreader.IText;
@@ -117,7 +116,7 @@ public class EssentialsPlayerListener extends PlayerListener
}
if (user.getSavedInventory() != null)
{
- EnchantmentFix.setContents(user.getInventory(), user.getSavedInventory());
+ user.getInventory().setContents(user.getSavedInventory());
user.setSavedInventory(null);
}
user.updateActivity(false);
diff --git a/Essentials/src/com/earth2me/essentials/InventoryWorkaround.java b/Essentials/src/com/earth2me/essentials/InventoryWorkaround.java
index 19edce8d0..3ffda0ab3 100644
--- a/Essentials/src/com/earth2me/essentials/InventoryWorkaround.java
+++ b/Essentials/src/com/earth2me/essentials/InventoryWorkaround.java
@@ -1,6 +1,5 @@
package com.earth2me.essentials;
-import com.earth2me.essentials.craftbukkit.EnchantmentFix;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Location;
@@ -152,27 +151,13 @@ public final class InventoryWorkaround
{
final ItemStack stack = item.clone();
stack.setAmount(maxAmount);
- if (cinventory instanceof FakeInventory)
- {
- cinventory.setItem(firstFree, stack);
- }
- else
- {
- EnchantmentFix.setItem(cinventory, firstFree, stack);
- }
+ cinventory.setItem(firstFree, stack);
item.setAmount(item.getAmount() - maxAmount);
}
else
{
// Just store it
- if (cinventory instanceof FakeInventory)
- {
- cinventory.setItem(firstFree, item);
- }
- else
- {
- EnchantmentFix.setItem(cinventory, firstFree, item);
- }
+ cinventory.setItem(firstFree, item);
break;
}
}
@@ -251,7 +236,7 @@ public final class InventoryWorkaround
{
// split the stack and store
itemStack.setAmount(amount - toDelete);
- EnchantmentFix.setItem(cinventory, first, itemStack);
+ cinventory.setItem(first, itemStack);
toDelete = 0;
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java
index 3ef886347..055b8d640 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
-import com.earth2me.essentials.craftbukkit.EnchantmentFix;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@@ -113,7 +112,7 @@ public class Commandenchant extends EssentialsCommand
} else {
stack.addEnchantment(enchantment, level);
}
- EnchantmentFix.setItemInHand(user.getInventory(), stack);
+ user.getInventory().setItemInHand(stack);
user.updateInventory();
final String enchantmentName = enchantment.getName().toLowerCase(Locale.ENGLISH);
if (level == 0) {
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java
index d53fe8a77..1f5c32faa 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
-import com.earth2me.essentials.craftbukkit.EnchantmentFix;
import java.util.Arrays;
import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
@@ -30,7 +29,7 @@ public class Commandinvsee extends EssentialsCommand
}
if (invUser == user && user.getSavedInventory() != null)
{
- EnchantmentFix.setContents(invUser.getInventory(), user.getSavedInventory());
+ invUser.getInventory().setContents(user.getSavedInventory());
user.setSavedInventory(null);
user.sendMessage(_("invRestored"));
throw new NoChargeException();
@@ -50,7 +49,7 @@ public class Commandinvsee extends EssentialsCommand
{
throw new Exception(_("invBigger"));
}
- EnchantmentFix.setContents(user.getInventory(), invUserStack);
+ user.getInventory().setContents(invUserStack);
user.sendMessage(_("invSee", invUser.getDisplayName()));
user.sendMessage(_("invSeeHelp"));
throw new NoChargeException();
diff --git a/Essentials/src/com/earth2me/essentials/craftbukkit/EnchantmentFix.java b/Essentials/src/com/earth2me/essentials/craftbukkit/EnchantmentFix.java
deleted file mode 100644
index b6e18cb3f..000000000
--- a/Essentials/src/com/earth2me/essentials/craftbukkit/EnchantmentFix.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.earth2me.essentials.craftbukkit;
-
-import org.bukkit.craftbukkit.inventory.CraftInventory;
-import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
-import org.bukkit.craftbukkit.inventory.CraftItemStack;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.ItemStack;
-
-
-public class EnchantmentFix
-{
- public static void setContents(Inventory inventory, ItemStack[] items)
- {
- CraftInventory cInventory = (CraftInventory)inventory;
- if (cInventory.getContents().length != items.length)
- {
- throw new IllegalArgumentException("Invalid inventory size; expected " + cInventory.getContents().length);
- }
-
- net.minecraft.server.ItemStack[] mcItems = cInventory.getInventory().getContents();
-
- for (int i = 0; i < items.length; i++)
- {
- ItemStack item = items[i];
- if (item == null || item.getTypeId() <= 0)
- {
- mcItems[i] = null;
- }
- else
- {
- mcItems[i] = new net.minecraft.server.ItemStack(item.getTypeId(), item.getAmount(), item.getDurability());
- new CraftItemStack(mcItems[i]).addUnsafeEnchantments(item.getEnchantments());
- }
- }
- }
-
- public static void setItem(Inventory inventory, int index, ItemStack item)
- {
- CraftInventory cInventory = (CraftInventory)inventory;
- if (item == null)
- {
- cInventory.getInventory().setItem(index, null);
- }
- else
- {
- net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(item.getTypeId(), item.getAmount(), item.getDurability());
- new CraftItemStack(stack).addUnsafeEnchantments(item.getEnchantments());
- cInventory.getInventory().setItem(index, stack);
- }
- }
-
- public static void setItemInHand(Inventory inventory, ItemStack item)
- {
- CraftInventoryPlayer cInventory = (CraftInventoryPlayer)inventory;
- if (item == null)
- {
- cInventory.getInventory().setItem(cInventory.getInventory().itemInHandIndex, null);
- }
- else
- {
- net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(item.getTypeId(), item.getAmount(), item.getDurability());
- new CraftItemStack(stack).addUnsafeEnchantments(item.getEnchantments());
- cInventory.getInventory().setItem(cInventory.getInventory().itemInHandIndex, stack);
- }
- }
-}