Use Chat::formatMessage in Players/*
This commit is contained in:
		@@ -165,11 +165,11 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
 | 
			
		||||
	public function forcePlayerToTeam($adminLogin, $targetLogin, $teamId, $calledByAdmin = true) {
 | 
			
		||||
		if ($calledByAdmin) {
 | 
			
		||||
			$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
 | 
			
		||||
			if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_TEAM)) {
 | 
			
		||||
				$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
 | 
			
		||||
			if (!$admin) {
 | 
			
		||||
				return false;
 | 
			
		||||
			}
 | 
			
		||||
			if (!$admin) {
 | 
			
		||||
			if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_TEAM)) {
 | 
			
		||||
				$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
 | 
			
		||||
				return false;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@@ -183,52 +183,54 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
 | 
			
		||||
				if (!$this->forcePlayerToPlay($adminLogin, $targetLogin, true, false, $calledByAdmin)) {
 | 
			
		||||
					return false;
 | 
			
		||||
				}
 | 
			
		||||
			} catch (FaultException $exception) {
 | 
			
		||||
				if ($calledByAdmin) {
 | 
			
		||||
					$this->maniaControl->getChat()->sendException($exception, $admin);
 | 
			
		||||
				}
 | 
			
		||||
			} catch (FaultException $e) {
 | 
			
		||||
				$this->maniaControl->getChat()->sendException($e, $adminLogin);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		try {
 | 
			
		||||
			$this->maniaControl->getClient()->forcePlayerTeam($target->login, $teamId);
 | 
			
		||||
		} catch (ServerOptionsException $exception) {
 | 
			
		||||
		} catch (ServerOptionsException $e) {
 | 
			
		||||
			$this->forcePlayerToPlay($adminLogin, $targetLogin);
 | 
			
		||||
			return false;
 | 
			
		||||
		} catch (UnknownPlayerException $exception) {
 | 
			
		||||
		} catch (UnknownPlayerException $e) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendException($e, $adminLogin);
 | 
			
		||||
			return false;
 | 
			
		||||
		} catch (GameModeException $e) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendException($e, $adminLogin);
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$message = false;
 | 
			
		||||
		$teamName = '';
 | 
			
		||||
		if ($teamId === self::TEAM_BLUE) {
 | 
			
		||||
			$teamName = '$00fBlue';
 | 
			
		||||
		} elseif ($teamId === self::TEAM_RED) {
 | 
			
		||||
			$teamName = '$f00Red';
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ($teamName) {
 | 
			
		||||
			if ($calledByAdmin) {
 | 
			
		||||
				$this->maniaControl->getChat()->sendException($exception, $admin);
 | 
			
		||||
			}
 | 
			
		||||
			return false;
 | 
			
		||||
		} catch (GameModeException $exception) {
 | 
			
		||||
			if ($calledByAdmin) {
 | 
			
		||||
				$this->maniaControl->getChat()->sendException($exception, $admin);
 | 
			
		||||
			}
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$chatMessage = false;
 | 
			
		||||
 | 
			
		||||
		if ($calledByAdmin) {
 | 
			
		||||
			$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
 | 
			
		||||
			if ($teamId === self::TEAM_BLUE) {
 | 
			
		||||
				$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' forced ' . $target->getEscapedNickname() . ' into the Blue-Team!';
 | 
			
		||||
			} else if ($teamId === self::TEAM_RED) {
 | 
			
		||||
				$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' forced ' . $target->getEscapedNickname() . ' into the Red-Team!';
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			if ($teamId === self::TEAM_BLUE) {
 | 
			
		||||
				$chatMessage = $target->getEscapedNickname() . ' got forced into the Blue-Team!';
 | 
			
		||||
			} else if ($teamId === self::TEAM_RED) {
 | 
			
		||||
				$chatMessage = $target->getEscapedNickname() . ' got forced into the Red-Team!';
 | 
			
		||||
				$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
					'%s %s forced %s into the %s-Team!',
 | 
			
		||||
					$admin->getAuthLevelName(),
 | 
			
		||||
					$admin,
 | 
			
		||||
					$target,
 | 
			
		||||
					$teamName
 | 
			
		||||
				);
 | 
			
		||||
			} else {
 | 
			
		||||
				$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
					'%s got forced %s into the %s-Team!',
 | 
			
		||||
					$target,
 | 
			
		||||
					$teamName
 | 
			
		||||
				);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (!$chatMessage) {
 | 
			
		||||
			return false;
 | 
			
		||||
		if ($message) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendInformation($message);
 | 
			
		||||
			Logger::logInfo($chatMessage, true);
 | 
			
		||||
		}
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($chatMessage);
 | 
			
		||||
		Logger::logInfo($chatMessage, true);
 | 
			
		||||
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
@@ -260,24 +262,20 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
 | 
			
		||||
 | 
			
		||||
		try {
 | 
			
		||||
			$this->maniaControl->getClient()->forceSpectator($target->login, self::SPECTATOR_PLAYER);
 | 
			
		||||
		} catch (ServerOptionsException $exception) {
 | 
			
		||||
			if ($calledByAdmin) {
 | 
			
		||||
				$this->maniaControl->getChat()->sendException($exception, $admin);
 | 
			
		||||
			}
 | 
			
		||||
		} catch (ServerOptionsException $e) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendException($e, $adminLogin);
 | 
			
		||||
			return false;
 | 
			
		||||
		} catch (UnknownPlayerException $exception) {
 | 
			
		||||
			if ($calledByAdmin) {
 | 
			
		||||
				$this->maniaControl->getChat()->sendException($exception, $admin);
 | 
			
		||||
			}
 | 
			
		||||
		} catch (UnknownPlayerException $e) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendException($e, $adminLogin);
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ($userIsAbleToSelect) {
 | 
			
		||||
			try {
 | 
			
		||||
				$this->maniaControl->getClient()->forceSpectator($target->login, self::SPECTATOR_USER_SELECTABLE);
 | 
			
		||||
			} catch (ServerOptionsException $exception) {
 | 
			
		||||
			} catch (ServerOptionsException $e) {
 | 
			
		||||
				if ($calledByAdmin) {
 | 
			
		||||
					$this->maniaControl->getChat()->sendException($exception, $admin);
 | 
			
		||||
					$this->maniaControl->getChat()->sendException($e, $admin);
 | 
			
		||||
				}
 | 
			
		||||
				return false;
 | 
			
		||||
			}
 | 
			
		||||
@@ -286,13 +284,20 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
 | 
			
		||||
		// Announce force
 | 
			
		||||
		if ($displayAnnouncement) {
 | 
			
		||||
			if ($calledByAdmin) {
 | 
			
		||||
				$chatMessage = $admin->getEscapedNickname() . ' forced ' . $target->getEscapedNickname() . ' to Play!';
 | 
			
		||||
				$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
					'%s %s forced %s to Play!',
 | 
			
		||||
					$admin->getAuthLevelName(),
 | 
			
		||||
					$admin,
 | 
			
		||||
					$target
 | 
			
		||||
				);
 | 
			
		||||
			} else {
 | 
			
		||||
				$chatMessage = $target->getEscapedNickname() . ' got forced to Play!';
 | 
			
		||||
				$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
					'%s got forced to Play!',
 | 
			
		||||
					$target
 | 
			
		||||
				);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
			$this->maniaControl->getChat()->sendInformation($chatMessage);
 | 
			
		||||
			$this->maniaControl->getChat()->sendInformation($message);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return true;
 | 
			
		||||
@@ -312,12 +317,12 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
 | 
			
		||||
	public function forcePlayerToSpectator($adminLogin, $targetLogin, $spectatorState = self::SPECTATOR_BUT_KEEP_SELECTABLE, $releaseSlot = true, $calledByAdmin = true) {
 | 
			
		||||
		if ($calledByAdmin) {
 | 
			
		||||
			$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
 | 
			
		||||
			if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_SPEC)) {
 | 
			
		||||
				$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
 | 
			
		||||
			if (!$admin) {
 | 
			
		||||
				return false;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if (!$admin) {
 | 
			
		||||
			if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_SPEC)) {
 | 
			
		||||
				$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
 | 
			
		||||
				return false;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
@@ -330,21 +335,27 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
 | 
			
		||||
 | 
			
		||||
		try {
 | 
			
		||||
			$this->maniaControl->getClient()->forceSpectator($target->login, $spectatorState);
 | 
			
		||||
		} catch (ServerOptionsException $exception) {
 | 
			
		||||
			if ($calledByAdmin) {
 | 
			
		||||
				$this->maniaControl->getChat()->sendException($exception, $admin->login);
 | 
			
		||||
			}
 | 
			
		||||
		} catch (ServerOptionsException $e) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendException($e, $adminLogin);
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ($calledByAdmin) {
 | 
			
		||||
			$title       = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
 | 
			
		||||
			$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' forced ' . $target->getEscapedNickname() . ' to Spectator!';
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'%s %s forced %s to Spectator!',
 | 
			
		||||
				$admin->getAuthLevelName(),
 | 
			
		||||
				$admin,
 | 
			
		||||
				$target
 | 
			
		||||
			);
 | 
			
		||||
		} else {
 | 
			
		||||
			$chatMessage = $target->getEscapedNickname() . ' got forced to Spectator!';
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'%s got forced to Spectator!',
 | 
			
		||||
				$target
 | 
			
		||||
			);
 | 
			
		||||
		}
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($chatMessage);
 | 
			
		||||
		Logger::logInfo($chatMessage, true);
 | 
			
		||||
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($message);
 | 
			
		||||
		Logger::logInfo($message, true);
 | 
			
		||||
 | 
			
		||||
		if ($releaseSlot) {
 | 
			
		||||
			// Free player slot
 | 
			
		||||
@@ -375,8 +386,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
 | 
			
		||||
				return false;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
 | 
			
		||||
 | 
			
		||||
		$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
 | 
			
		||||
		if (!$target) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
@@ -384,19 +395,30 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
 | 
			
		||||
		try {
 | 
			
		||||
			$this->maniaControl->getClient()->unIgnore($targetLogin);
 | 
			
		||||
		} catch (NotInListException $e) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendError('Player is not ignored!', $adminLogin);
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'%s is not muted!',
 | 
			
		||||
				$player
 | 
			
		||||
			);
 | 
			
		||||
			$this->maniaControl->getChat()->sendError($message, $adminLogin);
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ($calledByAdmin) {
 | 
			
		||||
			$title       = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
 | 
			
		||||
			$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' un-muted ' . $target->getEscapedNickname() . '!';
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'%s %s un-muted %s!',
 | 
			
		||||
				$admin->getAuthLevelName(),
 | 
			
		||||
				$admin,
 | 
			
		||||
				$target
 | 
			
		||||
			);
 | 
			
		||||
		} else {
 | 
			
		||||
			$chatMessage = $target->getEscapedNickname() . ' got un-muted!';
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'%s got un-muted!',
 | 
			
		||||
				$target
 | 
			
		||||
			);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($chatMessage);
 | 
			
		||||
		Logger::logInfo($chatMessage, true);
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($message);
 | 
			
		||||
		Logger::logInfo($message, true);
 | 
			
		||||
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
@@ -418,8 +440,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
 | 
			
		||||
				return false;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
 | 
			
		||||
 | 
			
		||||
		$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
 | 
			
		||||
		if (!$target) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
@@ -427,20 +449,30 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
 | 
			
		||||
		try {
 | 
			
		||||
			$this->maniaControl->getClient()->ignore($targetLogin);
 | 
			
		||||
		} catch (AlreadyInListException $e) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendError("Player already ignored!", $adminLogin);
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'%s is already muted!',
 | 
			
		||||
				$player
 | 
			
		||||
			);
 | 
			
		||||
			$this->maniaControl->getChat()->sendError($message, $adminLogin);
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Announce warning
 | 
			
		||||
		if ($calledByAdmin) {
 | 
			
		||||
			$title       = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
 | 
			
		||||
			$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' muted ' . $target->getEscapedNickname() . '!';
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'%s %s muted %s!',
 | 
			
		||||
				$admin->getAuthLevelName(),
 | 
			
		||||
				$admin,
 | 
			
		||||
				$target
 | 
			
		||||
			);
 | 
			
		||||
		} else {
 | 
			
		||||
			$chatMessage = $target->getEscapedNickname() . ' got muted!';
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'%s got muted!',
 | 
			
		||||
				$target
 | 
			
		||||
			);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($chatMessage);
 | 
			
		||||
		Logger::logInfo($chatMessage, true);
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($message);
 | 
			
		||||
		Logger::logInfo($message, true);
 | 
			
		||||
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
@@ -464,7 +496,6 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
 | 
			
		||||
 | 
			
		||||
		if (!$target) {
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
@@ -527,16 +558,22 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
 | 
			
		||||
		// Display manialink
 | 
			
		||||
		$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $target);
 | 
			
		||||
 | 
			
		||||
		// Announce warning
 | 
			
		||||
		if ($calledByAdmin) {
 | 
			
		||||
			$title       = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
 | 
			
		||||
			$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' warned ' . $target->getEscapedNickname() . '!';
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'%s %s warned %s!',
 | 
			
		||||
				$admin->getAuthLevelName(),
 | 
			
		||||
				$admin,
 | 
			
		||||
				$target
 | 
			
		||||
			);
 | 
			
		||||
		} else {
 | 
			
		||||
			$chatMessage = $target->getEscapedNickname() . ' got an administrative warning!';
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'%s got warned!',
 | 
			
		||||
				$target
 | 
			
		||||
			);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($chatMessage);
 | 
			
		||||
		Logger::log($chatMessage, true);
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($message);
 | 
			
		||||
		Logger::log($message, true);
 | 
			
		||||
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
@@ -570,37 +607,37 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
 | 
			
		||||
			try {
 | 
			
		||||
				$this->maniaControl->getClient()->disconnectFakePlayer($target->login);
 | 
			
		||||
			} catch (PlayerStateException $e) {
 | 
			
		||||
				if ($calledByAdmin) {
 | 
			
		||||
					$this->maniaControl->getChat()->sendException($e, $admin);
 | 
			
		||||
				}
 | 
			
		||||
				$this->maniaControl->getChat()->sendException($e, $adminLogin);
 | 
			
		||||
				return false;
 | 
			
		||||
			} catch (UnknownPlayerException $e) { //TODO check why it's actually needed, but there was a crash at this place
 | 
			
		||||
				if ($calledByAdmin) {
 | 
			
		||||
					$this->maniaControl->getChat()->sendException($e, $admin);
 | 
			
		||||
				}
 | 
			
		||||
			} catch (UnknownPlayerException $e) {
 | 
			
		||||
				$this->maniaControl->getChat()->sendException($e, $adminLogin);
 | 
			
		||||
				return false;
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			try {
 | 
			
		||||
				$this->maniaControl->getClient()->kick($target->login, $message);
 | 
			
		||||
			} catch (UnknownPlayerException $e) {
 | 
			
		||||
				if ($calledByAdmin) {
 | 
			
		||||
					$this->maniaControl->getChat()->sendException($e, $admin);
 | 
			
		||||
				}
 | 
			
		||||
				$this->maniaControl->getChat()->sendException($e, $adminLogin);
 | 
			
		||||
				return false;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Announce kick
 | 
			
		||||
		if ($calledByAdmin) {
 | 
			
		||||
			$title       = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
 | 
			
		||||
			$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' kicked ' . $target->getEscapedNickname() . '!';
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'%s %s kicked %s!',
 | 
			
		||||
				$admin->getAuthLevelName(),
 | 
			
		||||
				$admin,
 | 
			
		||||
				$target
 | 
			
		||||
			);
 | 
			
		||||
		} else {
 | 
			
		||||
			$chatMessage = $target->getEscapedNickname() . ' got kicked!';
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'%s got kicked!',
 | 
			
		||||
				$target
 | 
			
		||||
			);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($chatMessage);
 | 
			
		||||
		Logger::logInfo($chatMessage, true);
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($message);
 | 
			
		||||
		Logger::logInfo($message, true);
 | 
			
		||||
 | 
			
		||||
		return true;
 | 
			
		||||
	}
 | 
			
		||||
@@ -639,12 +676,14 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		// Announce ban
 | 
			
		||||
		$title       = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
 | 
			
		||||
		$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' banned ' . $target->getEscapedNickname() . '!';
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($chatMessage);
 | 
			
		||||
		Logger::logInfo($chatMessage, true);
 | 
			
		||||
		$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
			'%s %s banned %s!',
 | 
			
		||||
			$admin->getAuthLevelName(),
 | 
			
		||||
			$admin,
 | 
			
		||||
			$target
 | 
			
		||||
		);
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($message);
 | 
			
		||||
		Logger::logInfo($message, true);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
@@ -679,35 +718,52 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Announce ban
 | 
			
		||||
		$title       = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
 | 
			
		||||
		$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' unbanned ' . $targetLogin . '!';
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($chatMessage);
 | 
			
		||||
		Logger::logInfo($chatMessage, true);
 | 
			
		||||
		$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
			'%s %s unbanned %s!',
 | 
			
		||||
			$admin->getAuthLevelName(),
 | 
			
		||||
			$admin,
 | 
			
		||||
			$target
 | 
			
		||||
		);
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($message);
 | 
			
		||||
		Logger::logInfo($message, true);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Grands the Player an Authorization Level
 | 
			
		||||
	 *
 | 
			
		||||
	 * @api
 | 
			
		||||
	 * @deprecated
 | 
			
		||||
	 * @param string $adminLogin
 | 
			
		||||
	 * @param string $targetLogin
 | 
			
		||||
	 * @param int    $authLevel
 | 
			
		||||
	 */
 | 
			
		||||
	public function grandAuthLevel($adminLogin, $targetLogin, $authLevel) {
 | 
			
		||||
		$this->grantAuthLevel($adminLogin, $targetLogin, $authLevel);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Grants the Player an Authorization Level
 | 
			
		||||
	 *
 | 
			
		||||
	 * @api
 | 
			
		||||
	 * @deprecated
 | 
			
		||||
	 * @param string $adminLogin
 | 
			
		||||
	 * @param string $targetLogin
 | 
			
		||||
	 * @param int    $authLevel
 | 
			
		||||
	 */
 | 
			
		||||
	public function grantAuthLevel($adminLogin, $targetLogin, $authLevel) {
 | 
			
		||||
		$admin  = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
 | 
			
		||||
		$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
 | 
			
		||||
		if (!$admin || !$target) {
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$authLevelName = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($authLevel);
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkRight($admin, $authLevel + 1)) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendError("You don't have the permission to add a {$authLevelName}!", $admin);
 | 
			
		||||
		$authLevelName = AuthenticationManager::getAuthLevelName($authLevel);
 | 
			
		||||
		if (!AuthenticationManager::checkRight($admin, $authLevel + 1)) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendError("You do not have the permission to add a {$authLevelName}!", $admin);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ($this->maniaControl->getAuthenticationManager()->checkRight($target, $authLevel)) {
 | 
			
		||||
		if (AuthenticationManager::checkRight($target, $authLevel)) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendError("This Player is already {$authLevelName}!", $admin);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
@@ -718,11 +774,14 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Announce granting
 | 
			
		||||
		$title       = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
 | 
			
		||||
		$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' added ' . $target->getEscapedNickname() . ' as $< ' . $authLevelName . '$>!';
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($chatMessage);
 | 
			
		||||
		Logger::logInfo($chatMessage, true);
 | 
			
		||||
		$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
			"%s %s added %s as {$authLevelName}!",
 | 
			
		||||
			$admin->getAuthLevelName(),
 | 
			
		||||
			$admin,
 | 
			
		||||
			$target
 | 
			
		||||
		);
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($message);
 | 
			
		||||
		Logger::logInfo($message, true);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
@@ -739,14 +798,13 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkRight($admin, $target->authLevel + 1)) {
 | 
			
		||||
			$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($target->authLevel);
 | 
			
		||||
			$this->maniaControl->getChat()->sendError("You can't revoke the Rights of a {$title}!", $admin);
 | 
			
		||||
		if ($admin->authLevel <= $target->authLevel) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendError("You cannot revoke the Rights of a {$target->getAuthLevelName()}!", $admin);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if ($this->maniaControl->getAuthenticationManager()->checkRight($target, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendError("MasterAdmins can't be removed!", $admin);
 | 
			
		||||
		if (AuthenticationManager::checkRight($target, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendError("MasterAdmins cannot be removed!", $admin);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@@ -756,11 +814,13 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Announce revoke
 | 
			
		||||
		$title       = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
 | 
			
		||||
		$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' revoked the Rights of ' . $target->getEscapedNickname() . '!';
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($chatMessage);
 | 
			
		||||
		Logger::logInfo($chatMessage, true);
 | 
			
		||||
		$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
			"%s %s revoked the Rights of %s!",
 | 
			
		||||
			$admin->getAuthLevelName(),
 | 
			
		||||
			$admin,
 | 
			
		||||
			$target
 | 
			
		||||
		);
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($message);
 | 
			
		||||
		Logger::logInfo($message, true);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -45,6 +45,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
 | 
			
		||||
 | 
			
		||||
		// Admin commands
 | 
			
		||||
		$this->maniaControl->getCommandManager()->registerCommandListener(array('balance', 'teambalance', 'autoteambalance'), $this, 'command_TeamBalance', true, 'Balances the teams.');
 | 
			
		||||
		$this->maniaControl->getCommandManager()->registerCommandListener('warn', $this, 'command_Warn', true, 'Warns a player from the server.');
 | 
			
		||||
		$this->maniaControl->getCommandManager()->registerCommandListener('kick', $this, 'command_Kick', true, 'Kicks player from the server.');
 | 
			
		||||
		$this->maniaControl->getCommandManager()->registerCommandListener('ban', $this, 'command_Ban', true, 'Bans a player from the server.');
 | 
			
		||||
		$this->maniaControl->getCommandManager()->registerCommandListener('unban', $this, 'command_UnBan', true, 'Unbans a player from the server.');
 | 
			
		||||
@@ -112,7 +113,11 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($player->getEscapedNickname() . ' balanced Teams!');
 | 
			
		||||
		$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
			'%s balanced Teams!',
 | 
			
		||||
			$player
 | 
			
		||||
		);
 | 
			
		||||
		$this->maniaControl->getChat()->sendInformation($message);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
@@ -122,22 +127,27 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
 | 
			
		||||
	 * @param Player $player
 | 
			
		||||
	 */
 | 
			
		||||
	public function command_Kick(array $chat, Player $player) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_KICK_PLAYER)
 | 
			
		||||
		) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_KICK_PLAYER)) {
 | 
			
		||||
			$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$params = explode(' ', $chat[1][2], 3);
 | 
			
		||||
		if (count($params) <= 1) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//kick login'", $player->login);
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'No Login given! Example: %s',
 | 
			
		||||
				'//kick login'
 | 
			
		||||
			);
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo($message, $player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$targetLogin = $params[1];
 | 
			
		||||
		$message     = '';
 | 
			
		||||
		if (isset($params[2])) {
 | 
			
		||||
			$message = $params[2];
 | 
			
		||||
		}
 | 
			
		||||
		$this->maniaControl->getPlayerManager()->getPlayerActions()->kickPlayer($player->login, $targetLogin, $message);
 | 
			
		||||
		$this->maniaControl->getPlayerManager()->getPlayerActions()->kickPlayer($player, $targetLogin, $message);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
@@ -147,22 +157,27 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
 | 
			
		||||
	 * @param Player $player
 | 
			
		||||
	 */
 | 
			
		||||
	public function command_Ban(array $chat, Player $player) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_BAN_PLAYER)
 | 
			
		||||
		) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_BAN_PLAYER)) {
 | 
			
		||||
			$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$params = explode(' ', $chat[1][2], 3);
 | 
			
		||||
		if (count($params) <= 1) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//ban login'", $player->login);
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'No Login given! Example: %s',
 | 
			
		||||
				'//ban login'
 | 
			
		||||
			);
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo($message, $player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$targetLogin = $params[1];
 | 
			
		||||
		$message     = '';
 | 
			
		||||
		if (isset($params[2])) {
 | 
			
		||||
			$message = $params[2];
 | 
			
		||||
		}
 | 
			
		||||
		$this->maniaControl->getPlayerManager()->getPlayerActions()->banPlayer($player->login, $targetLogin, $message);
 | 
			
		||||
		$this->maniaControl->getPlayerManager()->getPlayerActions()->banPlayer($player, $targetLogin, $message);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
@@ -172,18 +187,23 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
 | 
			
		||||
	 * @param Player $player
 | 
			
		||||
	 */
 | 
			
		||||
	public function command_UnBan(array $chat, Player $player) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_BAN_PLAYER)
 | 
			
		||||
		) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_BAN_PLAYER)) {
 | 
			
		||||
			$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$params = explode(' ', $chat[1][2], 3);
 | 
			
		||||
		if (count($params) <= 1) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//ban login'", $player->login);
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'No Login given! Example: %s',
 | 
			
		||||
				'//unban login'
 | 
			
		||||
			);
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo($message, $player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$targetLogin = $params[1];
 | 
			
		||||
		$this->maniaControl->getPlayerManager()->getPlayerActions()->unBanPlayer($player->login, $targetLogin);
 | 
			
		||||
		$this->maniaControl->getPlayerManager()->getPlayerActions()->unBanPlayer($player, $targetLogin);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
@@ -193,13 +213,23 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
 | 
			
		||||
	 * @param Player $player
 | 
			
		||||
	 */
 | 
			
		||||
	public function command_Warn(array $chatCallback, Player $player) {
 | 
			
		||||
		$params = explode(' ', $chatCallback[1][2], 3);
 | 
			
		||||
		if (count($params) <= 1) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//warn login'", $player->login);
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_WARN_PLAYER)) {
 | 
			
		||||
			$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$params = explode(' ', $chatCallback[1][2], 3);
 | 
			
		||||
		if (count($params) <= 1) {
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'No Login given! Example: %s',
 | 
			
		||||
				'//warn login'
 | 
			
		||||
			);
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo($message, $player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$targetLogin = $params[1];
 | 
			
		||||
		$this->maniaControl->getPlayerManager()->getPlayerActions()->warnPlayer($player->login, $targetLogin);
 | 
			
		||||
		$this->maniaControl->getPlayerManager()->getPlayerActions()->warnPlayer($player, $targetLogin);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
@@ -209,23 +239,27 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
 | 
			
		||||
	 * @param Player $player
 | 
			
		||||
	 */
 | 
			
		||||
	public function command_ForceSpectator(array $chat, Player $player) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_SPEC)
 | 
			
		||||
		) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_SPEC)) {
 | 
			
		||||
			$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$params = explode(' ', $chat[1][2]);
 | 
			
		||||
		if (count($params) <= 1) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//forcespec login'", $player->login);
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'No Login given! Example: %s',
 | 
			
		||||
				'//forcespec login'
 | 
			
		||||
			);
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo($message, $player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		$targetLogin = $params[1];
 | 
			
		||||
 | 
			
		||||
		$targetLogin = $params[1];
 | 
			
		||||
		if (isset($params[2]) && is_numeric($params[2])) {
 | 
			
		||||
			$type = (int) $params[2];
 | 
			
		||||
			$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToSpectator($player->login, $targetLogin, $type);
 | 
			
		||||
			$type = intval($params[2]);
 | 
			
		||||
			$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToSpectator($player, $targetLogin, $type);
 | 
			
		||||
		} else {
 | 
			
		||||
			$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToSpectator($player->login, $targetLogin);
 | 
			
		||||
			$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToSpectator($player, $targetLogin);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -236,25 +270,29 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
 | 
			
		||||
	 * @param Player $player
 | 
			
		||||
	 */
 | 
			
		||||
	public function command_ForcePlay(array $chat, Player $player) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_PLAY)
 | 
			
		||||
		) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_PLAY)) {
 | 
			
		||||
			$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$params = explode(' ', $chat[1][2]);
 | 
			
		||||
		if (!isset($params[1])) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//forceplay login'", $player->login);
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'No Login given! Example: %s',
 | 
			
		||||
				'//forceplay login'
 | 
			
		||||
			);
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo($message, $player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		$targetLogin = $params[1];
 | 
			
		||||
 | 
			
		||||
		$targetLogin = $params[1];
 | 
			
		||||
		$type = 2;
 | 
			
		||||
		if (isset($params[2]) && is_numeric($params[2])) {
 | 
			
		||||
			$type = (int) $params[2];
 | 
			
		||||
			$type = intval($params[2]);
 | 
			
		||||
		}
 | 
			
		||||
		$selectable = ($type === 2);
 | 
			
		||||
 | 
			
		||||
		$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToPlay($player->login, $targetLogin, $selectable);
 | 
			
		||||
		$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToPlay($player, $targetLogin, $selectable);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
@@ -264,19 +302,23 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
 | 
			
		||||
	 * @param Player $player
 | 
			
		||||
	 */
 | 
			
		||||
	public function command_ForceBlue(array $chat, Player $player) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)
 | 
			
		||||
		) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)) {
 | 
			
		||||
			$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$params = explode(' ', $chat[1][2]);
 | 
			
		||||
		if (!isset($params[1])) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//forceblue login'", $player->login);
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'No Login given! Example: %s',
 | 
			
		||||
				'//forceblue login'
 | 
			
		||||
			);
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo($message, $player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		$targetLogin = $params[1];
 | 
			
		||||
 | 
			
		||||
		$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_BLUE);
 | 
			
		||||
		$targetLogin = $params[1];
 | 
			
		||||
		$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToTeam($player, $targetLogin, PlayerActions::TEAM_BLUE);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
