From 26ebc72cfb007227c7e337fb409e3fba77156211 Mon Sep 17 00:00:00 2001 From: Abdullah Arafat <62858251+kmaba@users.noreply.github.com> Date: Sat, 1 Feb 2025 22:11:51 +0800 Subject: [PATCH] Add response to lobby commands --- .../java/io/github/kmaba/vLobbyConnect/HubCommand.java | 8 ++++++-- .../java/io/github/kmaba/vLobbyConnect/LobbyCommand.java | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/github/kmaba/vLobbyConnect/HubCommand.java b/src/main/java/io/github/kmaba/vLobbyConnect/HubCommand.java index 96145db..53b23f3 100644 --- a/src/main/java/io/github/kmaba/vLobbyConnect/HubCommand.java +++ b/src/main/java/io/github/kmaba/vLobbyConnect/HubCommand.java @@ -80,8 +80,12 @@ public void execute(Invocation invocation) { return; } + if (player.getCurrentServer().isPresent() && player.getCurrentServer().get().getServerInfo().getName().equals(actualLobbyName)) { + player.sendMessage(Component.text("&cYou are already in a lobby.")); + return; + } + logger.info("Player {} connecting to lobby '{}'", player.getUsername(), typedKey); player.createConnectionRequest(targetServer.get()).fireAndForget(); - player.sendMessage(Component.text("Connecting to " + typedKey + "...")); } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/kmaba/vLobbyConnect/LobbyCommand.java b/src/main/java/io/github/kmaba/vLobbyConnect/LobbyCommand.java index 71ea4e5..4c3a214 100644 --- a/src/main/java/io/github/kmaba/vLobbyConnect/LobbyCommand.java +++ b/src/main/java/io/github/kmaba/vLobbyConnect/LobbyCommand.java @@ -80,8 +80,12 @@ public void execute(Invocation invocation) { return; } + if (player.getCurrentServer().isPresent() && player.getCurrentServer().get().getServerInfo().getName().equals(actualLobbyName)) { + player.sendMessage(Component.text("&cYou are already in a lobby.")); + return; + } + logger.info("Player {} connecting to lobby '{}'", player.getUsername(), typedKey); player.createConnectionRequest(targetServer.get()).fireAndForget(); - player.sendMessage(Component.text("Connecting to " + typedKey + "...")); } -} \ No newline at end of file +}