Why are we being forced to enter a player's entire name?

Discussion in 'Bukkit Help' started by GEN3RIC, Jan 17, 2011.

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

    GEN3RIC

    I've been making admin tools for a while now (I make BC2CC for Bad Company 2) and since day one we have required very few characters to ascertain the proper player.

    If you've got a player in your server with a long or difficult to type name, it's almost sadistic that we have to type it in perfectly. I haven't inspected how it's done programmatically, but it seems like it's just using a straight up equals() comparison when it should be matching startswith() or contains(). If the plugin has low confidence, return a message saying the name was too ambiguous to be certain and to increase the complexity of the characters supplied.

    Anybody oppose this?

    Edit: I'm aware some plugins do it right. Just thinking that with Bukkit being "new and improved" we could all agree upon a proper method of ascertaining a player from the list.
     
  2. Agreeing, here. This was one of the things hMod got right and it shouldn't be too hard to implement.
     
  3. Offline

    GEN3RIC

    My work was done in C# using LINQ. Does Java extend any similar functions? Regardless, it's easy. Just for the sake of discussion here's how I do it and my users love it.

    PHP:
            internal static string GetPlayerName(IEnumerable<PlayerplayerListstring playerName)
            {
                var 
    player = (playerList.Where(=> p.PlayerName.ToLower().Contains(playerName.ToLower())));

                if (
    player != null && player.Count() == 1)
                {
                    return 
    Enumerable.FirstOrDefault(player).PlayerName;
                }
                return 
    null;
            }
     
  4. Offline

    Afforess

  5. Offline

    GEN3RIC

  6. Offline

    Afforess

    Apologies. I edited my post before you even replied.
     
  7. Offline

    GEN3RIC

    Oh -- no worries.
     
Thread Status:
Not open for further replies.

Share This Page