Give item not working

Discussion in 'Plugin Development' started by SizGen, Mar 26, 2020.

Thread Status:
Not open for further replies.
  1. Offline

    SizGen

    I'm making a plugin and when someone executes a command it gets a crossbow but it doesn't work.
    Code:
    package me.sizgen.beewars;
    
    
    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;
    import org.bukkit.inventory.meta.ItemMeta;
    
    public class HoneygunCommand implements CommandExecutor {
    
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if(label.equalsIgnoreCase("honeygun")){
                Player player = (Player) sender;
                sender.sendMessage(ChatColor.GOLD + "Je hebt je HoneyGun gekregen!");
                ItemStack item = new ItemStack(Material.CROSSBOW, 1);
                ItemMeta meta = item.getItemMeta();
                meta.setDisplayName(ChatColor.GOLD + "HoneyGun");
                item.setItemMeta(meta);
                player.getInventory().addItem(item);
                return true;
    
    
            }
       
            return false;
        }
    
    }
     
    Last edited by a moderator: Mar 26, 2020
  2. Offline

    timtower Moderator Moderator

    @SizGen Does the message show? Tried printing the label?
    What does happen?
     
  3. Offline

    NukerFall

    As i see now, you haven't registered your Executor in Main class. What's the problem? Try adding item and then apllying meta, maybe something would change
     
Thread Status:
Not open for further replies.

Share This Page