Skip to content

Commit

Permalink
[Networking] Documentation fixes 🚂
Browse files Browse the repository at this point in the history
  • Loading branch information
ScribbleTAS committed Nov 16, 2023
1 parent 780a311 commit 022d31b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/main/java/com/minecrafttas/common/events/EventClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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()) {
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/com/minecrafttas/common/events/EventServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 022d31b

Please sign in to comment.