Solved Help with txt commands

Discussion in 'Plugin Development' started by fatmarley, Mar 18, 2013.

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

    fatmarley

    So, I have been maintaining a plugin that uses txt files to show rules. I had the great idea to add in a sort of FAQ feature to the plugin, but I am having issues.

    The reason I am maintaining this plugin is to help my learn to make more complex plugins (which I am failing at right now)

    If you could help me out, it would be great. ( and possibly use noob lingo)

    Basically, the /rules command works, but the /faq command comes up as being an 'unknown command'
    I figure it must be to do with the return true/return false over the place. But I can't figure out how to optimize it to run both commands and check the files to ensure they are working.

    Code:
          public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args)
          {
            String commandName = command.getName().toLowerCase();
            if (commandName.equals("rules") && (sender instanceof Player)) {
                if (!enableRules) { return true; }
                if (!Rules.send((Player)sender, args)) { return false; }
                return true;
            }
            else if(commandName.equals("faq") && (sender instanceof Player)) {
                if (!enableInfo) { return true; }
                if (!Info.send((Player)sender, args)) { return false; }
                return true;
            }
       
       
       
        return false;
    }
    }
    
     
  2. Offline

    kaskoepoes112

    make sure the command is in your plugin.yml :p
     
  3. Offline

    Nitnelave

    First of all, the title of your post MUST describe your issue, not "HELP PLZ!!" or something like that. A better title in your case would be "Problem with processing commands".

    Why do you check that sender instanceof Player? Can't you send the messages to the console too, if they want?

    Another way to write:
    if (! somecondition) return false; return true;
    is to simply write :
    return somecondition;

    As for your question, returning false means that there was a syntax error in the command line, and it displays the help for the command. Now, I don't know what your Info.send and Rules.send do, or what they return, so I can't help you more than that.
     
  4. Offline

    fatmarley

Thread Status:
Not open for further replies.

Share This Page