Exemplo n.º 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);
  }
Exemplo n.º 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());
   }
 }
Exemplo n.º 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;
  }