Command Issues With Latest Bukkit Dev Releases

Discussion in 'Plugin Development' started by Intelli, Mar 26, 2011.

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

    Intelli

    Hey everyone,

    With the latest dev builds of bukkit (such as #588), I can no longer get commands to work.

    The code I was using was :

    Code:
    @Override
        public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
    String commandName = command.getName().toLowerCase();
    Player player = (Player)sender;
     String[] split = args;
    
    if (commandName.equals("help")) {
    player.sendMessage("Hello");
    }
    }
    
    This previously worked. However, now when someone types a command, it just shows in the chat.

    Such as "Username: /hello".

    --

    Any help is appreciated! =]

    Thanks!

    Is anyone else experiencing this issue with the latest builds?
    (onCommand not working)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
  2. Offline

    Acrobot

    You need to return true after you've executed your command.
    Also, from your example, are you really using correct command?
    Because in your code it's help, and you said /hello.

    If not, it may be CB's fault.
     
  3. Offline

    Intelli

    Yes, that code is just a shortened example.
    It works fine with #577 and any earlier releases.
    However, I'm having issues with any builds after that.

    I'll assume it's just bukkit.
     
  4. Offline

    Intelli

    For some reason, commands are getting sent to the onPlayerChat. If you set the chat as cancelled, the command will also be cancelled.

    The fix is to do something like this:

    Code:
    @Override
    public void onPlayerChat (PlayerChatEvent event){
      if (!event.getMessage().startsWith("/")){
       event.setCancelled(true);
      }
    }
    
     
  5. Offline

    Drakia

    I'm not getting this issue at all. I ported Warpz0r over to the latest build and it works as-is with onCommand
     
Thread Status:
Not open for further replies.

Share This Page