@Override
 public void onPlayerQuit(PlayerQuitEvent event) {
   Player triggerMessage = event.getPlayer();
   plugin.triggerMessages(triggerMessage, "ondisconnect");
   if (plugin.triggerMessages(triggerMessage, "ondisconnect|override")) {
     event.setQuitMessage("");
   }
   plugin.deathCause.remove(triggerMessage.getEntityId());
   plugin.deathBringer.remove(triggerMessage.getEntityId());
   return;
 }
 public String getPlayerByID(int i) {
   String name = "";
   for (Player p : Bukkit.getServer().getOnlinePlayers()) {
     if (i == p.getEntityId()) name = p.getName();
   }
   return name;
 }
Example #3
0
  public void addChair(Player player, Block block) {

    if (disabled) return;
    try {
      PacketContainer entitymeta = ProtocolLibrary.getProtocolManager().createPacket(40);
      entitymeta.getSpecificModifier(int.class).write(0, player.getEntityId());
      WrappedDataWatcher watcher = new WrappedDataWatcher();
      watcher.setObject(0, (byte) 4);
      entitymeta.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());
      for (Player play : plugin.getServer().getOnlinePlayers()) {
        if (play.getWorld().equals(player.getPlayer().getWorld())) {
          try {
            ProtocolLibrary.getProtocolManager().sendServerPacket(play, entitymeta);
          } catch (InvocationTargetException e) {
            BukkitUtil.printStacktrace(e);
          }
        }
      }
    } catch (Error e) {
      Bukkit.getLogger().severe("Chairs do not work without ProtocolLib!");
      disabled = true;
      return;
    }
    if (chairs.containsKey(player.getName())) return;
    plugin.wrapPlayer(player).print(ChatColor.YELLOW + "You are now sitting.");
    chairs.put(player.getName(), block);
  }
 public static void removeSelfDisguise(Player player) {
   if (selfDisguised.contains(player.getUniqueId())) {
     // Send a packet to destroy the fake entity
     PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
     packet.getModifier().write(0, new int[] {DisguiseAPI.getSelfDisguiseId()});
     try {
       ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
     } catch (Exception ex) {
       ex.printStackTrace();
     }
     // Remove the fake entity ID from the disguise bin
     selfDisguised.remove(player.getUniqueId());
     // Get the entity tracker
     try {
       Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(player);
       if (entityTrackerEntry != null) {
         HashSet trackedPlayers =
             (HashSet)
                 ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
                     .get(entityTrackerEntry);
         // If the tracker exists. Remove himself from his tracker
         trackedPlayers.remove(ReflectionManager.getNmsEntity(player));
       }
     } catch (Exception ex) {
       ex.printStackTrace();
     }
     // Resend entity metadata else he will be invisible to himself until its resent
     try {
       ProtocolLibrary.getProtocolManager()
           .sendServerPacket(
               player,
               ProtocolLibrary.getProtocolManager()
                   .createPacketConstructor(
                       PacketType.Play.Server.ENTITY_METADATA,
                       player.getEntityId(),
                       WrappedDataWatcher.getEntityWatcher(player),
                       true)
                   .createPacket(
                       player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true));
     } catch (Exception ex) {
       ex.printStackTrace();
     }
     player.updateInventory();
   }
 }
Example #5
0
  public IceSpike(Player player) {
    BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
    if (bPlayer.isOnCooldown("IceSpike")) return;
    try {
      this.player = player;

      double lowestdistance = range + 1;
      Entity closestentity = null;
      for (Entity entity : GeneralMethods.getEntitiesAroundPoint(player.getLocation(), range)) {
        if (GeneralMethods.getDistanceFromLine(
                    player.getLocation().getDirection(), player.getLocation(), entity.getLocation())
                <= 2
            && (entity instanceof LivingEntity)
            && (entity.getEntityId() != player.getEntityId())) {
          double distance = player.getLocation().distance(entity.getLocation());
          if (distance < lowestdistance) {
            closestentity = entity;
            lowestdistance = distance;
          }
        }
      }
      if (closestentity != null) {
        Block temptestingblock =
            closestentity.getLocation().getBlock().getRelative(BlockFace.DOWN, 1);
        // if (temptestingblock.getType() == Material.ICE){
        this.block = temptestingblock;
        // }
      } else {
        this.block = player.getTargetBlock((HashSet<Material>) null, (int) range);
      }
      for (IceSpike2 icespike : IceSpike2.instances.values()) {
        if (icespike.getBlock().equals(block)) {
          return;
        }
      }
      origin = block.getLocation();
      location = origin.clone();

    } catch (IllegalStateException e) {
      return;
    }

    loadAffectedBlocks();

    if (height != 0) {
      if (canInstantiate()) {
        id = ID;
        instances.put(id, this);
        if (ID >= Integer.MAX_VALUE) {
          ID = Integer.MIN_VALUE;
        }
        ID++;
        time = System.currentTimeMillis() - interval;
        bPlayer.addCooldown("IceSpike", cooldown);
      }
    }
  }
