public void closeConnection(String reason) { try { LOGGER.info("Disconnecting {}: {}", new Object[] {this.getConnectionInfo(), reason}); TextComponentString textcomponentstring = new TextComponentString(reason); this.networkManager.sendPacket(new SPacketDisconnect(textcomponentstring)); this.networkManager.closeChannel(textcomponentstring); } catch (Exception exception) { LOGGER.error((String)"Error whilst disconnecting player", (Throwable)exception); } }
/** * There are two recognized intentions for initiating a handshake: logging in and acquiring server status. The * NetworkManager's protocol will be reconfigured according to the specified intention, although a login-intention * must pass a versioncheck or receive a disconnect otherwise */ public void processHandshake(C00Handshake packetIn) { switch (packetIn.getRequestedState()) { case LOGIN: this.networkManager.setConnectionState(EnumConnectionState.LOGIN); if (packetIn.getProtocolVersion() > 316) { TextComponentString textcomponentstring = new TextComponentString("Outdated server! I\'m still on 1.11.2"); this.networkManager.sendPacket(new SPacketDisconnect(textcomponentstring)); this.networkManager.closeChannel(textcomponentstring); } else if (packetIn.getProtocolVersion() < 316) { TextComponentString textcomponentstring1 = new TextComponentString("Outdated client! Please use 1.11.2"); this.networkManager.sendPacket(new SPacketDisconnect(textcomponentstring1)); this.networkManager.closeChannel(textcomponentstring1); } else { this.networkManager.setNetHandler(new NetHandlerLoginServer(this.server, this.networkManager)); } break; case STATUS: this.networkManager.setConnectionState(EnumConnectionState.STATUS); this.networkManager.setNetHandler(new NetHandlerStatusServer(this.server, this.networkManager)); break; default: throw new UnsupportedOperationException("Invalid intention " + packetIn.getRequestedState()); } }
/** * There are two recognized intentions for initiating a handshake: logging in and acquiring server status. The * NetworkManager's protocol will be reconfigured according to the specified intention, although a login-intention * must pass a versioncheck or receive a disconnect otherwise */ public void processHandshake(C00Handshake packetIn) { if (!net.minecraftforge.fml.common.FMLCommonHandler.instance().handleServerHandshake(packetIn, this.networkManager)) return; switch (packetIn.getRequestedState()) { case LOGIN: this.networkManager.setConnectionState(EnumConnectionState.LOGIN); if (packetIn.getProtocolVersion() > 210) { TextComponentString textcomponentstring = new TextComponentString("Outdated server! I\'m still on 1.10.2"); this.networkManager.sendPacket(new SPacketDisconnect(textcomponentstring)); this.networkManager.closeChannel(textcomponentstring); } else if (packetIn.getProtocolVersion() < 210) { TextComponentString textcomponentstring1 = new TextComponentString("Outdated client! Please use 1.10.2"); this.networkManager.sendPacket(new SPacketDisconnect(textcomponentstring1)); this.networkManager.closeChannel(textcomponentstring1); } else { this.networkManager.setNetHandler(new NetHandlerLoginServer(this.server, this.networkManager)); } break; case STATUS: this.networkManager.setConnectionState(EnumConnectionState.STATUS); this.networkManager.setNetHandler(new NetHandlerStatusServer(this.server, this.networkManager)); break; default: throw new UnsupportedOperationException("Invalid intention " + packetIn.getRequestedState()); } }
public void handleDisconnect(SPacketDisconnect packetIn) { this.networkManager.closeChannel(packetIn.getReason()); }
void handleDisconnect(SPacketDisconnect packetIn);