下面列出了怎么用org.bukkit.entity.EnderDragonPart的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
protected void execute(final Event e) {
for (Entity entity : entities.getArray(e)) {
if (entity instanceof EnderDragonPart) {
entity = ((EnderDragonPart) entity).getParent();
}
if (entity instanceof Damageable) {
final boolean creative = entity instanceof Player && ((Player) entity).getGameMode() == GameMode.CREATIVE;
if (creative) // Set player to survival before applying damage
((Player) entity).setGameMode(GameMode.SURVIVAL);
HealthUtils.damage((Damageable) entity, HealthUtils.getMaxHealth((Damageable) entity) * 100); // just to make sure that it really dies >:)
if (creative) // Set creative player back to creative
((Player) entity).setGameMode(GameMode.CREATIVE);
}
// if everything done so far has failed to kill this thing
// We also don't want to remove a player as this would remove the player's data from the server.
if (entity.isValid() && !(entity instanceof Player))
entity.remove();
}
}