Example #6
0
 private void affect(Location location) {
   for (Entity entity : Tools.getEntitiesAroundPoint(location, 2.5)) {
     if (entity.getEntityId() == player.getEntityId()) continue;
     if (Tools.isRegionProtectedFromBuild(player, Abilities.OctopusForm, entity.getLocation()))
       continue;
     entity.setVelocity(
         Tools.getDirection(player.getLocation(), location).normalize().multiply(1.75));
     if (entity instanceof LivingEntity) Tools.damageEntity(player, entity, damage);
   }
 }
Example #7
0
 @SuppressWarnings("rawtypes")
 public static void replaceTrackerEntry(Player player) {
   WorldServer server = (WorldServer) NMS.getHandle(player).getWorld();
   EntityTrackerEntry entry = server.getTracker().trackedEntities.get(player.getEntityId());
   if (entry == null) return;
   PlayerlistTrackerEntry replace = new PlayerlistTrackerEntry(entry);
   server.getTracker().trackedEntities.a(player.getEntityId(), replace);
   if (TRACKED_ENTITY_SET != null) {
     try {
       Set set = (Set) TRACKED_ENTITY_SET.get(server.getTracker());
       set.remove(entry);
       set.add(replace);
     } catch (IllegalArgumentException e) {
       e.printStackTrace();
     } catch (IllegalAccessException e) {
       e.printStackTrace();
     }
   }
 }
Example #8
0
 // <Index = 3>
 @EventHandler
 public void onPlayerDeath(PlayerDeathEvent event) {
   Player att = event.getEntity().getKiller();
   String pName = event.getEntity().getName();
   if (att instanceof Player && att.getEntityId() != event.getEntity().getEntityId()) {
     String aName = att.getName();
     SQL.addKill(aName);
     SQL.addMoney(aName, SQL.getMoney(pName) > SQL.getMoney(aName) ? 10 : 5);
     ScoreboardHandler.addKill(aName);
   }
   SQL.addDeath(pName);
   event.getDrops().clear();
 }
Example #9
0
  public void refreshTag(NPC npc) {
    if (Depends.protocolManager == null || !npc.isSpawned()) return;

    int maxDistance = Bukkit.getServer().getViewDistance() * 16;
    List<Player> viewers = new ArrayList<Player>();

    for (Player p : getPlayersInRadius(npc, maxDistance)) {
      if (p.getEntityId() == npc.getBukkitEntity().getEntityId()) continue;

      viewers.add(p);
    }

    refreshTag(npc, viewers);
  }
Example #10
0
  /**
   * Turns on the plugin. Signs all users into IRC sets shutdown flag to false. parses config file.
   * registers events with bukkit.
   */
  @Override
  public void onEnable() {
    this.playerListener = new IRCTransportPlayerListener(this);
    this.entityListener = new IRCTransportEntityListener(this);
    getConfig().options().copyDefaults(true);
    PluginManager pm = getServer().getPluginManager();
    PluginDescriptionFile pdfFile = this.getDescription();
    if (getConfig().getString("server.address") == null) {
      LOG.severe(
          pdfFile.getName()
              + ": set \"server.address\" in "
              + this.getDataFolder()
              + "/config.yml");
      return;
    }

    getConfig()
        .options()
        .header("Config File for IRCTransport\nSee the website for more information");
    saveConfig();
    initDatabase();

    // establish list of players
    Player[] players = getServer().getOnlinePlayers();
    for (Player player : players) {
      this.bots.put(player.getEntityId(), new IrcAgent(this, player));
    }

    // register for events we care about
    pm.registerEvent(Event.Type.PLAYER_CHAT, playerListener, Priority.Normal, this);
    pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
    pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Normal, this);

    // Using Highest to allow other plugins to manipulate this before we propagate it
    pm.registerEvent(Event.Type.ENTITY_DEATH, entityListener, Priority.Highest, this);

    // set command executors
    IRCTransportCommandExecutor commandExecutor = new IRCTransportCommandExecutor(this);
    getCommand("join").setExecutor(commandExecutor);
    getCommand("leave").setExecutor(commandExecutor);
    getCommand("channel").setExecutor(commandExecutor);
    getCommand("msg").setExecutor(commandExecutor);
    getCommand("nick").setExecutor(commandExecutor);
    getCommand("names").setExecutor(commandExecutor);
    getCommand("me").setExecutor(commandExecutor);
    getCommand("topic").setExecutor(commandExecutor);
    getCommand("whois").setExecutor(commandExecutor);
    LOG.log(Level.INFO, pdfFile.getFullName() + " is enabled!");
  }
