Item on Command

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

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


    I've currently got this, it shows no errors however it recognise the command in-game.
    Any help is appreciated.
    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;
    public class MyFirstPlugin extends JavaPlugin {
        public void onEnable(){
            getLogger().info("Helsing has been enabled.");
        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



    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


    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