From 2ae3047787086b7a7945b04c2c909e683b31e093 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 2 Jan 2022 11:36:49 +0100 Subject: [PATCH] Implement execute command packet for lobby --- .../de/steamwar/comms/PacketIdManager.java | 1 + .../comms/packets/ExecuteCommandPacket.java | 47 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 SpigotCore_Main/src/de/steamwar/comms/packets/ExecuteCommandPacket.java diff --git a/SpigotCore_Main/src/de/steamwar/comms/PacketIdManager.java b/SpigotCore_Main/src/de/steamwar/comms/PacketIdManager.java index f7b71e4..d4e85a2 100644 --- a/SpigotCore_Main/src/de/steamwar/comms/PacketIdManager.java +++ b/SpigotCore_Main/src/de/steamwar/comms/PacketIdManager.java @@ -27,6 +27,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; public static final byte INVENTORY_CALLBACK_PACKET = 0x11; diff --git a/SpigotCore_Main/src/de/steamwar/comms/packets/ExecuteCommandPacket.java b/SpigotCore_Main/src/de/steamwar/comms/packets/ExecuteCommandPacket.java new file mode 100644 index 0000000..bede2b2 --- /dev/null +++ b/SpigotCore_Main/src/de/steamwar/comms/packets/ExecuteCommandPacket.java @@ -0,0 +1,47 @@ +/* + 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.comms.packets; + +import com.google.common.io.ByteArrayDataOutput; +import de.steamwar.comms.PacketIdManager; +import de.steamwar.sql.SteamwarUser; +import org.bukkit.entity.Player; + +public class ExecuteCommandPacket extends SpigotPacket { + + private final SteamwarUser user; + private final String command; + + public ExecuteCommandPacket(Player player, String command) { + this.user = SteamwarUser.get(player.getUniqueId()); + this.command = command; + } + + @Override + public int getName() { + return PacketIdManager.EXECUTE_COMMAND; + } + + @Override + public void writeVars(ByteArrayDataOutput out) { + out.writeInt(user.getId()); + out.writeUTF(command); + } +} -- 2.39.5