Fix minimessage tag resolver in list command (#4290)

fix: update resolver tag names for list command
This commit is contained in:
Pierre Maurice Schwang 2024-01-12 09:35:11 +01:00 committed by GitHub
parent 8c44b2d2d2
commit e4613cfc62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 6 deletions

View File

@ -55,6 +55,14 @@ public class TranslationUpdateManager {
String userMove = "userMove"; String userMove = "userMove";
String userMoveReplacement = "user_move"; String userMoveReplacement = "user_move";
// tag opening / closing characters are important, as the locale keys exist as well, which should not be replaced
String listInfoUnknown = "<info.unknown>";
String listInfoUnknownReplacement = "<unknown>";
String listInfoServer = "<info.server>";
String listInfoServerReplacement = "<server>";
String listInfoEveryone = "<info.everyone>";
String listInfoEveryoneReplacement = "<everyone>";
try (Stream<Path> paths = Files.walk(Paths.get(PlotSquared.platform().getDirectory().toPath().resolve("lang").toUri()))) { try (Stream<Path> paths = Files.walk(Paths.get(PlotSquared.platform().getDirectory().toPath().resolve("lang").toUri()))) {
paths paths
.filter(Files::isRegularFile) .filter(Files::isRegularFile)
@ -68,6 +76,9 @@ public class TranslationUpdateManager {
replaceInFile(p, minimumRadius, minimumRadiusReplacement); replaceInFile(p, minimumRadius, minimumRadiusReplacement);
replaceInFile(p, maximumMoves, maximumMovesReplacement); replaceInFile(p, maximumMoves, maximumMovesReplacement);
replaceInFile(p, userMove, userMoveReplacement); replaceInFile(p, userMove, userMoveReplacement);
replaceInFile(p, listInfoUnknown, listInfoUnknownReplacement);
replaceInFile(p, listInfoServer, listInfoServerReplacement);
replaceInFile(p, listInfoEveryone, listInfoEveryoneReplacement);
}); });
} }
} }

View File

