Command help

Discussion in 'Plugin Development' started by CraterHater, Jul 5, 2015.

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

    CraterHater

    Why doesn't this work, it does nothing when I type the command

    Code:
    package plugin;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    
    public class Factions {
    
        public void onEnable() {
            System.out.print("Faction class also loaded");
           
        }
        public void onDisable() {
            System.out.print("Faction class disabled");
        }
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if (sender instanceof Player) {
                }
               if (cmd.getLabel().equalsIgnoreCase("guild")) {
                    if (args.length == 2) {
                        if (args[0].equalsIgnoreCase("create")) {
                            if (args[1].equalsIgnoreCase("sample")) {
                             
                        sender.sendMessage("Guild created i guess");
                      return true;
                            }
    
                        }
    
                    }
    
        }
                return false;
            }
    }
    
    
     
  2. Did you register the command in plugin.yml?
    Your class doesn't extend JavaPlugin

    And I suggest you learning more Java (basics) before starting to make Bukkit plugins
     
  3. Offline

    CraterHater

    @FisheyLP this is my plugin.yml and I know that my class does not extend JavaPlugin because I have another class doing that.
    Code:
    name: Server plugin
    version: 1.2.1
    main: plugin.Pluginx
    author: CraterHater
    description: jeay, meh
    
    commands:
      tokens:
        usage: /<command>
        description: Shows the tokens
      guild:
        usage: /<command>
        description: basic guild command
     
  4. Then you need to implement CommandExecutor in the current class and register the executor in the main class in onEnable with getCommand("command name").setExecutor(executor instance);
     
Thread Status:
Not open for further replies.

Share This Page