@SuppressWarnings("deprecation")
	@EventHandler
	public void onPlayerJoin(PlayerJoinEvent event) {

		//HyperPVP.checkWorlds(event.getPlayer());

		try {

			if (!HyperPVP.getStorage().entryExists("SELECT * FROM users WHERE username = '" + event.getPlayer().getName() + "'")) {

				Bukkit.broadcastMessage(ChatColor.AQUA + "Welcome " + ChatColor.DARK_AQUA + event.getPlayer().getName() + ChatColor.AQUA +" to HyperPVP!");

				PreparedStatement statement = HyperPVP.getStorage().queryParams("INSERT INTO users (username, last_online, email) VALUES (?, ?, ?)"); {
					statement.setString(1, event.getPlayer().getName());
					statement.setLong(2, (System.currentTimeMillis() / 1000L));
					statement.setString(3, "");
					statement.execute();
				}
			}

			PreparedStatement statement = HyperPVP.getStorage().queryParams("INSERT INTO servers_users (server_id, user) VALUES (?, ?)"); {
				statement.setString(1, HyperPVP.getConfiguration().getConfig().getString("Server"));
				statement.setString(2, event.getPlayer().getName());
				statement.execute();
			}    

			statement = HyperPVP.getStorage().queryParams("UPDATE users SET last_online = ? WHERE username = ?"); {
				statement.setLong(1, (System.currentTimeMillis() / 1000L));
				statement.setString(2, event.getPlayer().getName());
				statement.execute();
			}


		} catch (Exception e) {
			e.printStackTrace();
		}
		Player player = event.getPlayer();

		//player.teleport(HyperPVP.getWorldSpawn());
		if (HyperPVP.isCycling() && HyperPVP.getPreviousWorld() != null) {
			player.teleport(HyperPVP.getPreviousWorld().getSpawn());
		} else {
			player.teleport(HyperPVP.getMap().getSpawn());
		}
		player.setGameMode(GameMode.CREATIVE);
		//player.setGameMode(GameMode.ADVENTURE);
		//player.setAllowFlight(false);
		player.setHealth(20.0);
		player.setFoodLevel(20);
		player.setLevel(0);

		for (PotionEffect effect : player.getActivePotionEffects()) {
			player.removePotionEffect(effect.getType());
		}

		player.getInventory().setHelmet(null);
		player.getInventory().setBoots(null);	
		player.getInventory().setChestplate(null);
		player.getInventory().setLeggings(null);
		player.getInventory().clear();
		player.updateInventory();
		//rplayer.setScoreboard(HyperPVP.getMap().getScoreboard());

		//HyperPVP.resetSpectatorInventory(player);
		CycleUtil.addSpectator(player, true);

		player.sendMessage(ChatColor.BLUE + "Welcome to " + ChatColor.GOLD + "Hyper PVP" + ChatColor.BLUE + "!");
		player.sendMessage(ChatColor.BLUE + "Here you can play " + ChatColor.GOLD + "intense PVP matches " + ChatColor.BLUE + "with others.");
		player.sendMessage(ChatColor.BLUE + "To start playing type " + ChatColor.GOLD + "/join");
		player.sendMessage(ChatColor.BLUE + "And to watch others type " + ChatColor.GOLD + "/spectate");

		//player.sendMessage(ChatColor.DARK_RED + "Attention!");
		//player.sendMessage(ChatColor.RED + "All statistics have been reset as of (05/09/2013) due to updates. Won't happen again!");

		event.setJoinMessage(ChatColor.DARK_AQUA + event.getPlayer().getName() + ChatColor.YELLOW + " joined the game");
		HyperPVP.setListName(ChatColor.AQUA, player);

		//player.sendMessage(ChatColor.RED + "Database error, statistics are not working!");

		for (Session session : HyperPVP.getGameSessions().values()) {

			Player game = session.getPlayer();

			if (HyperPVP.getSpectators().containsKey(game.getName())) {
				game.showPlayer(player);
			}

			if (HyperPVP.getGameSessions().containsKey(game.getName())) {
				game.hidePlayer(player);
			}
		}

		TagAPI.refreshPlayer(player);

	}