Item on Command

Discussion in 'Plugin Development' started by ProjectPurity, Dec 27, 2015.

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

    ProjectPurity

    I've currently got this, it shows no errors however it recognise the command in-game.
    Any help is appreciated.
    Code:
    package me.bukkit.Vampirism;
    
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.PlayerInventory;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class MyFirstPlugin extends JavaPlugin {
    
        @Override
        public void onEnable(){
            getLogger().info("Helsing has been enabled.");
        }
    
        @Override
        public void onDisable(){
        }
    
        public boolean onCommand(CommandSender sender, Command cmd, String Label, String[] args){
             if (cmd.getName().equalsIgnoreCase("stake") && sender instanceof Player) {
                 Player player = (Player) sender;
                 PlayerInventory inventory = player.getInventory();
                 inventory.addItem(new ItemStack(Material.STICK));
                 return true;
            }
            return false;
        }
       
    }
    
     
  2. Offline

    SergeantBud

    plugin.yml?

    And change return false to return true
     
  3. I'm confused... What's the issue? :p There's no error and it does recognize the command?
    Also, you don't need your onEnable method. Bukkit already does that for you.

    @SergeantBud He has return true; in his if statement, he returns false if his if statement is false. Which is correct.
     
  4. Offline

    87pen

    Debug messages, does it fire the command. What does your plugin.yml look like. You don't need the ondisable if you are not using it and bukkit auto announces when your plugin enables your onenable is unnecessary.

    I got dual ninja'd ;(
     
Thread Status:
Not open for further replies.

Share This Page