Example #11
0
  public void removeChair(Player player) {

    if (disabled) return;
    PacketContainer entitymeta = ProtocolLibrary.getProtocolManager().createPacket(40);
    entitymeta.getSpecificModifier(int.class).write(0, player.getEntityId());
    WrappedDataWatcher watcher = new WrappedDataWatcher();
    watcher.setObject(0, (byte) 0);
    entitymeta.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());

    for (Player play : plugin.getServer().getOnlinePlayers()) {
      if (play.getWorld().equals(player.getPlayer().getWorld())) {
        try {
          ProtocolLibrary.getProtocolManager().sendServerPacket(play, entitymeta);
        } catch (InvocationTargetException e) {
          BukkitUtil.printStacktrace(e);
        }
      }
    }
    plugin.wrapPlayer(player).print(ChatColor.YELLOW + "You are no longer sitting.");
    chairs.remove(player.getName());
  }
Example #12
0
 private boolean increase(Block block) {
   if (block == null) return false;
   if (hasAnyMoved(block)) return false;
   setMoved(block);
   Block botblock = block.getRelative(BlockFace.DOWN);
   int length = 1;
   if (BlockTools.isEarthbendable(player, botblock)) {
     length = 2;
   }
   if (BlockTools.moveEarth(player, block, new Vector(0, 1, 0), length, false)) {
     for (Entity entity :
         EntityTools.getEntitiesAroundPoint(block.getLocation().clone().add(0, 1, 0), 2)) {
       if (entity.getEntityId() != player.getEntityId() && !entities.contains(entity)) {
         if (!(entity instanceof FallingBlock)) {
           entities.add(entity);
         }
       }
     }
     return true;
   }
   return false;
 }
Example #13
0
 public void trip(Player p) {
   Packet41MobEffect packetm = new Packet41MobEffect();
   packetm.a = p.getEntityId();
   packetm.b = 9;
   packetm.c = 0;
   packetm.d = 300;
   ((CraftPlayer) p).getHandle().netServerHandler.sendPacket(packetm);
   p.playEffect(p.getLocation(), Effect.POTION_BREAK, 0);
   final Player p2 = p;
   getServer()
       .getScheduler()
       .scheduleSyncDelayedTask(
           this,
           new Runnable() {
             public void run() {
               Packet42RemoveMobEffect packetr = new Packet42RemoveMobEffect();
               packetr.a = p2.getEntityId();
               packetr.b = 9;
               ((CraftPlayer) p2).getHandle().netServerHandler.sendPacket(packetr);
             }
           },
           300L);
 }
Example #14
0
  void formatWho(CommandSender sender, Player recipient) {
    String recipientName =
        plugin.getAPI().ParsePlayerName(recipient.getName(), recipient.getWorld().getName());
    Integer locX = (int) recipient.getLocation().getX();
    Integer locY = (int) recipient.getLocation().getY();
    Integer locZ = (int) recipient.getLocation().getZ();
    String loc = ("X: " + locX + ", " + "Y: " + locY + ", " + "Z: " + locZ);
    String world = recipient.getWorld().getName();

    sender.sendMessage(
        Messanger.addColour(
            plugin.getLocale().getOption("player") + " Name: " + recipient.getName()));
    sender.sendMessage(Messanger.addColour("Display Name: " + recipient.getDisplayName()));
    sender.sendMessage(Messanger.addColour("Formatted Name: " + recipientName));
    sender.sendMessage(
        Messanger.addColour(
            plugin.getLocale().getOption("player") + "'s Location: [ " + loc + " ]"));
    sender.sendMessage(
        Messanger.addColour(plugin.getLocale().getOption("player") + "'s World: " + world));
    sender.sendMessage(
        Messanger.addColour(
            plugin.getLocale().getOption("player")
                + "'s Health: "
                + plugin.getAPI().healthBar(recipient)
                + " "
                + recipient.getHealth()
                + "/20"));
    sender.sendMessage(
        Messanger.addColour(
            plugin.getLocale().getOption("player")
                + "'s IP: "
                + recipient.getAddress().getHostString()));
    sender.sendMessage(
        Messanger.addColour("Current Item: " + recipient.getItemInHand().getType().name()));
    sender.sendMessage(Messanger.addColour("Entity ID: #" + recipient.getEntityId()));
  }
