Not need full name

Discussion in 'Plugin Development' started by gamingod, Feb 17, 2014.

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

    gamingod

    Hello,
    Just wonder, how would I make it so that you do not need to type a entire player's name in a command. For example if the player "Notch" was online and you did /msg n then it would message him. Please help, thanks!
     
  2. Offline

    Arcoz

    Bukkit already does this...
     
  3. Offline

    gamingod

    what about a custom plugin, like essentials. I do not mean tab complete
     
  4. Offline

    Retherz_

    public Player getPlayer(String name) {
    for(Player player : Bukkit.getOnlinePlayers()) {
    if(player.getName().toLowerCase().startsWith(name.toLowerCase()) return player;
    }
     
  5. Offline

    gamingod

    thanks, Ill try that
     
  6. Offline

    zack6849

    Retherz_, that method is a bad idea, use getServer().getPlayer(), that will do what you're looking for.
     
  7. Offline

    Retherz_

    Doesn't Bukkit.getPlayer(name) require the full name?
     
  8. Offline

    McMhz

    No, But Bukkit.getPlayerExact(String) does.
     
    zack6849 likes this.
Thread Status:
Not open for further replies.

Share This Page