DatabaseAPI.java 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package com.gmail.nossr50.api;
  2. import com.gmail.nossr50.datatypes.player.PlayerProfile;
  3. import com.gmail.nossr50.mcMMO;
  4. import org.bukkit.OfflinePlayer;
  5. import org.jetbrains.annotations.NotNull;
  6. import java.util.UUID;
  7. public class DatabaseAPI {
  8. /**
  9. * Checks if a player exists in the mcMMO Database
  10. * @param offlinePlayer target player
  11. * @return true if the player exists in the DB, false if they do not
  12. */
  13. public boolean doesPlayerExistInDB(@NotNull OfflinePlayer offlinePlayer) {
  14. PlayerProfile playerProfile = mcMMO.getDatabaseManager().loadPlayerProfile(offlinePlayer);
  15. return playerProfile.isLoaded();
  16. }
  17. /**
  18. * Checks if a player exists in the mcMMO Database
  19. * @param uuid target player
  20. * @return true if the player exists in the DB, false if they do not
  21. */
  22. public boolean doesPlayerExistInDB(@NotNull UUID uuid) {
  23. PlayerProfile playerProfile = null;
  24. try {
  25. playerProfile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid);
  26. } catch (Exception e) {
  27. return false;
  28. }
  29. return playerProfile.isLoaded();
  30. }
  31. /**
  32. * Checks if a player exists in the mcMMO Database
  33. * @param playerName target player
  34. * @return true if the player exists in the DB, false if they do not
  35. */
  36. public boolean doesPlayerExistInDB(@NotNull String playerName) {
  37. PlayerProfile playerProfile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName);
  38. return playerProfile.isLoaded();
  39. }
  40. }