@@ -286,19 +328,23 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
 | 
			
		||||
	 * @param Player $player
 | 
			
		||||
	 */
 | 
			
		||||
	public function command_ForceRed(array $chat, Player $player) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)
 | 
			
		||||
		) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)) {
 | 
			
		||||
			$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$params = explode(' ', $chat[1][2]);
 | 
			
		||||
		if (!isset($params[1])) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//forcered login'", $player->login);
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'No Login given! Example: %s',
 | 
			
		||||
				'//forcered login'
 | 
			
		||||
			);
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo($message, $player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		$targetLogin = $params[1];
 | 
			
		||||
 | 
			
		||||
		$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_RED);
 | 
			
		||||
		$targetLogin = $params[1];
 | 
			
		||||
		$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToTeam($player, $targetLogin, PlayerActions::TEAM_RED);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
@@ -308,11 +354,11 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
 | 
			
		||||
	 * @param Player $player
 | 
			
		||||
	 */
 | 
			
		||||
	public function command_AddFakePlayers(array $chatCallback, Player $player) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_ADD_BOT)
 | 
			
		||||
		) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_ADD_BOT)) {
 | 
			
		||||
			$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$amount       = 1;
 | 
			
		||||
		$messageParts = explode(' ', $chatCallback[1][2]);
 | 
			
		||||
		if (isset($messageParts[1]) && is_numeric($messageParts[1])) {
 | 
			
		||||
@@ -325,7 +371,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
 | 
			
		||||
			}
 | 
			
		||||
			$this->maniaControl->getChat()->sendSuccess('Fake players connected!', $player);
 | 
			
		||||
		} catch (UnavailableFeatureException $e) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendSuccess('Error while connecting a Fake-Player.', $player);
 | 
			
		||||
			$this->maniaControl->getChat()->sendError('Error while connecting a Fake-Player.', $player);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -336,11 +382,11 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
 | 
			
		||||
	 * @param Player $player
 | 
			
		||||
	 */
 | 
			
		||||
	public function command_RemoveFakePlayers(array $chatCallback, Player $player) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_ADD_BOT)
 | 
			
		||||
		) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_ADD_BOT)) {
 | 
			
		||||
			$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$this->maniaControl->getClient()->disconnectFakePlayer('*');
 | 
			
		||||
		$this->maniaControl->getChat()->sendSuccess('Fake players disconnected!', $player);
 | 
			
		||||
	}
 | 
			
		||||
