File tree Expand file tree Collapse file tree 3 files changed +41
-4
lines changed
java/io/tofpu/speedbridge2/game/infra Expand file tree Collapse file tree 3 files changed +41
-4
lines changed Original file line number Diff line number Diff line change 11package io .tofpu .speedbridge2 .game .infra .command ;
22
33import io .tofpu .speedbridge2 .command .ChildrenCommand ;
4+ import io .tofpu .speedbridge2 .game .infra .message .GameMessage ;
45import io .tofpu .speedbridge2 .game .service .GameService ;
56import io .tofpu .speedbridge2 .island .domain .Island ;
67import revxrsal .commands .annotation .Subcommand ;
@@ -17,18 +18,22 @@ public GameCommand(GameService gameService) {
1718 @ Subcommand ("join" )
1819 public void joinGame (BukkitCommandActor actor , Island island ) {
1920 if (gameService .startGame (actor .requirePlayer (), island )) {
20- actor .reply (String .format ("You joined island %d" , island .slot ()));
21+ GameMessage .GAME_JOINED .of (island .slot ())
22+ .send (actor .sender ());
2123 } else {
22- actor .reply ("&cYou're already in a game!" );
24+ GameMessage .ALREADY_IN_GAME .of (island .slot ())
25+ .send (actor .sender ());
2326 }
2427 }
2528
2629 @ Subcommand ("leave" )
2730 public void leaveGame (BukkitCommandActor actor ) {
2831 if (gameService .stopGame (actor .requirePlayer ())) {
29- actor .reply ("&eYou left the game" );
32+ GameMessage .GAME_LEFT .of ()
33+ .send (actor .sender ());
3034 } else {
31- actor .reply ("&cYou're not in a game!" );
35+ GameMessage .NOT_IN_GAME .of ()
36+ .send (actor .sender ());
3237 }
3338 }
3439}
Original file line number Diff line number Diff line change 1+ package io .tofpu .speedbridge2 .game .infra .message ;
2+
3+ import io .tofpu .speedbridge2 .util .message .MessageKey ;
4+
5+ public enum GameMessage implements MessageKey {
6+ GAME_JOINED ("game.joined" , "game" ),
7+ ALREADY_IN_GAME ("game.alreadyInGame" , "game" ),
8+ GAME_LEFT ("game.left" , "game" ),
9+ NOT_IN_GAME ("game.notInGame" , "game" );
10+
11+ private final String key ;
12+ private final String component ;
13+
14+ GameMessage (String key , String component ) {
15+ this .key = key ;
16+ this .component = component ;
17+ }
18+
19+ @ Override
20+ public String key () {
21+ return key ;
22+ }
23+
24+ @ Override
25+ public String component () {
26+ return component ;
27+ }
28+ }
Original file line number Diff line number Diff line change 1+ game.joined =&eYou have joined island {0}!
2+ game.alreadyInGame =&cYou are already in a game!
3+ game.left =&eYou have left island {0}!
4+ game.notInGame =&cYou are not in a game!
You can’t perform that action at this time.
0 commit comments