added removerights command

This commit is contained in:
kremsy 2015-06-19 19:07:39 +02:00
parent 925b7a38a4
commit eaf8819a57
2 changed files with 63 additions and 1 deletions

View File

@ -2,6 +2,7 @@
#Additions
- added changelog
- added "//removerights login" command
- added new EchoManager which handles Interactions between different Controllers
- It is possible to send an Echo command via the Method sendEcho, as message Parameter strings, objects or arrays can get used
- An EchoListener can be added, callable by closure or implicit use (like on callbacks)
@ -10,8 +11,18 @@
- 4 Echos are Implemented by ManiaControl (ManiaControl.Restart, ManiaControl.AuthenticationManager.GrandLevel, ManiaControl.AuthenticationManager.RevokeLevel, ManiaControl.PlayerManager.WarnPlayer)
- added Method getServerLoginByIndex to Server object
- added some missing PHP Docs
- updated some depency libraries
#Bug Fixes
- fixed TriggerDebugNotice Method
- Exception fix on kicking Players
- updated FaultException List
- updated FaultException List
###v0.157###
- labelline improvements
- new usage examples:
$positions = array($posX + 5, $posX + 18, $posX + 70);
$texts = array($index, $admin->nickname, $admin->login);
$this->maniaControl->getManialinkManager()->labelLine($playerFrame, array($positions, $texts));
- improvements on Billmanager, added receiver to the BillData
- increased timeout time (fixes crashes on speedball)

View File

@ -32,6 +32,8 @@ class AuthCommands implements CommandListener {
$this->maniaControl->getCommandManager()->registerCommandListener('addsuperadmin', $this, 'command_AddSuperAdmin', true, 'Add Player to the AdminList as SuperAdmin.');
$this->maniaControl->getCommandManager()->registerCommandListener('addadmin', $this, 'command_AddAdmin', true, 'Add Player to the AdminList as Admin.');
$this->maniaControl->getCommandManager()->registerCommandListener('addmod', $this, 'command_AddModerator', true, 'Add Player to the AdminList as Moderator.');
$this->maniaControl->getCommandManager()->registerCommandListener('removerights', $this, 'command_RemoveRights', true, 'Remove Player from the AdminList.');
}
/**
@ -159,4 +161,53 @@ class AuthCommands implements CommandListener {
$message = "Usage Example: '//addmod login'";
return $this->maniaControl->getChat()->sendUsageInfo($message, $player);
}
/**
* Handle //removerights command
*
* @param array $chatCallback
* @param Player $player
*/
public function command_RemoveRights(array $chatCallback, Player $player) {
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
return;
}
$text = $chatCallback[1][2];
$commandParts = explode(' ', $text);
if (!array_key_exists(1, $commandParts)) {
$this->sendRemoveRightsUsageInfo($player);
return;
}
$target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]);
if (!$target) {
$this->maniaControl->getChat()->sendError("Player '{$commandParts[1]}' not found!", $player);
return;
}
if ($target->authLevel == AuthenticationManager::AUTH_LEVEL_MASTERADMIN) {
$this->maniaControl->getChat()->sendError("You can't remove an MasterAdmin from the Adminlists", $player);
return;
}
$success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_PLAYER);
if (!$success) {
$this->maniaControl->getChat()->sendError('Error occurred.', $player);
return;
}
$message = $player->getEscapedNickname() . ' removed ' . $target->getEscapedNickname() . ' from the Adminlists!';
$this->maniaControl->getChat()->sendSuccess($message);
}
/**
* Send usage example for //removerights command
*
* @param Player $player
* @return bool
*/
private function sendRemoveRightsUsageInfo(Player $player) {
$message = "Usage Example: '//addadmin login'";
return $this->maniaControl->getChat()->sendUsageInfo($message, $player);
}
}