Solved Commands not working

Discussion in 'Plugin Development' started by Iervolino, Jun 30, 2013.

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

    Iervolino

    Code:

    Code:java
    1. public boolean Comandos(CommandSender sender, Command cmd, String cmdLabel, String[] args){
    2. Player player = (Player)sender;
    3. if (cmd.getName().equalsIgnoreCase("fakejoin")){
    4. if (player.hasPermission("iervocommands.fakejoin")){
    5. if (args.length == 0)
    6. Bukkit.broadcastMessage(ChatColor.YELLOW + player.getName() + ChatColor.YELLOW + " joined the game.");
    7. if ((args.length == 1) &&
    8. (player.hasPermission("iervocommands.fakejoinother")))
    9. Bukkit.broadcastMessage(ChatColor.YELLOW + args[0] + ChatColor.YELLOW + " joined the game.");
    10. }
    11. }
    12. if (cmd.getName().equalsIgnoreCase("fakeleave")){
    13. if (player.hasPermission("iervocommands.fakeleave")){
    14. if (args.length == 0)
    15. Bukkit.broadcastMessage(ChatColor.YELLOW + player.getName() + ChatColor.YELLOW + " left the game.");
    16. if ((args.length == 1) &&
    17. (player.hasPermission("iervocommands.fakeleaveother")))
    18. Bukkit.broadcastMessage(ChatColor.YELLOW + args[0] + ChatColor.YELLOW + " left the game.");
    19. }
    20. }
    21. return true;
    22. }


    plugin.yml

    Code:
    name: IervoCommands
    main: me.Iervolino.IervoCommands.IervoCommands
    version: 1.0
     
    commands:
      fakejoin:
        usage: /<command> 
        description: Executa o FakeJoin.
      fakeleave:
        usage: /<command> 
        description: Executa o FakeLeave.
      admin:
        usage: /<command> 
        description: Executa o modo ADMIN.
     
    permissions:
        iervocommands.fakejoin:
            description: Permite o uso de FakeJoin.
            default: op
        iervocommands.fakeleave:
            description: Permite o uso de FakeLeave.
            default: op
        iervocommands.admin:
            description: Permite entrar e sair do modo ADMIN.
            default: op
    Problem: When I do the command look what happen..

    [​IMG]
     
  2. Offline

    caseif

    Without even looking at your code, I can tell you the problem is that you're not returning true in your onCommand() method. Returning true tells the server that your plugin has handled the command, while returning false tells it the opposite and prompts it to send the usage.
     
  3. Offline

    Kodfod

    Read this part of the Wiki Plugin Tutorial. You should be able to see your mistake.

    AngryNerd - While that is true, it is not processing the rest of the code. That would be the last thing to be done (end of operations in the method). So they should add that.
     
  4. Offline

    caseif

    Hm. Perhaps it would have been for the best if I had looked at it before posting. Yeah, I see the problem now.
     
  5. Offline

    Iervolino


    AngryNerd I already tried to return false, and it still not working..

    Also, idk where is the mistake..
     
  6. Offline

    caseif

    My post was based on prior experience; I didn't think any other errors were probable. As Kodfod said, you need to figure it out on your own. We can't just spoon-feed you the answer.
     
  7. Offline

    Iervolino


    Fixed..

    Code:
    commands:
      fakejoin:
          description: Executa o FakeJoin.
          usage: /<command>
          permission: iervocommands.fakejoin
      fakeleave:
          description: Executa o FakeLeave.
          usage: /<command>
          permission: iervocommands.fakeleave
      admin:
          description: Entra ou sai do modo ADMIN.
          usage: /<command>
          permission: iervocommands.admin
     
  8. Offline

    caseif

    Not quite. You've still got one more thing to take care of. Keep in mind, setting permissions for commands in the YAML is entirely optional.
     
  9. Offline

    Iervolino


    Yes but the command worked after that..
     
Thread Status:
Not open for further replies.

Share This Page