use of pl.plajer.villagedefense3.villagedefenseapi.VillageGameStopEvent 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();
}
}
Aggregations