Need some help with a simple plugin

Discussion in 'WIP and Development Status' started by keelar, Sep 1, 2011.

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

    keelar

    I need some help with this plugin I am making, it is very simple but I just got started with Java around 5 days ago so I'm still very new to this. I already know it's something very simple so hopefully someone will help me out. I am making a Plugin called 'TalkFor' it's very self explanatory. What I want to do is, when someone types "/talkfor <player> <message>" and it will say the message you entered under the name of the player you entered. And the problem I am having is, is when you enter a message and hit enter, it will only display the first part of the message, because as soon as you hit space it creates a new index for the array, I want my message to be more than a single word xD.

    here is the code
    Code:
    if (sender instanceof Player) {
      
                if(args.length == 2){
    
                try{
                    Player player2 = Bukkit.getServer().getPlayer(args[0]);
                    String message = (args[1]);
                    player2.chat(message);
                    }catch(Exception ex){
                        sender.sendMessage(ChatColor.DARK_AQUA + "Player not found");
                    }
                return false;
    
                }else{
                    return false;
                }
    
            } else {
                return false;
          }

    I know it's probably really simple, but like I said I just started learning java around 5 days ago so don't be too harsh.

    I also know it's a pretty stupid plugin, but it's just a starting point for me and will only be used on my server.

    Any help would be really appreciated.

    I think I posted this in the wrong area. My bad.

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

    dak393

    yep you did ;) just thinking about it for a sec I think I would just use a for loop to loop through all the args :) so:
    Code:
    String message = args[1];
    for (int i = 2; i < args.length; i++){
    message = message.concat(" " + args[i]);
    }
    I didn't test it so... if somethings wrong just message me XD
     
  3. Offline

    OzoneBuu

    I can see a whole lot of admin trolls downloading this.
     
Thread Status:
Not open for further replies.

Share This Page