Coding Help! Command keeps repeating.

Discussion in 'Spigot Plugin Development' started by TidesVI, Jun 28, 2016.

Thread Status:
Not open for further replies.
  1. Well by reading the title you guys should be able to tell whats going on.
    My command keeps repeating for some reason. and yes i returned true and all that stuff but i still don't know whats the problem. Here is my code:

    CustomEnchants command Class (Where the command is written): http://pastebin.com/xe7p01G2

    Core Class: http://pastebin.com/8aM3Qa2s

    Plugin.yml: http://pastebin.com/a752sKaS

    p.s this is the first time i ever ran into this problem.
     
  2. Code (Text):

    public void registerCommands() {
        this.getCommand("ce").setExecutor(new CustomEnchant());
        this.getCommand("customenchants").setExecutor(new CustomEnchant())
    }
    Why are you making a different instance of the command class at all, let alone just for an alias which you could just put in the plugin YML?

    Oh and your YML has an issue, the aliases should be
    Code (Text):
    aliases: [ce]
     
  3. I tried removing that. it says command didnt exist.
     
  4.  
  5. I fixed all that. Still have the problem.
     
  6. what exactly ? have you done what @Trophonix said ?

    Code (Java):
    // onEnable() {
    registerCommand("customenchant").setExecutor(new CustomEnchant()):
    Code (Java):
    // plugin.yml
    commands:
      customenchant:
         description: desc
         aliases: [ce, more]
     
  7. yup I did
    Code (Text):
    //Plugin yml
    commands:
      customenchants:
        aliases: [ce]
        description: Shows a list of commands
       
    Code (Text):
    //the register command func.
    public void registerCommands() {
            this.getCommand("customenchants").setExecutor(new CustomEnchant());
        }
     
  8. the error then ? or the output in console ?
     
  9. There is no error.
     
  10. Is the plugin enabled at all?
    Can another plugin find it with getPluginCommand?
     
  11. Yes it is loaded and it works. and yes it can also be found by another plugin.
     
  12. I fixed it thanks to a friend i did :
    After:
    Code (Text):
    if(args.length == 0) {
                        p.sendMessage(ChatColor.RED + "-------- " + ChatColor.BLUE + "[Custom Enchants]" + ChatColor.RED + " --------");
                        showCommands(p);//?
                    } else if (args.length == 1 || args.length == 3) {
                        if (args[0].equalsIgnoreCase("gui")) {                      
                            showMainGUI(p);
                            return true;
                        }
    //More code down here
    Before:
    Code (Text):

    if (args.length == 1 || args.length == 3) {
                        if (args[0].equalsIgnoreCase("gui")) {                      
                            showMainGUI(p);
                            return true;
                        }
    //more code down here
    Now it doesn't repeat thanks for helping me though! I appreciate how fast you guys responded!
     
  13. actually there's no difference unless you add
    Code (Java):
    if(args.length == 0) {
                        p.sendMessage(ChatColor.RED + "-------- " + ChatColor.BLUE + "[Custom Enchants]" + ChatColor.RED + " --------");
                        showCommands(p);
    }
     
  14. well thanks for your help! and yea your right i just realized that :p
     
Thread Status:
Not open for further replies.