Discussion in 'Spigot Plugin Help' started by CoreyplaysYT, Apr 16, 2017.

  1. Code (Text):
    package me.ExpansionPvP.Custom;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemStack;

    public class Strip implements CommandExecutor {

        public Strip(main main) {

        public boolean onCommand(CommandSender sender, Command command, String Label, String[] args) {
            if(Label.equalsIgnoreCase("Strip")) {
                Player player = (Player) sender;
                if (player.hasPermission("ExpansionPvP.Strip")) {
                 player.getInventory().setHelmet(new ItemStack(Material.AIR, 1));
                    player.getInventory().setChestplate(new ItemStack(Material.AIR, 1));
                    player.getInventory().setLeggings(new ItemStack(Material.AIR, 1));
                    player.getInventory().setBoots(new ItemStack(Material.AIR, 1));
                    Player target = Bukkit.getPlayerExact(args[0]);
                    if (target == null) {
                        player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&4&lExpansion&9Players &8&l> &c&lPlayer is Not Online"));
                    target.getInventory().setHelmet(new ItemStack(Material.AIR, 1));
                    target.getInventory().setChestplate(new ItemStack(Material.AIR, 1));
                    target.getInventory().setLeggings(new ItemStack(Material.AIR, 1));
                    target.getInventory().setBoots(new ItemStack(Material.AIR, 1));
            return false;
            return false;

    So Today i was coding a /strip plugin and iv got as far as u take the armour of the target player but i want to know how do you Take the Armour off and return the armour back when the command has been ran
  2. Get the armor contents, and add it to their inventory example:

    Code (Text):
    for (ItemStack item: player.getinventory().getArmorContents())
    then remove their armor :) Make sure to do this before removing their armor, otherwise it will give them nothing
  3. Doesnt seem to work
  4. The code is persudo code, meaning that its not going to work. Its just a basic example of what you should do to give the player their armor contents

    You need to make a for loop, Then loop the ItemStack[] from the getArmorContents() to an ItemStack.
    What you then give that ItemStack to the player :)