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();
}
}
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;
}
}
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();
}
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"));
}
}
}
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());
}
Aggregations