Command not working?

Discussion in 'Plugin Development' started by Rick221, Feb 25, 2015.

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

    Rick221

    I honestally do not know what is wrong with my command, Plugin yml is good and everything

    Code:
    package me.horseflames;
    
    import me.horseflames.Staffs.Premium;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    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;
    import org.bukkit.inventory.meta.ItemMeta;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class GLStaffs extends JavaPlugin {
       
        public void onEnable() {
           
            PluginManager pm = Bukkit.getPluginManager();
            pm.registerEvents(new Premium(), this);
                   
        }
       
       
        public boolean onCommand(CommandSender sender, Command command,
                String label, String[] args) {
    
        if(command.getName().equalsIgnoreCase("pstaff")) {
            Player p = (Player) sender;
            ItemStack pstaff = new ItemStack(Material.BLAZE_ROD);
            ItemMeta psm = pstaff.getItemMeta();
            psm.setDisplayName(ChatColor.YELLOW + "Staff of Trees");
            pstaff.setItemMeta(psm);
           
            Inventory inv = p.getInventory();
           
            inv.addItem(pstaff);
           
            p.sendMessage("Enjoy dis");
        }
        return false;
        }
       
       
    
    }
    
     
  2. Offline

    Synapz

    You forgot to implement Command Executor

    Code:
    extends JavaPlugin implements CommandExecutor
     
  3. Offline

    Rick221

    Still doesnt work mate :/
     
  4. Offline

    Synapz

    Is there any error messages, a stacktrace? If not it has to do with your plugin.yml. Can you post that?
     
  5. Offline

    Rick221

    Code:
    name: GLStaffs
    main: me.horseflames.GLStaffs
    version: 1.0
    commands:
      pstaff:
        usage: /<command>
        description: launch yourself!!
    
    @Synapz
     
  6. Offline

    Synapz

    @Rick221
    Are there any errors in console?

    If you can, can you post your console startup
     
  7. Offline

    Konato_K

    @Synapz JavaPlugin already implements CommandExecutor, so there is no need for that.


    @Rick221 Say what the problem is "doesn't work" means nothing.
     
  8. Offline

    Rick221

    @Konato_K when I say doesn't work, I mean literally when I type the command in game it says no such command, no errors anywhere
     
  9. Offline

    stormneo7

    There's no error on your code. You do not need to implement CommandExecutor if the class already extends JavaPlugin.

    For your plugin.yml, might I suggest trying the following...
    Code:
    name: GLStaffs
    main: me.horseflames.GLStaffs
    version: 1.0
    commands:
      pstaff:
    It might not change anything but I am not 100% sure, it might!

    Also, when the server starts up, does the console give you any errors?
    Ex: Error while enabling <plugin>. Is it up to date?
    Im feeling like there's an error in your Premium class when you try to register it onEnable().
     
Thread Status:
Not open for further replies.

Share This Page