1111import net .swofty .type .murdermysterygame .role .GameRole ;
1212import net .swofty .type .murdermysterygame .user .MurderMysteryPlayer ;
1313import net .swofty .type .generic .HypixelConst ;
14+ import net .swofty .type .generic .i18n .I18n ;
1415import net .swofty .type .generic .scoreboard .HypixelScoreboard ;
1516
1617import java .text .SimpleDateFormat ;
1718import java .util .ArrayList ;
1819import java .util .Date ;
1920import java .util .List ;
21+ import java .util .Map ;
2022
2123public class MurderMysteryGameScoreboard {
2224 private static final HypixelScoreboard scoreboard = new HypixelScoreboard ();
@@ -37,102 +39,106 @@ public static void start() {
3739 if (player .getInstance () == null ) continue ;
3840
3941 List <String > lines = new ArrayList <>();
40- lines .add ("§7" + new SimpleDateFormat ("MM/dd/yy" ).format (new Date ()) + " §8" + HypixelConst .getServerName ());
42+ lines .add ("§7" + new SimpleDateFormat (I18n . string ( "scoreboard.common.date_format" ) ).format (new Date ()) + " §8" + HypixelConst .getServerName ());
4143 lines .add ("§7 " );
4244
4345 if (game .getGameStatus () == GameStatus .WAITING ) {
44- lines .add ("§fMap: §a" + game .getMapEntry ().getName ());
45- lines .add ("§fPlayers: §a" + game .getPlayers ().size () + "/" + game .getGameType ().getMaxPlayers ());
46+ lines .add (I18n . string ( "scoreboard.murdermystery_game.map_label" ) + game .getMapEntry ().getName ());
47+ lines .add (I18n . string ( "scoreboard.murdermystery_game.players_label" ) + game .getPlayers ().size () + "/" + game .getGameType ().getMaxPlayers ());
4648 lines .add ("§7 " );
4749 if (game .getCountdown ().isActive ()) {
48- lines .add ("§fStarting in §a" + game .getCountdown ().getSecondsRemaining () + "s" );
50+ lines .add (I18n . string ( "scoreboard.murdermystery_game.starting_in_label" ) + game .getCountdown ().getSecondsRemaining () + I18n . string ( "scoreboard.murdermystery_game.starting_in_suffix" ) );
4951 } else {
50- lines .add ("§fWaiting for players..." );
52+ lines .add (I18n . string ( "scoreboard.murdermystery_game.waiting_for_players" ) );
5153 }
5254 lines .add ("§7 " );
53- lines .add ("§fMode: §a" + game .getGameType ().getDisplayName ());
55+ lines .add (I18n . string ( "scoreboard.murdermystery_game.mode_label" ) + game .getGameType ().getDisplayName ());
5456
5557 int playerCount = game .getPlayers ().size ();
5658 int murdererChance = playerCount > 0 ? Math .round (100f / playerCount ) : 0 ;
5759 int detectiveChance = playerCount > 0 ? Math .round (100f / playerCount ) : 0 ;
5860 Component actionBar = Component .empty ()
59- .append (Component .text ("Murderer Chance: " + murdererChance + "%" , NamedTextColor .RED ))
61+ .append (Component .text (I18n . string ( "scoreboard.murdermystery_game.actionbar.murderer_chance" , Map . of ( "chance" , String . valueOf ( murdererChance ))) , NamedTextColor .RED ))
6062 .append (Component .text (" " , NamedTextColor .GRAY ))
61- .append (Component .text ("Detective Chance: " + detectiveChance + "%" , NamedTextColor .AQUA ));
63+ .append (Component .text (I18n . string ( "scoreboard.murdermystery_game.actionbar.detective_chance" , Map . of ( "chance" , String . valueOf ( detectiveChance ))) , NamedTextColor .AQUA ));
6264 player .sendActionBar (actionBar );
6365 } else if (game .getGameStatus () == GameStatus .IN_PROGRESS ) {
6466 GameRole role = game .getRoleManager ().getRole (player .getUuid ());
6567
6668 if (player .isEliminated ()) {
67- lines .add ("§7§lSPECTATING" );
69+ lines .add (I18n . string ( "scoreboard.murdermystery_game.spectating_label" ) );
6870 lines .add ("§7 " );
6971
7072 if (role != null ) {
71- lines .add ("§fYour Role: " + getScoreboardRoleColor (role ) + role .getDisplayName ());
73+ lines .add (I18n . string ( "scoreboard.murdermystery_game.your_role_label" ) + " " + getScoreboardRoleColor (role ) + role .getDisplayName ());
7274 }
7375 lines .add ("§7 " );
7476
7577 int playersAlive = game .getRoleManager ().countAliveWithRole (GameRole .INNOCENT )
7678 + game .getRoleManager ().countAliveWithRole (GameRole .DETECTIVE )
7779 + game .getRoleManager ().countAliveWithRole (GameRole .MURDERER );
78- lines .add ("§fPlayers Alive: §a" + playersAlive );
80+ lines .add (I18n . string ( "scoreboard.murdermystery_game.players_alive_label" ) + playersAlive );
7981
8082 String timeLeft = formatTimeRemaining (game .getGameStartTime ());
81- lines .add ("§fTime Left: §a" + timeLeft );
83+ lines .add (I18n . string ( "scoreboard.murdermystery_game.time_left_label" ) + timeLeft );
8284 lines .add ("§7 " );
8385
8486 boolean detectiveAlive = game .getRoleManager ().countAliveWithRole (GameRole .DETECTIVE ) > 0 ;
85- String detectiveStatus = detectiveAlive ? "§aAlive" : "§cDead" ;
86- lines .add ("§fDetective: " + detectiveStatus );
87+ String detectiveStatus = detectiveAlive
88+ ? I18n .string ("scoreboard.murdermystery_game.detective_alive" )
89+ : I18n .string ("scoreboard.murdermystery_game.detective_dead" );
90+ lines .add (I18n .string ("scoreboard.murdermystery_game.detective_label" ) + " " + detectiveStatus );
8791 lines .add ("§7 " );
8892
89- lines .add ("§fMap: §a" + game .getMapEntry ().getName ());
93+ lines .add (I18n . string ( "scoreboard.murdermystery_game.map_label" ) + game .getMapEntry ().getName ());
9094 } else {
9195 if (role != null ) {
92- lines .add ("§fRole: " + getScoreboardRoleColor (role ) + role .getDisplayName ());
96+ lines .add (I18n . string ( "scoreboard.murdermystery_game.role_label" ) + " " + getScoreboardRoleColor (role ) + role .getDisplayName ());
9397 }
9498 lines .add ("§7 " );
9599
96100 int innocentsLeft = game .getRoleManager ().countAliveWithRole (GameRole .INNOCENT )
97101 + game .getRoleManager ().countAliveWithRole (GameRole .DETECTIVE );
98- lines .add ("§fInnocents Left: §a" + innocentsLeft );
102+ lines .add (I18n . string ( "scoreboard.murdermystery_game.innocents_left_label" ) + innocentsLeft );
99103
100104 String timeLeft = formatTimeRemaining (game .getGameStartTime ());
101- lines .add ("§fTime Left: §a" + timeLeft );
105+ lines .add (I18n . string ( "scoreboard.murdermystery_game.time_left_label" ) + timeLeft );
102106 lines .add ("§7 " );
103107
104108 boolean detectiveAlive = game .getRoleManager ().countAliveWithRole (GameRole .DETECTIVE ) > 0 ;
105- String detectiveStatus = detectiveAlive ? "§aAlive" : "§cDead" ;
106- lines .add ("§fDetective: " + detectiveStatus );
109+ String detectiveStatus = detectiveAlive
110+ ? I18n .string ("scoreboard.murdermystery_game.detective_alive" )
111+ : I18n .string ("scoreboard.murdermystery_game.detective_dead" );
112+ lines .add (I18n .string ("scoreboard.murdermystery_game.detective_label" ) + " " + detectiveStatus );
107113 lines .add ("§7 " );
108114
109- lines .add ("§fMap: §a" + game .getMapEntry ().getName ());
115+ lines .add (I18n . string ( "scoreboard.murdermystery_game.map_label" ) + game .getMapEntry ().getName ());
110116 }
111117 } else if (game .getGameStatus () == GameStatus .ENDING ) {
112- lines .add ("§a§lGAME OVER!" );
118+ lines .add (I18n . string ( "scoreboard.murdermystery_game.game_over" ) );
113119 lines .add ("§7 " );
114120
115121 GameRole role = game .getRoleManager ().getRole (player .getUuid ());
116122 if (role != null ) {
117- lines .add ("§fYour Role: " + getScoreboardRoleColor (role ) + role .getDisplayName ());
123+ lines .add (I18n . string ( "scoreboard.murdermystery_game.your_role_label" ) + " " + getScoreboardRoleColor (role ) + role .getDisplayName ());
118124 }
119125 lines .add ("§7 " );
120126
121127 int kills = player .getKillsThisGame ();
122128 if (kills > 0 ) {
123- lines .add ("§fYour Kills: §a" + kills );
129+ lines .add (I18n . string ( "scoreboard.murdermystery_game.your_kills_label" ) + kills );
124130 }
125131
126132 int tokens = player .getTokensEarnedThisGame ();
127- lines .add ("§fTokens Earned: §6" + tokens );
133+ lines .add (I18n . string ( "scoreboard.murdermystery_game.tokens_earned_label" ) + tokens );
128134 lines .add ("§7 " );
129135
130- lines .add ("§fMap: §a" + game .getMapEntry ().getName ());
131- lines .add ("§fMode: §a" + game .getGameType ().getDisplayName ());
136+ lines .add (I18n . string ( "scoreboard.murdermystery_game.map_label" ) + game .getMapEntry ().getName ());
137+ lines .add (I18n . string ( "scoreboard.murdermystery_game.mode_label" ) + game .getGameType ().getDisplayName ());
132138 }
133139
134140 lines .add ("§7 " );
135- lines .add ("§ewww.hypixel.net" );
141+ lines .add (I18n . string ( "scoreboard.common.footer" ) );
136142
137143 if (!scoreboard .hasScoreboard (player )) {
138144 scoreboard .createScoreboard (player , getSidebarName (animationFrame ));
@@ -148,15 +154,15 @@ public static void start() {
148154
149155 private static String getScoreboardRoleColor (GameRole role ) {
150156 return switch (role ) {
151- case MURDERER -> "§c" ;
152- case DETECTIVE -> "§b" ;
153- case INNOCENT -> "§a" ;
154- case ASSASSIN -> "§6" ;
157+ case MURDERER -> I18n . string ( "scoreboard.murdermystery_game.role_color.murderer" ) ;
158+ case DETECTIVE -> I18n . string ( "scoreboard.murdermystery_game.role_color.detective" ) ;
159+ case INNOCENT -> I18n . string ( "scoreboard.murdermystery_game.role_color.innocent" ) ;
160+ case ASSASSIN -> I18n . string ( "scoreboard.murdermystery_game.role_color.assassin" ) ;
155161 };
156162 }
157163
158164 private static String formatTimeRemaining (long gameStartTime ) {
159- if (gameStartTime == 0 ) return "5:00" ;
165+ if (gameStartTime == 0 ) return I18n . string ( "scoreboard.murdermystery_game.time_left_default" ) ;
160166 long elapsed = System .currentTimeMillis () - gameStartTime ;
161167 long remaining = GAME_DURATION_MS - elapsed ;
162168 if (remaining < 0 ) remaining = 0 ;
@@ -171,7 +177,7 @@ public static void removeCache(Player player) {
171177 }
172178
173179 private static String getSidebarName (int counter ) {
174- String baseText = "MURDER MYSTERY" ;
180+ String baseText = I18n . string ( "scoreboard.murdermystery_game.title_base" ) ;
175181 String [] colors = {"§f§l" , "§6§l" , "§e§l" };
176182 String endColor = "§a§l" ;
177183
0 commit comments