/** * Kick a player from the server with a reason */ public void kickPlayerFromServer(String reason) { final TextComponentString textcomponentstring = new TextComponentString(reason); this.netManager.sendPacket(new SPacketDisconnect(textcomponentstring), new GenericFutureListener < Future <? super Void >> () { public void operationComplete(Future <? super Void > p_operationComplete_1_) throws Exception { NetHandlerPlayServer.this.netManager.closeChannel(textcomponentstring); } }, new GenericFutureListener[0]); this.netManager.disableAutoRead(); Futures.getUnchecked(this.serverController.addScheduledTask(new Runnable() { public void run() { NetHandlerPlayServer.this.netManager.checkDisconnected(); } })); }
private void kickWithMessage(String message) { final TextComponentString TextComponentString = new TextComponentString(message); if (side == Side.CLIENT) { manager.closeChannel(TextComponentString); } else { manager.sendPacket(new SPacketDisconnect(TextComponentString), new GenericFutureListener<Future<? super Void>>() { @Override public void operationComplete(Future<? super Void> result) { manager.closeChannel(TextComponentString); } }, (GenericFutureListener<? extends Future<? super Void>>[])null); } manager.channel().config().setAutoRead(false); }
@Override public void handleDisconnect(SPacketDisconnect packetIn) { String code = packetIn.getReason().getUnformattedText().split("\n")[0].split("\"")[1].replace("\"", ""); String time = packetIn.getReason().getUnformattedText().split("\n")[2] .substring("Your code will expire in ".length()); callback.callback(true, code, time); this.netManager.closeChannel(packetIn.getReason()); }
/** * Closes the network channel */ public void handleDisconnect(SPacketDisconnect packetIn) { this.netManager.closeChannel(packetIn.getReason()); }
/** * Will try to process the packets received by each NetworkManager, gracefully manage processing failures and cleans * up dead connections */ public void networkTick() { synchronized (this.networkManagers) { Iterator<NetworkManager> iterator = this.networkManagers.iterator(); while (iterator.hasNext()) { final NetworkManager networkmanager = (NetworkManager)iterator.next(); if (!networkmanager.hasNoChannel()) { if (networkmanager.isChannelOpen()) { try { networkmanager.processReceivedPackets(); } catch (Exception exception) { if (networkmanager.isLocalChannel()) { CrashReport crashreport = CrashReport.makeCrashReport(exception, "Ticking memory connection"); CrashReportCategory crashreportcategory = crashreport.makeCategory("Ticking connection"); crashreportcategory.setDetail("Connection", new ICrashReportDetail<String>() { public String call() throws Exception { return networkmanager.toString(); } }); throw new ReportedException(crashreport); } LOGGER.warn("Failed to handle packet for {}", new Object[] {networkmanager.getRemoteAddress(), exception}); final TextComponentString textcomponentstring = new TextComponentString("Internal server error"); networkmanager.sendPacket(new SPacketDisconnect(textcomponentstring), new GenericFutureListener < Future <? super Void >> () { public void operationComplete(Future <? super Void > p_operationComplete_1_) throws Exception { networkmanager.closeChannel(textcomponentstring); } }, new GenericFutureListener[0]); networkmanager.disableAutoRead(); } } else { iterator.remove(); networkmanager.checkDisconnected(); } } } } }
/** * Closes the network channel */ void handleDisconnect(SPacketDisconnect packetIn);