Solved Commands not Working...?

Discussion in 'Plugin Development' started by Jugglernaught, Feb 2, 2014.

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


    So, I am creating a magical items plugin that works a lot off of a lot of event driven code. When testing a particular item, I noticed that none of the commands would work. Here is my onCommand code. Anyone have any suggestions (I can include my onPlayerInteractEvent code too if it helps)?

    1. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args[]) {
    2. Player player = (Player) sender;
    3. if(label.equalsIgnoreCase("gxorb")) {
    4. if(rct == false) {
    5. player.sendMessage(ChatColor.GREEN + "The Pulsar orb has been turned on!");
    6. rct = true;
    7. } else {
    8. rct = false;
    9. player.sendMessage(ChatColor.GREEN + "The Pulsar Orb has been turned off!");
    10. }
    11. }
    12. return false;
    13. }
  2. Offline


    Did you add the command to your plugin.yml?
  3. Offline


    Yes. I have essentials as well on my testing server, and it appears in the /help, but it just doesn't run the command. It even appears in the command prompt.

    Anyone else (Bump)?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 6, 2016
  4. Offline


    In your onEnable() put

    <classname> <abbreviation> = new <classname>();

    Commands cmd = new Commands();
  5. Offline


    Someone just recently told me that @Override tags don't do anything and there is no need for them. Well, this is exactly one of the cases where putting @Override before your onCommand method would tell you that the fourth parameter of the method should be a single-dimensional String array, not a two-dimensional one.
    igwb and Jake6177 like this.
  6. Offline


    What exactly does that do? I don't mean to insult your help, but that doesn't look like it would effect my commands.

    I don't have a @Override. Have any other ideas?
  7. Offline


  8. Offline


    Do Return True;
  9. Offline


    That is quite irrelevant to the question.

    KraZ__ If he has that method in the main class that wouldn't make any difference at all. Further, it wouldn't solve the problem entirely. Read my first post in this thread.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Feb 11, 2022
  10. Offline


    Issue is not returning true on success, this method will always return false.
  11. Offline


    I can agree to that, definitely.

    Whether the command does what it is supposed to is independent on whether the method returns true or false.
Thread Status:
Not open for further replies.

Share This Page