Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix minimessage tag resolver in list command #4290

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ public static void upgradeTranslationFile() throws IOException {
String userMove = "userMove";
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()))) {
paths
.filter(Files::isRegularFile)
Expand All @@ -68,6 +76,9 @@ public static void upgradeTranslationFile() throws IOException {
replaceInFile(p, minimumRadius, minimumRadiusReplacement);
replaceInFile(p, maximumMoves, maximumMovesReplacement);
replaceInFile(p, userMove, userMoveReplacement);
replaceInFile(p, listInfoUnknown, listInfoUnknownReplacement);
replaceInFile(p, listInfoServer, listInfoServerReplacement);
replaceInFile(p, listInfoEveryone, listInfoEveryoneReplacement);
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ public void run(Integer i, Plot plot, CaptionHolder caption) {
TextComponent.Builder builder = Component.text();
if (plot.getFlag(ServerPlotFlag.class)) {
TagResolver serverResolver = TagResolver.resolver(
"info.server",
"server",
Tag.inserting(TranslatableCaption.of("info.server").toComponent(player))
);
builder.append(MINI_MESSAGE.deserialize(server, serverResolver));
Expand All @@ -483,13 +483,13 @@ public void run(Integer i, Plot plot, CaptionHolder caption) {
builder.append(MINI_MESSAGE.deserialize(online, resolver));
} else if (uuidMapping.username().equalsIgnoreCase("unknown")) {
TagResolver unknownResolver = TagResolver.resolver(
"info.unknown",
"unknown",
Tag.inserting(TranslatableCaption.of("info.unknown").toComponent(player))
);
builder.append(MINI_MESSAGE.deserialize(unknown, unknownResolver));
} else if (uuidMapping.uuid().equals(DBFunc.EVERYONE)) {
TagResolver everyoneResolver = TagResolver.resolver(
"info.everyone",
"everyone",
Tag.inserting(TranslatableCaption.of("info.everyone").toComponent(player))
);
builder.append(MINI_MESSAGE.deserialize(everyone, everyoneResolver));
Expand Down
6 changes: 3 additions & 3 deletions Core/src/main/resources/lang/messages_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,9 @@
"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_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_server": "<hover:show_text:'<red>The plot is owned by the server</red>'><white><info.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_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><server></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_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>",
Expand Down
Loading