@@ -349,32 +395,52 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
 | 
			
		||||
	 * Handle //mute Command
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param array  $chatCallback
 | 
			
		||||
	 * @param Player $admin
 | 
			
		||||
	 * @param Player $player
 | 
			
		||||
	 */
 | 
			
		||||
	public function command_MutePlayer(array $chatCallback, Player $admin) {
 | 
			
		||||
		$commandParts = explode(' ', $chatCallback[1][2]);
 | 
			
		||||
		if (count($commandParts) <= 1) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo("No login specified! Example: '//mute login'", $admin);
 | 
			
		||||
	public function command_MutePlayer(array $chatCallback, Player $player) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_MUTE_PLAYER)) {
 | 
			
		||||
			$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$commandParts = explode(' ', $chatCallback[1][2]);
 | 
			
		||||
		if (count($commandParts) <= 1) {
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'No Login given! Example: %s',
 | 
			
		||||
				'//mute login'
 | 
			
		||||
			);
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo($message, $player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$targetLogin = $commandParts[1];
 | 
			
		||||
		$this->maniaControl->getPlayerManager()->getPlayerActions()->mutePlayer($admin->login, $targetLogin);
 | 
			
		||||
		$this->maniaControl->getPlayerManager()->getPlayerActions()->mutePlayer($player, $targetLogin);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Handle //unmute Command
 | 
			
		||||
	 *
 | 
			
		||||
	 * @param array  $chatCallback
 | 
			
		||||
	 * @param Player $admin
 | 
			
		||||
	 * @param Player $player
 | 
			
		||||
	 */
 | 
			
		||||
	public function command_UnmutePlayer(array $chatCallback, Player $admin) {
 | 
			
		||||
		$commandParts = explode(' ', $chatCallback[1][2]);
 | 
			
		||||
		if (count($commandParts) <= 1) {
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo("No login specified! Example: '//unmute login'", $admin);
 | 
			
		||||
	public function command_UnmutePlayer(array $chatCallback, Player $player) {
 | 
			
		||||
		if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_MUTE_PLAYER)) {
 | 
			
		||||
			$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$commandParts = explode(' ', $chatCallback[1][2]);
 | 
			
		||||
		if (count($commandParts) <= 1) {
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				'No Login given! Example: %s',
 | 
			
		||||
				'//unmute login'
 | 
			
		||||
			);
 | 
			
		||||
			$this->maniaControl->getChat()->sendUsageInfo($message, $player);
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$targetLogin = $commandParts[1];
 | 
			
		||||
		$this->maniaControl->getPlayerManager()->getPlayerActions()->unMutePlayer($admin->login, $targetLogin);
 | 
			
		||||
		$this->maniaControl->getPlayerManager()->getPlayerActions()->unMutePlayer($player, $targetLogin);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
 
 | 
			
		||||
@@ -714,13 +714,13 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
 | 
			
		||||
					break;
 | 
			
		||||
				case self::ACTION_ADD_AS_MASTER:
 | 
			
		||||
				case self::ACTION_ADD_AS_SUPER:
 | 
			
		||||
					$this->maniaControl->getPlayerManager()->getPlayerActions()->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
 | 
			
		||||
					$this->maniaControl->getPlayerManager()->getPlayerActions()->grantAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
 | 
			
		||||
					break;
 | 
			
		||||
				case self::ACTION_ADD_AS_ADMIN:
 | 
			
		||||
					$this->maniaControl->getPlayerManager()->getPlayerActions()->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_ADMIN);
 | 
			
		||||
					$this->maniaControl->getPlayerManager()->getPlayerActions()->grantAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_ADMIN);
 | 
			
		||||
					break;
 | 
			
		||||
				case self::ACTION_ADD_AS_MOD:
 | 
			
		||||
					$this->maniaControl->getPlayerManager()->getPlayerActions()->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_MODERATOR);
 | 
			
		||||
					$this->maniaControl->getPlayerManager()->getPlayerActions()->grantAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_MODERATOR);
 | 
			
		||||
					break;
 | 
			
		||||
				case self::ACTION_REVOKE_RIGHTS:
 | 
			
		||||
					$this->maniaControl->getPlayerManager()->getPlayerActions()->revokeAuthLevel($adminLogin, $targetLogin);
 | 
			
		||||
