From f75e24787fc4deac074df3e37875fdd4a0fe0b7c Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 2 Jan 2022 11:31:57 +0100 Subject: [PATCH] Implement execute command handler for lobby Signed-off-by: Lixfel --- .../bungeecore/comms/PacketIdManager.java | 1 + .../bungeecore/comms/SpigotReceiver.java | 1 + .../comms/handlers/ExecuteCommandHandler.java | 36 +++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 src/de/steamwar/bungeecore/comms/handlers/ExecuteCommandHandler.java diff --git a/src/de/steamwar/bungeecore/comms/PacketIdManager.java b/src/de/steamwar/bungeecore/comms/PacketIdManager.java index 01d474a..8db10ad 100644 --- a/src/de/steamwar/bungeecore/comms/PacketIdManager.java +++ b/src/de/steamwar/bungeecore/comms/PacketIdManager.java @@ -26,6 +26,7 @@ public class PacketIdManager { public static final byte TABLIST_NAME = 0x02; public static final byte PREPARE_SCHEM = 0x03; public static final byte BAUMEMBER_UPDATE = 0x04; + public static final byte EXECUTE_COMMAND = 0x05; //0x1(X) Bungee Inventory public static final byte INVENTORY_PACKET = 0x10; diff --git a/src/de/steamwar/bungeecore/comms/SpigotReceiver.java b/src/de/steamwar/bungeecore/comms/SpigotReceiver.java index ab6d246..8eadfd7 100644 --- a/src/de/steamwar/bungeecore/comms/SpigotReceiver.java +++ b/src/de/steamwar/bungeecore/comms/SpigotReceiver.java @@ -58,5 +58,6 @@ public class SpigotReceiver extends BasicListener { registerHandler(PacketIdManager.PREPARE_SCHEM, new PrepareSchemHandler()); registerHandler(PacketIdManager.I_AM_A_LOBBY, new ImALobbyHandler()); registerHandler(PacketIdManager.FIGHT_INFO, new FightInfoHandler()); + registerHandler(PacketIdManager.EXECUTE_COMMAND, new ExecuteCommandHandler()); } } diff --git a/src/de/steamwar/bungeecore/comms/handlers/ExecuteCommandHandler.java b/src/de/steamwar/bungeecore/comms/handlers/ExecuteCommandHandler.java new file mode 100644 index 0000000..0051e55 --- /dev/null +++ b/src/de/steamwar/bungeecore/comms/handlers/ExecuteCommandHandler.java @@ -0,0 +1,36 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2021 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +package de.steamwar.bungeecore.comms.handlers; + +import com.google.common.io.ByteArrayDataInput; +import de.steamwar.bungeecore.comms.SpigotHandler; +import de.steamwar.bungeecore.sql.SteamwarUser; +import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.config.ServerInfo; + +public class ExecuteCommandHandler implements SpigotHandler { + @Override + public void handle(ByteArrayDataInput in, ServerInfo info) { + SteamwarUser target = SteamwarUser.get(in.readInt()); + String command = in.readUTF(); + + ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getPlayer(target.getUuid()), command); + } +} -- 2.39.2