Example #15
0
  private void progress() {
    BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
    if (player.isDead()
        || !player.isOnline()
        || !GeneralMethods.canBend(player.getName(), "IceBlast")
        || bPlayer.isOnCooldown("IceBlast")) {
      cancel();
      return;
    }

    if (!player.getWorld().equals(location.getWorld())) {
      cancel();
      return;
    }

    if (player.getEyeLocation().distance(location) >= range) {
      if (progressing) {
        breakParticles(20);
        cancel();
        returnWater();
      } else {
        breakParticles(20);
        cancel();
      }
      return;
    }

    if ((GeneralMethods.getBoundAbility(player) == null
            || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("IceBlast"))
        && prepared) {
      cancel();
      return;
    }

    if (System.currentTimeMillis() < time + interval) return;

    time = System.currentTimeMillis();

    if (progressing) {

      Vector direction;

      if (location.getBlockY() == firstdestination.getBlockY()) settingup = false;

      if (location.distance(destination) <= 2) {
        cancel();
        returnWater();
        return;
      }

      if (settingup) {
        direction = GeneralMethods.getDirection(location, firstdestination).normalize();
      } else {
        direction = GeneralMethods.getDirection(location, destination).normalize();
      }

      location.add(direction);

      Block block = location.getBlock();

      if (block.equals(sourceblock)) return;

      source.revertBlock();
      source = null;

      if (EarthMethods.isTransparentToEarthbending(player, block) && !block.isLiquid()) {
        GeneralMethods.breakBlock(block);
      } else if (!WaterMethods.isWater(block)) {
        breakParticles(20);
        cancel();
        returnWater();
        return;
      }

      if (GeneralMethods.isRegionProtectedFromBuild(player, "IceBlast", location)) {
        cancel();
        returnWater();
        return;
      }

      for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, affectingradius)) {
        if (entity.getEntityId() != player.getEntityId() && entity instanceof LivingEntity) {
          affect((LivingEntity) entity);
          progressing = false;
          returnWater();
        }
      }

      if (!progressing) {
        cancel();
        return;
      }

      sourceblock = block;
      source = new TempBlock(sourceblock, Material.PACKED_ICE, data);

      for (int x = 0; x < 10; x++) {
        ParticleEffect.ITEM_CRACK.display(
            new ParticleEffect.ItemData(Material.ICE, (byte) 0),
            new Vector(
                ((Math.random() - 0.5) * .5),
                ((Math.random() - 0.5) * .5),
                ((Math.random() - 0.5) * .5)),
            .5f,
            location,
            257.0D);
        ParticleEffect.SNOW_SHOVEL.display(
            location,
            (float) (Math.random() - 0.5),
            (float) (Math.random() - 0.5),
            (float) (Math.random() - 0.5),
            0,
            5);
      }
      if (GeneralMethods.rand.nextInt(4) == 0) {
        WaterMethods.playIcebendingSound(location);
      }
      location = location.add(direction.clone());

    } else if (prepared) {
      WaterMethods.playFocusWaterEffect(sourceblock);
    }
  }
