Search in sources :

Example 11 with IronGolem

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

the class Arena method stopGame.

/**
 * Stops current arena. Calls VillageGameStopEvent event
 *
 * @param quickStop should arena be stopped immediately? (use only in important cases)
 * @see VillageGameStopEvent
 */
public void stopGame(boolean quickStop) {
    VillageGameStopEvent villageGameStopEvent = new VillageGameStopEvent(this);
    Bukkit.getPluginManager().callEvent(villageGameStopEvent);
    if (getPlayersLeft().size() > 0) {
        for (Player p : getPlayers()) {
            p.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Messages.Game-End-Messages.All-Villagers-Died"));
            p.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Messages.Game-End-Messages.Reached-Wave-X").replaceAll("%NUMBER%", String.valueOf(getWave())));
            p.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Messages.Game-End-Messages.Teleporting-To-Lobby-In-10-Seconds"));
        }
    } else {
        for (Player p : getPlayers()) {
            p.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Messages.Game-End-Messages.All-Players-Died"));
            p.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Messages.Game-End-Messages.Reached-Wave-X").replaceAll("%NUMBER%", String.valueOf(getWave())));
            p.sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Messages.Game-End-Messages.Teleporting-To-Lobby-In-10-Seconds"));
        }
    }
    for (final Player player : getPlayers()) {
        setStat(player, "highestwave", wave);
        addExperience(player, wave);
        UserManager.getUser(player.getUniqueId()).removeScoreboard();
        if (!quickStop) {
            if (plugin.getConfig().getBoolean("Firework-When-Game-Ends")) {
                new BukkitRunnable() {

                    int i = 0;

                    public void run() {
                        if (i == 4)
                            this.cancel();
                        if (!getPlayers().contains(player))
                            this.cancel();
                        Util.spawnRandomFirework(player.getLocation());
                        i++;
                    }
                }.runTaskTimer(plugin, 30, 30);
            }
        }
    }
    this.resetRottenFlesh();
    this.restoreDoors();
    for (Zombie zombie : getZombies()) {
        zombie.remove();
    }
    zombies.clear();
    for (IronGolem ironGolem : getIronGolems()) {
        ironGolem.remove();
    }
    ironGolems.clear();
    for (Villager villager : getVillagers()) {
        villager.remove();
    }
    villagers.clear();
    for (Wolf wolf : getWolfs()) {
        wolf.remove();
    }
    wolfs.clear();
    clearZombies();
    clearGolems();
    clearVillagers();
    clearWolfs();
    for (Entity entity : getStartLocation().getWorld().getEntities()) {
        if (entity.getWorld().getName().equalsIgnoreCase(getStartLocation().getWorld().getName()) && entity.getLocation().distance(getStartLocation()) < 300)
            if (entity.getType() != EntityType.PLAYER)
                entity.remove();
    }
}
Also used : Entity(org.bukkit.entity.Entity) Player(org.bukkit.entity.Player) Zombie(org.bukkit.entity.Zombie) Villager(org.bukkit.entity.Villager) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) VillageGameStopEvent(pl.plajer.villagedefense3.villagedefenseapi.VillageGameStopEvent) IronGolem(org.bukkit.entity.IronGolem) Wolf(org.bukkit.entity.Wolf)

Example 12 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_11_R1.EntityIronGolem)

Example 13 with IronGolem

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

the class Arena method restoreMap.

private void restoreMap() {
    this.restoreDoors();
    for (Zombie zombie : getZombies()) {
        zombie.remove();
    }
    for (IronGolem ironGolem : getIronGolems()) {
        ironGolem.remove();
    }
    for (Villager villager : getVillagers()) {
        villager.remove();
    }
    for (Wolf wolf : getWolfs()) {
        wolf.remove();
    }
    clearZombies();
    clearGolems();
    clearVillagers();
    clearWolfs();
    spawnVillagers();
}
Also used : Zombie(org.bukkit.entity.Zombie) Villager(org.bukkit.entity.Villager) IronGolem(org.bukkit.entity.IronGolem) Wolf(org.bukkit.entity.Wolf)

Example 14 with IronGolem

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

the class Events method onEntityInteractEntity.

