Skip to content

Commit

Permalink
Create separate Bingo.translatable and Bingo.translatableEscape
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed May 24, 2024
1 parent 4656ee1 commit 08c1f12
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
6 changes: 5 additions & 1 deletion common/src/main/java/io/github/gaming32/bingo/Bingo.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ public static void updateCommandTree(PlayerList playerList) {
playerList.getPlayers().forEach(playerList.getServer().getCommands()::sendCommands);
}

public static MutableComponent translatable(@Translatable(allowArbitraryArgs = true) String key, Object... args) {
public static MutableComponent translatable(@Translatable String key, Object... args) {
return BingoUtil.ensureHasFallback(Component.translatable(key, args));
}

public static MutableComponent translatableEscape(@Translatable(allowArbitraryArgs = true) String key, Object... args) {
return BingoUtil.ensureHasFallback(Component.translatableEscape(key, args));
}

Expand Down
15 changes: 8 additions & 7 deletions common/src/main/java/io/github/gaming32/bingo/BingoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,21 +77,21 @@ public class BingoCommand {
private static final SimpleCommandExceptionType NO_GAME_RUNNING =
new SimpleCommandExceptionType(Bingo.translatable("bingo.no_game_running"));
private static final DynamicCommandExceptionType CANNOT_SHOW_BOARD =
new DynamicCommandExceptionType(size -> Bingo.translatable("bingo.cannot_show_board", size));
new DynamicCommandExceptionType(size -> Bingo.translatableEscape("bingo.cannot_show_board", size));
private static final DynamicCommandExceptionType TEAM_ALREADY_EXISTS =
new DynamicCommandExceptionType(team -> Bingo.translatable(
new DynamicCommandExceptionType(team -> Bingo.translatableEscape(
"bingo.team_already_exists", ((PlayerTeam)team).getFormattedDisplayName()
));
private static final DynamicCommandExceptionType DUPLICATE_TEAMS =
new DynamicCommandExceptionType(team -> Bingo.translatable("bingo.duplicate_teams", ((PlayerTeam)team).getFormattedDisplayName()));
new DynamicCommandExceptionType(team -> Bingo.translatableEscape("bingo.duplicate_teams", ((PlayerTeam)team).getFormattedDisplayName()));
private static final DynamicCommandExceptionType UNKNOWN_DIFFICULTY =
new DynamicCommandExceptionType(difficultyId -> Bingo.translatable("bingo.unknown_difficulty", difficultyId));
new DynamicCommandExceptionType(difficultyId -> Bingo.translatableEscape("bingo.unknown_difficulty", difficultyId));
private static final DynamicCommandExceptionType UNKNOWN_GOAL =
new DynamicCommandExceptionType(goalId -> Bingo.translatable("bingo.unknown_goal", goalId));
new DynamicCommandExceptionType(goalId -> Bingo.translatableEscape("bingo.unknown_goal", goalId));
private static final DynamicCommandExceptionType UNKNOWN_TAG =
new DynamicCommandExceptionType(tagId -> Bingo.translatable("bingo.unknown_tag", tagId));
new DynamicCommandExceptionType(tagId -> Bingo.translatableEscape("bingo.unknown_tag", tagId));
private static final DynamicCommandExceptionType UNKNOWN_GAMEMODE =
new DynamicCommandExceptionType(gamemodeId -> Bingo.translatable("bingo.unknown_gamemode", gamemodeId));
new DynamicCommandExceptionType(gamemodeId -> Bingo.translatableEscape("bingo.unknown_gamemode", gamemodeId));
private static final DynamicCommandExceptionType FAILED_TO_START =
new DynamicCommandExceptionType(e ->
Bingo.translatable(e instanceof IllegalArgumentException ? "bingo.start.invalid_goal" : "bingo.start.failed")
Expand All @@ -101,6 +101,7 @@ public class BingoCommand {
);
private static final SimpleCommandExceptionType NO_TEAMS =
new SimpleCommandExceptionType(Bingo.translatable("bingo.no_teams"));

private static final SuggestionProvider<CommandSourceStack> ACTIVE_GOAL_SUGGESTOR = (context, builder) -> {
if (Bingo.activeGame == null) {
return builder.buildFuture();
Expand Down

0 comments on commit 08c1f12

Please sign in to comment.