Skip to content

Obtaining a Person Object

HelightDev edited this page Sep 2, 2019 · 2 revisions

You generally have three options to obtain a Person object.

Using the UserAPI

Example

UserAPI.getPerson("PlayerNameOrUUID");

Advantages & Disadvantages

  • Can resolve UUID and Name [+]
  • Is thread-blocking and should therefor only be used in asynchronous Processes [/]
  • Does multiple Database Queries [-]

Using SpecificPerson Implementations

Example

Person person = BukkitPerson.fromPlayer(player);

Advantages & Disadvantages

  • Doesn't need any Database Connection and therefor is very fast [+]
  • Isn't thread-blocking and can therefor be used in the mainthread without interrupting the heartbeat [/]
  • Code is platform-specific [-]

Using Constructors of Person

Example

Person person = new Person(null,"YourUUID","YourName");

Advantages & Disadvantages (Deprecated)

  • Completely depends on the way, the arguments are obtained [/]