Issuing Command Only Returns Usage Message

Discussion in 'Plugin Development' started by willies952002, Mar 25, 2013.

?

What kind of Minecrafter Are You?

  1. Survival -- Peaceful

    11.1%
  2. Survival -- Easy

    22.2%
  3. Survival -- Normal

    33.3%
  4. Survival -- Hard

    44.4%
  5. Survival -- Hardcore

    44.4%
  6. Creative -- Buildings

    55.6%
  7. Creative -- Redston Contraptions

    66.7%
Multiple votes are allowed.
Thread Status:
Not open for further replies.
  1. Offline

    willies952002

    Hello,

    I am having an issue with a plugin I am developing. When ever I call the command, it only returns the usage and does not do anything other than this. This is actually an issue I have with all the plugins I am developing.

    I'm unfortunately not going to post my code or any snippets of it due to it being closed source prior to release.

    Thanks in Advance :D
     
  2. Offline

    chasechocolate

    It's hard to help you when you don't post code... What's your onCommand method and your plugin.yml?
     
  3. Offline

    willies952002

    ok, as long as no one uses it to copy the mechanics of the plugin...

    onCommand():
    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String lbl, String[] args) {
            if (sender instanceof Player) {
                if (cmd.equals("cape") ) {
                    if ( args[0].equalsIgnoreCase("enable") ) {
                        Cape cape = new Cape((Player)sender, pl); cape.renderCape();
                        pl.getLogger().info("Gave Cape To: " + (Player)sender); return true;
                    }
                    if ( args[0].equalsIgnoreCase("disable")) {
                        Cape cape = new Cape((Player)sender, pl); cape.removeCape();
                        pl.getLogger().info("Took Cape From: " + (Player)sender); return true;
                    }
                }
            }
            else {
                sender.sendMessage("You Must Be a Player To Do That");
                pl.getLogger().info(sender + "Tried Getting A Cape And Failed");
            } return false;
        }
    Code:
        public void renderCape() {
            String capeURL = pl.getConfig().getString("capeDir") + player.getDisplayName() + ".png";
            player.setCape(capeURL);
        }
       
        public void removeCape() { player.setCape(null); }
     
  4. Offline

    Lolmewn

    plugin.yml? Startup-log?
     
  5. Offline

    willies952002

    plugin.yml
    Code:
    name: ServerCapes
    main: com.gmail.willies952002.ServerCapes.ServerCapes
    version: 0.4a
     
    commands:
      cape:
          description: Used to Enable or Disable Player Capes.
          usage: /cape <enable|disable>
          permission: ServerCapes.cape
          permission-message: No Access to This Command;
     
  6. you keep returning false within your command, this means, print out usage message
     
  7. Offline

    Lolmewn

    Oh, yeah.
    Fail from me not noticing that.

    You should return true instead, when the command does stuff. I always let it return true, except for the last return statement right before the bracket.
     
  8. Offline

    ZeusAllMighty11

    I'm a hardcore survival player! :D


    And you can always remove the usage since most people print their own.
     
  9. Offline

    willies952002

    Code:
    210 recipes
    27 achievements
    16:38:29 [INFO] Starting minecraft server version 1.4.7
    16:38:29 [INFO] Loading properties
    16:38:29 [INFO] Default game type: CREATIVE
    16:38:29 [INFO] Generating keypair
    16:38:30 [INFO] Starting Minecraft server on *:25565
    16:38:30 [INFO] This server is running CraftBukkit version git-Bukkit-1.4.7-R1.0-b2624jnks (MC: 1.4.7) (Implementing API version 1.4.7-R1.0)
    16:38:30 [INFO] [Spout] Loading Spout v1.4.7 b1432
    16:38:30 [INFO] [ServerCapes] Loading ServerCapes v0.4a
    16:38:30 [INFO] [Spout] Enabling Spout v1.4.7 b1432
    16:38:34 [INFO] [SpoutPlugin] Initializing precache for Spout
    16:38:34 [INFO] Preparing level "PluginTest"
    16:38:34 [INFO] Preparing start region for level 0 (Seed: 7542626980601056724)
    16:38:35 [INFO] Preparing spawn area: 20%
    16:38:36 [INFO] Preparing spawn area: 73%
    16:38:37 [INFO] [ServerCapes] Enabling ServerCapes v0.4a
    16:38:37 [INFO] [ServerCapes] ServerCapes Enabled
    16:38:37 [INFO] [SpoutPlugin] Initializing precache for ServerCapes
    16:38:37 [INFO] Server permissions file permissions.yml is empty, ignoring it
    16:38:37 [INFO] Done (2.996s)! For help, type "help" or "?"
    
    It still will not return true even if told to.

    At least the
    Code:
    if (sender instanceof Player)
    works...
    Code:
    16:42:16 [INFO] You Must Be a Player To Do That
    16:42:16 [INFO] [ServerCapes] org.bukkit.craftbukkit.v1_4_R1.command.ColouredConsoleSender@7e913c56Tried Getting A Cape And Failed
    16:42:16 [INFO] /cape <enable|disable>
    
     
Thread Status:
Not open for further replies.

Share This Page