Ver Fonte

Add new DatabaseAPI

nossr50 há 6 anos atrás
pai
commit
7679afd3e0
2 ficheiros alterados com 34 adições e 1 exclusões
  1. 1 1
      Changelog.txt
  2. 33 0
      src/main/java/com/gmail/nossr50/api/DatabaseAPI.java

+ 1 - 1
Changelog.txt

@@ -1,5 +1,5 @@
 Version 2.1.70
-
+    Added new DatabaseAPI to the API package, has features relating to database operations
 
 Version 2.1.69
     Fixed a few places where mcMMO would not save player data immediately which may cause players to lose a few minutes of progress

+ 33 - 0
src/main/java/com/gmail/nossr50/api/DatabaseAPI.java

@@ -0,0 +1,33 @@
+package com.gmail.nossr50.api;
+
+import com.gmail.nossr50.datatypes.player.PlayerProfile;
+import com.gmail.nossr50.mcMMO;
+
+import java.util.UUID;
+
+public class DatabaseAPI {
+
+    /**
+     * Checks if a player exists in the mcMMO Database
+     * @param uuid player UUID
+     * @return true if the player exists in the DB, false if they do not
+     */
+    public boolean doesPlayerExistInDB(String uuid) {
+        return doesPlayerExistInDB(UUID.fromString(uuid));
+    }
+
+    /**
+     * Checks if a player exists in the mcMMO Database
+     * @param uuid player UUID
+     * @return true if the player exists in the DB, false if they do not
+     */
+    public boolean doesPlayerExistInDB(UUID uuid) {
+        PlayerProfile playerProfile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid);
+
+        if(playerProfile.isLoaded())
+            return true;
+        else
+            return false;
+    }
+
+}