UUID method

Discussion in 'Plugin Development' started by thecreator153, May 2, 2014.

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

    thecreator153

    Due to the changes from names to UUID's, i made a simple method that can allow you to get a player by their name. This is useful for when you want the user to type a command that requires the name of anohter player. Hope you find this practical.
    Code:java
    1. public Player getPlayerByName(String name) {
    2. for (Player p : Bukkit.getOnlinePlayers()) {
    3. if (p.getName().equalsIgnoreCase(name)) {
    4. return p;
    5. }
    6. }
    7. return null;
    8. }
     
  2. Offline

    LucasEmanuel

    Bukkit.getPlayer(UUID) is probably the preferred method ;)
     
  3. Offline

    hintss

    Or you could just Bukkit.getPlayer(name)...
     
  4. Offline

    DiamGamingWTF

    In a lot of situations, that method is depreciated. This method is perfect for my current project.
     
  5. Offline

    Rocoty

    DiamGamingWTF They will remove the @Deprecated annotation in 1.8...just continue using it.
     
  6. Offline

    hintss

    Deprecation doesn't mean you can't use it
     
  7. Offline

    DiamGamingWTF

    Rocoty hintss
    As far as I gathered, they remove all the methods with that @Deprecated annotation in 1.8. Meaning you should not use it if your planning to update your plugins to 1.8
     
  8. Offline

    DxDy

    Wrong.
    From here
     
  9. Offline

    TGRHavoc

    DiamGamingWTF
    Please do some more research the deprecation is just to raise the awareness if the changes that are coming in 1.8. They remove the deprecation annotation after the update NOT the methods.. Just for laughs and giggles reference, where did you gather your information from?
     
  10. Offline

    RawCode

    since most users never read any tutorials, news or frontpage marking method as deprecated was a bad move
     
  11. Offline

    XDdrummer

    Yeaah, Bukkit.getPlayer(name), player.getName(), Bukkit.getPlayerExact().. etc, etc, etc. Why is this necessary? o-O
     
  12. Offline

    raGan.

    I know that people already told you it's useless, but I just felt the need to show you why exactly it's useless.

    Take a look at what Bukkit.getPlayerExact(String name) does.
     
Thread Status:
Not open for further replies.

Share This Page