mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-13 10:04:51 +02:00
[trunk] Add compatibility with backpack plugin.
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1382 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
package com.earth2me.essentials.commands;
|
package com.earth2me.essentials.commands;
|
||||||
|
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
|
import java.util.Arrays;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
|
||||||
public class Commandinvsee extends EssentialsCommand
|
public class Commandinvsee extends EssentialsCommand
|
||||||
@@ -37,7 +39,15 @@ public class Commandinvsee extends EssentialsCommand
|
|||||||
{
|
{
|
||||||
user.setSavedInventory(user.getInventory().getContents());
|
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("You see the inventory of " + invUser.getDisplayName() + ".");
|
||||||
user.sendMessage("Use /invsee to restore your inventory.");
|
user.sendMessage("Use /invsee to restore your inventory.");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user