@@ -737,7 +737,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
 | 
			
		||||
					$votesPlugin->defineVote('forcespec', 'Force ' . $target->getEscapedNickname() . ' Spec', true, $startMessage);
 | 
			
		||||
 | 
			
		||||
					$votesPlugin->startVote($admin, 'forcespec', function ($result) use (&$votesPlugin, &$target) {
 | 
			
		||||
						$this->maniaControl->getChat()->sendInformation('$sVote successful -> Player ' . $target->getEscapedNickname() . ' forced to Spectator!');
 | 
			
		||||
						$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
							'Vote successful -> %s forced to Spectator!',
 | 
			
		||||
							$target
 | 
			
		||||
						);
 | 
			
		||||
						$this->maniaControl->getChat()->sendSuccess($message);
 | 
			
		||||
						$votesPlugin->undefineVote('forcespec');
 | 
			
		||||
 | 
			
		||||
						try {
 | 
			
		||||
@@ -761,10 +765,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
 | 
			
		||||
					$votesPlugin->defineVote('kick', 'Kick ' . $target->getEscapedNickname(), true, $startMessage);
 | 
			
		||||
 | 
			
		||||
					$votesPlugin->startVote($admin, 'kick', function ($result) use (&$votesPlugin, &$target) {
 | 
			
		||||
						$this->maniaControl->getChat()->sendInformation('$sVote successful -> ' . $target->getEscapedNickname() . ' got Kicked!');
 | 
			
		||||
						$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
							'Vote successful -> %s got kicked!',
 | 
			
		||||
							$target
 | 
			
		||||
						);
 | 
			
		||||
						$this->maniaControl->getChat()->sendSuccess($message);
 | 
			
		||||
						$votesPlugin->undefineVote('kick');
 | 
			
		||||
 | 
			
		||||
						$message = '$39F You got kicked due to a Public Vote!$z ';
 | 
			
		||||
						$message = '$39FYou got kicked due to a Public Vote!';
 | 
			
		||||
						try {
 | 
			
		||||
							$this->maniaControl->getClient()->kick($target->login, $message);
 | 
			
		||||
						} catch (UnknownPlayerException $e) {
 | 
			
		||||
@@ -780,7 +788,6 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
 | 
			
		||||
				$neededPage = (int) substr($action, strlen(self::ACTION_PAGING_CHUNKS));
 | 
			
		||||
				$this->showPlayerList($player, $neededPage - 1);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -42,7 +42,6 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis
 | 
			
		||||
	const CB_SERVER_EMPTY                       = 'PlayerManagerCallback.ServerEmpty';
 | 
			
		||||
	const TABLE_PLAYERS                         = 'mc_players';
 | 
			
		||||
	const SETTING_JOIN_LEAVE_COLORING           = 'Enable Join & Leave Coloring';
 | 
			
		||||
	const SETTING_JOIN_LEAVE_LOGIN              = 'Enable Join & Leave Login';
 | 
			
		||||
	const SETTING_JOIN_LEAVE_MESSAGES           = 'Enable Join & Leave Messages';
 | 
			
		||||
	const SETTING_JOIN_LEAVE_MESSAGES_SPECTATOR = 'Enable Join & Leave Messages for Spectators';
 | 
			
		||||
	const STAT_JOIN_COUNT                       = 'Joins';
 | 
			
		||||
@@ -95,7 +94,6 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis
 | 
			
		||||
 | 
			
		||||
		// Settings
 | 
			
		||||
		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_JOIN_LEAVE_COLORING, false);
 | 
			
		||||
		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_JOIN_LEAVE_LOGIN, false);
 | 
			
		||||
		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES, true);
 | 
			
		||||
		$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES_SPECTATOR, true);
 | 
			
		||||
 | 
			
		||||
