Added unban command
This commit is contained in:
parent
d310500723
commit
f6297215c5
@ -436,6 +436,38 @@ class PlayerActions {
|
|||||||
Logger::logInfo($chatMessage, true);
|
Logger::logInfo($chatMessage, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unbans a Player
|
||||||
|
*
|
||||||
|
* @param string $adminLogin
|
||||||
|
* @param string $targetLogin
|
||||||
|
*/
|
||||||
|
public function unBanPlayer($adminLogin, $targetLogin) {
|
||||||
|
$admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin);
|
||||||
|
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_BAN_PLAYER)
|
||||||
|
) {
|
||||||
|
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
||||||
|
if (!$target) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($target->isFakePlayer()) {
|
||||||
|
$this->maniaControl->getChat()->sendError('It is not possible to Un-Ban a bot', $admin);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->maniaControl->getClient()->unBan($target->login);
|
||||||
|
|
||||||
|
// Announce ban
|
||||||
|
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
||||||
|
$chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' unbanned ' . $target->getEscapedNickname() . '!';
|
||||||
|
$this->maniaControl->getChat()->sendInformation($chatMessage);
|
||||||
|
Logger::logInfo($chatMessage, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Grands the Player an Authorization Level
|
* Grands the Player an Authorization Level
|
||||||
*
|
*
|
||||||
|
@ -46,7 +46,8 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
|||||||
// Admin commands
|
// Admin commands
|
||||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('balance', 'teambalance', 'autoteambalance'), $this, 'command_TeamBalance', true, 'Balances the teams.');
|
$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('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('ban', $this, 'command_Ban', true, 'Bans a player from the server.');
|
||||||
|
$this->maniaControl->getCommandManager()->registerCommandListener('unban', $this, 'command_UnBan', true, 'Unbans a player from the server.');
|
||||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('forcespec', 'forcespectator'), $this, 'command_ForceSpectator', true, 'Forces player into spectator.');
|
$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('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('forceblue', $this, 'command_ForceBlue', true, 'Forces player into blue team.');
|
||||||
@ -164,6 +165,27 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
|||||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->banPlayer($player->login, $targetLogin, $message);
|
$this->maniaControl->getPlayerManager()->getPlayerActions()->banPlayer($player->login, $targetLogin, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle //unban command
|
||||||
|
*
|
||||||
|
* @param array $chat
|
||||||
|
* @param Player $player
|
||||||
|
*/
|
||||||
|
public function command_UnBan(array $chat, Player $player) {
|
||||||
|
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_BAN_PLAYER)
|
||||||
|
) {
|
||||||
|
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$params = explode(' ', $chat[1][2], 3);
|
||||||
|
if (count($params) <= 1) {
|
||||||
|
$this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//ban login'", $player->login);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$targetLogin = $params[1];
|
||||||
|
$this->maniaControl->getPlayerManager()->getPlayerActions()->unBanPlayer($player->login, $targetLogin);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle //warn Command
|
* Handle //warn Command
|
||||||
*
|
*
|
||||||
@ -200,7 +222,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
|||||||
$targetLogin = $params[1];
|
$targetLogin = $params[1];
|
||||||
|
|
||||||
if (isset($params[2]) && is_numeric($params[2])) {
|
if (isset($params[2]) && is_numeric($params[2])) {
|
||||||
$type = (int)$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 {
|
} else {
|
||||||
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToSpectator($player->login, $targetLogin);
|
$this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToSpectator($player->login, $targetLogin);
|
||||||
@ -228,7 +250,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
|||||||
|
|
||||||
$type = 2;
|
$type = 2;
|
||||||
if (isset($params[2]) && is_numeric($params[2])) {
|
if (isset($params[2]) && is_numeric($params[2])) {
|
||||||
$type = (int)$params[2];
|
$type = (int) $params[2];
|
||||||
}
|
}
|
||||||
$selectable = ($type === 2);
|
$selectable = ($type === 2);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user