From 412ef6fcce8b39abe0362ca66e18ccc57b445fb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Berke=20Ak=C3=A7en?= Date: Sun, 3 Dec 2023 12:20:57 +0300 Subject: [PATCH] Updated stats command messages and design --- .github/README.md | 4 ++-- pom.xml | 2 +- .../me/despical/oitc/api/StatsStorage.java | 5 +++++ .../me/despical/oitc/arena/ArenaManager.java | 10 ++++++---- .../oitc/commands/AbstractCommand.java | 1 + src/main/resources/messages.yml | 18 ++++++++++-------- 6 files changed, 25 insertions(+), 15 deletions(-) diff --git a/.github/README.md b/.github/README.md index 5c38da2..48bb741 100644 --- a/.github/README.md +++ b/.github/README.md @@ -36,7 +36,7 @@ The project isn't in the Central Repository yet, so specifying a repository is n com.github.Despical OITC - 2.5.0 + 2.5.2 compile ``` @@ -53,7 +53,7 @@ repositories { ``` ``` dependencies { - compileOnly group: "com.github.Despical", name: "OITC", version: "2.5.1"; + compileOnly group: "com.github.Despical", name: "OITC", version: "2.5.2"; } ``` diff --git a/pom.xml b/pom.xml index 82b02c5..605fb01 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 me.despical one-in-the-chamber - 2.5.1 + 2.5.2 jar One In The Chamber diff --git a/src/main/java/me/despical/oitc/api/StatsStorage.java b/src/main/java/me/despical/oitc/api/StatsStorage.java index 7b3703d..088e407 100644 --- a/src/main/java/me/despical/oitc/api/StatsStorage.java +++ b/src/main/java/me/despical/oitc/api/StatsStorage.java @@ -22,6 +22,7 @@ import me.despical.commons.sorter.SortUtils; import me.despical.oitc.ConfigPreferences; import me.despical.oitc.Main; +import me.despical.oitc.user.User; import me.despical.oitc.user.data.MysqlManager; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; @@ -90,6 +91,10 @@ public enum StatisticType { this.persistent = persistent; } + public String from(User user) { + return Integer.toString(user.getStat(this)); + } + public String getName() { return name; } diff --git a/src/main/java/me/despical/oitc/arena/ArenaManager.java b/src/main/java/me/despical/oitc/arena/ArenaManager.java index eae0b1b..f2a7c60 100644 --- a/src/main/java/me/despical/oitc/arena/ArenaManager.java +++ b/src/main/java/me/despical/oitc/arena/ArenaManager.java @@ -193,8 +193,10 @@ public static void leaveAttempt(Player player, Arena arena) { User user = plugin.getUserManager().getUser(player); - if (user.getStat(StatsStorage.StatisticType.LOCAL_KILLS) > user.getStat(StatsStorage.StatisticType.HIGHEST_SCORE)) { - user.setStat(StatsStorage.StatisticType.HIGHEST_SCORE, user.getStat(StatsStorage.StatisticType.LOCAL_KILLS)); + int localKills = user.getStat(StatsStorage.StatisticType.LOCAL_KILLS); + + if (localKills > user.getStat(StatsStorage.StatisticType.HIGHEST_SCORE)) { + user.setStat(StatsStorage.StatisticType.HIGHEST_SCORE, localKills); } plugin.getUserManager().saveAllStatistic(user); @@ -317,8 +319,8 @@ private static String formatSummaryPlaceholders(String msg, Arena arena, Player String formatted = msg, topPlayerName = arena.getScoreboardManager().getTopPlayerName(0); User user = plugin.getUserManager().getUser(player); - formatted = formatted.replace("%score%", Integer.toString(user.getStat(StatsStorage.StatisticType.LOCAL_KILLS))); - formatted = formatted.replace("%deaths%", Integer.toString(user.getStat(StatsStorage.StatisticType.LOCAL_DEATHS))); + formatted = formatted.replace("%score%", StatsStorage.StatisticType.LOCAL_KILLS.from(user)); + formatted = formatted.replace("%deaths%", StatsStorage.StatisticType.LOCAL_DEATHS.from(user)); formatted = formatted.replace("%rank%", Integer.toString(arena.getScoreboardManager().getRank(player))); formatted = formatted.replace("%winner%", topPlayerName); formatted = formatted.replace("%winner_score%", Integer.toString(StatsStorage.getUserStats(plugin.getServer().getPlayer(topPlayerName), StatsStorage.StatisticType.LOCAL_KILLS))); diff --git a/src/main/java/me/despical/oitc/commands/AbstractCommand.java b/src/main/java/me/despical/oitc/commands/AbstractCommand.java index d28c5fc..d70a7b5 100644 --- a/src/main/java/me/despical/oitc/commands/AbstractCommand.java +++ b/src/main/java/me/despical/oitc/commands/AbstractCommand.java @@ -16,6 +16,7 @@ public AbstractCommand(final Main plugin) { this.chatManager = plugin.getChatManager(); this.plugin.getCommandFramework().registerCommands(this); } + public static void registerCommands(final Main plugin) { new AdminCommands(plugin); new PlayerCommands(plugin); diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml index cd6db1f..d263e65 100644 --- a/src/main/resources/messages.yml +++ b/src/main/resources/messages.yml @@ -35,14 +35,16 @@ Commands: Stats-Command: Header: "&l-----[YOUR STATS]-----" Header-Other: "&l-----[STATS FOR %player%]-----" - Footer: "&l----------------------" - Kills: "&aKills: &e" - Deaths: "&aDeaths: &e" - Wins: "&aWins: &e" - Loses: "&aLoses: &e" - Highest-Score: "&aHighest score: &e" - Games-Played: "&aGames played: &e" - + Messages: + - "%header%" + - "&8 * &aKills: &e%kills%" + - "&8 * &aDeaths: &e%deaths%" + - "&8 * &aWins: &e%wins%" + - "&8 * &aLoses: &e%loses%" + - "&8 * &aHighest score: &e%highest_score%" + - "&8 * &aGames played: &e%games_played%" + - "&l----------------------" + # In game scoreboard messages. # Don't use more than 48 characters if you use old versions of Minecraft! # Can be used up to 144 characters in 1.14 and higher versions.