Command outputting to chat

Discussion in 'Plugin Development' started by UnRatable, Dec 18, 2014.

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

    UnRatable

    So i've been having this problem for a while now.. I rewritten my entire plugin to try and fix it but I just cant :/.
    With a couple of commands it works fine but with the 7 I currently have they just output the command I type. It does do what it is told to do for example

    ------------------------
    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] arg) {
    if(sender instanceof Player) {
    Player player = (Player) sender;
    player.setHealth(20);
    player.setFoodLevel(20);
    player.sendMessage(ChatColor.GRAY + "Info" + ChatColor.DARK_GRAY + ">" + ChatColor.YELLOW + " Healed");
    } else {
    sender.sendMessage(ChatColor.GRAY + "Info" + ChatColor.DARK_GRAY + ">" + ChatColor.YELLOW + " Only usable by players");
    }
    return false;
    }
    ------------------------
    This will still heal the player and say in chat "Info> Healed".

    But when I type /heal I get:

    "/heal"
    "Info> Healed"

    I know I can just use essentials but im working on a completely custom plugin server, apart from anticheat. Also I am semi good at java the language itself but sorta new to bukkit development. I know the basics I have made tonnes of plugins to practice etc.

    Please help & reply asap as it would help me out alot! <3

    (If this is a common issue tell me aswell because I was looking on google for like half a hour and could not find anything)
     
  2. Offline

    teej107

    Returning false outputs the command usage. Return true to let the user know that the command was successfully executed.
     
  3. Offline

    ZackBlazes

    I've been having similar trouble with commands. @teej107 It has nothing to do with the return statement; I tried that.
     
  4. Offline

    WesJD

    @ZackBlazes You really shouldn't be telling someone they're wrong when I see that you don't know any better...
     
  5. Offline

    ZackBlazes

    WesJD, I'm not telling him that he's wrong. I'm just saying that I played around with it and it didn't change anything.

    Let's not start an argument here, ok?
     
  6. Offline

    teej107

    @ZackBlazes returning true is proven to not show the command usage as returning false does. Anything else is a failure on your logic. Don't believe me? Try it on an empty onCommand method returning true.
     
  7. Offline

    ZackBlazes

    I never meant for an entire argument to nascent from this. All I said was that it doesn't change anything FOR ME, and suddenly everyone's on my case.
     
  8. Offline

    teej107

    @ZackBlazes
    Taken from http://wiki.bukkit.org/Plugin_Tutorial#Commands
    If you want help with your problem, post a thread about it and I can help.
     
  9. Offline

    UnRatable

    @teej107, your method worked. Thanks as I said I know Java but not bukkit. And anyways don't start a argument.

    @teej107 also it only worked for the heal command, not for most of the others :/

    @teej107 I'd like to know what commands would use return true and or return false. Like heal uses return true, but day doesent :/ Thanks for your help so far aswell! :D

    EDIT by Timtower: merged posts, please use the edit button instead of double posting
     
    Last edited by a moderator: Dec 19, 2014
Thread Status:
Not open for further replies.

Share This Page