@EventHandler
public void onEntityInteractEntity(PlayerInteractEntityEvent event) {
    Arena arena = ArenaRegistry.getArena(event.getPlayer());
    if (arena == null)
        return;
    User user = UserManager.getUser(event.getPlayer().getUniqueId());
    if (user.isFakeDead()) {
        event.setCancelled(true);
        return;
    }
    if (event.getPlayer().getItemInHand().getType() == Material.SADDLE) {
        if (event.getRightClicked().getType() == EntityType.IRON_GOLEM || event.getRightClicked().getType() == EntityType.VILLAGER) {
            event.getRightClicked().setPassenger(event.getPlayer());
            event.setCancelled(true);
            return;
        }
    }
    if (event.getRightClicked().getType() == EntityType.VILLAGER) {
        event.setCancelled(true);
        ShopManager.openShop(event.getPlayer());
    } else if (event.getRightClicked().getType() == EntityType.IRON_GOLEM) {
        IronGolem ironGolem = (IronGolem) event.getRightClicked();
        if (ironGolem.getCustomName() != null && ironGolem.getCustomName().contains(event.getPlayer().getName())) {
            event.getRightClicked().setPassenger(event.getPlayer());
        } else {
            event.getPlayer().sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Messages.Cant-Ride-Others-Golem"));
        }
    }
}
Also used : User(pl.plajer.villagedefense3.User) IronGolem(org.bukkit.entity.IronGolem) Arena(pl.plajer.villagedefense3.arena.Arena) EventHandler(org.bukkit.event.EventHandler)

Example 15 with IronGolem

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

the class GolemEvents method onGolemClick.

@EventHandler
public void onGolemClick(PlayerInteractEntityEvent e) {
    if (!ArenaRegistry.isInGameInstance(e.getPlayer()) || !(e.getRightClicked() instanceof IronGolem)) {
        return;
    }
    if (UserManager.getUser(e.getPlayer().getUniqueId()).isSpectator())
        return;
    if (e.getRightClicked().getCustomName() == null || !(e.getRightClicked().getCustomName().contains(e.getPlayer().getName()))) {
        e.getPlayer().sendMessage(ChatManager.PLUGIN_PREFIX + ChatManager.colorMessage("In-Game.Golem-Upgrades.Cant-Upgrade-Others"));
        return;
    }
    Inventory inv = Bukkit.createInventory(null, 3 * 9, ChatManager.colorMessage("In-Game.Golem-Upgrades.Upgrade-Inventory"));
    for (int i = 1; i <= 3; i++) {
        ItemStack golemHealthUpgrade = new ItemStack(Material.IRON_INGOT, i);
        ItemMeta meta = golemHealthUpgrade.getItemMeta();
        meta.setDisplayName(ChatManager.colorMessage("In-Game.Golem-Upgrades.Upgrade-Tier" + i));
        meta.setLore(Arrays.asList(ChatManager.colorMessage("In-Game.Golem-Upgrades.Upgrade-Tier" + i + "-Lore").split(";")));
        golemHealthUpgrade.setItemMeta(meta);
        inv.setItem((i * 3) + 7, golemHealthUpgrade);
    }
    ItemStack golemHeal = new ItemStack(Material.GOLD_BLOCK, 1);
    ItemMeta healMeta = golemHeal.getItemMeta();
    healMeta.setDisplayName(ChatManager.colorMessage("In-Game.Golem-Upgrades.Upgrade-Heal"));
    healMeta.setLore(Arrays.asList(ChatManager.colorMessage("In-Game.Golem-Upgrades.Upgrade-Heal-Lore").split(";")));
    golemHeal.setItemMeta(healMeta);
    ItemStack golemHealth = new ItemStack(Material.BOOK, 1);
    ItemMeta healthMeta = golemHealth.getItemMeta();
    healthMeta.setDisplayName(ChatManager.colorMessage("In-Game.Golem-Upgrades.Health").replaceAll("%health%", String.valueOf(((IronGolem) e.getRightClicked()).getHealth())));
    golemHealth.setItemMeta(healthMeta);
    inv.setItem(4, golemHealth);
    inv.setItem(22, golemHeal);
    e.getPlayer().openInventory(inv);
    clickedGolem.put(e.getPlayer(), (IronGolem) e.getRightClicked());
}
Also used : IronGolem(org.bukkit.entity.IronGolem) ItemStack(org.bukkit.inventory.ItemStack) Inventory(org.bukkit.inventory.Inventory) ItemMeta(org.bukkit.inventory.meta.ItemMeta) 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