Java Code Examples for org.bukkit.entity.Entity#isDead()

The following examples show how to use org.bukkit.entity.Entity#isDead() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Webbed.java    From MineTinker with GNU General Public License v3.0 6 votes vote down vote up
private void effect(Player player, ItemStack tool, Entity entity, Event event) {
	if (!player.hasPermission("minetinker.modifiers.webbed.use")) {
		return;
	}

	if (entity.isDead()) {
		return;
	}

	if (!modManager.hasMod(tool, this)) {
		return;
	}

	if (modManager.hasMod(tool, Shrouded.instance())) { //Should not trigger twice
		return;
	}

	((LivingEntity) entity).addPotionEffect(getPotionEffect(event, entity, player, tool));
}
 
Example 2
Source File: SentinelTargetingHelper.java    From Sentinel with MIT License 6 votes vote down vote up
/**
 * Updates the current avoids set for the NPC.
 */
public void updateAvoids() {
    for (SentinelCurrentTarget curTarg : new HashSet<>(currentAvoids)) {
        Entity e = SentinelUtilities.getEntityForID(curTarg.targetID);
        if (e == null) {
            currentAvoids.remove(curTarg);
            continue;
        }
        if (e.isDead()) {
            currentAvoids.remove(curTarg);
            continue;
        }
        if (curTarg.ticksLeft > 0) {
            curTarg.ticksLeft -= SentinelPlugin.instance.tickRate;
            if (curTarg.ticksLeft <= 0) {
                currentAvoids.remove(curTarg);
            }
        }
    }
}
 
Example 3
Source File: SentinelTargetingHelper.java    From Sentinel with MIT License 6 votes vote down vote up
/**
 * Returns whether an entity is not able to be targeted at all.
 */
public static boolean isUntargetable(Entity e) {
    if (e == null) {
        return true;
    }
    if (e.isDead()) {
        return true;
    }
    if (e instanceof Player) {
        GameMode mode = ((Player) e).getGameMode();
        if (mode == GameMode.CREATIVE || mode == GameMode.SPECTATOR) {
            return true;
        }
    }
    return false;
}
 
Example 4
Source File: CraftLivingEntity.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
public boolean setLeashHolder(Entity holder) {
    if ((getHandle() instanceof net.minecraft.entity.boss.EntityWither) || !(getHandle() instanceof net.minecraft.entity.EntityLiving)) {
        return false;
    }

    if (holder == null) {
        return unleash();
    }

    if (holder.isDead()) {
        return false;
    }

    unleash();
    ((net.minecraft.entity.EntityLiving) getHandle()).setLeashedToEntity(((CraftEntity) holder).getHandle(), true);
    return true;
}
 
Example 5
Source File: MobSpawnEvent.java    From SkyWarsReloaded with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void endEvent(boolean force) {
	if (fired) {
		if (force) {
			br1.cancel();
			if (length != -1) {
				br2.cancel();
			}
		}
		for (Entity ent: mobsSpawned) {
			if (ent != null && !ent.isDead()) {
				ent.remove();
			}
		}
		mobsSpawned.clear();
		if (gMap.getMatchState() == MatchState.PLAYING) {
			MatchManager.get().message(gMap, ChatColor.translateAlternateColorCodes('&', endMessage));
		}
		if (repeatable || force) {
			setStartTime();
			this.startTime = this.startTime + gMap.getTimer();
			this.fired = false;
		}
	}
}
 
Example 6
Source File: EntitySpawnListener.java    From IridiumSkyblock with GNU General Public License v2.0 5 votes vote down vote up
public void monitorEntity(Entity entity) {
    if (entity == null) return;
    if (entity.isDead()) return;

    final UUID uuid = entity.getUniqueId();
    final Island startingIsland = IridiumSkyblock.getInstance().entities.get(uuid);
    if (startingIsland.isInIsland(entity.getLocation())) {
        //The entity is still in the island, so make a scheduler to check again
        Bukkit.getScheduler().scheduleSyncDelayedTask(IridiumSkyblock.getInstance(), () -> monitorEntity(entity), 20);
    } else {
        //The entity is not in the island, so remove it
        entity.remove();
        IridiumSkyblock.getInstance().entities.remove(uuid);
    }
}
 
Example 7
Source File: GDClaim.java    From GriefDefender with MIT License 5 votes vote down vote up
public List<Entity> getEntities() {
    Collection<Entity> worldEntityList = Bukkit.getServer().getWorld(this.world.getUID()).getEntities();
    List<Entity> entityList = new ArrayList<>();
    for (Entity entity : worldEntityList) {
        if (!(entity.isDead() && this.contains(VecHelper.toVector3i(entity.getLocation())))) {
            entityList.add(entity);
        }
    }

    return entityList;
}
 
Example 8
Source File: StackLogic.java    From StackMob-3 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean notSuitableForStacking(Entity entity){
    if(!(StackTools.hasValidStackData(entity))){
        return true;
    }
    if(entity.isDead()){
        return true;
    }
    if(StackTools.hasValidMetadata(entity, GlobalValues.NO_STACK) &&
            entity.getMetadata(GlobalValues.NO_STACK).get(0).asBoolean()){
        return true;
    }
    int stackSize = StackTools.getSize(entity);
    return (getMaxSize(entity) == stackSize);
}
 
Example 9
Source File: MainListener.java    From HolographicDisplays with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkUnload(ChunkUnloadEvent event) {
	for (Entity entity : event.getChunk().getEntities()) {
		if (!entity.isDead()) {
			NMSEntityBase entityBase = nmsManager.getNMSEntityBase(entity);
			
			if (entityBase != null) {
				((CraftHologram) entityBase.getHologramLine().getParent()).despawnEntities();
			}
		}
	}
}
 
Example 10
Source File: BatBomb.java    From NBTEditor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onExplode(Item item, Location location) {
	List<Entity> passengers = item.getPassengers();
	if (passengers.size() != 0) {
		Entity bat = passengers.get(0);
		if (bat != null && bat instanceof Bat && !bat.isDead()) {
			bat.remove();
			spawnBatsAt(location, 10, 50);
		}
	}
}
 
Example 11
Source File: CondIsAlive.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean check(Entity e) {
	return isNegated == e.isDead();
}