下面列出了org.bukkit.entity.Entity#isDead ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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));
}
/**
* 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);
}
}
}
}
/**
* 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;
}
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;
}
@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;
}
}
}
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);
}
}
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;
}
@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);
}
@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();
}
}
}
}
@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);
}
}
}
@Override
public boolean check(Entity e) {
return isNegated == e.isDead();
}