TotalFreedomMod/src/main/java/me/totalfreedom/totalfreedommod/command/Command_invsee.java
untuned f23818a9f9 fix invsee offhand bug (#52)
https://i.untuned.me/jndoUt.png
chest size can only be a multiple of 9, it was set to 1
2018-03-30 09:58:19 +05:00

77 lines
2.5 KiB
Java

package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.player.FPlayer;
import me.totalfreedom.totalfreedommod.rank.Rank;
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> [offhand | armor]", aliases = "inv,insee")
public class Command_invsee extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length < 1)
{
return false;
}
Player player = getPlayer(args[0]);
if (player == null)
{
msg("This player is not online.");
return false;
}
if (playerSender == player)
{
msg("You cannot invsee yourself.");
return true;
}
if (plugin.al.isAdmin(player) && !plugin.al.isAdmin(playerSender))
{
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, 9, 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);
Inventory playerInv = player.getInventory();
playerSender.openInventory(playerInv);
return true;
}
}