Kick reason

Discussion in 'Plugin Development' started by Th3Controller, Jul 6, 2012.

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

    Th3Controller

    Title is pretty self explanatory. I know how to make the reason work however, if I type something like this "/kick thecontroller Horrible coder", it will only catch/display "You have been kicked. Reason: Horrible".

    Here's my code:
    Code:
    if(!(sender instanceof Player)){
                    if(args.length == 1){
                        Player other = (Bukkit.getServer().getPlayer(args[0]));
                        if(other == null){
                            sender.sendMessage(args[0] + " is not online!");
                        }else{
                            other.kickPlayer("You have been kicked. Reason: Undefined.");
                            Bukkit.getServer().broadcastMessage(args[0] + ChatColor.YELLOW + " has been kicked. Reason: Undefined.");
                        }
                    }else{
                        if(args.length >= 2){
                            Player other = (Bukkit.getServer().getPlayer(args[0]));
                            if(other == null){
                                sender.sendMessage(args[0] + " is not online!");
                            }else{
                                other.kickPlayer("You have been kicked. Reason: " + args[1]);
                                Bukkit.getServer().broadcastMessage(args[0] + ChatColor.YELLOW + " has been kicked. Reason: " + args[1]);
                            }
                        }else{
                            if(args.length < 1){
                                sender.sendMessage("Incorrect aguments!");
                                sender.sendMessage("Usage: /kick <player> [reason]");
                            }
                        }
                    }
                    return true;
                }
     
  2. thr code is working 100 as it should be, it is saying the 2ste argument as kick reason and not the arguments after it, like you coded, whats wrong whit that?
     
  3. Offline

    Th3Controller

    I want it to display more. However I don't know how to do that.
    For example:
    If I type /kick person You are dumb
    It will only display "You have been kicked. Reason: You"

    WHAT I want/expect:
    If I type /kick person You are smart
    It will display "You have been kicked. Reason: You are smart"

    Catch what I'm saying?
     
  4. String reason = "";
    for(int i = 2;i<args.lenght;i++)reason+=args+" ";
     
  5. Offline

    Th3Controller

    Where do I place that :confused:
     
  6. Offline

    JOPHESTUS

    Code:java
    1. StringBuilder b = new StringBuilder();
    2. /* 57 */ for (int i = 1; i < args.length; i++) {
    3. /* 58 */ if (i != 1)
    4. /* 59 */ b.append(" ");
    5. /* 60 */ b.append(args[i]);[/i]
     
    Th3Controller likes this.
  7. Offline

    Th3Controller

    You sir has just won one of your internets!
     
  8. Offline

    JOPHESTUS

    :)
     
Thread Status:
Not open for further replies.

Share This Page