Package org.bukkit.entity

Examples of org.bukkit.entity.Entity


   * Check getPassenger recursively until a player is found, return that one or null.
   * @param entity
   * @return
   */
  public static Player getFirstPlayerPassenger(final Entity entity) {
    Entity passenger = entity.getPassenger();
    while (passenger != null){
      if (passenger instanceof Player){
        return (Player) passenger;
      }
      passenger = passenger.getPassenger();
    }
    return null;
  }
View Full Code Here


   * Check recursively for vehicles, returns null if players are vehicles, otherwise the lowest vehicle (that has no vehicle).
   * @param entity
   * @return
   */
  public static Entity getLastNonPlayerVehicle(final Entity entity) {
    Entity vehicle = entity.getVehicle();
    while (vehicle != null){
      if (vehicle instanceof Player){
        return null;
      }
      vehicle = vehicle.getVehicle();
    }
    return vehicle;
  }
View Full Code Here

   * @param location
   */
  public static void teleport(final Entity vehicle, final Player player, final Location location, final boolean debug) {
    // TODO: This handling could conflict with WorldGuard region flags.
    // TODO: Account for nested passengers and inconsistencies.
    final Entity passenger = vehicle.getPassenger();
    final boolean vehicleTeleported;
    final boolean playerIsPassenger = player.equals(passenger);
    if (playerIsPassenger && !vehicle.isDead()){ // && vehicle.equals(player.getVehicle).
      // TODO: Does VehicleExit fire here !?  Consequences?
      vehicle.eject();
View Full Code Here

        return CraftItemStack.asCraftMirror(cis);
    }

    public static LivingEntity addCustomNBT(LivingEntity entity, String key, String value) {
        if (entity == null) return null;
        Entity bukkitEntity = entity;
        net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
        NBTTagCompound tag = new NBTTagCompound();

        // Writes the entity's NBT data to tag
        nmsEntity.c(tag);
View Full Code Here

        return entity;
    }

    public static LivingEntity removeCustomNBT(LivingEntity entity, String key) {
        if (entity == null) return null;
        Entity bukkitEntity = entity;
        net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
        NBTTagCompound tag = new NBTTagCompound();

        // Writes the entity's NBT data to tag
        nmsEntity.c(tag);
View Full Code Here

        return entity;
    }

    public static boolean hasCustomNBT(LivingEntity entity, String key) {
        if (entity == null) return false;
        Entity bukkitEntity = entity;
        net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
        NBTTagCompound tag = new NBTTagCompound();

        // Writes the entity's NBT data to tag
        nmsEntity.c(tag);
View Full Code Here

        return tag.hasKey(key);
    }

    public static String getCustomNBT(LivingEntity entity, String key) {
        if (entity == null) return null;
        Entity bukkitEntity = entity;
        net.minecraft.server.v1_7_R4.Entity nmsEntity = ((CraftEntity) bukkitEntity).getHandle();
        NBTTagCompound tag = new NBTTagCompound();

        // Writes the entity's NBT data to tag
        nmsEntity.c(tag);
View Full Code Here

    @EventHandler(priority = EventPriority.MONITOR)
    public void creatureSpawn(CreatureSpawnEvent event) {

        String reason = event.getSpawnReason().name();
        Entity entity = event.getEntity();
    }
View Full Code Here

     * @param entities The list of entities
     */

    public static void mount(List<Entity> entities) {

        Entity lastEntity = null;

        for (Entity entity : entities) {

            if (entity != null) {

                if (lastEntity != null && entity != lastEntity) {

                    // Because setPassenger() is a toggle, only use it if the new passenger
                    // is not already the current passenger, and also make sure we're not
                    // mounting the entity on itself

                    if (entity.getPassenger() != lastEntity) {
                        lastEntity.teleport(entity.getLocation());
                        entity.setPassenger(lastEntity);
                    }
                }

                lastEntity = entity;
View Full Code Here

    super(plugin);
  }

  @EventHandler(priority = EventPriority.LOWEST)
  public void damage(EntityDamageEvent event) {
    Entity entity = event.getEntity();
    if (entity instanceof Player) {
      Player player = (Player) entity;
      if (prevent(event, player, "damage")) {
        player.setFireTicks(0);
      }
View Full Code Here

TOP

Related Classes of org.bukkit.entity.Entity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.