refactor: improved List command for server plots

This commit is contained in:
xaver106 2022-04-24 01:14:02 +02:00
parent c5d1655868
commit fed700f0d8
No known key found for this signature in database
GPG Key ID: 71FE12787D85A17E

View File

@ -462,6 +462,13 @@ public class ListCmd extends SubCommand {
String server = TranslatableCaption.of("info.plot_list_player_server").getComponent(player); String server = TranslatableCaption.of("info.plot_list_player_server").getComponent(player);
String everyone = TranslatableCaption.of("info.plot_list_player_everyone").getComponent(player); String everyone = TranslatableCaption.of("info.plot_list_player_everyone").getComponent(player);
TextComponent.Builder builder = Component.text(); TextComponent.Builder builder = Component.text();
if (plot.getFlag(ServerPlotFlag.class)) {
Template serverTemplate = Template.of(
"player",
TranslatableCaption.of("info.server").getComponent(player)
);
builder.append(MINI_MESSAGE.parse(server, serverTemplate));
} else {
try { try {
final List<UUIDMapping> names = PlotSquared.get().getImpromptuUUIDPipeline().getNames(plot.getOwners()) final List<UUIDMapping> names = PlotSquared.get().getImpromptuUUIDPipeline().getNames(plot.getOwners())
.get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS); .get(Settings.UUID.BLOCKING_TIMEOUT, TimeUnit.MILLISECONDS);
@ -511,6 +518,7 @@ public class ListCmd extends SubCommand {
} catch (TimeoutException e) { } catch (TimeoutException e) {
player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout")); player.sendMessage(TranslatableCaption.of("players.fetching_players_timeout"));
} }
}
Template players = Template.of("players", builder.asComponent()); Template players = Template.of("players", builder.asComponent());
caption.set(TranslatableCaption.of("info.plot_list_item")); caption.set(TranslatableCaption.of("info.plot_list_item"));
caption.setTemplates(command_tp, command_info, hover_info, numberTemplate, plotTemplate, players); caption.setTemplates(command_tp, command_info, hover_info, numberTemplate, plotTemplate, players);