Getting Player From String

Discussion in 'Plugin Development' started by onVoid, Jun 30, 2014.

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

    onVoid

    Okay so I know how to use, getPlayerExact, and getPlayer, to get a player from a string, but those are now deprecated. Is there a non deprecated method I can use to achieve this?
     
  2. Offline

    minoneer

    Hey,

    those methods are just temporarily deprecated, to allert plugin authors for the new changes to player UUID's. But those methods are still valid and can be used - if it makes sense in your plugin. They will be "undeprecated" soon.
     
  3. Offline

    1Rogue

    You should be retrieving players by UUID's if possible. Really the only sensible time to lookup by name is in commands.
     
  4. Offline

    onVoid

    This is an event in a kitpvp server. I only need it temporarily.
     
  5. Offline

    Garris0n

    Regardless, if you're saving players in any way, use UUIDs. Even if it's temporary, you should still use UUIDs. The only time using the name is really needed is if you're displaying it or taking input from a player (such as, say, /kick [player]).

    Anyway, read the PSA.
     
  6. Offline

    MCForger

    onVoid
    Instead of using the deprecated method you could just loop through all online players and check if the name provided equals ignore case the player online (If you really wanted to).
     
  7. Offline

    1Rogue


    which is exactly what the deprecated method does...
     
  8. Offline

    MCForger

    1Rogue
    Right but you would not be using the deprecated method...
     
  9. Offline

    Garris0n

    1. So? What's the point. If it were deprecated, doing the same thing the method does accomplishes absolutely nothing.
    2. I linked the PSA earlier in the thread. Read it. What you're saying doesn't make sense even if just cloning a deprecated method was a logical solution.
     
  10. Offline

    IkBenHarm

  11. Offline

    1Rogue


    UUID lookups will be faster as the server will be internally indexing by UUID. It's also more consistent and (in most cases) gives a clearer output of what your key-value represents (a UUID is more likely a player, but a string could be anything).
     
    IkBenHarm and Garris0n like this.
  12. Offline

    MCForger

    IkBenHarm 1Rogue
    The only reason I suggested this is because he's working with a string so I thought he might be using a string passed from a command.
     
  13. Offline

    Garris0n

    Well, he'll have to be getting the player object to verify they exist, and he can get the UUID from that.
     
Thread Status:
Not open for further replies.

Share This Page