Skip to content

Commit

Permalink
Merge pull request #236 from cervinakuy/next-update
Browse files Browse the repository at this point in the history
v2.2.3
  • Loading branch information
cervinakuy authored Apr 8, 2024
2 parents dc187fa + 31d3506 commit 6954f42
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 21 deletions.
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@
<artifactId>worldguard-bukkit</artifactId>
<version>7.0.0</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
Expand All @@ -134,7 +140,7 @@
<dependency>
<groupId>com.github.cryptomorin</groupId>
<artifactId>XSeries</artifactId>
<version>9.9.0</version>
<version>9.10.0</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
45 changes: 30 additions & 15 deletions src/main/java/com/planetgallium/kitpvp/game/Leaderboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,40 @@ public Leaderboard(String name, List<TopEntry> 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);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/planetgallium/kitpvp/game/Leaderboards.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down

0 comments on commit 6954f42

Please sign in to comment.