diff --git a/pom.xml b/pom.xml index e39d301..b163c73 100644 --- a/pom.xml +++ b/pom.xml @@ -124,6 +124,12 @@ worldguard-bukkit 7.0.0 provided + + + org.bstats + bstats-bukkit + + com.sk89q.worldguard @@ -134,7 +140,7 @@ com.github.cryptomorin XSeries - 9.9.0 + 9.10.0 compile diff --git a/src/main/java/com/planetgallium/kitpvp/command/MainCommand.java b/src/main/java/com/planetgallium/kitpvp/command/MainCommand.java index e826664..9bef710 100644 --- a/src/main/java/com/planetgallium/kitpvp/command/MainCommand.java +++ b/src/main/java/com/planetgallium/kitpvp/command/MainCommand.java @@ -225,12 +225,10 @@ private void executeDebugCommand(CommandSender sender) { String pluginVersion = plugin.getDescription().getVersion() + " " + (plugin.needsUpdate() ? "&c(Requires Update)" : "&a(Latest Version)"); String isSpawnSet = (config.contains("Arenas") ? "&aConfigured" : "&cUnconfigured"); - String supportDiscordLink = "https://discord.gg/Hfej6UR8Bk"; sender.sendMessage(Toolkit.translate("&7[&b&lKIT-PVP&7] &aServer Version: &7" + serverVersion)); sender.sendMessage(Toolkit.translate("&7[&b&lKIT-PVP&7] &aPlugin Version: &7" + pluginVersion)); sender.sendMessage(Toolkit.translate("&7[&b&lKIT-PVP&7] &aSpawn Set: " + isSpawnSet)); - sender.sendMessage(Toolkit.translate("&7[&b&lKIT-PVP&7] &aSupport Discord: &7" + supportDiscordLink)); sender.sendMessage(Toolkit.translate("&7[&b&lKIT-PVP&7] &aPlugin List: &7" + names)); } diff --git a/src/main/java/com/planetgallium/kitpvp/game/Leaderboard.java b/src/main/java/com/planetgallium/kitpvp/game/Leaderboard.java index b3b9028..4269b9e 100644 --- a/src/main/java/com/planetgallium/kitpvp/game/Leaderboard.java +++ b/src/main/java/com/planetgallium/kitpvp/game/Leaderboard.java @@ -19,25 +19,40 @@ public Leaderboard(String name, List initialRankings, int maxSize) { } public void updateRankings(TopEntry playerEntry) { - if (rankings.size() < maxSize) { - rankings.add(playerEntry); - sortRankings(); - } else if (rankings.size() == maxSize) { - TopEntry lowestRankingPlayer = rankings.get(rankings.size() - 1); - if (playerEntry.getValue() > lowestRankingPlayer.getValue()) { - if (!rankingsContainPlayer(playerEntry.getIdentifier())) { - // remove lowest ranking player and add new better player - rankings.remove(rankings.size() - 1); - rankings.add(playerEntry); - } else { - // update ranking for player already in leaderboard - updatePlayerEntryInRanking(playerEntry); - } - sortRankings(); // resort in both above cases + if (rankingsContainPlayer(playerEntry.getIdentifier())) { + // Update the player's score if they are already in the leaderboard + updatePlayerEntryInRanking(playerEntry); + } else if (rankings.size() < maxSize || playerEntry.getValue() > rankings.get(rankings.size() - 1).getValue()) { + // Add the new player if there's space, or they have a higher score than the lowest in the leaderboard + if (rankings.size() == maxSize) { + // Remove the lowest ranking player to make space for the new entry + rankings.remove(rankings.size() - 1); } + rankings.add(playerEntry); } + sortRankings(); } +// public void updateRankings(TopEntry playerEntry) { +// if (rankings.size() < maxSize) { +// rankings.add(playerEntry); +// sortRankings(); +// } else if (rankings.size() == maxSize) { +// TopEntry lowestRankingPlayer = rankings.get(rankings.size() - 1); +// if (playerEntry.getValue() > lowestRankingPlayer.getValue()) { +// if (!rankingsContainPlayer(playerEntry.getIdentifier())) { +// // remove lowest ranking player and add new better player +// rankings.remove(rankings.size() - 1); +// rankings.add(playerEntry); +// } else { +// // update ranking for player already in leaderboard +// updatePlayerEntryInRanking(playerEntry); +// } +// sortRankings(); // resort in both above cases +// } +// } +// } + public TopEntry getNRanking(int n) { // n = 1 is top player if (n <= rankings.size() && n >= 1) { return rankings.get(n - 1); diff --git a/src/main/java/com/planetgallium/kitpvp/game/Leaderboards.java b/src/main/java/com/planetgallium/kitpvp/game/Leaderboards.java index 709723b..fff22a6 100644 --- a/src/main/java/com/planetgallium/kitpvp/game/Leaderboards.java +++ b/src/main/java/com/planetgallium/kitpvp/game/Leaderboards.java @@ -17,9 +17,9 @@ public Leaderboards(Game plugin) { leaderboards.put("kills", new Leaderboard("kills", database.getTopNStats("kills", 25), 25)); leaderboards.put("deaths", - new Leaderboard("kills", database.getTopNStats("deaths", 25), 25)); + new Leaderboard("deaths", database.getTopNStats("deaths", 25), 25)); leaderboards.put("level", - new Leaderboard("kills", database.getTopNStats("level", 25), 25)); + new Leaderboard("level", database.getTopNStats("level", 25), 25)); } public void updateRankings(String leaderboardName, TopEntry newEntry) { diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 99786ce..78c4a35 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,7 +1,7 @@ name: KitPvP author: Cervinakuy main: com.planetgallium.kitpvp.Game -version: 2.2.2 +version: 2.2.3 description: The ultimate all-in-one KitPvP plugin. website: https://www.spigotmc.org/resources/27107/ softdepend: [PlaceholderAPI, WorldGuard]