Procházet zdrojové kódy

Added API to get a players rank on the leaderboards

TfT_02 před 12 roky
rodič
revize
3ddd8d2056

+ 2 - 1
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.

+ 34 - 0
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.
+     * </br>
+     * 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.
+     * </br>
+     * 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.
      * </br>