added playermute

This commit is contained in:
kremsy 2014-01-02 16:37:52 +01:00
parent 45803ef443
commit f935fa9b43
3 changed files with 205 additions and 107 deletions

View File

@ -38,32 +38,34 @@ class Player {
* @param array $rpcInfos * @param array $rpcInfos
*/ */
public function __construct(array $rpcInfos) { public function __construct(array $rpcInfos) {
if (!$rpcInfos) { if(!$rpcInfos) {
return; return;
} }
$this->pid = $rpcInfos['PlayerId']; $this->pid = $rpcInfos['PlayerId'];
$this->login = $rpcInfos['Login']; $this->login = $rpcInfos['Login'];
$this->nickname = Formatter::stripDirtyCodes($rpcInfos['NickName']); $this->nickname = Formatter::stripDirtyCodes($rpcInfos['NickName']);
$this->path = $rpcInfos['Path']; $this->path = $rpcInfos['Path'];
$this->language = $rpcInfos['Language']; $this->language = $rpcInfos['Language'];
$this->avatar = $rpcInfos['Avatar']['FileName']; $this->avatar = $rpcInfos['Avatar']['FileName'];
$this->allies = $rpcInfos['Allies']; $this->allies = $rpcInfos['Allies'];
$this->clubLink = $rpcInfos['ClubLink']; $this->clubLink = $rpcInfos['ClubLink'];
$this->teamId = $rpcInfos['TeamId']; $this->teamId = $rpcInfos['TeamId'];
$this->isSpectator = $rpcInfos['IsSpectator']; $this->isSpectator = $rpcInfos['IsSpectator'];
$this->isOfficial = $rpcInfos['IsInOfficialMode']; $this->isOfficial = $rpcInfos['IsInOfficialMode'];
$this->isReferee = $rpcInfos['IsReferee']; $this->isReferee = $rpcInfos['IsReferee'];
$this->ladderScore = $rpcInfos['LadderStats']['PlayerRankings'][0]['Score']; $this->ladderScore = $rpcInfos['LadderStats']['PlayerRankings'][0]['Score'];
$this->ladderRank = $rpcInfos['LadderStats']['PlayerRankings'][0]['Ranking']; $this->ladderRank = $rpcInfos['LadderStats']['PlayerRankings'][0]['Ranking'];
$this->ipAddress = $rpcInfos['IPAddress']; $this->ipAddress = $rpcInfos['IPAddress'];
$this->joinTime = time(); $this->joinTime = time();
if($this->nickname == '') if($this->nickname == '') {
$this->nickname = $this->login; $this->nickname = $this->login;
}
} }
/** /**
* Check if player is not a real player * Check if player is not a real player
* *
@ -80,7 +82,7 @@ class Player {
*/ */
public function getProvince() { public function getProvince() {
$pathParts = explode('|', $this->path); $pathParts = explode('|', $this->path);
if (isset($pathParts[3])) { if(isset($pathParts[3])) {
return $pathParts[3]; return $pathParts[3];
} }
return $this->getCountry(); return $this->getCountry();
@ -93,13 +95,13 @@ class Player {
*/ */
public function getCountry() { public function getCountry() {
$pathParts = explode('|', $this->path); $pathParts = explode('|', $this->path);
if (isset($pathParts[2])) { if(isset($pathParts[2])) {
return $pathParts[2]; return $pathParts[2];
} }
if (isset($pathParts[1])) { if(isset($pathParts[1])) {
return $pathParts[1]; return $pathParts[1];
} }
if (isset($pathParts[0])) { if(isset($pathParts[0])) {
return $pathParts[0]; return $pathParts[0];
} }
return $this->path; return $this->path;
@ -112,10 +114,10 @@ class Player {
*/ */
public function getContinent() { public function getContinent() {
$pathParts = explode('|', $this->path); $pathParts = explode('|', $this->path);
if (isset($pathParts[1])) { if(isset($pathParts[1])) {
return $pathParts[1]; return $pathParts[1];
} }
if (isset($pathParts[0])) { if(isset($pathParts[0])) {
return $pathParts[0]; return $pathParts[0];
} }
return $this->path; return $this->path;

View File

@ -6,7 +6,6 @@ use FML\Controls\Control;
use FML\Controls\Frame; use FML\Controls\Frame;
use FML\Controls\Labels\Label_Text; use FML\Controls\Labels\Label_Text;
use FML\Controls\Quad; use FML\Controls\Quad;
use FML\Controls\Quads\Quad_BgRaceScore2;
use FML\Controls\Quads\Quad_Icons64x64_1; use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\ManiaLink; use FML\ManiaLink;
use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Admin\AuthenticationManager;
@ -23,13 +22,13 @@ class PlayerActions {
/** /**
* Constants * Constants
*/ */
const BLUE_TEAM = 0; const BLUE_TEAM = 0;
const RED_TEAM = 1; const RED_TEAM = 1;
const SPECTATOR_USER_SELECTABLE = 0; const SPECTATOR_USER_SELECTABLE = 0;
const SPECTATOR_SPECTATOR = 1; const SPECTATOR_SPECTATOR = 1;
const SPECTATOR_PLAYER = 2; const SPECTATOR_PLAYER = 2;
const SPECTATOR_BUT_KEEP_SELECTABLE = 3; const SPECTATOR_BUT_KEEP_SELECTABLE = 3;
/** /**
* Private Properties * Private Properties
*/ */
@ -49,65 +48,122 @@ class PlayerActions {
* *
* @param string $adminLogin * @param string $adminLogin
* @param string $targetLogin * @param string $targetLogin
* @param int $teamId * @param int $teamId
*/ */
public function forcePlayerToTeam($adminLogin, $targetLogin, $teamId) { public function forcePlayerToTeam($adminLogin, $targetLogin, $teamId) {
// TODO: get used by playercommands // TODO: get used by playercommands
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin); $admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
if (!$admin || !$target) return; if(!$admin || !$target) {
return;
}
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
if ($target->isSpectator) { if($target->isSpectator) {
$success = $this->maniaControl->client->query('ForceSpectator', $target->login, self::SPECTATOR_PLAYER); $success = $this->maniaControl->client->query('ForceSpectator', $target->login, self::SPECTATOR_PLAYER);
if (!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
} }
$success = $this->maniaControl->client->query('ForcePlayerTeam', $target->login, $teamId); $success = $this->maniaControl->client->query('ForcePlayerTeam', $target->login, $teamId);
if (!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
$chatMessage = false; $chatMessage = false;
if ($teamId == self::BLUE_TEAM) { if($teamId == self::BLUE_TEAM) {
$chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Blue-Team!'; $chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Blue-Team!';
} } else if($teamId == self::RED_TEAM) {
else if ($teamId == self::RED_TEAM) {
$chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Red-Team!'; $chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Red-Team!';
} }
if (!$chatMessage) return; if(!$chatMessage)
return;
$this->maniaControl->chat->sendInformation($chatMessage); $this->maniaControl->chat->sendInformation($chatMessage);
$this->maniaControl->log(Formatter::stripCodes($chatMessage)); $this->maniaControl->log(Formatter::stripCodes($chatMessage));
} }
/** /**
* Force a Player to Spectator * Force a Player to Spectator
* *
* @param string $adminLogin * @param string $adminLogin
* @param string $targetLogin * @param string $targetLogin
* @param int $spectatorState * @param int $spectatorState
*/ */
public function forcePlayerToSpectator($adminLogin, $targetLogin, $spectatorState = self::SPECTATOR_BUT_KEEP_SELECTABLE) { public function forcePlayerToSpectator($adminLogin, $targetLogin, $spectatorState = self::SPECTATOR_BUT_KEEP_SELECTABLE) {
// TODO: get used by playercommands // TODO: get used by playercommands
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin); $admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
$success = $this->maniaControl->client->query('ForceSpectator', $targetLogin, $spectatorState); $success = $this->maniaControl->client->query('ForceSpectator', $targetLogin, $spectatorState);
if (!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
$chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> to Spectator!'; $chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> to Spectator!';
$this->maniaControl->chat->sendInformation($chatMessage); $this->maniaControl->chat->sendInformation($chatMessage);
$this->maniaControl->log(Formatter::stripCodes($chatMessage)); $this->maniaControl->log(Formatter::stripCodes($chatMessage));
} }
/**
* UnMutes a Player
*
* @param string $adminLogin
* @param string $targetLogin
* @param int $spectatorState
*/
public function unMutePlayer($adminLogin, $targetLogin) {
// TODO: playercommand
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
$target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
$success = $this->maniaControl->client->query('UnIgnore', $targetLogin);
var_dump($success);
var_dump($this->maniaControl->client->getResponse());
if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return;
}
$chatMessage = $title . ' $<' . $admin->nickname . '$> un-muted $<' . $target->nickname . '$>!';
$this->maniaControl->chat->sendInformation($chatMessage);
$this->maniaControl->log(Formatter::stripCodes($chatMessage));
}
/**
* Mutes a Player
*
* @param string $adminLogin
* @param string $targetLogin
* @param int $spectatorState
*/
public function mutePlayer($adminLogin, $targetLogin) {
// TODO: playercommand
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
$target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
$success = $this->maniaControl->client->query('Ignore', $targetLogin);
if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return;
}
$chatMessage = $title . ' $<' . $admin->nickname . '$> muted $<' . $target->nickname . '$>!';
$this->maniaControl->chat->sendInformation($chatMessage);
$this->maniaControl->log(Formatter::stripCodes($chatMessage));
}
/** /**
* Warn a Player * Warn a Player
* *
@ -116,35 +172,35 @@ class PlayerActions {
*/ */
public function warnPlayer($adminLogin, $targetLogin) { public function warnPlayer($adminLogin, $targetLogin) {
// TODO: chatcommand // TODO: chatcommand
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin); $admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
// display warning message // display warning message
$message = '$s$f00This is an administrative warning.{br}{br}$gWhatever you wrote or you have done is against {br} our server\'s policy. $message = '$s$f00This is an administrative warning.{br}{br}$gWhatever you wrote or you have done is against {br} our server\'s policy.
{br}Not respecting other players, or{br}using offensive language might result in a{br}$f00kick, or ban $ff0the next time. {br}Not respecting other players, or{br}using offensive language might result in a{br}$f00kick, or ban $ff0the next time.
{br}{br}$gThe server administrators.'; {br}{br}$gThe server administrators.';
$message = preg_split('/{br}/', $message); $message = preg_split('/{br}/', $message);
$width = 80; $width = 80;
$height = 50; $height = 50;
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle(); $quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle(); $quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID); $maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
// mainframe // mainframe
$frame = new Frame(); $frame = new Frame();
$maniaLink->add($frame); $maniaLink->add($frame);
$frame->setSize($width, $height); $frame->setSize($width, $height);
$frame->setPosition(0, 10); $frame->setPosition(0, 10);
// Background Quad // Background Quad
$backgroundQuad = new Quad(); $backgroundQuad = new Quad();
$frame->add($backgroundQuad); $frame->add($backgroundQuad);
$backgroundQuad->setSize($width, $height); $backgroundQuad->setSize($width, $height);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle); $backgroundQuad->setStyles($quadStyle, $quadSubstyle);
// Add Close Quad (X) // Add Close Quad (X)
$closeQuad = new Quad_Icons64x64_1(); $closeQuad = new Quad_Icons64x64_1();
$frame->add($closeQuad); $frame->add($closeQuad);
@ -152,7 +208,7 @@ class PlayerActions {
$closeQuad->setSize(6, 6); $closeQuad->setSize(6, 6);
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace); $closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
$closeQuad->setAction(ManialinkManager::ACTION_CLOSEWIDGET); $closeQuad->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
// Headline Label // Headline Label
$label = new Label_Text(); $label = new Label_Text();
$frame->add($label); $frame->add($label);
@ -163,9 +219,9 @@ class PlayerActions {
$label->setTextSize(4); $label->setTextSize(4);
$label->setText('Administrative Warning'); $label->setText('Administrative Warning');
$label->setTextColor('F00'); $label->setTextColor('F00');
$y = $height / 2 - 15; $y = $height / 2 - 15;
foreach ($message as &$line) { foreach($message as &$line) {
// Warn Labels // Warn Labels
$label = new Label_Text(); $label = new Label_Text();
$frame->add($label); $frame->add($label);
@ -179,10 +235,10 @@ class PlayerActions {
$label->setTextColor('FF0'); $label->setTextColor('FF0');
$y -= 4; $y -= 4;
} }
// Display manialink // Display manialink
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $target); $this->maniaControl->manialinkManager->displayWidget($maniaLink, $target);
$chatMessage = $title . ' $<' . $admin->nickname . '$> warned $<' . $target->nickname . '$>!'; $chatMessage = $title . ' $<' . $admin->nickname . '$> warned $<' . $target->nickname . '$>!';
$this->maniaControl->chat->sendInformation($chatMessage); $this->maniaControl->chat->sendInformation($chatMessage);
$this->maniaControl->log(Formatter::stripCodes($chatMessage)); $this->maniaControl->log(Formatter::stripCodes($chatMessage));
@ -196,22 +252,21 @@ class PlayerActions {
* @param string $message * @param string $message
*/ */
public function kickPlayer($adminLogin, $targetLogin, $message = '') { public function kickPlayer($adminLogin, $targetLogin, $message = '') {
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin); $admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
if ($target->isFakePlayer()) { if($target->isFakePlayer()) {
$success = $this->maniaControl->client->query('DisconnectFakePlayer', $target->login); $success = $this->maniaControl->client->query('DisconnectFakePlayer', $target->login);
} } else {
else {
$success = $this->maniaControl->client->query('Kick', $target->login, $message); $success = $this->maniaControl->client->query('Kick', $target->login, $message);
} }
if (!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
$chatMessage = $title . ' $<' . $admin->nickname . '$> kicked $<' . $target->nickname . '$>!'; $chatMessage = $title . ' $<' . $admin->nickname . '$> kicked $<' . $target->nickname . '$>!';
$this->maniaControl->chat->sendInformation($chatMessage); $this->maniaControl->chat->sendInformation($chatMessage);
$this->maniaControl->log(Formatter::stripCodes($chatMessage)); $this->maniaControl->log(Formatter::stripCodes($chatMessage));
@ -225,17 +280,17 @@ class PlayerActions {
* @param string $message * @param string $message
*/ */
public function banPlayer($adminLogin, $targetLogin, $message = '') { public function banPlayer($adminLogin, $targetLogin, $message = '') {
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin); $admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
$success = $this->maniaControl->client->query('Ban', $target->login, $message); $success = $this->maniaControl->client->query('Ban', $target->login, $message);
if (!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
$chatMessage = $title . ' $<' . $admin->nickname . '$> banned $<' . $target->nickname . '$>!'; $chatMessage = $title . ' $<' . $admin->nickname . '$> banned $<' . $target->nickname . '$>!';
$this->maniaControl->chat->sendInformation($chatMessage); $this->maniaControl->chat->sendInformation($chatMessage);
$this->maniaControl->log(Formatter::stripCodes($chatMessage)); $this->maniaControl->log(Formatter::stripCodes($chatMessage));
@ -246,35 +301,32 @@ class PlayerActions {
* *
* @param string $adminLogin * @param string $adminLogin
* @param string $targetLogin * @param string $targetLogin
* @param int $authLevel * @param int $authLevel
*/ */
public function grandAuthLevel($adminLogin, $targetLogin, $authLevel) { public function grandAuthLevel($adminLogin, $targetLogin, $authLevel) {
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin); $admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
if ($this->maniaControl->authenticationManager->checkRight($target, $authLevel)) { if($this->maniaControl->authenticationManager->checkRight($target, $authLevel)) {
$this->maniaControl->chat->sendError( $this->maniaControl->chat->sendError('This Player is already ' . $this->maniaControl->authenticationManager->getAuthLevelName($target->authLevel), $admin->login);
'This Player is already ' . $this->maniaControl->authenticationManager->getAuthLevelName($target->authLevel),
$admin->login);
return; return;
} }
$authLevelName = $this->maniaControl->authenticationManager->getAuthLevelName($authLevel); $authLevelName = $this->maniaControl->authenticationManager->getAuthLevelName($authLevel);
if ($this->maniaControl->authenticationManager->checkRight($admin, $authLevel) <= if($this->maniaControl->authenticationManager->checkRight($admin, $authLevel) <= $this->maniaControl->authenticationManager->checkRight($target, $authLevel)) {
$this->maniaControl->authenticationManager->checkRight($target, $authLevel)) {
$this->maniaControl->chat->sendError('You don\'t have the permission to add a ' . $authLevelName . '!', $admin->login); $this->maniaControl->chat->sendError('You don\'t have the permission to add a ' . $authLevelName . '!', $admin->login);
return; return;
} }
$success = $this->maniaControl->authenticationManager->grantAuthLevel($target, $authLevel); $success = $this->maniaControl->authenticationManager->grantAuthLevel($target, $authLevel);
if (!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
$chatMessage = $title . ' $<' . $admin->nickname . '$> added $<' . $target->nickname . '$> as $< ' . $authLevelName . '$>!'; $chatMessage = $title . ' $<' . $admin->nickname . '$> added $<' . $target->nickname . '$> as $< ' . $authLevelName . '$>!';
$this->maniaControl->chat->sendInformation($chatMessage); $this->maniaControl->chat->sendInformation($chatMessage);
$this->maniaControl->log(Formatter::stripCodes($chatMessage)); $this->maniaControl->log(Formatter::stripCodes($chatMessage));
@ -287,24 +339,39 @@ class PlayerActions {
* @param string $targetLogin * @param string $targetLogin
*/ */
public function revokeAuthLevel($adminLogin, $targetLogin) { public function revokeAuthLevel($adminLogin, $targetLogin) {
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin); $admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
if ($this->maniaControl->authenticationManager->checkRight($target, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)) { if($this->maniaControl->authenticationManager->checkRight($target, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)) {
$this->maniaControl->chat->sendError('MasterAdmins can\'t be removed ', $admin->login); $this->maniaControl->chat->sendError('MasterAdmins can\'t be removed ', $admin->login);
return; return;
} }
$success = $this->maniaControl->authenticationManager->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_PLAYER); $success = $this->maniaControl->authenticationManager->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_PLAYER);
if (!$success) { if(!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
$chatMessage = $title . ' $<' . $admin->nickname . '$> revokes the Rights of $<' . $target->nickname . '$>!'; $chatMessage = $title . ' $<' . $admin->nickname . '$> revokes the Rights of $<' . $target->nickname . '$>!';
$this->maniaControl->chat->sendInformation($chatMessage); $this->maniaControl->chat->sendInformation($chatMessage);
$this->maniaControl->log(Formatter::stripCodes($chatMessage)); $this->maniaControl->log(Formatter::stripCodes($chatMessage));
} }
/**
* Checks if a Player is Muted
*
* @param $login
* @return bool
*/
public function isPlayerMuted($login) {
$this->maniaControl->client->query('GetIgnoreList', 100, 0);
foreach($this->maniaControl->client->getResponse() as $ignoredPlayers) {
if($ignoredPlayers["Login"] == $login)
return true;
}
return false;
}
} }

View File

@ -38,6 +38,8 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
const ACTION_FORCE_SPEC = 'PlayerList.ForceSpec'; const ACTION_FORCE_SPEC = 'PlayerList.ForceSpec';
const ACTION_PLAYER_ADV = 'PlayerList.PlayerAdvancedActions'; const ACTION_PLAYER_ADV = 'PlayerList.PlayerAdvancedActions';
const ACTION_CLOSE_PLAYER_ADV = 'PlayerList.ClosePlayerAdvWidget'; const ACTION_CLOSE_PLAYER_ADV = 'PlayerList.ClosePlayerAdvWidget';
const ACTION_MUTE_PLAYER = 'PlayerList.MutePlayer';
const ACTION_UNMUTE_PLAYER = 'PlayerList.UnMutePlayer';
const ACTION_WARN_PLAYER = 'PlayerList.WarnPlayer'; const ACTION_WARN_PLAYER = 'PlayerList.WarnPlayer';
const ACTION_KICK_PLAYER = 'PlayerList.KickPlayer'; const ACTION_KICK_PLAYER = 'PlayerList.KickPlayer';
const ACTION_BAN_PLAYER = 'PlayerList.BanPlayer'; const ACTION_BAN_PLAYER = 'PlayerList.BanPlayer';
@ -363,7 +365,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
// todo all configurable or as constants // todo all configurable or as constants
$x = $this->width / 2 + 2.5; $x = $this->width / 2 + 2.5;
$width = 35; $width = 35;
$height = $this->height * 0.7; $height = $this->height * 0.75;
$hAlign = Control::LEFT; $hAlign = Control::LEFT;
$style = Label_Text::STYLE_TextCardSmall; $style = Label_Text::STYLE_TextCardSmall;
$textSize = 1.5; $textSize = 1.5;
@ -413,15 +415,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$label->setText($player->nickname); $label->setText($player->nickname);
$label->setTextColor($textColor); $label->setTextColor($textColor);
$y = $height / 2 - 14; //Mute Player
// Show Warn $y = $height / 2 - 14;
$quad = new Quad_BgsPlayerCard(); $quad = new Quad_BgsPlayerCard();
$frame->add($quad); $frame->add($quad);
$quad->setX(0); $quad->setX(0);
$quad->setY($y); $quad->setY($y);
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig); $quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
$quad->setSize($quadWidth, 5); $quad->setSize($quadWidth, 5);
$quad->setAction(self::ACTION_WARN_PLAYER . "." . $login);
$label = new Label_Button(); $label = new Label_Button();
$frame->add($label); $frame->add($label);
@ -430,6 +431,26 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
$label->setY($y); $label->setY($y);
$label->setStyle($style); $label->setStyle($style);
$label->setTextSize($textSize); $label->setTextSize($textSize);
$label->setTextColor($textColor);
if(!$this->maniaControl->playerManager->playerActions->isPlayerMuted($login)) {
$label->setText("Mute");
$quad->setAction(self::ACTION_MUTE_PLAYER . "." . $login);
} else {
$label->setText("UnMute");
$quad->setAction(self::ACTION_UNMUTE_PLAYER . "." . $login);
}
//Warn Player
$y -= 5;
$quad = clone $quad;
$frame->add($quad);
$quad->setY($y);
$quad->setAction(self::ACTION_KICK_PLAYER . "." . $login);
$label = clone $label;
$frame->add($label);
$label->setY($y);
$label->setText("Warn"); $label->setText("Warn");
$label->setTextColor($textColor); $label->setTextColor($textColor);
@ -565,6 +586,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener {
case self::ACTION_FORCE_SPEC: case self::ACTION_FORCE_SPEC:
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($adminLogin, $targetLogin, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE); $this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($adminLogin, $targetLogin, PlayerActions::SPECTATOR_BUT_KEEP_SELECTABLE);
break; break;
case self::ACTION_MUTE_PLAYER:
$this->maniaControl->playerManager->playerActions->mutePlayer($adminLogin, $targetLogin);
$this->showPlayerList($this->maniaControl->playerManager->getPlayer($adminLogin));
break;
case self::ACTION_UNMUTE_PLAYER:
$this->maniaControl->playerManager->playerActions->unMutePlayer($adminLogin, $targetLogin);
$this->showPlayerList($this->maniaControl->playerManager->getPlayer($adminLogin));
break;
case self::ACTION_WARN_PLAYER: case self::ACTION_WARN_PLAYER:
$this->maniaControl->playerManager->playerActions->warnPlayer($adminLogin, $targetLogin); $this->maniaControl->playerManager->playerActions->warnPlayer($adminLogin, $targetLogin);
break; break;