diff --git a/src/de/steamwar/bungeecore/comms/PacketIdManager.java b/src/de/steamwar/bungeecore/comms/PacketIdManager.java index 8db10ad7..1ee0c27a 100644 --- a/src/de/steamwar/bungeecore/comms/PacketIdManager.java +++ b/src/de/steamwar/bungeecore/comms/PacketIdManager.java @@ -36,4 +36,5 @@ public class PacketIdManager { //0x2(X) Server Information System public static final byte I_AM_A_LOBBY = 0x20; public static final byte FIGHT_INFO = 0x21; + public static final byte FIGHT_ENDS = 0x22; } diff --git a/src/de/steamwar/bungeecore/comms/SpigotReceiver.java b/src/de/steamwar/bungeecore/comms/SpigotReceiver.java index 8eadfd74..3ad1a68e 100644 --- a/src/de/steamwar/bungeecore/comms/SpigotReceiver.java +++ b/src/de/steamwar/bungeecore/comms/SpigotReceiver.java @@ -22,6 +22,7 @@ package de.steamwar.bungeecore.comms; import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteStreams; import de.steamwar.bungeecore.comms.handlers.*; +import de.steamwar.bungeecore.comms.packets.FightEndsPacket; import de.steamwar.bungeecore.listeners.BasicListener; import net.md_5.bungee.api.connection.Server; import net.md_5.bungee.api.event.PluginMessageEvent; @@ -59,5 +60,6 @@ public class SpigotReceiver extends BasicListener { registerHandler(PacketIdManager.I_AM_A_LOBBY, new ImALobbyHandler()); registerHandler(PacketIdManager.FIGHT_INFO, new FightInfoHandler()); registerHandler(PacketIdManager.EXECUTE_COMMAND, new ExecuteCommandHandler()); + registerHandler(PacketIdManager.FIGHT_ENDS, new FightEndsHandler()); } } diff --git a/src/de/steamwar/bungeecore/comms/handlers/FightEndsHandler.java b/src/de/steamwar/bungeecore/comms/handlers/FightEndsHandler.java new file mode 100644 index 00000000..1592fccc --- /dev/null +++ b/src/de/steamwar/bungeecore/comms/handlers/FightEndsHandler.java @@ -0,0 +1,34 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 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.comms.packets.FightEndsPacket; +import net.md_5.bungee.api.config.ServerInfo; + +public class FightEndsHandler implements SpigotHandler { + + @Override + public void handle(ByteArrayDataInput in, ServerInfo info) { + FightEndsPacket fightEndsPacket = new FightEndsPacket(in); + + } +} diff --git a/src/de/steamwar/bungeecore/comms/packets/FightEndsPacket.java b/src/de/steamwar/bungeecore/comms/packets/FightEndsPacket.java new file mode 100644 index 00000000..cd9d4ea4 --- /dev/null +++ b/src/de/steamwar/bungeecore/comms/packets/FightEndsPacket.java @@ -0,0 +1,74 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 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.packets; + +import com.google.common.io.ByteArrayDataInput; +import com.google.common.io.ByteArrayDataOutput; +import de.steamwar.bungeecore.comms.BungeePacket; +import de.steamwar.bungeecore.comms.PacketIdManager; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.List; + +@AllArgsConstructor +@Getter +public class FightEndsPacket extends BungeePacket { + + private byte win; + private int blueSchem; + private int redSchem; + private List bluePlayers; + private List redPlayers; + + public FightEndsPacket(ByteArrayDataInput byteArrayDataInput) { + win = byteArrayDataInput.readByte(); + blueSchem = byteArrayDataInput.readInt(); + redSchem = byteArrayDataInput.readInt(); + int blueSize = byteArrayDataInput.readInt(); + for (int i = 0; i < blueSize; i++) { + bluePlayers.add(byteArrayDataInput.readInt()); + } + int redSize = byteArrayDataInput.readInt(); + for (int i = 0; i < redSize; i++) { + redPlayers.add(byteArrayDataInput.readInt()); + } + } + + @Override + public int getId() { + return PacketIdManager.FIGHT_ENDS; + } + + @Override + public void writeVars(ByteArrayDataOutput byteArrayDataOutput) { + byteArrayDataOutput.writeByte(win); + byteArrayDataOutput.writeInt(blueSchem); + byteArrayDataOutput.writeInt(redSchem); + byteArrayDataOutput.writeInt(bluePlayers.size()); + for (int i : bluePlayers) { + byteArrayDataOutput.writeInt(i); + } + byteArrayDataOutput.writeInt(redPlayers.size()); + for (int i : redPlayers) { + byteArrayDataOutput.writeInt(i); + } + } +}