Example #16
0
 @Override
 public int getEntityId() {
   return caller.getEntityId();
 }
  private boolean progress() {
    if (player.isDead()
        || !player.isOnline()
        || !GeneralMethods.canBend(player.getName(), "EarthBlast")) {
      breakBlock();
      return false;
    }
    if (System.currentTimeMillis() - time >= interval) {
      time = System.currentTimeMillis();

      if (falling) {
        breakBlock();
        return false;
      }

      if (!EarthMethods.isEarthbendable(player, sourceblock)
          && sourceblock.getType() != Material.COBBLESTONE) {
        instances.remove(id);
        return false;
      }

      if (!progressing && !falling) {

        if (GeneralMethods.getBoundAbility(player) == null) {
          unfocusBlock();
          return false;
        }

        if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("EarthBlast")) {
          unfocusBlock();
          return false;
        }

        if (sourceblock == null) {
          instances.remove(id);
          return false;
        }
        if (!player.getWorld().equals(sourceblock.getWorld())) {
          unfocusBlock();
          return false;
        }
        if (sourceblock.getLocation().distance(player.getLocation()) > preparerange) {
          unfocusBlock();
          return false;
        }
      }

      if (falling) {
        breakBlock();

      } else {
        if (!progressing) {
          return false;
        }

        if (sourceblock.getY() == firstdestination.getBlockY()) {
          settingup = false;
        }

        Vector direction;
        if (settingup) {
          direction = GeneralMethods.getDirection(location, firstdestination).normalize();
        } else {
          direction = GeneralMethods.getDirection(location, destination).normalize();
        }

        location = location.clone().add(direction);

        WaterMethods.removeWaterSpouts(location, player);
        AirMethods.removeAirSpouts(location, player);

        Block block = location.getBlock();
        if (block.getLocation().equals(sourceblock.getLocation())) {
          location = location.clone().add(direction);
          block = location.getBlock();
        }

        if (EarthMethods.isTransparentToEarthbending(player, block) && !block.isLiquid()) {
          GeneralMethods.breakBlock(block);
        } else if (!settingup) {
          breakBlock();
          return false;
        } else {
          location = location.clone().subtract(direction);
          direction = GeneralMethods.getDirection(location, destination).normalize();
          location = location.clone().add(direction);

          WaterMethods.removeWaterSpouts(location, player);
          AirMethods.removeAirSpouts(location, player);
          double radius = FireBlast.AFFECTING_RADIUS;
          Player source = player;
          if (EarthBlast.annihilateBlasts(location, radius, source)
              || WaterManipulation.annihilateBlasts(location, radius, source)
              || FireBlast.annihilateBlasts(location, radius, source)) {
            breakBlock();
            return false;
          }

          Combustion.removeAroundPoint(location, radius);

          Block block2 = location.getBlock();
          if (block2.getLocation().equals(sourceblock.getLocation())) {
            location = location.clone().add(direction);
            block2 = location.getBlock();
          }

          if (EarthMethods.isTransparentToEarthbending(player, block) && !block.isLiquid()) {
            GeneralMethods.breakBlock(block);
          } else {
            breakBlock();
            return false;
          }
        }

        for (Entity entity :
            GeneralMethods.getEntitiesAroundPoint(location, FireBlast.AFFECTING_RADIUS)) {
          if (GeneralMethods.isRegionProtectedFromBuild(
              player, "EarthBlast", entity.getLocation())) {
            continue;
          }
          if (entity instanceof LivingEntity
              && (entity.getEntityId() != player.getEntityId() || hitself)) {

            AirMethods.breakBreathbendingHold(entity);

            Location location = player.getEyeLocation();
            Vector vector = location.getDirection();
            entity.setVelocity(vector.normalize().multiply(pushfactor));
            double damage = this.damage;
            if (EarthMethods.isMetal(sourceblock) && EarthMethods.canMetalbend(player)) {
              damage = EarthMethods.getMetalAugment(this.damage);
            }
            GeneralMethods.damageEntity(player, entity, damage);
            progressing = false;
          }
        }

        if (!progressing) {
          breakBlock();
          return false;
        }

        if (revert) {
          // Methods.addTempEarthBlock(sourceblock, block);
          if (sourceblock.getType() == Material.RED_SANDSTONE) {
            sourceblock.setType(sourcetype);
            if (sourcetype == Material.SAND) {
              sourceblock.setData((byte) 0x1);
            }
          } else {
            sourceblock.setType(sourcetype);
          }
          EarthMethods.moveEarthBlock(sourceblock, block);

          if (block.getType() == Material.SAND) {
            block.setType(Material.SANDSTONE);
          }
          if (block.getType() == Material.GRAVEL) {
            block.setType(Material.STONE);
          }
        } else {
          block.setType(sourceblock.getType());
          sourceblock.setType(Material.AIR);
        }

        sourceblock = block;

        if (location.distance(destination) < 1) {
          if (sourcetype == Material.SAND || sourcetype == Material.GRAVEL) {
            progressing = false;
            if (sourceblock.getType() == Material.RED_SANDSTONE) {
              sourcetype = Material.SAND;
              sourceblock.setType(sourcetype);
              sourceblock.setData((byte) 0x1);
            } else {
              sourceblock.setType(sourcetype);
            }
          }

          falling = true;
          progressing = false;
        }

        return true;
      }
    }

    return false;
  }
  /** Sends the self disguise to the player */
  public static void sendSelfDisguise(final Player player, final TargetedDisguise disguise) {
    try {
      if (!disguise.isDisguiseInUse()
          || !player.isValid()
          || !player.isOnline()
          || !disguise.isSelfDisguiseVisible()
          || !disguise.canSee(player)) {
        return;
      }
      Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(player);
      if (entityTrackerEntry == null) {
        // A check incase the tracker is null.
        // If it is, then this method will be run again in one tick. Which is when it should be
        // constructed.
        // Else its going to run in a infinite loop hue hue hue..
        // At least until this disguise is discarded
        Bukkit.getScheduler()
            .runTask(
                libsDisguises,
                new Runnable() {
                  public void run() {
                    if (DisguiseAPI.getDisguise(player, player) == disguise) {
                      sendSelfDisguise(player, disguise);
                    }
                  }
                });
        return;
      }
      // Add himself to his own entity tracker
      ((HashSet<Object>)
              ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
                  .get(entityTrackerEntry))
          .add(ReflectionManager.getNmsEntity(player));
      ProtocolManager manager = ProtocolLibrary.getProtocolManager();
      // Send the player a packet with himself being spawned
      manager.sendServerPacket(
          player,
          manager
              .createPacketConstructor(PacketType.Play.Server.NAMED_ENTITY_SPAWN, player)
              .createPacket(player));
      WrappedDataWatcher dataWatcher = WrappedDataWatcher.getEntityWatcher(player);
      sendSelfPacket(
          player,
          manager
              .createPacketConstructor(
                  PacketType.Play.Server.ENTITY_METADATA, player.getEntityId(), dataWatcher, true)
              .createPacket(player.getEntityId(), dataWatcher, true));

      boolean isMoving = false;
      try {
        Field field =
            ReflectionManager.getNmsClass("EntityTrackerEntry").getDeclaredField("isMoving");
        field.setAccessible(true);
        isMoving = field.getBoolean(entityTrackerEntry);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
      // Send the velocity packets
      if (isMoving) {
        Vector velocity = player.getVelocity();
        sendSelfPacket(
            player,
            manager
                .createPacketConstructor(
                    PacketType.Play.Server.ENTITY_VELOCITY,
                    player.getEntityId(),
                    velocity.getX(),
                    velocity.getY(),
                    velocity.getZ())
                .createPacket(
                    player.getEntityId(), velocity.getX(), velocity.getY(), velocity.getZ()));
      }

      // Why the hell would he even need this. Meh.
      if (player.getVehicle() != null && player.getEntityId() > player.getVehicle().getEntityId()) {
        sendSelfPacket(
            player,
            manager
                .createPacketConstructor(
                    PacketType.Play.Server.ATTACH_ENTITY, 0, player, player.getVehicle())
                .createPacket(0, player, player.getVehicle()));
      } else if (player.getPassenger() != null
          && player.getEntityId() > player.getPassenger().getEntityId()) {
        sendSelfPacket(
            player,
            manager
                .createPacketConstructor(
                    PacketType.Play.Server.ATTACH_ENTITY, 0, player.getPassenger(), player)
                .createPacket(0, player.getPassenger(), player));
      }

      // Resend the armor
      for (int i = 0; i < 5; i++) {
        ItemStack item;
        if (i == 0) {
          item = player.getItemInHand();
        } else {
          item = player.getInventory().getArmorContents()[i - 1];
        }

        if (item != null && item.getType() != Material.AIR) {
          sendSelfPacket(
              player,
              manager
                  .createPacketConstructor(
                      PacketType.Play.Server.ENTITY_EQUIPMENT, player.getEntityId(), i, item)
                  .createPacket(player.getEntityId(), i, item));
        }
      }
      Location loc = player.getLocation();
      // If the disguised is sleeping for w/e reason
      if (player.isSleeping()) {
        sendSelfPacket(
            player,
            manager
                .createPacketConstructor(
                    PacketType.Play.Server.BED,
                    player,
                    loc.getBlockX(),
                    loc.getBlockY(),
                    loc.getBlockZ())
                .createPacket(player, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
      }

      // Resend any active potion effects
      for (Object potionEffect : player.getActivePotionEffects()) {
        sendSelfPacket(
            player,
            manager
                .createPacketConstructor(
                    PacketType.Play.Server.ENTITY_EFFECT, player.getEntityId(), potionEffect)
                .createPacket(player.getEntityId(), potionEffect));
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Example #19
0
 private void in(Player player) {
   this.entityIDMap.put(player.getEntityId(), player);
 }