package me.stefvanschie;

import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;

public class Leave
{
	//public static Leave leave;
	public static void leaveGame(Player player)
	{
		if (player.hasPermission("leave"))
		{
			String worldstr = BuildingGame.main.arenas.getString("main-spawn.world");
			World world = BuildingGame.main.getServer().getWorld(worldstr);
			Location location = new Location(world, BuildingGame.main.arenas.getInt("main-spawn.x"), BuildingGame.main.arenas.getInt("main-spawn.y"), BuildingGame.main.arenas.getInt("main-spawn.z"));
			if (BuildingGame.main.players.containsKey(player))
			{
				BuildingGame.main.playersInArena.put(BuildingGame.main.players.get(player), BuildingGame.main.playersInArena.get(BuildingGame.main.players.get(player)) - 1);
				BuildingGame.main.players.remove(player);
				BuildingGame.main.playernumbers.remove(player);
				BuildingGame.main.votes.remove(player);
				player.teleport(location);
				player.sendMessage(ChatColor.GOLD + "You have left the game!");
				for (Player pl : BuildingGame.main.players.keySet())
				{
					if (BuildingGame.main.players.get(pl).equals(BuildingGame.main.players.get(player)))
					{
						pl.sendMessage(ChatColor.GOLD + "" + player.getName() + " has left the arena!");
					}
				}
			}
			else
			{
				player.sendMessage(ChatColor.GOLD + "You're not in a game!");
			}
		}
		else if (!player.hasPermission("leave"))
		{
			player.sendMessage(ChatColor.RED + "You don't have the required permission for that!");
		}
		else
		{
			player.sendMessage(ChatColor.RED + "An unexpected error occured: Error: bg.leave.permission");
		}
	}
}

@@ -160,38 +160,8 @@
 e%0A%7B%0A
-%09//public static Leave leave;%0A
 %09pub
@@ -1001,50 +1001,166 @@
 age(
-ChatColor.GOLD + %22You have left the game!%22
+BuildingGame.main.messages.getString(%22global.prefix%22).replaceAll(%22&%22, %22%C2%A7%22) + BuildingGame.main.messages.getString(%22leave.message%22)%0A%09%09%09%09%09%09.replaceAll(%22&%22, %22%C2%A7%22)
 );%0A%09
@@ -1343,315 +1343,607 @@
 age(
-ChatColor.GOLD + %22%22 + player.getName() + %22 has left the arena!%22);%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09else%0A%09%09%09%7B%0A%09%09%09%09player.sendMessage(ChatColor.GOLD + %22You're not in a game!%22);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09else if (!player.hasPermission(%22leave%22))%0A%09%09%7B%0A%09%09%09player.sendMessage(ChatColor.RED + %22You don't have the required permission for that!%22
+BuildingGame.main.messages.getString(%22global.prefix%22).replaceAll(%22&%22, %22%C2%A7%22) + BuildingGame.main.messages.getString(%22leave.otherPlayers%22)%0A%09%09%09%09%09%09%09%09.replace(%22%25player%25%22, pl.getName())%0A%09%09%09%09%09%09%09%09.replaceAll(%22&%22, %22%C2%A7%22));%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%09//update all signs%0A%09%09%09%09SignUpdate.update();%0A%09%09%09%7D%0A%09%09%09else%0A%09%09%09%7B%0A%09%09%09%09player.sendMessage(ChatColor.GOLD + %22You're not in a game!%22);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09else if (!player.hasPermission(%22leave%22))%0A%09%09%7B%0A%09%09%09player.sendMessage(BuildingGame.main.messages.getString(%22global.prefix%22).replaceAll(%22&%22, %22%C2%A7%22) + BuildingGame.main.messages.getString(%22global.permissionNode%22)%0A%09%09%09%09%09.replaceAll(%22&%22, %22%C2%A7%22)
 );%0A%09

Update Leave.java