Browse Source

Adding new messages

RedstoneFuture 1 năm trước cách đây
mục cha
commit
d065202dea

+ 4 - 4
missilewars-plugin/src/main/java/de/butzlabben/missilewars/commands/StatsCommands.java

@@ -182,7 +182,7 @@ public class StatsCommands extends BaseCommand {
 
     private StatsFetcher getFetcher(Player player, String[] args) {
         if (!Config.isFightStatsEnabled()) {
-            player.sendMessage(Messages.getPrefix() + "§cFightStats are not enabled!");
+            player.sendMessage(Messages.getMessage(true, Messages.MessageEnum.STATS_NOT_ENABLED));
             return null;
         }
         Date from = new Date(0);
@@ -191,7 +191,7 @@ public class StatsCommands extends BaseCommand {
             try {
                 from = format.parse(args[0]);
             } catch (ParseException e) {
-                player.sendMessage(Messages.getPrefix() + "§cPlease use the date format dd.MM.yyyy");
+                player.sendMessage(Messages.getMessage(true, Messages.MessageEnum.STATS_WRONG_DATE_FORMAT));
                 return null;
             }
             if (args.length > 1) {
@@ -201,10 +201,10 @@ public class StatsCommands extends BaseCommand {
 
         StatsFetcher fetcher = new StatsFetcher(from, arena);
         if (fetcher.getGameCount() < 10) {
-            player.sendMessage(Messages.getPrefix() + "Please play more than 10 games to enable fight stats");
+            player.sendMessage(Messages.getMessage(true, Messages.MessageEnum.STATS_TOO_FEW_GAMES));
             return null;
         }
-        player.sendMessage(Messages.getPrefix() + "Loading data...");
+        player.sendMessage(Messages.getMessage(true, Messages.MessageEnum.STATS_LOADING_DATA));
         return fetcher;
     }
 }

+ 7 - 1
missilewars-plugin/src/main/java/de/butzlabben/missilewars/configuration/Messages.java

@@ -168,7 +168,13 @@ public class Messages {
         SIGN_STATE_LOBBY("sign.state.lobby", "&aLobby"),
         SIGN_STATE_INGAME("sign.state.ingame", "&bIngame"),
         SIGN_STATE_ENDED("sign.state.ended", "&cRestarting..."),
-        SIGN_STATE_ERROR("sign.state.error", "&cError...");
+        SIGN_STATE_ERROR("sign.state.error", "&cError..."),
+
+        STATS_NOT_ENABLED("stats.not_enabled", "&cThe Fight Stats are not enabled!"),
+        STATS_FETCHING_PLAYERS("stats.fetching_players", "Fetching not cached player names: %currentSize%/%realSize%"),
+        STATS_LOADING_DATA("stats.loading_data", "Loading data..."),
+        STATS_WRONG_DATE_FORMAT("stats.wrong_date_format", "&cPlease use the date format 'dd.MM.yyyy'."),
+        STATS_TOO_FEW_GAMES("stats.too_few_games", "&cPlease play more than 10 games to enable the Fight Stats for you.");
 
         private final String path;
         private final String defaultMsg;

+ 3 - 1
missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/stats/PlayerGuiFactory.java

@@ -72,7 +72,9 @@ public class PlayerGuiFactory {
         int currentSize = names.size();
         if (realSize > currentSize) {
             if (Config.isContactAuth()) {
-                player.sendMessage(Messages.getPrefix() + "Fetching not cached player names: " + currentSize + "/" + realSize);
+                player.sendMessage(Messages.getMessage(true, Messages.MessageEnum.STATS_FETCHING_PLAYERS)
+                        .replace("currentSize", Integer.toString(currentSize))
+                        .replace("realSize", Integer.toString(realSize)));
                 ForkJoinPool.commonPool().execute(() -> {
                     List<UUID> missing = getMissingUUIDs();
                     int maxFetches = Math.min(missing.size(), MAX_FETCHES);