Solved Check If String Contains Partial Name

Discussion in 'Plugin Development' started by zachoooo, Nov 10, 2012.

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

    zachoooo

    I want to be able to color player names, and its really easy to check if a string contains a players name, but how do I check if it contains a partial player name. Like if there is a player named zachoooo on the server and someone says "zach" How can I get that to be detected and colored?
     
  2. Bukkit.matchPlayer("zach") != null means that there are players with that in their name, it returns a List, so you probably want to get the first Player from that list, because that most likely is the player you want.
    To color it you just add the colorcode you want in front of it.
     
  3. Offline

    zachoooo

    I can't just match the player, I have a string that needs to be scanned fro the matched player
     
  4. This will try to match that name: "zach" to a player, if it finds a match it will return a list of players that have that string in their name, if that isn't what you want than i don't get what you do want:p
     
  5. Offline

    Slipswhitley

    You need to use a for statement. for(Player player : getServer().getOnlinePlayers)
     
  6. Offline

    zachoooo

    Fixed with:
    Code:
    String message = event.getMessage();
            List<String> msgArgs =  Arrays.asList(message.split("\\s+"));
     
Thread Status:
Not open for further replies.

Share This Page