From 022d31b9bc1236766759bdbca01be37cdede8d96 Mon Sep 17 00:00:00 2001 From: Scribble Date: Wed, 15 Nov 2023 20:39:21 +0100 Subject: [PATCH] =?UTF-8?q?[Networking]=20Documentation=20fixes=20?= =?UTF-8?q?=F0=9F=9A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/minecrafttas/common/events/EventClient.java | 12 ++++++++---- .../com/minecrafttas/common/events/EventServer.java | 11 +++++++++-- .../common/server/ByteBufferBuilder.java | 8 ++++++++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/minecrafttas/common/events/EventClient.java b/src/main/java/com/minecrafttas/common/events/EventClient.java index 724af00a..c789148c 100644 --- a/src/main/java/com/minecrafttas/common/events/EventClient.java +++ b/src/main/java/com/minecrafttas/common/events/EventClient.java @@ -265,12 +265,13 @@ public static void firePlayerJoinedClientSide(EntityPlayerSP player) { */ public static interface EventOtherPlayerJoinedClientSide extends EventBase { - public void onOtherPlayerJoinedClientSide(GameProfile profile); - /** * Fired when a different player other than yourself joins a server or a world * @param player The game profile of the player that joins the server or the world */ + public void onOtherPlayerJoinedClientSide(GameProfile profile); + + public static void fireOtherPlayerJoinedClientSide(GameProfile profile) { Common.LOGGER.trace(Common.Event, "Firing OtherPlayerJoinedClientSide"); for (EventBase eventListener : EventListenerRegistry.getEventListeners()) { @@ -283,14 +284,17 @@ public static void fireOtherPlayerJoinedClientSide(GameProfile profile) { } + /** + * Fired when the connection to the custom server was closed on the client side. + */ public static interface EventDisconnectClient extends EventBase { - public void onDisconnectClient(Client client); - /** * Fired when the connection to the custom server was closed on the client side. * @param client The client that is disconnecting */ + public void onDisconnectClient(Client client); + public static void fireDisconnectClient(Client client) { Common.LOGGER.trace(Common.Event, "Firing EventDisconnectClient"); for (EventBase eventListener : EventListenerRegistry.getEventListeners()) { diff --git a/src/main/java/com/minecrafttas/common/events/EventServer.java b/src/main/java/com/minecrafttas/common/events/EventServer.java index c4da5942..852d05aa 100644 --- a/src/main/java/com/minecrafttas/common/events/EventServer.java +++ b/src/main/java/com/minecrafttas/common/events/EventServer.java @@ -145,10 +145,14 @@ public static void firePlayerLeaveServerSide(EntityPlayerMP player) { } } + /** + * Fired when authentication was successful on the server side + */ public static interface EventClientCompleteAuthentication extends EventBase { /** * Fired when authentication was successful on the server side + * @param username The username of the client that is connecting */ public void onClientCompleteAuthentication(String username); @@ -163,14 +167,17 @@ public static void fireClientCompleteAuthentication(String username) { } } + /** + * Fired when the connection to the custom server was closed on the server side. + */ public static interface EventDisconnectServer extends EventBase { - public void onDisconnectServer(Client client); - /** * Fired when the connection to the custom server was closed on the server side. * @param client The client that is disconnecting */ + public void onDisconnectServer(Client client); + public static void fireDisconnectServer(Client client) { Common.LOGGER.trace(Common.Event, "Firing CustomServerClientDisconnect"); for (EventBase eventListener : EventListenerRegistry.getEventListeners()) { diff --git a/src/main/java/com/minecrafttas/common/server/ByteBufferBuilder.java b/src/main/java/com/minecrafttas/common/server/ByteBufferBuilder.java index 31d77c97..fedfc8a7 100644 --- a/src/main/java/com/minecrafttas/common/server/ByteBufferBuilder.java +++ b/src/main/java/com/minecrafttas/common/server/ByteBufferBuilder.java @@ -28,11 +28,19 @@ public ByteBufferBuilder(int id) { buffer.putInt(id); } + /** + * Creates a new ByteBufferBuilder with a packetId + * @param packet The address to which the packet is sent. Usually an enum. + */ public ByteBufferBuilder(PacketID packet) { this(packet.getID()); this.bufferPacketId = packet; } + /** + * Creates a ByteBufferBuilder from an existing buffer. Useful for sending the same buffer back. + * @param buf + */ public ByteBufferBuilder(ByteBuffer buf) { bufferIndex = SecureList.POOL.available(); buffer = SecureList.POOL.lock(bufferIndex);