diff --git a/README.md b/README.md index 1f11a61..ec71339 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ You can view the full documentation [here](https://docs.auroramc.gg/auroralevels gg.auroramc AuroraLevels - 1.5.0 + 1.5.1 provided ``` @@ -51,7 +51,7 @@ repositories { } dependencies { - compileOnly 'gg.auroramc:AuroraLevels:1.5.0' + compileOnly 'gg.auroramc:AuroraLevels:1.5.1' } ``` @@ -62,6 +62,6 @@ repositories { } dependencies { - compileOnly("gg.auroramc:AuroraLevels:1.5.0") + compileOnly("gg.auroramc:AuroraLevels:1.5.1") } ``` \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 52cfc8b..8ebbf4f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,7 +18,7 @@ plugins { } group = "gg.auroramc" -version = "1.5.0" +version = "1.5.1" java.sourceCompatibility = JavaVersion.VERSION_21 java.targetCompatibility = JavaVersion.VERSION_21 @@ -37,7 +37,7 @@ repositories { dependencies { compileOnly("io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT") - compileOnly("gg.auroramc:Aurora:1.5.0") + compileOnly("gg.auroramc:Aurora:1.5.7") compileOnly("net.luckperms:api:5.4") compileOnly("dev.aurelium:auraskills-api-bukkit:2.0.7") compileOnly("io.lumine:Mythic-Dist:5.6.1") diff --git a/src/main/java/gg/auroramc/levels/leveler/PlayerLeveler.java b/src/main/java/gg/auroramc/levels/leveler/PlayerLeveler.java index c89559d..f809897 100644 --- a/src/main/java/gg/auroramc/levels/leveler/PlayerLeveler.java +++ b/src/main/java/gg/auroramc/levels/leveler/PlayerLeveler.java @@ -102,6 +102,7 @@ public double addXpToPlayer(Player player, double xp) { if (newXP < requiredXpToLevelUp) { data.setCurrentXP(newXP); + AuroraAPI.getLeaderboards().updateUser(AuroraAPI.getUserManager().getUser(player), "levels"); return xp; } @@ -116,6 +117,8 @@ public double addXpToPlayer(Player player, double xp) { Bukkit.getPluginManager().callEvent(new PlayerLevelUpEvent(player, data.getLevel())); } + AuroraAPI.getLeaderboards().updateUser(AuroraAPI.getUserManager().getUser(player), "levels"); + return xp; } @@ -205,6 +208,7 @@ public void setPlayerLevel(Player player, int level) { if (data.getLevel() > level) { data.setLevel(level); Bukkit.getPluginManager().callEvent(new PlayerLevelUpEvent(player, level)); + AuroraAPI.getLeaderboards().updateUser(AuroraAPI.getUserManager().getUser(player), "levels"); return; } @@ -213,12 +217,15 @@ public void setPlayerLevel(Player player, int level) { rewardPlayer(player, l); Bukkit.getPluginManager().callEvent(new PlayerLevelUpEvent(player, level)); } + + AuroraAPI.getLeaderboards().updateUser(AuroraAPI.getUserManager().getUser(player), "levels"); } public void setPlayerLevelRaw(Player player, int level) { var data = getUserData(player); data.setCurrentXP(0); data.setLevel(level); + AuroraAPI.getLeaderboards().updateUser(AuroraAPI.getUserManager().getUser(player), "levels"); } public double getXpForLevel(int level) { @@ -245,11 +252,4 @@ public void onUserLoaded(AuroraUserLoadedEvent event) { if (player == null) return; rewardAutoCorrector.correctRewards(player); } - - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onPlayerXPGain(PlayerXpGainEvent event) { - var user = AuroraAPI.getUser(event.getPlayer().getUniqueId()); - if (!user.isLoaded()) return; - AuroraAPI.getLeaderboards().updateUser(user, "levels"); - } } diff --git a/src/main/java/gg/auroramc/levels/menu/LevelMenu.java b/src/main/java/gg/auroramc/levels/menu/LevelMenu.java index 5d64f19..fb4afa7 100644 --- a/src/main/java/gg/auroramc/levels/menu/LevelMenu.java +++ b/src/main/java/gg/auroramc/levels/menu/LevelMenu.java @@ -52,13 +52,13 @@ private AuroraMenu createMenu() { var lbm = AuroraAPI.getLeaderboards(); var lb = AuroraAPI.getUser(player.getUniqueId()).getLeaderboardEntries().get("levels"); - var lbPositionPlaceholder = Placeholder.of("{lb_position}", lb == null ? lbm.getEmptyPlaceholder() : AuroraAPI.formatNumber(lb.getPosition())); + var lbPositionPlaceholder = Placeholder.of("{lb_position}", lb == null || lb.getPosition() == 0 ? lbm.getEmptyPlaceholder() : AuroraAPI.formatNumber(lb.getPosition())); var lbPositionPercentPlaceholder = Placeholder.of("{lb_position_percent}", - lb == null ? lbm.getEmptyPlaceholder() : AuroraAPI.formatNumber( + lb == null || lb.getPosition() == 0 ? lbm.getEmptyPlaceholder() : AuroraAPI.formatNumber( Math.min(((double) lb.getPosition() / Math.max(1, AuroraAPI.getLeaderboards().getBoardSize("levels"))) * 100, 100) ) ); - var lbBoardSizePlaceholder = Placeholder.of("{lb_size}", AuroraAPI.formatNumber(Math.max(AuroraAPI.getLeaderboards().getBoardSize("levels"), lb == null ? Bukkit.getOnlinePlayers().size() : Math.max(lb.getPosition(), Bukkit.getOnlinePlayers().size())))); + var lbBoardSizePlaceholder = Placeholder.of("{lb_size}", AuroraAPI.formatNumber(Math.max(AuroraAPI.getLeaderboards().getBoardSize("levels"), lb == null || lb.getPosition() == 0 ? Bukkit.getOnlinePlayers().size() : Math.max(lb.getPosition(), Bukkit.getOnlinePlayers().size())))); var totalCurrentXP = leveler.getXpForLevel(leveler.getUserData(player).getLevel()) + leveler.getUserData(player).getCurrentXP(); for (var customItem : menuConfig.getCustomItems().values()) { diff --git a/src/main/resources/menus/levels.yml b/src/main/resources/menus/levels.yml index c9fbd8d..603b9fa 100644 --- a/src/main/resources/menus/levels.yml +++ b/src/main/resources/menus/levels.yml @@ -2,12 +2,12 @@ title: "Player levels" # First is always the current completed level # Then the next level and the locked levels -level-track: [20, 21, 22, 23, 24] +level-track: [ 20, 21, 22, 23, 24 ] progress-bar: - length: 10 - filled-character: "&a&l■" - unfilled-character: "&7&l■" + length: 10 + filled-character: "&a&l■" + unfilled-character: "&7&l■" display-components: rewards: @@ -51,6 +51,19 @@ items: # Just set it to {} if you don't want to use custom menu items custom-items: + info: + name: "&aYour level ranking" + material: self_head + slot: 4 + lore: + - "&8Global ranking" + - "" + - "&7Your level: &f{level}" + - "&7Total XP: &f{current_short}" + - "" + - "&7Rank: &8#&a{lb_position}" + - "&8You are in the top &a{lb_position_percent}%&8 of &7{lb_size}" + - "&8players!" milestones: name: "&aMilestones" material: NETHER_STAR