From c6a4a68ae856b580213971c6d922b59ccb13084f Mon Sep 17 00:00:00 2001 From: Zak <34372536+ZakShearman@users.noreply.github.com> Date: Mon, 19 Aug 2024 22:31:14 +0100 Subject: [PATCH] feat: improved current server command --- .../currentserver/CurrentServerCommand.java | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/main/java/dev/emortal/minestom/core/module/kubernetes/command/currentserver/CurrentServerCommand.java b/src/main/java/dev/emortal/minestom/core/module/kubernetes/command/currentserver/CurrentServerCommand.java index d516a09..c70f3ea 100644 --- a/src/main/java/dev/emortal/minestom/core/module/kubernetes/command/currentserver/CurrentServerCommand.java +++ b/src/main/java/dev/emortal/minestom/core/module/kubernetes/command/currentserver/CurrentServerCommand.java @@ -22,14 +22,9 @@ public final class CurrentServerCommand extends Command { private static final Logger LOGGER = LoggerFactory.getLogger(CurrentServerCommand.class); - private static final String MESSAGE = """ - Proxy: - Server: - Fleet: """; private static final String COPY_MESSAGE = """ Proxy: %s Server: %s - Instance: %s Position: %s"""; private final @NotNull PlayerTrackerService playerTracker; @@ -59,13 +54,30 @@ private void onExecute(@NotNull CommandSender sender, @NotNull CommandContext co return; } - var serverId = Placeholder.unparsed("server_id", currentServer.getServerId()); - var proxyId = Placeholder.unparsed("proxy_id", currentServer.getProxyId()); - var fleetId = Placeholder.unparsed("fleet_id", currentServer.getFleetName()); + Component message = Component.text().append( + Component.text("Proxy: ", NamedTextColor.DARK_PURPLE) + .append(Component.text(currentServer.getProxyId(), NamedTextColor.LIGHT_PURPLE)) + .hoverEvent(HoverEvent.showText(Component.text("Click to copy Proxy ID", NamedTextColor.GREEN))) + .clickEvent(ClickEvent.copyToClipboard(currentServer.getProxyId())) + ).append( + Component.newline() + .append(Component.text("Server: ", NamedTextColor.DARK_PURPLE)) + .append(Component.text(currentServer.getServerId(), NamedTextColor.LIGHT_PURPLE)) + .hoverEvent(HoverEvent.showText(Component.text("Click to copy Server ID", NamedTextColor.GREEN))) + .clickEvent(ClickEvent.copyToClipboard(currentServer.getServerId())) + ).append( + Component.newline() + .append(Component.text("Fleet: ", NamedTextColor.DARK_PURPLE)) + .append(Component.text(currentServer.getFleetName(), NamedTextColor.LIGHT_PURPLE)) + .hoverEvent(HoverEvent.showText(Component.text("Click to copy Fleet Name", NamedTextColor.GREEN))) + .clickEvent(ClickEvent.copyToClipboard(currentServer.getFleetName())) + ).append( + Component.newline() + .append(Component.text("⎘ Click to copy", NamedTextColor.GREEN)) + .clickEvent(ClickEvent.copyToClipboard(this.createCopyableData(currentServer, player))) + .hoverEvent(HoverEvent.showText(Component.text("Click to copy all data", NamedTextColor.GREEN))) + ).build(); - var message = MiniMessage.miniMessage().deserialize(MESSAGE, serverId, proxyId, fleetId) - .clickEvent(ClickEvent.copyToClipboard(this.createCopyableData(currentServer, player))) - .hoverEvent(HoverEvent.showText(Component.text("Click to copy", NamedTextColor.GREEN))); sender.sendMessage(message); } @@ -73,7 +85,6 @@ private void onExecute(@NotNull CommandSender sender, @NotNull CommandContext co return COPY_MESSAGE.formatted( server.getProxyId(), server.getServerId(), - player.getInstance().getUniqueId(), this.formatPos(player.getPosition()) ); }