@SubscribeEvent public void onPacketData(ServerCustomPacketEvent event) { if (event.getPacket().channel().equals(ForgeWorldEdit.CUI_PLUGIN_CHANNEL)) { EntityPlayerMP player = getPlayerFromEvent(event); LocalSession session = ForgeWorldEdit.inst.getSession((EntityPlayerMP) player); if (session.hasCUISupport()) { return; } String text = event.getPacket().payload().toString(UTF_8_CHARSET); session.handleCUIInitializationMessage(text); session.describeCUI(ForgeWorldEdit.inst.wrap(player)); } }
private static EntityPlayerMP getPlayerFromEvent(ServerCustomPacketEvent event) { return ((NetHandlerPlayServer) event.getHandler()).playerEntity; }