Add armor & offhand functionality to invsee

This commit is contained in:
Lemon 2018-01-24 00:00:15 +05:00 committed by GitHub
parent 9b6394c8c6
commit 4f2a6bfcb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,9 +6,10 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = " Look into another player's inventory, optionally take items out.", usage = "/<command> <player>", aliases = "inv,insee")
@CommandParameters(description = " Look into another player's inventory, optionally take items out.", usage = "/<command> <player> [offhand, armor]", aliases = "inv,insee")
public class Command_invsee extends FreedomCommand
{
@ -16,9 +17,8 @@ public class Command_invsee extends FreedomCommand
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
if (args.length < 1)
{
msg("You need to specify a player.");
return false;
}
@ -40,14 +40,37 @@ public class Command_invsee extends FreedomCommand
{
msg("You can't spy on admins!");
return true;
}
}
if(args.length >= 2)
{
if (args[1].equals("offhand"))
{
ItemStack offhand = player.getInventory().getItemInOffHand();
if (offhand == null)
{
msg("That player has nothing in their offhand.");
return true;
}
Inventory inventory = server.createInventory(null, 1, player.getName() + "'s offhand");
inventory.setItem(1, offhand);
playerSender.openInventory(inventory);
return true;
}
if (args[1].equals("armor"))
{
Inventory inventory = server.createInventory(null, 9, player.getName() + "'s armor");
inventory.setContents(player.getInventory().getArmorContents());
playerSender.openInventory(inventory);
return true;
}
}
playerSender.closeInventory();
FPlayer fPlayer = plugin.pl.getPlayer(playerSender);
fPlayer.setInvSee(true);
fPlayer.setInvsee(true);
Inventory playerInv = player.getInventory();
playerSender.openInventory(playerInv);
return true;
}
}