use of pl.plajer.villagedefense3.kits.GolemFriendKit in project Village_Defense by Plajer.
the class Arena method leaveAttempt.
/**
* Attempts player to leave arena.
* Calls VillageGameLeaveAttemptEvent event.
*
* @param p player to join
* @see VillageGameLeaveAttemptEvent
*/
public void leaveAttempt(Player p) {
VillageGameLeaveAttemptEvent villageGameLeaveAttemptEvent = new VillageGameLeaveAttemptEvent(p, this);
Bukkit.getPluginManager().callEvent(villageGameLeaveAttemptEvent);
if (Main.isDebugged()) {
System.out.println("[Village Debugger] Player " + p.getName() + " is attemping to leave arena!");
}
User user = UserManager.getUser(p.getUniqueId());
user.setInt("orbs", 0);
p.getInventory().clear();
ArmorHelper.clearArmor(p);
this.removePlayer(p);
if (!user.isSpectator()) {
ChatManager.broadcastLeaveMessage(this, p);
}
user.setFakeDead(false);
user.setSpectator(false);
user.removeScoreboard();
if (user.getKit() instanceof GolemFriendKit) {
for (IronGolem ironGolem : getIronGolems()) {
if (ironGolem.getCustomName().contains(user.toPlayer().getName()))
ironGolem.remove();
}
}
if (plugin.isBossbarEnabled()) {
gameBar.removePlayer(p);
}
p.setMaxHealth(20.0);
p.setHealth(p.getMaxHealth());
p.setFoodLevel(20);
p.setFlying(false);
p.setAllowFlight(false);
for (PotionEffect effect : p.getActivePotionEffects()) {
p.removePotionEffect(effect.getType());
}
p.setFireTicks(0);
if (getPlayers().size() == 0) {
this.setArenaState(ArenaState.RESTARTING);
}
p.setGameMode(GameMode.SURVIVAL);
for (Player players : plugin.getServer().getOnlinePlayers()) {
if (ArenaRegistry.getArena(players) != null)
players.showPlayer(p);
p.showPlayer(players);
}
this.teleportToEndLocation(p);
if (!plugin.isBungeeActivated() && plugin.isInventoryManagerEnabled()) {
plugin.getInventoryManager().loadInventory(p);
}
}
Aggregations