summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-05-09 00:12:58 +0000
committersnowleo <snowleo@e251c2fe-e539-e718-e476-b85c1f46cddb>2011-05-09 00:12:58 +0000
commite0f103c7d8a5008349436da61d4d17ee0a8c5485 (patch)
tree345335c20e5e5d7a8d5d8854c7fb1f4802435aec
parentabc22d4e21e3b6903e3013f40d913590c55999cb (diff)
downloadEssentials-e0f103c7d8a5008349436da61d4d17ee0a8c5485.tar
Essentials-e0f103c7d8a5008349436da61d4d17ee0a8c5485.tar.gz
Essentials-e0f103c7d8a5008349436da61d4d17ee0a8c5485.tar.lz
Essentials-e0f103c7d8a5008349436da61d4d17ee0a8c5485.tar.xz
Essentials-e0f103c7d8a5008349436da61d4d17ee0a8c5485.zip
[trunk] Add compatibility with backpack plugin.
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1382 e251c2fe-e539-e718-e476-b85c1f46cddb
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java
index 562ee7ad4..c9569feff 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java
@@ -1,7 +1,9 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
+import java.util.Arrays;
import org.bukkit.Server;
+import org.bukkit.inventory.ItemStack;
public class Commandinvsee extends EssentialsCommand
@@ -37,7 +39,15 @@ public class Commandinvsee extends EssentialsCommand
{
user.setSavedInventory(user.getInventory().getContents());
}
- user.getInventory().setContents(invUser.getInventory().getContents());
+ ItemStack[] invUserStack = invUser.getInventory().getContents();
+ int userStackLength = user.getInventory().getContents().length;
+ if (invUserStack.length < userStackLength) {
+ invUserStack = Arrays.copyOf(invUserStack, userStackLength);
+ }
+ if (invUserStack.length > userStackLength) {
+ throw new Exception("The other users inventory is bigger than yours.");
+ }
+ user.getInventory().setContents(invUserStack);
user.sendMessage("You see the inventory of " + invUser.getDisplayName() + ".");
user.sendMessage("Use /invsee to restore your inventory.");
}