From 4c79af01820259984ea8587703db67f06a27c3ae Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 24 Apr 2022 20:55:46 +0200 Subject: [PATCH] :tada: Add Network Packets --- .../network/packets/NetworkHandler.java | 6 ++-- .../packets/client/ClientNetworkHandler.java | 13 +++++---- .../packets/common/FightInfoPacket.java | 28 +++++++++---------- .../packets/server/ServerNetworkHandler.java | 13 +++++---- 4 files changed, 31 insertions(+), 29 deletions(-) diff --git a/src/de/steamwar/network/packets/NetworkHandler.java b/src/de/steamwar/network/packets/NetworkHandler.java index cd068d0..926d3f7 100644 --- a/src/de/steamwar/network/packets/NetworkHandler.java +++ b/src/de/steamwar/network/packets/NetworkHandler.java @@ -22,7 +22,7 @@ package de.steamwar.network.packets; import de.steamwar.network.packets.common.FightInfoPacket; import de.steamwar.network.packets.common.FightEndsPacket; -public interface NetworkHandler { - void handle(FightEndsPacket packet); - void handle(FightInfoPacket packet); +public abstract class NetworkHandler { + public void handle(FightEndsPacket packet) {}; + public void handle(FightInfoPacket packet) {}; } diff --git a/src/de/steamwar/network/packets/client/ClientNetworkHandler.java b/src/de/steamwar/network/packets/client/ClientNetworkHandler.java index c8b7434..6698fe1 100644 --- a/src/de/steamwar/network/packets/client/ClientNetworkHandler.java +++ b/src/de/steamwar/network/packets/client/ClientNetworkHandler.java @@ -19,12 +19,13 @@ package de.steamwar.network.packets.client; +import de.steamwar.network.packets.NetworkHandler; import de.steamwar.network.packets.server.*; -public interface ClientNetworkHandler { - void handle(BaumemberUpdatePacket packet); - void handle(CloseInventoryPacket packet); - void handle(InventoryPacket packet); - void handle(PingPacket packet); - void handle(StartingServerPacket packet); +public abstract class ClientNetworkHandler extends NetworkHandler { + public void handle(BaumemberUpdatePacket packet) {}; + public void handle(CloseInventoryPacket packet) {}; + public void handle(InventoryPacket packet) {} + public void handle(PingPacket packet) {} + public void handle(StartingServerPacket packet) {} } diff --git a/src/de/steamwar/network/packets/common/FightInfoPacket.java b/src/de/steamwar/network/packets/common/FightInfoPacket.java index d0f416b..1d9e1e5 100644 --- a/src/de/steamwar/network/packets/common/FightInfoPacket.java +++ b/src/de/steamwar/network/packets/common/FightInfoPacket.java @@ -28,20 +28,20 @@ import java.util.List; public class FightInfoPacket extends CommonPacket{ private static final long serialVersionUID = 7448644597856605853L; - private String serverName; // Name of the Server - private String gameMode; // GameMode aka Schematictype (if known, else "") - private String arena; // Name of the arena - private String blueName; // Name of the blue team, expected to begin with "§a" colorcode - private String redName; // Name of the red team, expected to begin with "§a" colorcode - private String fightState; // Fight state (technical term) (if known, else "") - private int countdown; // Countdown state in seconds (if known, else 0) - private int blueLeader; // SWUserID of the blue team leader (if known, else 0) - private int redLeader; // SWUserID of the red team leader (if known, else 0) - private int blueSchem; // Blue SchemID (if known, else 0) - private int redSchem; // Red SchemID (if known, else 0) - private List bluePlayers; // List of Blue SWUserIDs - private List redPlayers; // List of Red SWUserIDs - private List spectators; // List of Spectator SWUserIDs + private String serverName; + private String gameMode; + private String arena; + private String blueName; + private String redName; + private String fightState; + private int countdown; + private int blueLeader; + private int redLeader; + private int blueSchem; + private int redSchem; + private List bluePlayers; + private List redPlayers; + private List spectators; @Override public void handle(NetworkHandler handler) { diff --git a/src/de/steamwar/network/packets/server/ServerNetworkHandler.java b/src/de/steamwar/network/packets/server/ServerNetworkHandler.java index 0a8cb7c..c418380 100644 --- a/src/de/steamwar/network/packets/server/ServerNetworkHandler.java +++ b/src/de/steamwar/network/packets/server/ServerNetworkHandler.java @@ -19,12 +19,13 @@ package de.steamwar.network.packets.server; +import de.steamwar.network.packets.NetworkHandler; import de.steamwar.network.packets.client.*; -public interface ServerNetworkHandler { - void handle(ExecuteCommandPacket packet); - void handle(ImALobbyPacket packet); - void handle(InventoryCallbackPacket packet); - void handle(PrepareSchemPacket packet); - void handle(TablistNamePacket packet); +public abstract class ServerNetworkHandler extends NetworkHandler { + public void handle(ExecuteCommandPacket packet) {}; + public void handle(ImALobbyPacket packet) {} + public void handle(InventoryCallbackPacket packet) {} + public void handle(PrepareSchemPacket packet) {} + public void handle(TablistNamePacket packet) {} }