refactor codestyle (chaining)
This commit is contained in:
@ -313,9 +313,7 @@ class Player {
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPlayerData($object, $dataName, $serverIndex = -1) {
|
||||
return $this->maniaControl->getPlayerManager()
|
||||
->getPlayerDataManager()
|
||||
->getPlayerData($object, $dataName, $this, $serverIndex);
|
||||
return $this->maniaControl->getPlayerManager()->getPlayerDataManager()->getPlayerData($object, $dataName, $this, $serverIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -328,9 +326,7 @@ class Player {
|
||||
* @return bool
|
||||
*/
|
||||
public function setPlayerData($object, $dataName, $value, $serverIndex = -1) {
|
||||
return $this->maniaControl->getPlayerManager()
|
||||
->getPlayerDataManager()
|
||||
->setPlayerData($object, $dataName, $this, $value, $serverIndex);
|
||||
return $this->maniaControl->getPlayerManager()->getPlayerDataManager()->setPlayerData($object, $dataName, $this, $value, $serverIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,20 +63,13 @@ class PlayerActions {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Permissions
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_BAN_PLAYER, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_KICK_PLAYER, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_WARN_PLAYER, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_MUTE_PLAYER, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_FORCE_PLAYER_PLAY, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_FORCE_PLAYER_TEAM, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_FORCE_PLAYER_SPEC, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_BAN_PLAYER, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_KICK_PLAYER, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_WARN_PLAYER, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_MUTE_PLAYER, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_FORCE_PLAYER_PLAY, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_FORCE_PLAYER_TEAM, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_FORCE_PLAYER_SPEC, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -87,17 +80,13 @@ class PlayerActions {
|
||||
* @param int $teamId
|
||||
*/
|
||||
public function forcePlayerToTeam($adminLogin, $targetLogin, $teamId) {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_TEAM)
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_TEAM)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($admin);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||
return;
|
||||
}
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
if (!$target || !$admin) {
|
||||
return;
|
||||
}
|
||||
@ -108,14 +97,12 @@ class PlayerActions {
|
||||
return;
|
||||
}
|
||||
} catch (FaultException $exception) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendException($exception, $admin);
|
||||
$this->maniaControl->getChat()->sendException($exception, $admin);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->forcePlayerTeam($target->login, $teamId);
|
||||
$this->maniaControl->getClient()->forcePlayerTeam($target->login, $teamId);
|
||||
} catch (ServerOptionsException $exception) {
|
||||
$this->forcePlayerToPlay($adminLogin, $targetLogin);
|
||||
return;
|
||||
@ -125,8 +112,7 @@ class PlayerActions {
|
||||
}
|
||||
|
||||
$chatMessage = false;
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin->authLevel);
|
||||
$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) {
|
||||
@ -135,8 +121,7 @@ class PlayerActions {
|
||||
if (!$chatMessage) {
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::logInfo($chatMessage, true);
|
||||
}
|
||||
|
||||
@ -150,37 +135,29 @@ class PlayerActions {
|
||||
* @return bool
|
||||
*/
|
||||
public function forcePlayerToPlay($adminLogin, $targetLogin, $userIsAbleToSelect = true, $displayAnnouncement = true) {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_PLAY)
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_PLAY)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($admin);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||
return false;
|
||||
}
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
if (!$target) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->forceSpectator($target->login, self::SPECTATOR_PLAYER);
|
||||
$this->maniaControl->getClient()->forceSpectator($target->login, self::SPECTATOR_PLAYER);
|
||||
} catch (ServerOptionsException $exception) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendException($exception, $admin);
|
||||
$this->maniaControl->getChat()->sendException($exception, $admin);
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($userIsAbleToSelect) {
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->forceSpectator($target->login, self::SPECTATOR_USER_SELECTABLE);
|
||||
$this->maniaControl->getClient()->forceSpectator($target->login, self::SPECTATOR_USER_SELECTABLE);
|
||||
} catch (ServerOptionsException $exception) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendException($exception, $admin);
|
||||
$this->maniaControl->getChat()->sendException($exception, $admin);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -188,8 +165,7 @@ class PlayerActions {
|
||||
// Announce force
|
||||
if ($displayAnnouncement) {
|
||||
$chatMessage = $admin->getEscapedNickname() . ' forced ' . $target->getEscapedNickname() . ' to Play!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -205,43 +181,34 @@ class PlayerActions {
|
||||
*/
|
||||
public function forcePlayerToSpectator($adminLogin, $targetLogin, $spectatorState = self::SPECTATOR_BUT_KEEP_SELECTABLE,
|
||||
$releaseSlot = true) {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_SPEC)
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_SPEC)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($admin);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||
return;
|
||||
}
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
|
||||
if (!$admin || !$target || $target->isSpectator) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->forceSpectator($target->login, $spectatorState);
|
||||
$this->maniaControl->getClient()->forceSpectator($target->login, $spectatorState);
|
||||
} catch (ServerOptionsException $exception) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendException($exception, $admin->login);
|
||||
$this->maniaControl->getChat()->sendException($exception, $admin->login);
|
||||
return;
|
||||
}
|
||||
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin->authLevel);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' forced ' . $target->getEscapedNickname() . ' to Spectator!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::logInfo($chatMessage, true);
|
||||
|
||||
if ($releaseSlot) {
|
||||
// Free player slot
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->spectatorReleasePlayerSlot($target->login);
|
||||
$this->maniaControl->getClient()->spectatorReleasePlayerSlot($target->login);
|
||||
} catch (PlayerStateException $e) {
|
||||
} catch (UnknownPlayerException $e) {
|
||||
}
|
||||
@ -255,37 +222,29 @@ class PlayerActions {
|
||||
* @param string $targetLogin
|
||||
*/
|
||||
public function unMutePlayer($adminLogin, $targetLogin) {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($admin, self::SETTING_PERMISSION_MUTE_PLAYER)
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_MUTE_PLAYER)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($admin);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||
return;
|
||||
}
|
||||
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
|
||||
if (!$target) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->unIgnore($targetLogin);
|
||||
$this->maniaControl->getClient()->unIgnore($targetLogin);
|
||||
} catch (NotInListException $e) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Player is not ignored!');
|
||||
$this->maniaControl->getChat()->sendError('Player is not ignored!');
|
||||
return;
|
||||
}
|
||||
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin->authLevel);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' un-muted ' . $target->getEscapedNickname() . '!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::logInfo($chatMessage, true);
|
||||
}
|
||||
|
||||
@ -296,37 +255,29 @@ class PlayerActions {
|
||||
* @param string $targetLogin
|
||||
*/
|
||||
public function mutePlayer($adminLogin, $targetLogin) {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($admin, self::SETTING_PERMISSION_MUTE_PLAYER)
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_MUTE_PLAYER)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($admin);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||
return;
|
||||
}
|
||||
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
|
||||
if (!$target) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->ignore($targetLogin);
|
||||
$this->maniaControl->getClient()->ignore($targetLogin);
|
||||
} catch (AlreadyInListException $e) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("Player already ignored!");
|
||||
$this->maniaControl->getChat()->sendError("Player already ignored!");
|
||||
return;
|
||||
}
|
||||
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin->authLevel);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' muted ' . $target->getEscapedNickname() . '!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::logInfo($chatMessage, true);
|
||||
}
|
||||
|
||||
@ -337,18 +288,14 @@ class PlayerActions {
|
||||
* @param string $targetLogin
|
||||
*/
|
||||
public function warnPlayer($adminLogin, $targetLogin) {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($admin, self::SETTING_PERMISSION_WARN_PLAYER)
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_WARN_PLAYER)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($admin);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||
return;
|
||||
}
|
||||
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
|
||||
if (!$target) {
|
||||
return;
|
||||
@ -363,12 +310,8 @@ class PlayerActions {
|
||||
// Build Manialink
|
||||
$width = 80;
|
||||
$height = 50;
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultMainWindowStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultMainWindowSubStyle();
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowSubStyle();
|
||||
|
||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||
$frame = new Frame();
|
||||
@ -412,15 +355,12 @@ class PlayerActions {
|
||||
}
|
||||
|
||||
// Display manialink
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->displayWidget($maniaLink, $target);
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $target);
|
||||
|
||||
// Announce warning
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin->authLevel);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' warned ' . $target->getEscapedNickname() . '!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::log($chatMessage, true);
|
||||
}
|
||||
|
||||
@ -432,41 +372,32 @@ class PlayerActions {
|
||||
* @param string $message
|
||||
*/
|
||||
public function kickPlayer($adminLogin, $targetLogin, $message = '') {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($admin, self::SETTING_PERMISSION_KICK_PLAYER)
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_KICK_PLAYER)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($admin);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||
return;
|
||||
}
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
if (!$target) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if ($target->isFakePlayer()) {
|
||||
$this->maniaControl->getClient()
|
||||
->disconnectFakePlayer($target->login);
|
||||
$this->maniaControl->getClient()->disconnectFakePlayer($target->login);
|
||||
} else {
|
||||
$this->maniaControl->getClient()
|
||||
->kick($target->login, $message);
|
||||
$this->maniaControl->getClient()->kick($target->login, $message);
|
||||
}
|
||||
} catch (UnknownPlayerException $e) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendException($e, $admin);
|
||||
$this->maniaControl->getChat()->sendException($e, $admin);
|
||||
return;
|
||||
}
|
||||
|
||||
// Announce kick
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin->authLevel);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' kicked ' . $target->getEscapedNickname() . '!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::logInfo($chatMessage, true);
|
||||
}
|
||||
|
||||
@ -478,36 +409,28 @@ class PlayerActions {
|
||||
* @param string $message
|
||||
*/
|
||||
public function banPlayer($adminLogin, $targetLogin, $message = '') {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($admin, self::SETTING_PERMISSION_BAN_PLAYER)
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_BAN_PLAYER)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($admin);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||
return;
|
||||
}
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
if (!$target) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($target->isFakePlayer()) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('It is not possible to Ban a bot', $admin);
|
||||
$this->maniaControl->getChat()->sendError('It is not possible to Ban a bot', $admin);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->maniaControl->getClient()
|
||||
->ban($target->login, $message);
|
||||
$this->maniaControl->getClient()->ban($target->login, $message);
|
||||
|
||||
// Announce ban
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin->authLevel);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' banned ' . $target->getEscapedNickname() . '!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::logInfo($chatMessage, true);
|
||||
}
|
||||
|
||||
@ -519,46 +442,35 @@ class PlayerActions {
|
||||
* @param int $authLevel
|
||||
*/
|
||||
public function grandAuthLevel($adminLogin, $targetLogin, $authLevel) {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$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)
|
||||
$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);
|
||||
$this->maniaControl->getChat()->sendError("You don't have the permission to add a {$authLevelName}!", $admin);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkRight($target, $authLevel)
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkRight($target, $authLevel)
|
||||
) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("This Player is already {$authLevelName}!", $admin);
|
||||
$this->maniaControl->getChat()->sendError("This Player is already {$authLevelName}!", $admin);
|
||||
return;
|
||||
}
|
||||
|
||||
$success = $this->maniaControl->getAuthenticationManager()
|
||||
->grantAuthLevel($target, $authLevel);
|
||||
$success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, $authLevel);
|
||||
if (!$success) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Error occurred.', $admin);
|
||||
$this->maniaControl->getChat()->sendError('Error occurred.', $admin);
|
||||
return;
|
||||
}
|
||||
|
||||
// Announce granting
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin->authLevel);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' added ' . $target->getEscapedNickname() . ' as $< ' . $authLevelName . '$>!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::logInfo($chatMessage, true);
|
||||
}
|
||||
|
||||
@ -569,46 +481,35 @@ class PlayerActions {
|
||||
* @param string $targetLogin
|
||||
*/
|
||||
public function revokeAuthLevel($adminLogin, $targetLogin) {
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
if (!$admin || !$target) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkRight($admin, $target->authLevel + 1)
|
||||
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);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($target->authLevel);
|
||||
$this->maniaControl->getChat()->sendError("You can't revoke the Rights of a {$title}!", $admin);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkRight($target, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkRight($target, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)
|
||||
) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError("MasterAdmins can't be removed!", $admin);
|
||||
$this->maniaControl->getChat()->sendError("MasterAdmins can't be removed!", $admin);
|
||||
return;
|
||||
}
|
||||
|
||||
$success = $this->maniaControl->getAuthenticationManager()
|
||||
->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_PLAYER);
|
||||
$success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_PLAYER);
|
||||
if (!$success) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendError('Error occurred.', $admin);
|
||||
$this->maniaControl->getChat()->sendError('Error occurred.', $admin);
|
||||
return;
|
||||
}
|
||||
|
||||
// Announce revoke
|
||||
$title = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($admin->authLevel);
|
||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||
$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' revoked the Rights of ' . $target->getEscapedNickname() . '!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||
Logger::logInfo($chatMessage, true);
|
||||
}
|
||||
|
||||
@ -619,8 +520,7 @@ class PlayerActions {
|
||||
* @return bool
|
||||
*/
|
||||
public function isPlayerMuted($login) {
|
||||
$ignoreList = $this->maniaControl->getClient()
|
||||
->getIgnoreList(100, 0);
|
||||
$ignoreList = $this->maniaControl->getClient()->getIgnoreList(100, 0);
|
||||
foreach ($ignoreList as $ignoredPlayers) {
|
||||
if ($ignoredPlayers->login === $login) {
|
||||
return true;
|
||||
|
@ -44,51 +44,34 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Admin commands
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener(array('balance', 'teambalance', 'autoteambalance'), $this, 'command_TeamBalance', true, 'Balances the teams.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('kick', $this, 'command_Kick', true, 'Kicks player from the server.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('ban', $this, 'command_Ban', true, 'Bans player from the server.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener(array('forcespec', 'forcespectator'), $this, 'command_ForceSpectator', true, 'Forces player into spectator.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('forceplay', $this, 'command_ForcePlay', true, 'Forces player into Play mode.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('forceblue', $this, 'command_ForceBlue', true, 'Forces player into blue team.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('forcered', $this, 'command_ForceRed', true, 'Forces player into red team.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener(array('addbots', 'addbot'), $this, 'command_AddFakePlayers', true, 'Adds bots to the game.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener(array('removebot', 'removebots'), $this, 'command_RemoveFakePlayers', true, 'Removes bots from the game.');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('mute', $this, 'command_MutePlayer', true, 'Mutes a player (prevents player from chatting).');
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener('unmute', $this, 'command_UnmutePlayer', true, 'Unmute a player (enables player to chat again).');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('balance', 'teambalance', 'autoteambalance'), $this, 'command_TeamBalance', true, 'Balances the teams.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('kick', $this, 'command_Kick', true, 'Kicks player from the server.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('ban', $this, 'command_Ban', true, 'Bans player from the server.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('forcespec', 'forcespectator'), $this, 'command_ForceSpectator', true, 'Forces player into spectator.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('forceplay', $this, 'command_ForcePlay', true, 'Forces player into Play mode.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('forceblue', $this, 'command_ForceBlue', true, 'Forces player into blue team.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('forcered', $this, 'command_ForceRed', true, 'Forces player into red team.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('addbots', 'addbot'), $this, 'command_AddFakePlayers', true, 'Adds bots to the game.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('removebot', 'removebots'), $this, 'command_RemoveFakePlayers', true, 'Removes bots from the game.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('mute', $this, 'command_MutePlayer', true, 'Mutes a player (prevents player from chatting).');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('unmute', $this, 'command_UnmutePlayer', true, 'Unmute a player (enables player to chat again).');
|
||||
|
||||
// Player commands
|
||||
$this->maniaControl->getCommandManager()
|
||||
->registerCommandListener(array('player', 'players'), $this, 'command_playerList', false, 'Shows players currently on the server.');
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('player', 'players'), $this, 'command_playerList', false, 'Shows players currently on the server.');
|
||||
|
||||
// Permissions
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_ADD_BOT, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->definePermissionLevel(self::SETTING_PERMISSION_TEAM_BALANCE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_ADD_BOT, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_TEAM_BALANCE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(Server::CB_TEAM_MODE_CHANGED, $this, 'teamStatusChanged');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Server::CB_TEAM_MODE_CHANGED, $this, 'teamStatusChanged');
|
||||
|
||||
// Action Open PlayerList
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->registerManialinkPageAnswerListener(self::ACTION_OPEN_PLAYERLIST, $this, 'command_playerList');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_OPEN_PLAYERLIST, $this, 'command_playerList');
|
||||
$itemQuad = new Quad_UIConstruction_Buttons();
|
||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Author);
|
||||
$itemQuad->setAction(self::ACTION_OPEN_PLAYERLIST);
|
||||
$this->maniaControl->getActionsMenu()
|
||||
->addMenuItem($itemQuad, true, 15, 'Open PlayerList');
|
||||
$this->maniaControl->getActionsMenu()->addMenuItem($itemQuad, true, 15, 'Open PlayerList');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -100,13 +83,11 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
//Add Balance Team Icon if it's a teamMode
|
||||
if ($teamMode) {
|
||||
// Action Balance Teams
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->registerManialinkPageAnswerListener(self::ACTION_BALANCE_TEAMS, $this, 'command_TeamBalance');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_BALANCE_TEAMS, $this, 'command_TeamBalance');
|
||||
$itemQuad = new Quad_Icons128x32_1();
|
||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_RT_Team);
|
||||
$itemQuad->setAction(self::ACTION_BALANCE_TEAMS);
|
||||
$this->maniaControl->getActionsMenu()
|
||||
->addMenuItem($itemQuad, false, 40, 'Balance Teams');
|
||||
$this->maniaControl->getActionsMenu()->addMenuItem($itemQuad, false, 40, 'Balance Teams');
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,25 +98,20 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_TeamBalance(array $chatCallback, Player $player) {
|
||||
if (!$this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, self::SETTING_PERMISSION_TEAM_BALANCE)
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_TEAM_BALANCE)
|
||||
) {
|
||||
$this->maniaControl->getAuthenticationManager()
|
||||
->sendNotAllowed($player);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->autoTeamBalance();
|
||||
$this->maniaControl->getClient()->autoTeamBalance();
|
||||
} catch (GameModeException $exception) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendException($exception, $player);
|
||||
$this->maniaControl->getChat()->sendException($exception, $player);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation($player->getEscapedNickname() . ' balanced Teams!');
|
||||
$this->maniaControl->getChat()->sendInformation($player->getEscapedNickname() . ' balanced Teams!');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -145,17 +121,14 @@ 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);
|
||||
$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);
|
||||
$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//kick login'", $player->login);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
@ -163,9 +136,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
if (isset($params[2])) {
|
||||
$message = $params[2];
|
||||
}
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->kickPlayer($player->login, $targetLogin, $message);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->kickPlayer($player->login, $targetLogin, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -175,17 +146,14 @@ 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);
|
||||
$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);
|
||||
$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//ban login'", $player->login);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
@ -193,9 +161,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
if (isset($params[2])) {
|
||||
$message = $params[2];
|
||||
}
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->banPlayer($player->login, $targetLogin, $message);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->banPlayer($player->login, $targetLogin, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -207,14 +173,11 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
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);
|
||||
$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//warn login'", $player->login);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->warnPlayer($player->login, $targetLogin);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->warnPlayer($player->login, $targetLogin);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -224,30 +187,23 @@ 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);
|
||||
$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);
|
||||
$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//forcespec login'", $player->login);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
|
||||
if (isset($params[2]) && is_numeric($params[2])) {
|
||||
$type = (int)$params[2];
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->forcePlayerToSpectator($player->login, $targetLogin, $type);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToSpectator($player->login, $targetLogin, $type);
|
||||
} else {
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->forcePlayerToSpectator($player->login, $targetLogin);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToSpectator($player->login, $targetLogin);
|
||||
}
|
||||
}
|
||||
|
||||
@ -258,17 +214,14 @@ 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);
|
||||
$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);
|
||||
$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//forceplay login'", $player->login);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
@ -279,9 +232,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
}
|
||||
$selectable = ($type === 2);
|
||||
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->forcePlayerToPlay($player->login, $targetLogin, $selectable);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToPlay($player->login, $targetLogin, $selectable);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -291,24 +242,19 @@ 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);
|
||||
$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);
|
||||
$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//forceblue login'", $player->login);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_BLUE);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_BLUE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -318,24 +264,19 @@ 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);
|
||||
$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);
|
||||
$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//forcered login'", $player->login);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $params[1];
|
||||
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_RED);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_RED);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -345,11 +286,9 @@ 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);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$amount = 1;
|
||||
@ -360,14 +299,11 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
|
||||
try {
|
||||
for ($i = 0; $i < $amount; $i++) {
|
||||
$this->maniaControl->getClient()
|
||||
->connectFakePlayer();
|
||||
$this->maniaControl->getClient()->connectFakePlayer();
|
||||
}
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess('Fake players connected!', $player);
|
||||
$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()->sendSuccess('Error while connecting a Fake-Player.', $player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -378,17 +314,13 @@ 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);
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$this->maniaControl->getClient()
|
||||
->disconnectFakePlayer('*');
|
||||
$this->maniaControl->getChat()
|
||||
->sendSuccess('Fake players disconnected!', $player);
|
||||
$this->maniaControl->getClient()->disconnectFakePlayer('*');
|
||||
$this->maniaControl->getChat()->sendSuccess('Fake players disconnected!', $player);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -400,14 +332,11 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
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);
|
||||
$this->maniaControl->getChat()->sendUsageInfo("No login specified! Example: '//mute login'", $admin);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $commandParts[1];
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->mutePlayer($admin->login, $targetLogin);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->mutePlayer($admin->login, $targetLogin);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -419,14 +348,11 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
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);
|
||||
$this->maniaControl->getChat()->sendUsageInfo("No login specified! Example: '//unmute login'", $admin);
|
||||
return;
|
||||
}
|
||||
$targetLogin = $commandParts[1];
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->unMutePlayer($admin->login, $targetLogin);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->unMutePlayer($admin->login, $targetLogin);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -436,11 +362,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_playerList(array $chatCallback, Player $player) {
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerList()
|
||||
->addPlayerToShownList($player, PlayerList::SHOWN_MAIN_WINDOW);
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerList()
|
||||
->showPlayerList($player);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerList()->addPlayerToShownList($player, PlayerList::SHOWN_MAIN_WINDOW);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerList()->showPlayerList($player);
|
||||
}
|
||||
}
|
||||
|
@ -50,8 +50,7 @@ class PlayerDataManager {
|
||||
* @return bool
|
||||
*/
|
||||
private function initTables() {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$defaultType = "'" . self::TYPE_STRING . "'";
|
||||
$typeSet = $defaultType . ",'" . self::TYPE_INT . "','" . self::TYPE_REAL . "','" . self::TYPE_BOOL . "','" . self::TYPE_ARRAY . "'";
|
||||
$query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_PLAYERDATAMETADATA . "` (
|
||||
@ -104,8 +103,7 @@ class PlayerDataManager {
|
||||
* Store Meta Data from the Database in the Ram
|
||||
*/
|
||||
private function storeMetaData() {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
|
||||
$query = "SELECT * FROM `" . self::TABLE_PLAYERDATAMETADATA . "`;";
|
||||
$result = $mysqli->query($query);
|
||||
@ -139,8 +137,7 @@ class PlayerDataManager {
|
||||
* @return bool
|
||||
*/
|
||||
public function defineMetaData($object, $dataName, $default, $dataDescription = '') {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$className = ClassUtil::getClass($object);
|
||||
|
||||
$query = "INSERT INTO `" . self::TABLE_PLAYERDATAMETADATA . "` (
|
||||
@ -218,8 +215,7 @@ class PlayerDataManager {
|
||||
return $this->storedData[$player->index][$meta->dataId];
|
||||
}
|
||||
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$dataQuery = "SELECT `value` FROM `" . self::TABLE_PLAYERDATA . "`
|
||||
WHERE `dataId` = ?
|
||||
AND `playerId` = ?
|
||||
@ -275,8 +271,7 @@ class PlayerDataManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = "INSERT INTO `" . self::TABLE_PLAYERDATA . "` (
|
||||
`serverIndex`,
|
||||
`playerId`,
|
||||
|
@ -42,18 +42,10 @@ class PlayerDetailed {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Settings
|
||||
$this->width = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsWidth();
|
||||
$this->height = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsHeight();
|
||||
$this->quadStyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultMainWindowStyle();
|
||||
$this->quadSubstyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultMainWindowSubStyle();
|
||||
$this->width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$this->height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
$this->quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowStyle();
|
||||
$this->quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowSubStyle();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -64,17 +56,14 @@ class PlayerDetailed {
|
||||
*/
|
||||
public function showPlayerDetailed(Player $player, $targetLogin) {
|
||||
/** @var Player $target */
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
|
||||
// Create ManiaLink
|
||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||
$script = $maniaLink->getScript();
|
||||
|
||||
// Main frame
|
||||
$frame = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultListFrame($script);
|
||||
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script);
|
||||
$maniaLink->add($frame);
|
||||
|
||||
// Create script and features
|
||||
@ -179,8 +168,7 @@ class PlayerDetailed {
|
||||
$label = clone $mainLabel;
|
||||
$frame->add($label);
|
||||
$label->setY($posY);
|
||||
$label->setText($this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($target->authLevel));
|
||||
$label->setText($this->maniaControl->getAuthenticationManager()->getAuthLevelName($target->authLevel));
|
||||
|
||||
//LadderRank
|
||||
$posY -= 5;
|
||||
@ -224,8 +212,7 @@ class PlayerDetailed {
|
||||
$quad->setAction(PlayerCommands::ACTION_OPEN_PLAYERLIST);
|
||||
|
||||
// render and display xml
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->displayWidget($maniaLink, $player, 'PlayerDetailed');
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'PlayerDetailed');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -237,8 +224,7 @@ class PlayerDetailed {
|
||||
public function statisticsFrame(Player $player) {
|
||||
$frame = new Frame();
|
||||
|
||||
$playerStats = $this->maniaControl->getStatisticManager()
|
||||
->getAllPlayerStats($player);
|
||||
$playerStats = $this->maniaControl->getStatisticManager()->getAllPlayerStats($player);
|
||||
$posY = $this->height / 2 - 15;
|
||||
$posX = -$this->width / 2 + 52;
|
||||
$index = 1;
|
||||
|
@ -74,24 +74,16 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->registerManialinkPageAnswerListener(self::ACTION_CLOSE_PLAYER_ADV, $this, 'closePlayerAdvancedWidget');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_OPENED, $this, 'handleWidgetOpened');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_CLOSE_PLAYER_ADV, $this, 'closePlayerAdvancedWidget');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_OPENED, $this, 'handleWidgetOpened');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
|
||||
// Update Widget Events
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidget');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'updateWidget');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'updateWidget');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'updateWidget');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERINFOCHANGED, $this, 'updateWidget');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'updateWidget');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'updateWidget');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'updateWidget');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -143,16 +135,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
* @param Player $player
|
||||
*/
|
||||
public function showPlayerList(Player $player) {
|
||||
$width = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsHeight();
|
||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
|
||||
// get PlayerList
|
||||
$players = $this->maniaControl->getPlayerManager()
|
||||
->getPlayers();
|
||||
$players = $this->maniaControl->getPlayerManager()->getPlayers();
|
||||
|
||||
//create manialink
|
||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||
@ -161,9 +148,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$script->addFeature($paging);
|
||||
|
||||
// Main frame
|
||||
$frame = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultListFrame($script, $paging);
|
||||
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging);
|
||||
$maniaLink->add($frame);
|
||||
|
||||
// Start offsets
|
||||
@ -171,9 +156,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$posY = $height / 2;
|
||||
|
||||
// Predefine Description Label
|
||||
$descriptionLabel = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultDescriptionLabel();
|
||||
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
|
||||
$frame->add($descriptionLabel);
|
||||
|
||||
// Headline
|
||||
@ -181,13 +164,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$frame->add($headFrame);
|
||||
$headFrame->setY($posY - 5);
|
||||
$labelLineArray = array('Id' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Location' => $posX + 101);
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)
|
||||
) {
|
||||
$labelLineArray['Actions'] = $posX + 135;
|
||||
}
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->labelLine($headFrame, $labelLineArray);
|
||||
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $labelLineArray);
|
||||
|
||||
$index = 1;
|
||||
$posY = $height / 2 - 10;
|
||||
@ -215,8 +196,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
}
|
||||
|
||||
$array = array($index => $posX + 5, $listPlayer->nickname => $posX + 18, $listPlayer->login => $posX + 70, $path => $posX + 101);
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->labelLine($playerFrame, $array);
|
||||
$this->maniaControl->getManialinkManager()->labelLine($playerFrame, $array);
|
||||
|
||||
$playerFrame->setY($posY);
|
||||
|
||||
@ -282,13 +262,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerFrame->add($rightLabel);
|
||||
$rightLabel->setX($posX + 13.9);
|
||||
$rightLabel->setZ(3.1);
|
||||
$rightLabel->setText($this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelAbbreviation($listPlayer->authLevel));
|
||||
$rightLabel->setText($this->maniaControl->getAuthenticationManager()->getAuthLevelAbbreviation($listPlayer->authLevel));
|
||||
$rightLabel->setTextSize(0.8);
|
||||
$rightLabel->setTextColor('fff');
|
||||
|
||||
$description = $this->maniaControl->getAuthenticationManager()
|
||||
->getAuthLevelName($listPlayer) . ' ' . $listPlayer->nickname;
|
||||
$description = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($listPlayer) . ' ' . $listPlayer->nickname;
|
||||
$rightLabel->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
|
||||
// Player Statistics
|
||||
@ -326,8 +304,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$description = 'View Player Profile of $<' . $listPlayer->nickname . '$>';
|
||||
$playerQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)
|
||||
) {
|
||||
// Further Player actions Quad
|
||||
$playerQuad = new Quad_Icons64x64_1();
|
||||
@ -343,11 +320,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getServer()
|
||||
->isTeamMode()
|
||||
if ($this->maniaControl->getServer()->isTeamMode()
|
||||
) {
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)
|
||||
) {
|
||||
// Force to Red-Team Quad
|
||||
$redQuad = new Quad_Emblems();
|
||||
@ -375,8 +350,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$description = 'Force $<' . $listPlayer->nickname . '$> to Blue Team!';
|
||||
$blueQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
|
||||
} else if ($this->maniaControl->getPluginManager()
|
||||
->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)
|
||||
} else if ($this->maniaControl->getPluginManager()->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)
|
||||
) {
|
||||
// Kick Player Vote
|
||||
$kickQuad = new Quad_UIConstruction_Buttons();
|
||||
@ -391,8 +365,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$kickQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
}
|
||||
} else {
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_PLAY)
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_PLAY)
|
||||
) {
|
||||
// Force to Play
|
||||
$playQuad = new Quad_Emblems();
|
||||
@ -408,8 +381,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getAuthenticationManager()
|
||||
->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_SPEC)
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_SPEC)
|
||||
) {
|
||||
// Force to Spectator Quad
|
||||
$spectatorQuad = new Quad_BgRaceScore2();
|
||||
@ -423,8 +395,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
// Force to Spectator Description Label
|
||||
$description = 'Force $<' . $listPlayer->nickname . '$> to Spectator!';
|
||||
$spectatorQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
} else if ($this->maniaControl->getPluginManager()
|
||||
->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)
|
||||
} else if ($this->maniaControl->getPluginManager()->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)
|
||||
) {
|
||||
// Force to Spectator Quad
|
||||
$spectatorQuad = new Quad_BgRaceScore2();
|
||||
@ -452,8 +423,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
}
|
||||
|
||||
// Render and display xml
|
||||
$this->maniaControl->getManialinkManager()
|
||||
->displayWidget($maniaLink, $player, 'PlayerList');
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'PlayerList');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -464,20 +434,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
* @return Frame
|
||||
*/
|
||||
public function showAdvancedPlayerWidget(Player $admin, $login) {
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$width = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getListWidgetsHeight();
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultMainWindowStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()
|
||||
->getStyleManager()
|
||||
->getDefaultMainWindowSubStyle();
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowSubStyle();
|
||||
|
||||
//Settings
|
||||
$posX = $width / 2 + 2.5;
|
||||
@ -554,9 +515,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$label->setTextSize($textSize);
|
||||
$label->setTextColor($textColor);
|
||||
|
||||
if (!$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->isPlayerMuted($login)
|
||||
if (!$this->maniaControl->getPlayerManager()->getPlayerActions()->isPlayerMuted($login)
|
||||
) {
|
||||
$label->setText('Mute');
|
||||
$quad->setAction(self::ACTION_MUTE_PLAYER . '.' . $login);
|
||||
@ -645,8 +604,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$label->setTextColor($textColor);
|
||||
|
||||
if ($player->authLevel > 0
|
||||
&& $this->maniaControl->getAuthenticationManager()
|
||||
->checkRight($admin, $player->authLevel + 1)
|
||||
&& $this->maniaControl->getAuthenticationManager()->checkRight($admin, $player->authLevel + 1)
|
||||
) {
|
||||
$posY -= 5;
|
||||
// Revoke Rights
|
||||
@ -684,119 +642,79 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
switch ($action) {
|
||||
case self::ACTION_SPECTATE_PLAYER:
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->forceSpectator($adminLogin, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
|
||||
$this->maniaControl->getClient()
|
||||
->forceSpectatorTarget($adminLogin, $targetLogin, 1);
|
||||
$this->maniaControl->getClient()->forceSpectator($adminLogin, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
|
||||
$this->maniaControl->getClient()->forceSpectatorTarget($adminLogin, $targetLogin, 1);
|
||||
} catch (PlayerStateException $e) {
|
||||
}
|
||||
break;
|
||||
case self::ACTION_OPEN_PLAYER_DETAILED:
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerDetailed()
|
||||
->showPlayerDetailed($player, $targetLogin);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerDetailed()->showPlayerDetailed($player, $targetLogin);
|
||||
unset($this->playersListShown[$player->login]);
|
||||
break;
|
||||
case self::ACTION_FORCE_BLUE:
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::TEAM_BLUE);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::TEAM_BLUE);
|
||||
break;
|
||||
case self::ACTION_FORCE_RED:
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::TEAM_RED);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToTeam($adminLogin, $targetLogin, PlayerActions::TEAM_RED);
|
||||
break;
|
||||
case self::ACTION_FORCE_SPEC:
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->forcePlayerToSpectator($adminLogin, $targetLogin, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToSpectator($adminLogin, $targetLogin, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
|
||||
break;
|
||||
case self::ACTION_FORCE_PLAY:
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->forcePlayerToPlay($adminLogin, $targetLogin);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToPlay($adminLogin, $targetLogin);
|
||||
break;
|
||||
case self::ACTION_MUTE_PLAYER:
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->mutePlayer($adminLogin, $targetLogin);
|
||||
$this->showPlayerList($this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin));
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->mutePlayer($adminLogin, $targetLogin);
|
||||
$this->showPlayerList($this->maniaControl->getPlayerManager()->getPlayer($adminLogin));
|
||||
break;
|
||||
case self::ACTION_UNMUTE_PLAYER:
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->unMutePlayer($adminLogin, $targetLogin);
|
||||
$this->showPlayerList($this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin));
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->unMutePlayer($adminLogin, $targetLogin);
|
||||
$this->showPlayerList($this->maniaControl->getPlayerManager()->getPlayer($adminLogin));
|
||||
break;
|
||||
case self::ACTION_WARN_PLAYER:
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->warnPlayer($adminLogin, $targetLogin);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->warnPlayer($adminLogin, $targetLogin);
|
||||
break;
|
||||
case self::ACTION_KICK_PLAYER:
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->kickPlayer($adminLogin, $targetLogin);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->kickPlayer($adminLogin, $targetLogin);
|
||||
break;
|
||||
case self::ACTION_BAN_PLAYER:
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->banPlayer($adminLogin, $targetLogin);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->banPlayer($adminLogin, $targetLogin);
|
||||
break;
|
||||
case self::ACTION_PLAYER_ADV:
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
$this->advancedPlayerWidget($admin, $targetLogin);
|
||||
break;
|
||||
case self::ACTION_ADD_AS_MASTER:
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->grandAuthLevel($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()->grandAuthLevel($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()->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
break;
|
||||
case self::ACTION_REVOKE_RIGHTS:
|
||||
$this->maniaControl->getPlayerManager()
|
||||
->getPlayerActions()
|
||||
->revokeAuthLevel($adminLogin, $targetLogin);
|
||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->revokeAuthLevel($adminLogin, $targetLogin);
|
||||
break;
|
||||
case self::ACTION_FORCE_SPEC_VOTE:
|
||||
/** @var $votesPlugin CustomVotesPlugin */
|
||||
$votesPlugin = $this->maniaControl->getPluginManager()
|
||||
->getPlugin(self::DEFAULT_CUSTOM_VOTE_PLUGIN);
|
||||
$votesPlugin = $this->maniaControl->getPluginManager()->getPlugin(self::DEFAULT_CUSTOM_VOTE_PLUGIN);
|
||||
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
|
||||
$startMessage = $admin->getEscapedNickname() . '$s started a vote to force $<' . $target->nickname . '$> into spectator!';
|
||||
|
||||
$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!');
|
||||
$this->maniaControl->getChat()->sendInformation('$sVote successful -> Player ' . $target->getEscapedNickname() . ' forced to Spectator!');
|
||||
$votesPlugin->undefineVote('forcespec');
|
||||
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->forceSpectator($target->login, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
|
||||
$this->maniaControl->getClient()
|
||||
->spectatorReleasePlayerSlot($target->login);
|
||||
$this->maniaControl->getClient()->forceSpectator($target->login, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
|
||||
$this->maniaControl->getClient()->spectatorReleasePlayerSlot($target->login);
|
||||
} catch (PlayerStateException $e) {
|
||||
} catch (UnknownPlayerException $e) {
|
||||
}
|
||||
@ -804,13 +722,10 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
break;
|
||||
case self::ACTION_KICK_PLAYER_VOTE:
|
||||
/** @var $votesPlugin CustomVotesPlugin */
|
||||
$votesPlugin = $this->maniaControl->getPluginManager()
|
||||
->getPlugin(self::DEFAULT_CUSTOM_VOTE_PLUGIN);
|
||||
$votesPlugin = $this->maniaControl->getPluginManager()->getPlugin(self::DEFAULT_CUSTOM_VOTE_PLUGIN);
|
||||
|
||||
$admin = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($adminLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($targetLogin);
|
||||
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||
|
||||
$startMessage = $admin->getEscapedNickname() . '$s started a vote to kick $<' . $target->nickname . '$>!';
|
||||
|
||||
@ -818,14 +733,12 @@ 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!');
|
||||
$this->maniaControl->getChat()->sendInformation('$sVote successful -> ' . $target->getEscapedNickname() . ' got Kicked!');
|
||||
$votesPlugin->undefineVote('kick');
|
||||
|
||||
$message = '$39F You got kicked due to a Public Vote!$z ';
|
||||
try {
|
||||
$this->maniaControl->getClient()
|
||||
->kick($target->login, $message);
|
||||
$this->maniaControl->getClient()->kick($target->login, $message);
|
||||
} catch (UnknownPlayerException $e) {
|
||||
}
|
||||
});
|
||||
@ -859,8 +772,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
}
|
||||
|
||||
// Check if shown player still exists
|
||||
$player = $this->maniaControl->getPlayerManager()
|
||||
->getPlayer($login);
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||
if (!$player) {
|
||||
unset($this->playersListShown[$login]);
|
||||
continue;
|
||||
|
@ -80,24 +80,17 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
$this->adminLists = new AdminLists($maniaControl);
|
||||
|
||||
// Settings
|
||||
$this->maniaControl->getSettingManager()
|
||||
->initSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES, true);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES, true);
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(Callbacks::ONINIT, $this, 'onInit');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(CallbackManager::CB_MP_PLAYERCONNECT, $this, 'playerConnect');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(CallbackManager::CB_MP_PLAYERDISCONNECT, $this, 'playerDisconnect');
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->registerCallbackListener(CallbackManager::CB_MP_PLAYERINFOCHANGED, $this, 'playerInfoChanged');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'onInit');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERCONNECT, $this, 'playerConnect');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERDISCONNECT, $this, 'playerDisconnect');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERINFOCHANGED, $this, 'playerInfoChanged');
|
||||
|
||||
// Player stats
|
||||
$this->maniaControl->getStatisticManager()
|
||||
->defineStatMetaData(self::STAT_JOIN_COUNT);
|
||||
$this->maniaControl->getStatisticManager()
|
||||
->defineStatMetaData(self::STAT_SERVERTIME, StatisticManager::STAT_TYPE_TIME);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_JOIN_COUNT);
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_SERVERTIME, StatisticManager::STAT_TYPE_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,8 +99,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
* @return bool
|
||||
*/
|
||||
private function initTables() {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$playerTableQuery = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_PLAYERS . "` (
|
||||
`index` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`login` varchar(100) NOT NULL,
|
||||
@ -192,23 +184,20 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
*/
|
||||
public function onInit() {
|
||||
// Add all players
|
||||
$players = $this->maniaControl->getClient()
|
||||
->getPlayerList(300, 0, 2);
|
||||
$players = $this->maniaControl->getClient()->getPlayerList(300, 0, 2);
|
||||
foreach ($players as $playerItem) {
|
||||
if ($playerItem->playerId <= 0) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
$detailedPlayerInfo = $this->maniaControl->getClient()
|
||||
->getDetailedPlayerInfo($playerItem->login);
|
||||
$detailedPlayerInfo = $this->maniaControl->getClient()->getDetailedPlayerInfo($playerItem->login);
|
||||
} catch (UnknownPlayerException $exception) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if the Player is in a Team, to notify if its a TeamMode or not
|
||||
if ($playerItem->teamId >= 0) {
|
||||
$this->maniaControl->getServer()
|
||||
->setTeamMode(true);
|
||||
$this->maniaControl->getServer()->setTeamMode(true);
|
||||
}
|
||||
|
||||
$player = new Player($this->maniaControl, true);
|
||||
@ -238,8 +227,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
* @return bool
|
||||
*/
|
||||
private function savePlayer(Player &$player) {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
|
||||
// Save player
|
||||
$playerQuery = "INSERT INTO `" . self::TABLE_PLAYERS . "` (
|
||||
@ -298,8 +286,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
public function playerConnect(array $callback) {
|
||||
$login = $callback[1][0];
|
||||
try {
|
||||
$playerInfo = $this->maniaControl->getClient()
|
||||
->getDetailedPlayerInfo($login);
|
||||
$playerInfo = $this->maniaControl->getClient()->getDetailedPlayerInfo($login);
|
||||
$player = new Player($this->maniaControl, true);
|
||||
$player->setDetailedInfo($playerInfo);
|
||||
|
||||
@ -321,11 +308,9 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
}
|
||||
|
||||
// Trigger own callbacks
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_PLAYERDISCONNECT, $player);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYERDISCONNECT, $player);
|
||||
if ($this->getPlayerCount(false) <= 0) {
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_SERVER_EMPTY);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_SERVER_EMPTY);
|
||||
}
|
||||
|
||||
if ($player->isFakePlayer()) {
|
||||
@ -336,16 +321,13 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
$logMessage = "Player left: {$player->login} / {$player->nickname} Playtime: {$played}";
|
||||
Logger::logInfo($logMessage, true);
|
||||
|
||||
if ($this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES)
|
||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES)
|
||||
) {
|
||||
$this->maniaControl->getChat()
|
||||
->sendChat('$0f0$<$fff' . $player->nickname . '$> has left the game');
|
||||
$this->maniaControl->getChat()->sendChat('$0f0$<$fff' . $player->nickname . '$> has left the game');
|
||||
}
|
||||
|
||||
//Destroys stored PlayerData, after all Disconnect Callbacks got Handled
|
||||
$this->getPlayerDataManager()
|
||||
->destroyPlayerData($player);
|
||||
$this->getPlayerDataManager()->destroyPlayerData($player);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -379,8 +361,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
}
|
||||
$playedTime = time() - $player->joinTime;
|
||||
|
||||
return $this->maniaControl->getStatisticManager()
|
||||
->insertStat(self::STAT_SERVERTIME, $player, $this->maniaControl->getServer()->index, $playedTime);
|
||||
return $this->maniaControl->getStatisticManager()->insertStat(self::STAT_SERVERTIME, $player, $this->maniaControl->getServer()->index, $playedTime);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -418,8 +399,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
|
||||
//Check if the Player is in a Team, to notify if its a TeamMode or not
|
||||
if ($player->teamId >= 0) {
|
||||
$this->maniaControl->getServer()
|
||||
->setTeamMode(true);
|
||||
$this->maniaControl->getServer()->setTeamMode(true);
|
||||
}
|
||||
|
||||
$prevJoinState = $player->hasJoinedGame;
|
||||
@ -430,33 +410,27 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
//Check if Player finished joining the game
|
||||
if ($player->hasJoinedGame && !$prevJoinState) {
|
||||
|
||||
if ($this->maniaControl->getSettingManager()
|
||||
->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES)
|
||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES)
|
||||
&& !$player->isFakePlayer()
|
||||
) {
|
||||
$string = array(0 => '$0f0Player', 1 => '$0f0Moderator', 2 => '$0f0Admin', 3 => '$0f0SuperAdmin', 4 => '$0f0MasterAdmin');
|
||||
$chatMessage = '$0f0' . $string[$player->authLevel] . ' $<$fff' . $player->nickname . '$> Nation: $<$fff' . $player->getCountry() . '$> joined!';
|
||||
$this->maniaControl->getChat()
|
||||
->sendChat($chatMessage);
|
||||
$this->maniaControl->getChat()
|
||||
->sendInformation('This server uses ManiaControl v' . ManiaControl::VERSION . '!', $player->login);
|
||||
$this->maniaControl->getChat()->sendChat($chatMessage);
|
||||
$this->maniaControl->getChat()->sendInformation('This server uses ManiaControl v' . ManiaControl::VERSION . '!', $player->login);
|
||||
}
|
||||
|
||||
$logMessage = "Player joined: {$player->login} / {$player->nickname} Nation: " . $player->getCountry() . " IP: {$player->ipAddress}";
|
||||
Logger::logInfo($logMessage, true);
|
||||
|
||||
// Increment the Player Join Count
|
||||
$this->maniaControl->getStatisticManager()
|
||||
->incrementStat(self::STAT_JOIN_COUNT, $player, $this->maniaControl->getServer()->index);
|
||||
$this->maniaControl->getStatisticManager()->incrementStat(self::STAT_JOIN_COUNT, $player, $this->maniaControl->getServer()->index);
|
||||
|
||||
// Trigger own PlayerJoined callback
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_PLAYERCONNECT, $player);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYERCONNECT, $player);
|
||||
}
|
||||
|
||||
// Trigger own callback
|
||||
$this->maniaControl->getCallbackManager()
|
||||
->triggerCallback(self::CB_PLAYERINFOCHANGED, $player);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYERINFOCHANGED, $player);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -486,8 +460,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
* @return Player
|
||||
*/
|
||||
private function getPlayerFromDatabaseByLogin($playerLogin) {
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
|
||||
$query = "SELECT * FROM `" . self::TABLE_PLAYERS . "`
|
||||
WHERE `login` LIKE '" . $mysqli->escape_string($playerLogin) . "';";
|
||||
@ -572,8 +545,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
return null;
|
||||
}
|
||||
|
||||
$mysqli = $this->maniaControl->getDatabase()
|
||||
->getMysqli();
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = "SELECT * FROM `" . self::TABLE_PLAYERS . "`
|
||||
WHERE `index` = {$playerIndex};";
|
||||
$result = $mysqli->query($query);
|
||||
|
Reference in New Issue
Block a user