Search in sources :

Example 16 with IronGolem

use of org.bukkit.entity.IronGolem in project Village_Defense by Plajer.

the class GolemBuster method damageEntity.

@Override
public boolean damageEntity(DamageSource damagesource, float f) {
    if (damagesource != null && damagesource.getEntity() != null && damagesource.getEntity().getBukkitEntity().getType() == EntityType.IRON_GOLEM) {
        this.die();
        this.die();
        ItemStack[] itemStack = new ItemStack[] { new ItemStack(Material.ROTTEN_FLESH) };
        Bukkit.getServer().getPluginManager().callEvent(new EntityDeathEvent((LivingEntity) this.getBukkitEntity(), Arrays.asList(itemStack), expToDrop));
        IronGolem golem = (IronGolem) damagesource.getEntity().getBukkitEntity();
        golem.getWorld().spawnEntity(golem.getLocation(), EntityType.PRIMED_TNT);
        return true;
    } else {
        super.damageEntity(damagesource, f);
        return false;
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) EntityDeathEvent(org.bukkit.event.entity.EntityDeathEvent) IronGolem(org.bukkit.entity.IronGolem) EntityIronGolem(net.minecraft.server.v1_8_R3.EntityIronGolem) ItemStack(org.bukkit.inventory.ItemStack)

Example 17 with IronGolem

use of org.bukkit.entity.IronGolem in project Village_Defense by Plajer.

the class AdminCommands method clearGolems.

public void clearGolems(CommandSender sender) {
    if (checkSenderIsConsole(sender))
        return;
    if (!hasPermission(sender, "villagedefense.admin.clear"))
        return;
    if (!checkIsInGameInstance((Player) sender))
        return;
    Arena arena = ArenaRegistry.getArena((Player) sender);
    if (arena.getIronGolems() != null) {
        for (IronGolem golem : arena.getIronGolems()) {
            golem.getWorld().playEffect(golem.getLocation(), Effect.LAVA_POP, 20);
            golem.remove();
        }
        arena.getIronGolems().clear();
    } else {
        sender.sendMessage(ChatManager.colorMessage("Kits.Cleaner.Nothing-To-Clean"));
        return;
    }
    sendSound((Player) sender, "ENTITY_IRONGOLEM_DEATH", "IRONGOLEM_DEATH");
    for (Player loopPlayer : arena.getPlayers()) {
        String message = ChatManager.formatMessage(arena, ChatManager.colorMessage("In-Game.Messages.Admin-Messages.Removed-Golems"), new Player[] { (loopPlayer) });
        loopPlayer.sendMessage(ChatManager.PLUGIN_PREFIX + message);
    }
}
Also used : Player(org.bukkit.entity.Player) IronGolem(org.bukkit.entity.IronGolem) Arena(pl.plajer.villagedefense3.arena.Arena)

Example 18 with IronGolem

use of org.bukkit.entity.IronGolem in project Village_Defense by Plajer.

the class GolemBuster method damageEntity.

@Override
public boolean damageEntity(DamageSource damagesource, float f) {
    if (damagesource != null && damagesource.getEntity() != null && damagesource.getEntity().getBukkitEntity().getType() == EntityType.IRON_GOLEM) {
        this.die();
        this.die();
        org.bukkit.inventory.ItemStack[] itemStack = new org.bukkit.inventory.ItemStack[] { new org.bukkit.inventory.ItemStack(org.bukkit.Material.ROTTEN_FLESH) };
        Bukkit.getServer().getPluginManager().callEvent(new EntityDeathEvent((LivingEntity) this.getBukkitEntity(), Arrays.asList(itemStack), expToDrop));
        IronGolem golem = (IronGolem) damagesource.getEntity().getBukkitEntity();
        // golem.getWorld().createExplosion(golem.getLocation(), 4);
        org.bukkit.entity.Entity primed = golem.getWorld().spawnEntity(golem.getLocation(), EntityType.PRIMED_TNT);
        return true;
    } else {
        super.damageEntity(damagesource, f);
        return false;
    }
}
Also used : LivingEntity(org.bukkit.entity.LivingEntity) EntityDeathEvent(org.bukkit.event.entity.EntityDeathEvent) IronGolem(org.bukkit.entity.IronGolem) EntityIronGolem(net.minecraft.server.v1_9_R1.EntityIronGolem)

Example 19 with IronGolem

use of org.bukkit.entity.IronGolem in project askyblock by tastybento.

the class IslandGuard1_9 method onLingeringPotionDamage.

@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onLingeringPotionDamage(final EntityDamageByEntityEvent e) {
    if (!IslandGuard.inWorld(e.getEntity().getLocation())) {
        return;
    }
    if (e.getEntity() == null || e.getEntity().getUniqueId() == null) {
        return;
    }
    if (e.getCause().equals(DamageCause.ENTITY_ATTACK) && thrownPotions.containsKey(e.getDamager().getEntityId())) {
        UUID attacker = thrownPotions.get(e.getDamager().getEntityId());
        // Self damage
        if (attacker.equals(e.getEntity().getUniqueId())) {
            return;
        }
        Island island = plugin.getGrid().getIslandAt(e.getEntity().getLocation());
        boolean inNether = false;
        if (e.getEntity().getWorld().equals(ASkyBlock.getNetherWorld())) {
            inNether = true;
        }
        // Monsters being hurt
        if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime || e.getEntity() instanceof Squid) {
            // Normal island check
            if (island != null && island.getMembers().contains(attacker)) {
                // Members always allowed
                return;
            }
            if (actionAllowed(attacker, e.getEntity().getLocation(), SettingsFlag.HURT_MONSTERS)) {
                return;
            }
            // Not allowed
            e.setCancelled(true);
            return;
        }
        // Mobs being hurt
        if (e.getEntity() instanceof Animals || e.getEntity() instanceof IronGolem || e.getEntity() instanceof Snowman || e.getEntity() instanceof Villager) {
            if (island != null && (island.getIgsFlag(SettingsFlag.HURT_MOBS) || island.getMembers().contains(attacker))) {
                return;
            }
            e.setCancelled(true);
            return;
        }
        // Establish whether PVP is allowed or not.
        boolean pvp = false;
        if ((inNether && island != null && island.getIgsFlag(SettingsFlag.NETHER_PVP) || (!inNether && island != null && island.getIgsFlag(SettingsFlag.PVP)))) {
            pvp = true;
        }
        // Players being hurt PvP
        if (e.getEntity() instanceof Player) {
            if (pvp) {
            } else {
                e.setCancelled(true);
            }
        }
    }
}
Also used : Player(org.bukkit.entity.Player) Animals(org.bukkit.entity.Animals) Squid(org.bukkit.entity.Squid) Monster(org.bukkit.entity.Monster) Villager(org.bukkit.entity.Villager) Snowman(org.bukkit.entity.Snowman) IronGolem(org.bukkit.entity.IronGolem) UUID(java.util.UUID) Slime(org.bukkit.entity.Slime) Island(com.wasteofplastic.askyblock.Island) EventHandler(org.bukkit.event.EventHandler)

Aggregations

IronGolem (org.bukkit.entity.IronGolem)19 Player (org.bukkit.entity.Player)9 Villager (org.bukkit.entity.Villager)8 EventHandler (org.bukkit.event.EventHandler)8 LivingEntity (org.bukkit.entity.LivingEntity)7 Animals (org.bukkit.entity.Animals)6 Monster (org.bukkit.entity.Monster)6 Slime (org.bukkit.entity.Slime)6 Snowman (org.bukkit.entity.Snowman)6 Squid (org.bukkit.entity.Squid)6 Projectile (org.bukkit.entity.Projectile)4 EntityDeathEvent (org.bukkit.event.entity.EntityDeathEvent)4 ItemStack (org.bukkit.inventory.ItemStack)4 Island (com.wasteofplastic.acidisland.Island)3 Island (com.wasteofplastic.askyblock.Island)3 FixedMetadataValue (org.bukkit.metadata.FixedMetadataValue)3 MinorPowerPowerStance (com.magmaguy.elitemobs.powerstances.MinorPowerPowerStance)2 UUID (java.util.UUID)2 Creeper (org.bukkit.entity.Creeper)2 Entity (org.bukkit.entity.Entity)2