	protected void handleEvent(Event e) {
		if (e instanceof ConnectionDeniedEvent) {
			System.out.println("Server denied connection! Reason: '" + ((ConnectionDeniedEvent) e).getReason() + "'");
			setGamestate(GameState.LOBBY);
			menuController.actualizeScreen();
			clean();
			connector.disconnectFromServer();
		}else if (e instanceof ConnectionInitEvent) {
			startGame(((ConnectionInitEvent) e).getLevel());
		}else if (e instanceof KillEvent) {
			KillEvent kill = (KillEvent) e;
			Player p = getPlayerController().getPlayer(kill.getPlayerid());
			killPlayer(p);
		}else if (e instanceof PickupEvent) {
			PickupEvent pickup = (PickupEvent) e;
			Player p = getPlayerController().getPlayer(pickup.getPlayerid());
			Flube flube = getWorldController().getFlube(pickup.getMoveableid());
			pickup(p, flube);
		}else if (e instanceof PlaceEvent) {
			PlaceEvent place = (PlaceEvent) e;
			Player p = getPlayerController().getPlayer(place.getPlayerid());
			Flube f = getWorldController().getFlube(place.getMoveableid());
			Vector3f loc = place.getLocation();
			place(p, f, loc);
		}else if (e instanceof PlayerJoinEvent) {
			PlayerJoinEvent join = (PlayerJoinEvent) e;
			int playerid = join.getPlayerId();
			joinPlayer(playerid, join.getPlayername());
		}else if (e instanceof ChooseTeamEvent) {
			ChooseTeamEvent choose = (ChooseTeamEvent) e;
			Player p = getPlayerController().getPlayer(choose.getPlayerId());
			chooseTeam(p, choose.getTeam());
		}else if (e instanceof RespawnEvent) {
			RespawnEvent respawn = (RespawnEvent) e;
			Player p = getPlayerController().getPlayer(respawn.getPlayerid());
			respawn(p);
		}else if (e instanceof PlayerQuitEvent) {
			PlayerQuitEvent quit = (PlayerQuitEvent) e;
			Player p = getPlayerController().getPlayer(quit.getPlayerId());
			quitPlayer(p);
		}else if (e instanceof InputEvent) {
			InputEvent input = (InputEvent) e;
			if(player.getId() != input.getPlayerid() || !InputCommand.usedirect.contains(input.getClass())) {
				Player p = getPlayerController().getPlayer(input.getPlayerid());
				p.handleInput(input.getCommand(), input.isValue());
			}
		}else if (e instanceof RestartRoundEvent) {
			for (Player p : getPlayerController().getAllPlayers()) {
				if(p.isAlive()) {
					killPlayer(p);
				}
				getPlayerController().reset(p);
			}
			getWorldController().resetWorld();
			this.roundStartTime = System.currentTimeMillis();
			menuController.clearEventPanel();
			menuController.updateScoreboard();
		}else if (e instanceof RoundEndedEvent) {
			RoundEndedEvent roundEnded = (RoundEndedEvent) e;
			for (Player p : getPlayerController().getAllPlayers()) {
				p.setInputState(new PlayerInputState());
			}
			winTeam = roundEnded.getWinteam();
			setGamestate(GameState.ROUNDOVER);
			menuController.actualizeScreen();
		}else if(e instanceof FlagEvent) {
			FlagEvent flagev = (FlagEvent) e;
			if(flagev.getType() == FlagEvent.TAKE) {
				Flag f = getWorldController().getFlag(flagev.getFlagid());
				Player p = getPlayerController().getPlayer(flagev.getPlayerid());
				takeFlag(p, f);
			}else if(flagev.getType() == FlagEvent.SCORE) {
				Flag f = getWorldController().getFlag(flagev.getFlagid());
				Player p = getPlayerController().getPlayer(flagev.getPlayerid());
				scoreFlag(p, f);
				menuController.updateScoreboard();
			}else if(flagev.getType() == FlagEvent.RETURN) {
				Flag f = getWorldController().getFlag(flagev.getFlagid());
				returnFlag(f);
			}
		}else if(e instanceof BeamEvent) {
			BeamEvent beam = (BeamEvent) e;
			Player p = getPlayerController().getPlayer(beam.getSourceid());
			Player victim = getPlayerController().getPlayer(beam.getTargetid());
			beam(p, victim);
		}else if(e instanceof RemoveEvent) {
			RemoveEvent remove = (RemoveEvent) e;
			if("flube".equalsIgnoreCase(remove.getObjectType())) {
				Flube f = getWorldController().getFlube(remove.getObjectid());
				getWorldController().removeFlube(f);
			}else if("flag".equalsIgnoreCase(remove.getObjectType())) {
				Flag f = getWorldController().getFlag((int)remove.getObjectid());
				getWorldController().removeFlag(f);
			}else if("spawnpoint".equalsIgnoreCase(remove.getObjectType())) {
				SpawnPoint sp = getWorldController().getSpawnPoint((int)remove.getObjectid());
				getWorldController().removeSpawnPoint(sp);
			}
		}else if(e instanceof AddEvent) {
			AddEvent add = (AddEvent) e;
			if("flube".equalsIgnoreCase(add.getObjectType())) {
				Flube f = getWorldController().addNewFlube(add.getObjectid(), add.getLocation(), add.getObjectSpec());
				getWorldController().attachFlube(f);
			}else if("flag".equalsIgnoreCase(add.getObjectType())) {
				Flag f = getWorldController().addNewFlag((int)add.getObjectid(), add.getLocation(), add.getObjectSpec());
			}else if("spawnpoint".equalsIgnoreCase(add.getObjectType())) {
				SpawnPoint sp = getWorldController().addNewSpawnPoint((int)add.getObjectid(), add.getLocation(), add.getObjectSpec());
				if("editor".equalsIgnoreCase(getGameConfig().getString("mp_gamemode"))) {
					sp.getNode().setCullHint(CullHint.Dynamic);
				}else {
					sp.getNode().setCullHint(CullHint.Always);
				}
			}
		}else if(e instanceof ConfigEvent) {
			ConfigEvent event = (ConfigEvent) e;
			if("mp_gamemode".equalsIgnoreCase(event.getKey())) {
				switchGameMode((String)event.getNewValue());
			}else if("mp_scorelimit".equalsIgnoreCase(event.getKey())) {
				getGameConfig().putObject("mp_scorelimit", (Integer) event.getNewValue());
			}
		}
	}

	protected void handleEvent(Event e) {
		if (e instanceof ConnectionDeniedEvent) {
			System.out.println("Server denied connection! Reason: '" + ((ConnectionDeniedEvent) e).getReason() + "'");
			setGamestate(GameState.LOBBY);
			menuController.actualizeScreen();
			clean();
			connector.disconnectFromServer();
		}else if (e instanceof ConnectionInitEvent) {
			startGame(((ConnectionInitEvent) e).getLevel());
		}else if (e instanceof KillEvent) {
			KillEvent kill = (KillEvent) e;
			Player p = getPlayerController().getPlayer(kill.getPlayerid());
			killPlayer(p);
		}else if (e instanceof PickupEvent) {
			PickupEvent pickup = (PickupEvent) e;
			Player p = getPlayerController().getPlayer(pickup.getPlayerid());
			Flube flube = getWorldController().getFlube(pickup.getMoveableid());
			pickup(p, flube);
		}else if (e instanceof PlaceEvent) {
			PlaceEvent place = (PlaceEvent) e;
			Player p = getPlayerController().getPlayer(place.getPlayerid());
			Flube f = getWorldController().getFlube(place.getMoveableid());
			Vector3f loc = place.getLocation();
			place(p, f, loc);
		}else if (e instanceof PlayerJoinEvent) {
			PlayerJoinEvent join = (PlayerJoinEvent) e;
			int playerid = join.getPlayerId();
			joinPlayer(playerid, join.getPlayername());
		}else if (e instanceof ChooseTeamEvent) {
			ChooseTeamEvent choose = (ChooseTeamEvent) e;
			Player p = getPlayerController().getPlayer(choose.getPlayerId());
			chooseTeam(p, choose.getTeam());
		}else if (e instanceof RespawnEvent) {
			RespawnEvent respawn = (RespawnEvent) e;
			Player p = getPlayerController().getPlayer(respawn.getPlayerid());
			respawn(p);
		}else if (e instanceof PlayerQuitEvent) {
			PlayerQuitEvent quit = (PlayerQuitEvent) e;
			Player p = getPlayerController().getPlayer(quit.getPlayerId());
			quitPlayer(p);
		}else if (e instanceof InputEvent) {
			InputEvent input = (InputEvent) e;
			if(player.getId() != input.getPlayerid() || !InputCommand.usedirect.contains(input.getClass())) {
				Player p = getPlayerController().getPlayer(input.getPlayerid());
				p.handleInput(input.getCommand(), input.isValue());
			}
		}else if (e instanceof RestartRoundEvent) {
			for (Player p : getPlayerController().getAllPlayers()) {
				if(p.isAlive()) {
					killPlayer(p);
				}
				getPlayerController().reset(p);
			}
			getWorldController().resetWorld();
			this.roundStartTime = System.currentTimeMillis();
			menuController.clearEventPanel();
			menuController.updateScoreboard();
			getBulletAppState().setEnabled(true);
		}else if (e instanceof RoundEndedEvent) {
			getBulletAppState().setEnabled(false);
			RoundEndedEvent roundEnded = (RoundEndedEvent) e;
			for (Player p : getPlayerController().getAllPlayers()) {
				p.setInputState(new PlayerInputState());
			}
			winTeam = roundEnded.getWinteam();
			setGamestate(GameState.ROUNDOVER);
			menuController.actualizeScreen();
		}else if(e instanceof FlagEvent) {
			FlagEvent flagev = (FlagEvent) e;
			if(flagev.getType() == FlagEvent.TAKE) {
				Flag f = getWorldController().getFlag(flagev.getFlagid());
				Player p = getPlayerController().getPlayer(flagev.getPlayerid());
				takeFlag(p, f);
			}else if(flagev.getType() == FlagEvent.SCORE) {
				Flag f = getWorldController().getFlag(flagev.getFlagid());
				Player p = getPlayerController().getPlayer(flagev.getPlayerid());
				scoreFlag(p, f);
				menuController.updateScoreboard();
			}else if(flagev.getType() == FlagEvent.RETURN) {
				Flag f = getWorldController().getFlag(flagev.getFlagid());
				returnFlag(f);
			}
		}else if(e instanceof BeamEvent) {
			BeamEvent beam = (BeamEvent) e;
			Player p = getPlayerController().getPlayer(beam.getSourceid());
			Player victim = getPlayerController().getPlayer(beam.getTargetid());
			beam(p, victim);
		}else if(e instanceof RemoveEvent) {
			RemoveEvent remove = (RemoveEvent) e;
			if("flube".equalsIgnoreCase(remove.getObjectType())) {
				Flube f = getWorldController().getFlube(remove.getObjectid());
				getWorldController().removeFlube(f);
			}else if("flag".equalsIgnoreCase(remove.getObjectType())) {
				Flag f = getWorldController().getFlag((int)remove.getObjectid());
				getWorldController().removeFlag(f);
			}else if("spawnpoint".equalsIgnoreCase(remove.getObjectType())) {
				SpawnPoint sp = getWorldController().getSpawnPoint((int)remove.getObjectid());
				getWorldController().removeSpawnPoint(sp);
			}
		}else if(e instanceof AddEvent) {
			AddEvent add = (AddEvent) e;
			if("flube".equalsIgnoreCase(add.getObjectType())) {
				Flube f = getWorldController().addNewFlube(add.getObjectid(), add.getLocation(), add.getObjectSpec());
				getWorldController().attachFlube(f);
			}else if("flag".equalsIgnoreCase(add.getObjectType())) {
				Flag f = getWorldController().addNewFlag((int)add.getObjectid(), add.getLocation(), add.getObjectSpec());
			}else if("spawnpoint".equalsIgnoreCase(add.getObjectType())) {
				SpawnPoint sp = getWorldController().addNewSpawnPoint((int)add.getObjectid(), add.getLocation(), add.getObjectSpec());
				if("editor".equalsIgnoreCase(getGameConfig().getString("mp_gamemode"))) {
					sp.getNode().setCullHint(CullHint.Dynamic);
				}else {
					sp.getNode().setCullHint(CullHint.Always);
				}
			}
		}else if(e instanceof ConfigEvent) {
			ConfigEvent event = (ConfigEvent) e;
			if("mp_gamemode".equalsIgnoreCase(event.getKey())) {
				switchGameMode((String)event.getNewValue());
			}else if("mp_scorelimit".equalsIgnoreCase(event.getKey())) {
				getGameConfig().putObject("mp_scorelimit", (Integer) event.getNewValue());
			}
		}
	}