@@ -375,8 +373,8 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		$played     = Formatter::formatTimeH(time() - $player->joinTime);
 | 
			
		||||
		$logMessage = "Player left: {$player->login} / {$player->nickname} Playtime: {$played}";
 | 
			
		||||
		$playTime   = Formatter::formatTimeH(time() - $player->joinTime);
 | 
			
		||||
		$logMessage = "Player left: {$player->login} / {$player->nickname} Playtime: {$playTime}";
 | 
			
		||||
		Logger::logInfo($logMessage, true);
 | 
			
		||||
 | 
			
		||||
		if (!$player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES)
 | 
			
		||||
@@ -387,13 +385,13 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis
 | 
			
		||||
				$color = $this->maniaControl->getColorManager()->getColorByPlayer($player);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			$nickname = Formatter::escapeText('$fff' . $player->nickname);
 | 
			
		||||
			if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_LOGIN)) {
 | 
			
		||||
				$nickname .= 'Login: ' . Formatter::escapeText('$fff' . $player->login);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			$authname = AuthenticationManager::getAuthLevelName($player->authLevel);
 | 
			
		||||
			$this->maniaControl->getChat()->sendChat("{$color}{$authname} {$nickname} has left after \$<\$fff{$played}\$>!");
 | 
			
		||||
			$authName = $player->getAuthLevelName();
 | 
			
		||||
			$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
				"{$color}{$authName} %s has left after %s!",
 | 
			
		||||
				$player,
 | 
			
		||||
				$playTime
 | 
			
		||||
			);
 | 
			
		||||
			$this->maniaControl->getChat()->sendChat($message);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		//Destroys stored PlayerData, after all Disconnect Callbacks got Handled
 | 
			
		||||
