コード例 #1
0
  @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));
    }
  }
コード例 #2
0
 private static EntityPlayerMP getPlayerFromEvent(ServerCustomPacketEvent event) {
   return ((NetHandlerPlayServer) event.getHandler()).playerEntity;
 }