コード例 #1
0
 @Override
 public void write(final ChannelHandlerContext ctx, Object msg, final ChannelPromise promise)
     throws Exception {
   if (msg instanceof ChannelWriter) {
     @SuppressWarnings("unchecked")
     ChannelWriter dataWriter = (ChannelWriter) msg;
     if (dataWriter.flushMode == FlushMode.MANUAL_COMPLETE) {
       dataWriter.writeStream.subscribe(new FlushOnTerminateSubscriber(ctx, promise));
     } else {
       dataWriter.writeStream.subscribe(new FlushOnEachSubscriber(ctx, promise));
     }
   } else {
     super.write(ctx, msg, promise);
   }
 }
コード例 #2
0
    @Override
    public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
        throws Exception {
      for (Entry<PacketListener, List<Method>> listener : OUT.entrySet()) {
        for (Method method : listener.getValue()) {

          PacketHandler ann = method.getAnnotation(PacketHandler.class);
          if (!ann.packet().getName().equals(msg.getClass().getSimpleName())) continue;
          PacketEvent evt = new PacketEvent(player, msg);
          method.setAccessible(true);
          method.invoke(listener.getKey(), evt);
          msg = evt.getPacket();
        }
      }

      if (msg != null) {
        super.write(ctx, msg, promise);
      }
    }
コード例 #3
0
  @SuppressWarnings("unchecked")
  @Override
  public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
      throws Exception {
    if (PlayOutTileEntityData.isInstance(msg)) {

      Object tag = ReflectionUtil.getObject(msg, "c");
      Object owner =
          ReflectionUtil.invokeMethod(
              tag.getClass(), tag, "getCompound", new Class<?>[] {String.class}, "Owner");

      if (!owner.toString().isEmpty()) {

        Object props =
            ReflectionUtil.invokeMethod(
                owner.getClass(),
                owner,
                "getCompound",
                new Class<?>[] {String.class},
                "Properties");

        if (!props.toString().isEmpty()) {

          Map<String, Object> map = (Map<String, Object>) ReflectionUtil.getObject(props, "map");

          for (Entry<String, Object> entry : map.entrySet()) {

            if (!entry.getKey().equals("textures")) continue;

            String value = entry.getValue().toString();
            if (value.contains("\"\"") || !value.contains("Value:\"")) {
              return;
            }
          }
        }
      }
    }

    super.write(ctx, msg, promise);
  }