Пример #1
0
  public Channel getChannel(Player player) {
    Channel channel = channelLookup.get(player.getName());

    if (channel == null) {
      Object connection = getConnection.get(getPlayerHandle.invoke(player));
      Object manager = getManager.get(connection);

      channelLookup.put(player.getName(), channel = getChannel.get(manager));
    }

    return channel;
  }
Пример #2
0
  @SuppressWarnings("unchecked")
  private void registerChannelHandler() {
    Object mcServer = getMinecraftServer.get(Bukkit.getServer());
    Object serverConnection = getServerConnection.get(mcServer);
    boolean looking = true;

    networkManagers = (List<Object>) getNetworkMarkers.invoke(null, serverConnection);
    createServerChannelHandler();

    for (int i = 0; looking; i++) {
      List<Object> list =
          Reflection.getField(serverConnection.getClass(), List.class, i).get(serverConnection);

      for (Object item : list) {
        if (!ChannelFuture.class.isInstance(item)) break;

        Channel serverChannel = ((ChannelFuture) item).channel();

        serverChannels.add(serverChannel);
        serverChannel.pipeline().addFirst(serverChannelHandler);
        looking = false;
      }
    }
  }