Skip to content

Commit

Permalink
Updated stats command messages and design
Browse files Browse the repository at this point in the history
  • Loading branch information
Despical committed Dec 3, 2023
1 parent 412ab98 commit 412ef6f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The project isn't in the Central Repository yet, so specifying a repository is n
<dependency>
<groupId>com.github.Despical</groupId>
<artifactId>OITC</artifactId>
<version>2.5.0</version>
<version>2.5.2</version>
<scope>compile</scope>
</dependency>
```
Expand All @@ -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";
}
```
</details>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>me.despical</groupId>
<artifactId>one-in-the-chamber</artifactId>
<version>2.5.1</version>
<version>2.5.2</version>
<packaging>jar</packaging>

<name>One In The Chamber</name>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/me/despical/oitc/api/StatsStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/me/despical/oitc/arena/ArenaManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 10 additions & 8 deletions src/main/resources/messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 412ef6f

Please sign in to comment.