diff --git a/Changelog.txt b/Changelog.txt index 521d87312..a60346e2c 100644 --- a/Changelog.txt +++ b/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 diff --git a/src/main/java/com/gmail/nossr50/api/DatabaseAPI.java b/src/main/java/com/gmail/nossr50/api/DatabaseAPI.java new file mode 100644 index 000000000..76caad65b --- /dev/null +++ b/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; + } + +}