From 3ddd8d2056567fc3be8edb0165c99fdc111c4c56 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Tue, 13 Aug 2013 09:37:45 +0200 Subject: [PATCH] Added API to get a players rank on the leaderboards --- Changelog.txt | 3 +- .../com/gmail/nossr50/api/ExperienceAPI.java | 34 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 04fe48ddd..47fc7a989 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -11,7 +11,8 @@ Version 1.4.07-dev + Added snow to excavation + Added new experience curve option. Cumulative curve, calculates experience needed for next level using power level. + Added extra settings to config.yml for Call of the Wild (Taming) - + Added a 5 cooldown after teleporting before Acrobatics XP can be earned. + Config option to disable + + Added a 5 second cooldown after teleporting before Acrobatics XP can be earned. + Config option to disable + + Added new API methods to ExperienceAPI to get a players rank on the leaderboards + Added new McMMOPlayerDeathPenaltyEvent, fired when a player dies and would lose levels = Fixed bug with Skull Splitter not finding the locale string = Fixed issue where locale strings could cause the scoreboard header to be longer than 16 characters. diff --git a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java index fca322259..b817bc15b 100644 --- a/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java +++ b/src/main/java/com/gmail/nossr50/api/ExperienceAPI.java @@ -435,6 +435,40 @@ public final class ExperienceAPI { return Config.getInstance().getPowerLevelCap(); } + /** + * Get the position on the leaderboard of a player. + *
+ * This function is designed for API usage. + * + * @param playerName The name of the player to check + * @param skillType The skill to check + * + * @throws InvalidSkillException if the given skill is not valid + * @throws InvalidPlayerException if the given player does not exist in the database + * @throws UnsupportedOperationException if the given skill is a child skill + * + * @return the position on the leaderboard + */ + public static int getPlayerRankSkill(String playerName, String skillType) { + return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(getNonChildSkillType(skillType).toString()); + } + + + /** + * Get the position on the power level leaderboard of a player. + *
+ * This function is designed for API usage. + * + * @param playerName The name of the player to check + * + * @throws InvalidPlayerException if the given player does not exist in the database + * + * @return the position on the power level leaderboard + */ + public static int getPlayerRankOverall(String playerName) { + return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get("ALL"); + } + /** * Sets the level of a player in a specific skill type. *