Solved Message while using multiple arg commands

Discussion in 'Plugin Development' started by John Cena, Oct 5, 2015.

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

    John Cena

    Every time that a player runs a command that has multiple arguments it will send them a message showing the command without the argument in it for instance:

    Player runs '/fakename test':
    Recieves message "this is a test"
    Recieves message "/fakename" in white

    Any help is appreciated! Thank you!
  2. Offline


    @John Cena
    Can you show me your onEnable?

    I have had a thing similar to this.
  3. Offline


    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if (cmd.getName().equalsIgnoreCase("test"") && sender instanceof Player) {
                //You can remove this permission part if you want or change it freely idk really
                if (sender.hasPermission("tester.test") | sender.isOp()) {
                    if (args.length == 2) {
                    //This was extracted from a kick command of mine
                    ((Player)sender).sendMessage((Object)ChatColor.DARK_GRAY + "[Kicker]" + ChatColor.GREEN + "Player kicked!");
                    }     else {
                    ((Player)sender).sendMessage((Object)ChatColor.DARK_GRAY + "[Kicker]" + ChatColor.RED + "Usage: /kick <player> <reason>");
                //If you dont use permissions take this part out ;)
            }     else {
                    sender.sendMessage(ChatColor.DARK_GRAY + "[Kicker]" + ChatColor.RED + "Nope.");
            return true;
  4. Offline


    @John Cena what have you done so far? Can't help you if I cant see the error.
  5. Offline


    Whaaat??? Why is this even needed?

    You are almost certainly returning false after your onCommand method, which says that the command wasn't handled. This causes the usage from the plugin.yml to be sent back to the sender.
    Last edited: Oct 5, 2015
    John Cena likes this.
  6. Offline

    John Cena

    Ok thank you very much for your help!
Thread Status:
Not open for further replies.

Share This Page