Java Code Examples for org.bukkit.entity.LivingEntity#isDead()
The following examples show how to use
org.bukkit.entity.LivingEntity#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: HealthUtil.java From ActionHealth with MIT License | 4 votes |
public String getOutput(double health, String output, Player receiver, LivingEntity entity) { double maxHealth = entity.getMaxHealth(); if (health < 0.0 || entity.isDead()) health = 0.0; String name = getName(entity, receiver); if (plugin.healthUtil.isBlacklisted(entity, name)) return null; if (plugin.configStore.stripName) name = ChatColor.stripColor(name); if (plugin.configStore.isUsingWhiteList()) { if (!plugin.healthUtil.isWhiteListed(entity, name)) { return null; } } if (entity instanceof Player) { String displayName; Player player = (Player) entity; if (player.getDisplayName() == null) { displayName = name; } else { displayName = player.getDisplayName(); } output = output.replace("{displayname}", displayName); // Placeholder apis if (plugin.configStore.hasMVdWPlaceholderAPI) { output = be.maximvdw.placeholderapi.PlaceholderAPI.replacePlaceholders(player, output); } if (plugin.configStore.hasPlaceholderAPI) { output = me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(player, output); output = me.clip.placeholderapi.PlaceholderAPI.setRelationalPlaceholders(receiver, player, output); } } else { if (!plugin.configStore.healthMessageOther.isEmpty()) { output = plugin.configStore.healthMessageOther; } output = output.replace("{displayname}", name); } output = output.replace("{name}", name); output = output.replace("{health}", String.valueOf((int) health)); output = output.replace("{maxhealth}", String.valueOf((int) maxHealth)); output = output.replace("{percenthealth}", String.valueOf((int) ((health / maxHealth) * 100.0))); output = output.replace("{opponentlastdamage}", String.valueOf((int) entity.getLastDamage())); if (output.contains("{usestyle}")) { StringBuilder style = new StringBuilder(); int left = plugin.configStore.limitHealth; double heart = maxHealth / plugin.configStore.limitHealth; double halfHeart = heart / 2; double tempHealth = health; if (maxHealth != health && health >= 0 && !entity.isDead()) { for (int i = 0; i < plugin.configStore.limitHealth; i++) { if (tempHealth - heart > 0) { tempHealth = tempHealth - heart; style.append(plugin.configStore.filledHeartIcon); left--; } else { break; } } if (tempHealth > halfHeart) { style.append(plugin.configStore.filledHeartIcon); left--; } else if (tempHealth > 0 && tempHealth <= halfHeart) { style.append(plugin.configStore.halfHeartIcon); left--; } } if (maxHealth != health) { for (int i = 0; i < left; i++) { style.append(plugin.configStore.emptyHeartIcon); } } else { for (int i = 0; i < left; i++) { style.append(plugin.configStore.filledHeartIcon); } } output = output.replace("{usestyle}", style.toString()); } HealthSendEvent healthSendEvent = new HealthSendEvent(receiver, entity, output); Bukkit.getPluginManager().callEvent(healthSendEvent); if (healthSendEvent.isCancelled()) output = null; else output = healthSendEvent.getMessage(); return output; }
Example 2
Source File: LivingEntityMapAdapter.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@Override public boolean isValid(LivingEntity key) { return key != null && !key.isDead(); }
Example 3
Source File: SentinelTargetingHelper.java From Sentinel with MIT License | 4 votes |
/** * Process a specific set of multi-targets. */ public void processMultiTargets(SentinelTargetList baseList, TargetListType type) { if (type == null) { return; } if (baseList.byMultiple.isEmpty()) { return; } ArrayList<SentinelTargetList> subList = new ArrayList<>(baseList.byMultiple.size()); for (SentinelTargetList list : baseList.byMultiple) { SentinelTargetList toAdd = list.duplicate(); toAdd.recalculateCacheNoClear(); subList.add(toAdd); if (SentinelPlugin.debugMe) { SentinelPlugin.instance.getLogger().info("Multi-Target Debug: " + toAdd.totalTargetsCount() + " at start: " + toAdd.toMultiTargetString()); } } Location pos = sentinel.getGuardZone(); for (Entity loopEnt : getLivingEntity().getWorld().getNearbyEntities(pos, sentinel.range, sentinel.range, sentinel.range)) { if (!(loopEnt instanceof LivingEntity)) { continue; } LivingEntity ent = (LivingEntity) loopEnt; if (ent.isDead()) { continue; } if (isIgnored(ent)) { continue; } if (!canSee(ent)) { continue; } for (SentinelTargetList lister : subList) { if (lister.ifIsTargetDeleteTarget(ent)) { if (SentinelPlugin.debugMe) { SentinelPlugin.instance.getLogger().info("Multi-Target Debug: " + ent.getName() + " (" + ent.getType().name() + ") checked off for a list."); } lister.tempTargeted.add(ent); if (lister.totalTargetsCount() == 0) { if (SentinelPlugin.debugMe) { SentinelPlugin.instance.getLogger().info("Multi-Target Debug: " + lister.totalTargetsCount() + " completed: " + lister.toMultiTargetString()); } for (LivingEntity subEnt : lister.tempTargeted) { if (type == TargetListType.TARGETS) { addTarget(subEnt.getUniqueId()); } else if (type == TargetListType.AVOIDS) { addAvoid(subEnt.getUniqueId()); } } } } } } }