@@ -504,24 +502,26 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis
 | 
			
		||||
			if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_COLORING)) {
 | 
			
		||||
				$color = $this->maniaControl->getColorManager()->getColorByPlayer($player);
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			$nickname = Formatter::escapeText('$fff' . $player->nickname);
 | 
			
		||||
			if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_LOGIN)) {
 | 
			
		||||
				$nickname .= 'Login: ' . Formatter::escapeText('$fff' . $player->login);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			$authname = AuthenticationManager::getAuthLevelName($player->authLevel);
 | 
			
		||||
			$nation = '$<$fff' . $player->getCountry() . '$>';
 | 
			
		||||
			$authName = $player->getAuthLeveName();
 | 
			
		||||
 | 
			
		||||
			if (!$player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) {
 | 
			
		||||
				$chatMessage = "{$color}{$authname} {$nickname} Nation: {$nation} joined!";
 | 
			
		||||
				$this->maniaControl->getChat()->sendChat($chatMessage);
 | 
			
		||||
				$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
					"{$color}{$authName} %s Nation: %s joined!",
 | 
			
		||||
					$player,
 | 
			
		||||
					$player->getCountry()
 | 
			
		||||
				);
 | 
			
		||||
				$this->maniaControl->getChat()->sendChat($message);
 | 
			
		||||
			} else if ($player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES_SPECTATOR)) {
 | 
			
		||||
				$chatMessage = "{$color}{$authname} {$nickname} Nation: {$nation} joined as Spectator!";
 | 
			
		||||
				$this->maniaControl->getChat()->sendChat($chatMessage);
 | 
			
		||||
				$message = $this->maniaControl->getChat()->formatMessage(
 | 
			
		||||
					"{$color}{$authName} %s Nation: %s joined as Spectator!",
 | 
			
		||||
					$player,
 | 
			
		||||
					$player->getCountry()
 | 
			
		||||
				);
 | 
			
		||||
				$this->maniaControl->getChat()->sendChat($message);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			$this->maniaControl->getChat()->sendInformation('This server uses ManiaControl v' . ManiaControl::VERSION . '!', $player->login);
 | 
			
		||||
			$this->maniaControl->getChat()->sendInformation('This server uses ManiaControl v' . ManiaControl::VERSION . '!', $player);
 | 
			
		||||
 | 
			
		||||
			$logMessage = "Player joined: {$player->login} / {$player->nickname} Nation: {$nation} IP: {$player->ipAddress}";
 | 
			
		||||
			Logger::logInfo($logMessage, true);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user