@ -465,7 +465,7 @@ public class ListCmd extends SubCommand {
TextComponent.Builder builder = Component.text(); TextComponent.Builder builder = Component.text();
if (plot.getFlag(ServerPlotFlag.class)) { if (plot.getFlag(ServerPlotFlag.class)) {
TagResolver serverResolver = TagResolver.resolver( TagResolver serverResolver = TagResolver.resolver(
"info.server", "server",
Tag.inserting(TranslatableCaption.of("info.server").toComponent(player)) Tag.inserting(TranslatableCaption.of("info.server").toComponent(player))
); );
builder.append(MINI_MESSAGE.deserialize(server, serverResolver)); builder.append(MINI_MESSAGE.deserialize(server, serverResolver));
@ -483,13 +483,13 @@ public class ListCmd extends SubCommand {
builder.append(MINI_MESSAGE.deserialize(online, resolver)); builder.append(MINI_MESSAGE.deserialize(online, resolver));
} else if (uuidMapping.username().equalsIgnoreCase("unknown")) { } else if (uuidMapping.username().equalsIgnoreCase("unknown")) {
TagResolver unknownResolver = TagResolver.resolver( TagResolver unknownResolver = TagResolver.resolver(
"info.unknown", "unknown",
Tag.inserting(TranslatableCaption.of("info.unknown").toComponent(player)) Tag.inserting(TranslatableCaption.of("info.unknown").toComponent(player))
); );
builder.append(MINI_MESSAGE.deserialize(unknown, unknownResolver)); builder.append(MINI_MESSAGE.deserialize(unknown, unknownResolver));
} else if (uuidMapping.uuid().equals(DBFunc.EVERYONE)) { } else if (uuidMapping.uuid().equals(DBFunc.EVERYONE)) {
TagResolver everyoneResolver = TagResolver.resolver( TagResolver everyoneResolver = TagResolver.resolver(
"info.everyone", "everyone",
Tag.inserting(TranslatableCaption.of("info.everyone").toComponent(player)) Tag.inserting(TranslatableCaption.of("info.everyone").toComponent(player))
); );
builder.append(MINI_MESSAGE.deserialize(everyone, everyoneResolver)); builder.append(MINI_MESSAGE.deserialize(everyone, everyoneResolver));

View File

@ -381,9 +381,9 @@
"info.plot_list_default": "<gold><plot></gold>", "info.plot_list_default": "<gold><plot></gold>",
"info.plot_list_player_online": "<dark_aqua><prefix></dark_aqua><hover:show_text:'<dark_aqua>Online</dark_aqua>'><gold><player></gold></hover>", "info.plot_list_player_online": "<dark_aqua><prefix></dark_aqua><hover:show_text:'<dark_aqua>Online</dark_aqua>'><gold><player></gold></hover>",
"info.plot_list_player_offline": "<dark_aqua><prefix></dark_aqua><hover:show_text:'<dark_gray>Offline</dark_gray>'><gold><player></gold></hover>", "info.plot_list_player_offline": "<dark_aqua><prefix></dark_aqua><hover:show_text:'<dark_gray>Offline</dark_gray>'><gold><player></gold></hover>",
"info.plot_list_player_unknown": "<hover:show_text:'<red>The owner of this plot is unknown</red>'><white><info.unknown></white></hover>", "info.plot_list_player_unknown": "<hover:show_text:'<red>The owner of this plot is unknown</red>'><white><unknown></white></hover>",
"info.plot_list_player_server": "<hover:show_text:'<red>The plot is owned by the server</red>'><white><info.server></white></hover>", "info.plot_list_player_server": "<hover:show_text:'<red>The plot is owned by the server</red>'><white><server></white></hover>",
"info.plot_list_player_everyone": "<hover:show_text:'<blue>The plot is owned by everyone</blue>'><white><info.everyone></white></hover>", "info.plot_list_player_everyone": "<hover:show_text:'<blue>The plot is owned by everyone</blue>'><white><everyone></white></hover>",
"info.area_info_format": "<header>\n<reset><gold>Name: </gold><gray><name></gray>\n<gold>Type: </gold><gray><type></gray>\n<gold>Terrain: </gold><gray><terrain></gray>\n<gold>Usage: </gold><gray><usage>%</gray>\n<gold>Claimed: </gold><gray><claimed></gray>\n<gold>Clusters: </gold><gray><clusters></gray>\n<gold>Region: </gold><gray><region></gray>\n<gold>Generator: </gold><gray><generator></gray>\n<footer>", "info.area_info_format": "<header>\n<reset><gold>Name: </gold><gray><name></gray>\n<gold>Type: </gold><gray><type></gray>\n<gold>Terrain: </gold><gray><terrain></gray>\n<gold>Usage: </gold><gray><usage>%</gray>\n<gold>Claimed: </gold><gray><claimed></gray>\n<gold>Clusters: </gold><gray><clusters></gray>\n<gold>Region: </gold><gray><region></gray>\n<gold>Generator: </gold><gray><generator></gray>\n<footer>",
"info.area_list_tooltip": "<gold>Claimed=</gold><gray><claimed></gray>\n<gold>Usage=</gold><gray><usage></gray>\n<gold>Clusters=</gold><gray><clusters></gray>\n<gold>Region=</gold><gray><region></gray>\n<gold>Generator=</gold><gray><generator></gray>", "info.area_list_tooltip": "<gold>Claimed=</gold><gray><claimed></gray>\n<gold>Usage=</gold><gray><usage></gray>\n<gold>Clusters=</gold><gray><clusters></gray>\n<gold>Region=</gold><gray><region></gray>\n<gold>Generator=</gold><gray><generator></gray>",
"info.area_list_item": "<click:run_command:'<command_tp>'><hover:show_text:'<command_tp>'><dark_gray>[</dark_gray><gold><number></gold><dark_gray>]</dark_gray></hover></click> <click:run_command:'<command_info>'><hover:show_text:'<hover_info>'><gold><area_name></gold></hover></click><gray> - </gray><gray><area_type>:<area_terrain></gray>", "info.area_list_item": "<click:run_command:'<command_tp>'><hover:show_text:'<command_tp>'><dark_gray>[</dark_gray><gold><number></gold><dark_gray>]</dark_gray></hover></click> <click:run_command:'<command_info>'><hover:show_text:'<hover_info>'><gold><area_name></gold></hover></click><gray> - </gray><gray><area_type>:<area_terrain></gray>",