예제 #1
0
  @Override
  public void onPacketOut(Object packet, Player player) {
    GameProfile profile =
        (GameProfile)
            ReflectionUtils.getPrivateField(
                PACKET_CLASS,
                ReflectionUtils.byClass(PACKET_CLASS, GameProfile.class).getName(),
                packet);

    if (playerHandlers.containsKey(profile.getId())) playerHandlers.remove(profile.getId());

    PlayerHandler handler = new PlayerHandler(player);
    handler.setChannel(super.channel);

    playerHandlers.put(profile.getId(), handler);
  }
예제 #2
0
 public static void syncAllAugmentsToClient(EntityPlayer receiver) {
   List<EntityPlayerMP> players =
       MinecraftServer.getServer().getConfigurationManager().playerEntityList;
   for (EntityPlayerMP player : players) {
     PlayerHandler.setPlayerAugments(
         player, PlayerAugmentProperties.get(player).loadAugmentsFromInventory());
     EventHandlerEntity.syncSchedule.add(player.getEntityId());
     ChatHelper.sendTo(
         (EntityPlayer) receiver, "Synced Player Augments for " + player.getCommandSenderName());
   }
 }
예제 #3
0
  private PlayerHandler retrievePlayerHandler(Player player) {
    if (player == null) return null;

    Object entityPlayer = ReflectionUtils.getHandle(player);
    Object playerConnection =
        ReflectionUtils.getPrivateField(ENTITY_PLAYER_CLASS, "playerConnection", entityPlayer);
    Object networkManager =
        ReflectionUtils.getPrivateField(
            PLAYER_CONNECTION_CLASS, "networkManager", playerConnection);
    Channel channel =
        (Channel)
            ReflectionUtils.getPrivateField(NETWORK_MANAGER_CLASS, CHANNEL_FIELD, networkManager);

    PlayerHandler handler = new PlayerHandler(player);

    channel
        .pipeline()
        .addFirst(new InboundInitializer("PlayerHandler|" + player.getUniqueId().toString(), hook));

    handler.setChannel(channel);

    return handler;
  }