From 17994ba85376b1341ccca2de21749c3fe5f2e21f Mon Sep 17 00:00:00 2001 From: LapisBerry Date: Wed, 22 May 2024 10:18:57 +0700 Subject: [PATCH] feat: JoinRequestPacket --- .../lapisberry/net/packets/ClientPacket.java | 12 ++++++++++ .../net/packets/JoinRequestPacket.java | 24 +++++++++++++++++++ .../lapisberry/net/packets/ServerPacket.java | 12 ++++++++++ 3 files changed, 48 insertions(+) create mode 100644 src/main/java/com/lapisberry/net/packets/ClientPacket.java create mode 100644 src/main/java/com/lapisberry/net/packets/JoinRequestPacket.java create mode 100644 src/main/java/com/lapisberry/net/packets/ServerPacket.java diff --git a/src/main/java/com/lapisberry/net/packets/ClientPacket.java b/src/main/java/com/lapisberry/net/packets/ClientPacket.java new file mode 100644 index 0000000..cb3d97a --- /dev/null +++ b/src/main/java/com/lapisberry/net/packets/ClientPacket.java @@ -0,0 +1,12 @@ +package com.lapisberry.net.packets; + +import java.io.Serial; +import java.io.Serializable; + +/** + * The {@code ClientPacket} class is a packet sending from client to server. + */ +public class ClientPacket implements Serializable { + @Serial + private static final long serialVersionUID = -2286074370601221667L; +} diff --git a/src/main/java/com/lapisberry/net/packets/JoinRequestPacket.java b/src/main/java/com/lapisberry/net/packets/JoinRequestPacket.java new file mode 100644 index 0000000..b6eab95 --- /dev/null +++ b/src/main/java/com/lapisberry/net/packets/JoinRequestPacket.java @@ -0,0 +1,24 @@ +package com.lapisberry.net.packets; + +import java.io.Serial; +import java.io.Serializable; + +/** + * The {@code JoinRequestPacket} class is the first packet sending from client to server to join the server. + */ +public class JoinRequestPacket extends ClientPacket implements Serializable { + @Serial + private static final long serialVersionUID = -3120924882895484001L; + // Fields + private final String username; + + // Constructors + public JoinRequestPacket(String username) { + this.username = username; + } + + // Getters + public String getUsername() { + return username; + } +} diff --git a/src/main/java/com/lapisberry/net/packets/ServerPacket.java b/src/main/java/com/lapisberry/net/packets/ServerPacket.java new file mode 100644 index 0000000..75366cd --- /dev/null +++ b/src/main/java/com/lapisberry/net/packets/ServerPacket.java @@ -0,0 +1,12 @@ +package com.lapisberry.net.packets; + +import java.io.Serial; +import java.io.Serializable; + +/** + * The {@code ServerPacket} class is a packet sending from server to client. + */ +public class ServerPacket implements Serializable { + @Serial + private static final long serialVersionUID = 726935260428407157L; +}