Exemplo n.º 1
0
 @Override
 public void onPacketReceiving(PacketEvent event) {
   final Player player = event.getPlayer();
   if (dataFactory.getData(player).debug) {
     debug(player, "packet: " + event.getPacketType());
   }
 }
Exemplo n.º 2
0
 @Override
 public void onPacketReceiving(PacketEvent event) {
   // TODO
   if (getPlugin().sendDebug) System.out.println("[HUB] Packet received: " + event.getPacketID());
   String playername = event.getPlayer().getName().toLowerCase();
   if (getPlugin().playerServerMap.containsKey(playername)) {
     if (getPlugin().sendDebug)
       System.out.println(
           "[HUB] Passed On: "
               + playername
               + " ---> "
               + getPlugin().playerServerMap.get(playername));
     event.setCancelled(true);
     // TODO Pass onto server
     // sendToServer(Player p, getPlugin().playerServerMap.get(playername));
   }
 }
Exemplo n.º 3
0
  @Override
  public void onPacketSending(PacketEvent event) {

    if (!event.isCancelled() && event.getPacketID() == Packets.Server.NAMED_ENTITY_SPAWN) {

      PacketContainer packet = event.getPacket();
      StructureModifier<String> text = packet.getSpecificModifier(String.class);

      try {
        String tag = text.read(0);
        Player observer = event.getPlayer();
        Entity watched = packet.getEntityModifier(observer.getWorld()).read(0);

        if (watched instanceof Player) {
          ReceiveNameTagEvent nameTagEvent =
              new ReceiveNameTagEvent(event.getPlayer(), (Player) watched, tag);
          pluginManager.callEvent(nameTagEvent);

          if (nameTagEvent.isModified()) {
            // Trim excess
            tag = nameTagEvent.getTrimmedTag();

            // Uh, ok.
            if (tag == null) tag = "";
            text.write(0, tag);
          }

        } else {
          // Might as well notify about this
          logger.log(
              Level.WARNING,
              "Cannot find entity id " + packet.getSpecificModifier(int.class).read(0));
        }

      } catch (FieldAccessException e) {
        logger.log(Level.SEVERE, "Cannot read field.", e);
      }
    }
  }
 /**
  * Retrieve the entity.
  *
  * @param event - the packet event.
  * @return The entity.
  */
 public Entity getEntity(PacketEvent event) {
   return getEntity(event.getPlayer().getWorld());
 }
Exemplo n.º 5
0
 @Override
 public void onPacketSending(PacketEvent event) {
   if (event.getPacketType().equals(PacketType.Play.Server.LOGIN)) {
     event.getPacket().getBooleans().write(0, true);
   }
 }
 /**
  * Retrieve the location of the block that is changing.
  *
  * @param event - the parent event.
  * @return The location.
  */
 public Location getLocation(PacketEvent event) {
   return new Location(event.getPlayer().getWorld(), getX(), getY(), getZ());
 }