package me.stefvanschie;

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

public class Vote {
	
	@SuppressWarnings("deprecation")
	public static void vote(Player player, int points) {
		if (player.hasPermission("bg.vote")) {
			if (BuildingGame.main.players.containsKey(player)) {
				if (points >= 1 && points <= 10) {
					Player pl = BuildingGame.main.playernumbers.get(BuildingGame.main.place);
					BuildingGame.main.votes.put(pl, points + BuildingGame.main.votes.get(pl));
					//scoreboard
					BuildingGame.main.score = BuildingGame.main.objective.getScore(BuildingGame.main.playernumbers.get(BuildingGame.main.place));
					BuildingGame.main.score.setScore(BuildingGame.main.votes.get(BuildingGame.main.playernumbers.get(BuildingGame.main.place)));
					//message
					player.sendMessage(BuildingGame.main.messages.getString("global.prefix").replaceAll("&", "§") + BuildingGame.main.messages.getString("vote.message")
							.replace("%playerplot%", BuildingGame.main.playernumbers.get(BuildingGame.main.place) + "")
							.replace("%points%", points + "")
							.replaceAll("&", "§"));
				} else if (!(points >= 1 && points <= 10)) {
					player.sendMessage(ChatColor.RED + "Choose a number between 1 and 10");
				} else {
					player.sendMessage(ChatColor.RED + "An unexpected error occured. Error: bg.vote.number");
				}
			} else if (!BuildingGame.main.players.containsKey(player)) {
				player.sendMessage(ChatColor.RED + "You're not in a game");
			} else {
				player.sendMessage(ChatColor.RED + "An unexpected error occured. Error: bg.vote.cotains");
			}
		} else if (!player.hasPermission("bg.vote")) {
			player.sendMessage(BuildingGame.main.messages.getString("global.prefix").replaceAll("&", "§") + BuildingGame.main.messages.getString("global.permissionNode").replaceAll("&", "§"));
		} else {
			player.sendMessage(ChatColor.RED + "An unexpected error occured. Error: bg.vote.permission");
		}
	}
}

@@ -337,162 +337,621 @@
 %09%09%09%09
-Player pl = BuildingGame.main.playernumbers.get(BuildingGame.main.place);%0A%09%09%09%09%09BuildingGame.main.votes.put(pl, points + BuildingGame.main.votes.get(pl));%0A
+if (BuildingGame.main.playernumbers.get(BuildingGame.main.place) != player) %7B%0A%09%09%09%09%09%09Player pl = BuildingGame.main.playernumbers.get(BuildingGame.main.place);%0A%09%09%09%09%09%09if (BuildingGame.main.playervotes.containsKey(player)) %7B%0A%09%09%09%09%09%09%09int previousPoints = BuildingGame.main.playervotes.get(player);%0A%09%09%09%09%09%09%09BuildingGame.main.votes.put(pl, points + BuildingGame.main.votes.get(pl) - previousPoints);%0A%09%09%09%09%09%09%09BuildingGame.main.playervotes.put(player, points);%0A%09%09%09%09%09%09%7D else %7B%0A%09%09%09%09%09%09%09BuildingGame.main.votes.put(pl, points + BuildingGame.main.votes.get(pl));%0A%09%09%09%09%09%09%09BuildingGame.main.playervotes.put(player, points);%0A%09%09%09%09%09%09%7D%0A%09
 %09%09%09%09
@@ -964,16 +964,17 @@
 reboard%0A
+%09
 %09%09%09%09%09Bui
@@ -1092,24 +1092,25 @@
 in.place));%0A
+%09
 %09%09%09%09%09Buildin
@@ -1232,16 +1232,17 @@
 );%0A%09%09%09%09%09
+%09
 //messag
@@ -1243,16 +1243,17 @@
 message%0A
+%09
 %09%09%09%09%09pla
@@ -1397,32 +1397,33 @@
 essage%22)%0A%09%09%09%09%09%09%09
+%09
 .replace(%22%25playe
@@ -1491,23 +1491,34 @@
 n.place)
+.getName()
  + %22%22)%0A
+%09
 %09%09%09%09%09%09%09.
@@ -1553,24 +1553,25 @@
  %22%22)%0A%09%09%09%09%09%09%09
+%09
 .replaceAll(
@@ -1578,24 +1578,324 @@
 %22&%22, %22%C2%A7%22));%0A
+%09%09%09%09%09%7D else if (BuildingGame.main.playernumbers.get(BuildingGame.main.place) == player) %7B%0A%09%09%09%09%09%09player.sendMessage(ChatColor.RED + %22You can't vote on your own plot%22);%0A%09%09%09%09%09%7D else %7B%0A%09%09%09%09%09%09player.sendMessage(ChatColor.RED + %22An unexpected error occured. Error: bg.Vote.vote.playernumbers.get%22);%0A%09%09%09%09%09%7D%0A
 %09%09%09%09%7D else i

Update Vote.java