How do I disconnect player from server (client side)
semenishchev opened this issue ยท 6 comments
I want to make mod, that disconnects player from server when certain message appears in chat (I've done listening with mixin) and after all checks i need to disconnect player with message something like bad message was found blah blah and after and then I can return to multiplayer menu (all this must be clientside)
This is not a fabric bug report.
Use discord or the discussions tab to ask for help.
@warjort Imo such questions are fine for issues.
@SashaSemenishchev You can look into how the /kick
command is implemented.
@warjort Imo such questions are fine for issues.
You should make a template for it then, instead of pointing people to the discord/discussions when you "create new issue".
@SashaSemenishchev You can look into how the /kick command is implemented.
Kick is server side. You need to look at net.minecraft.client.gui.screen.GameMenuScreen.
It's basically:
MinecraftClient client = MinecraftClient.getInstance();
client.world.disconnect(); // tell the server you are disconnecting
client.disconnect(screenToShowWhenDisconnecting);
client.openScreen(screenToShowAfterwards);
Never done it myself. But I bet it only works properly if you are on the render thread?