Skip to content

Commit

Permalink
Add helper method for disconnection
Browse files Browse the repository at this point in the history
  • Loading branch information
apple502j committed Sep 8, 2023
1 parent 5038f42 commit 1cbc18e
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.listener.ServerCommonPacketListener;
import net.minecraft.network.packet.Packet;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.thread.ThreadExecutor;

Expand Down Expand Up @@ -393,6 +394,14 @@ public static <T extends FabricPacket> void send(T packet) {
throw new IllegalStateException("Cannot send packet while not configuring!");
}

/**
* Disconnects from the server.
* @param handler the network handler
*/
public static void disconnect(ClientConfigurationNetworkHandler handler, Text reason) {
((ClientCommonNetworkHandlerAccessor) handler).getConnection().disconnect(reason);
}

private ClientConfigurationNetworking() {
}

Expand Down

0 comments on commit 1cbc18e

Please sign in to comment.