resolved todo
This commit is contained in:
parent
7f0c33e45f
commit
fd5d2e59e9
@ -2,9 +2,7 @@
|
|||||||
|
|
||||||
namespace ManiaControl\Players;
|
namespace ManiaControl\Players;
|
||||||
|
|
||||||
use FML\Controls\Quads\Quad_Icons128x128_1;
|
|
||||||
use FML\Controls\Quads\Quad_Icons128x32_1;
|
use FML\Controls\Quads\Quad_Icons128x32_1;
|
||||||
use FML\Controls\Quads\Quad_Icons64x64_1;
|
|
||||||
use FML\Controls\Quads\Quad_UIConstruction_Buttons;
|
use FML\Controls\Quads\Quad_UIConstruction_Buttons;
|
||||||
use ManiaControl\Admin\AuthenticationManager;
|
use ManiaControl\Admin\AuthenticationManager;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
@ -20,10 +18,9 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
|||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const ACTION_BALANCE_TEAMS = 'PlayerCommands.BalanceTeams';
|
const ACTION_BALANCE_TEAMS = 'PlayerCommands.BalanceTeams';
|
||||||
const ACTION_OPEN_PLAYERLIST = 'PlayerCommands.OpenPlayerList';
|
const ACTION_OPEN_PLAYERLIST = 'PlayerCommands.OpenPlayerList';
|
||||||
const ACTION_CANCEL_VOTE = 'PlayerCommands.CancelVote';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private Properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
@ -36,7 +33,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
|||||||
*/
|
*/
|
||||||
public function __construct(ManiaControl $maniaControl) {
|
public function __construct(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
// Register for admin commands
|
// Register for admin commands
|
||||||
$this->maniaControl->commandManager->registerCommandListener('balance', $this, 'command_TeamBalance', true);
|
$this->maniaControl->commandManager->registerCommandListener('balance', $this, 'command_TeamBalance', true);
|
||||||
$this->maniaControl->commandManager->registerCommandListener('teambalance', $this, 'command_TeamBalance', true);
|
$this->maniaControl->commandManager->registerCommandListener('teambalance', $this, 'command_TeamBalance', true);
|
||||||
@ -53,27 +50,18 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
|||||||
$this->maniaControl->commandManager->registerCommandListener('removebots', $this, 'command_RemoveFakePlayers', true);
|
$this->maniaControl->commandManager->registerCommandListener('removebots', $this, 'command_RemoveFakePlayers', true);
|
||||||
$this->maniaControl->commandManager->registerCommandListener('mute', $this, 'command_MutePlayer', true);
|
$this->maniaControl->commandManager->registerCommandListener('mute', $this, 'command_MutePlayer', true);
|
||||||
$this->maniaControl->commandManager->registerCommandListener('unmute', $this, 'command_UnmutePlayer', true);
|
$this->maniaControl->commandManager->registerCommandListener('unmute', $this, 'command_UnmutePlayer', true);
|
||||||
// TODO: Move into another class
|
|
||||||
$this->maniaControl->commandManager->registerCommandListener('cancel', $this, 'command_CancelVote', true);
|
|
||||||
|
|
||||||
// Register for player chat commands
|
// Register for player chat commands
|
||||||
$this->maniaControl->commandManager->registerCommandListener('player', $this, 'command_playerList');
|
$this->maniaControl->commandManager->registerCommandListener('player', $this, 'command_playerList');
|
||||||
$this->maniaControl->commandManager->registerCommandListener('players', $this, 'command_playerList');
|
$this->maniaControl->commandManager->registerCommandListener('players', $this, 'command_playerList');
|
||||||
|
|
||||||
// Action Balance Teams
|
// Action Balance Teams
|
||||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_BALANCE_TEAMS, $this, 'command_TeamBalance');
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_BALANCE_TEAMS, $this, 'command_TeamBalance');
|
||||||
$itemQuad = new Quad_Icons128x32_1();
|
$itemQuad = new Quad_Icons128x32_1();
|
||||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_RT_Team);
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_RT_Team);
|
||||||
$itemQuad->setAction(self::ACTION_BALANCE_TEAMS);
|
$itemQuad->setAction(self::ACTION_BALANCE_TEAMS);
|
||||||
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 9, 'Balance Teams');
|
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 9, 'Balance Teams');
|
||||||
|
|
||||||
// Action cancel Vote
|
|
||||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CANCEL_VOTE, $this, 'command_cancelVote');
|
|
||||||
$itemQuad = new Quad_Icons64x64_1();
|
|
||||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ArrowRed);
|
|
||||||
$itemQuad->setAction(self::ACTION_CANCEL_VOTE);
|
|
||||||
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 6, 'Cancel Vote');
|
|
||||||
|
|
||||||
// Action Open Playerlist
|
// Action Open Playerlist
|
||||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_PLAYERLIST, $this, 'command_playerList');
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_PLAYERLIST, $this, 'command_playerList');
|
||||||
$itemQuad = new Quad_UIConstruction_Buttons();
|
$itemQuad = new Quad_UIConstruction_Buttons();
|
||||||
@ -82,38 +70,20 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
|||||||
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, true, 15, 'Open Playerlist');
|
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, true, 15, 'Open Playerlist');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle //cancelvote command
|
|
||||||
*
|
|
||||||
* @param array $chatCallback
|
|
||||||
* @param Player $player
|
|
||||||
*/
|
|
||||||
public function command_CancelVote(array $chatCallback, Player $player) {
|
|
||||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
|
||||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$success = $this->maniaControl->client->query('CancelVote');
|
|
||||||
if (!$success) {
|
|
||||||
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$this->maniaControl->chat->sendInformation('$<' . $player->nickname . '$> canceled the Vote!');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle //teambalance command
|
* Handle //teambalance command
|
||||||
*
|
*
|
||||||
* @param array $chatCallback
|
* @param array $chatCallback
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_TeamBalance(array $chatCallback, Player $player) {
|
public function command_TeamBalance(array $chatCallback, Player $player) {
|
||||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$success = $this->maniaControl->client->query('AutoTeamBalance');
|
$success = $this->maniaControl->client->query('AutoTeamBalance');
|
||||||
if (!$success) {
|
if(!$success) {
|
||||||
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
|
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -123,22 +93,22 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
|||||||
/**
|
/**
|
||||||
* Handle //kick command
|
* Handle //kick command
|
||||||
*
|
*
|
||||||
* @param array $chat
|
* @param array $chat
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_Kick(array $chat, Player $player) {
|
public function command_Kick(array $chat, Player $player) {
|
||||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$params = explode(' ', $chat[1][2], 3);
|
$params = explode(' ', $chat[1][2], 3);
|
||||||
if (count($params) <= 1) {
|
if(count($params) <= 1) {
|
||||||
$this->maniaControl->chat->sendUsageInfo("No Login given! Example: '//kick login'", $player->login);
|
$this->maniaControl->chat->sendUsageInfo("No Login given! Example: '//kick login'", $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$targetLogin = $params[1];
|
$targetLogin = $params[1];
|
||||||
$message = '';
|
$message = '';
|
||||||
if (isset($params[2])) {
|
if(isset($params[2])) {
|
||||||
$message = $params[2];
|
$message = $params[2];
|
||||||
}
|
}
|
||||||
$this->maniaControl->playerManager->playerActions->kickPlayer($player->login, $targetLogin, $message);
|
$this->maniaControl->playerManager->playerActions->kickPlayer($player->login, $targetLogin, $message);
|
||||||
@ -147,12 +117,12 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
|||||||
/**
|
/**
|
||||||
* Handle //warn Command
|
* Handle //warn Command
|
||||||
*
|
*
|
||||||
* @param array $chatCallback
|
* @param array $chatCallback
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_Warn(array $chatCallback, Player $player) {
|
public function command_Warn(array $chatCallback, Player $player) {
|
||||||
$params = explode(' ', $chat[1][2], 3);
|
$params = explode(' ', $chat[1][2], 3);
|
||||||
if (count($params) <= 1) {
|
if(count($params) <= 1) {
|
||||||
$this->maniaControl->chat->sendUsageInfo("No Login given! Example: '//kick login'", $player->login);
|
$this->maniaControl->chat->sendUsageInfo("No Login given! Example: '//kick login'", $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -163,26 +133,25 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
|||||||
/**
|
/**
|
||||||
* Handle //forcespec command
|
* Handle //forcespec command
|
||||||
*
|
*
|
||||||
* @param array $chat
|
* @param array $chat
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_ForceSpectator(array $chat, Player $player) {
|
public function command_ForceSpectator(array $chat, Player $player) {
|
||||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$params = explode(' ', $chat[1][2]);
|
$params = explode(' ', $chat[1][2]);
|
||||||
if (count($params) <= 1) {
|
if(count($params) <= 1) {
|
||||||
$this->maniaControl->chat->sendUsageInfo("No Login given! Example: '//forcespec login'", $player->login);
|
$this->maniaControl->chat->sendUsageInfo("No Login given! Example: '//forcespec login'", $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$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->playerManager->playerActions->forcePlayerToSpectator($player->login, $targetLogin, $type);
|
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($player->login, $targetLogin, $type);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($player->login, $targetLogin);
|
$this->maniaControl->playerManager->playerActions->forcePlayerToSpectator($player->login, $targetLogin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -190,23 +159,23 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
|||||||
/**
|
/**
|
||||||
* Handle //forceplay command
|
* Handle //forceplay command
|
||||||
*
|
*
|
||||||
* @param array $chat
|
* @param array $chat
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_ForcePlay(array $chat, Player $player) {
|
public function command_ForcePlay(array $chat, Player $player) {
|
||||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$params = explode(' ', $chat[1][2]);
|
$params = explode(' ', $chat[1][2]);
|
||||||
if (!isset($params[1])) {
|
if(!isset($params[1])) {
|
||||||
$this->maniaControl->chat->sendUsageInfo("No Login given! Example: '//forceplay login'", $player->login);
|
$this->maniaControl->chat->sendUsageInfo("No Login given! Example: '//forceplay login'", $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$targetLogin = $params[1];
|
$targetLogin = $params[1];
|
||||||
|
|
||||||
$type = 2;
|
$type = 2;
|
||||||
if (isset($params[2]) && is_numeric($params[2])) {
|
if(isset($params[2]) && is_numeric($params[2])) {
|
||||||
$type = intval($params[2]);
|
$type = intval($params[2]);
|
||||||
}
|
}
|
||||||
$this->maniaControl->playerManager->playerActions->forcePlayerToPlay($player->login, $targetLogin, $type);
|
$this->maniaControl->playerManager->playerActions->forcePlayerToPlay($player->login, $targetLogin, $type);
|
||||||
@ -215,68 +184,68 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
|||||||
/**
|
/**
|
||||||
* Handle //forceblue command
|
* Handle //forceblue command
|
||||||
*
|
*
|
||||||
* @param array $chat
|
* @param array $chat
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_ForceBlue(array $chat, Player $player) {
|
public function command_ForceBlue(array $chat, Player $player) {
|
||||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$params = explode(' ', $chat[1][2]);
|
$params = explode(' ', $chat[1][2]);
|
||||||
if (!isset($params[1])) {
|
if(!isset($params[1])) {
|
||||||
$this->maniaControl->chat->sendUsageInfo("No Login given! Example: '//forceblue login'", $player->login);
|
$this->maniaControl->chat->sendUsageInfo("No Login given! Example: '//forceblue login'", $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$targetLogin = $params[1];
|
$targetLogin = $params[1];
|
||||||
|
|
||||||
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_BLUE);
|
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_BLUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle //forcered command
|
* Handle //forcered command
|
||||||
*
|
*
|
||||||
* @param array $chat
|
* @param array $chat
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_ForceRed(array $chat, Player $player) {
|
public function command_ForceRed(array $chat, Player $player) {
|
||||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$params = explode(' ', $chat[1][2]);
|
$params = explode(' ', $chat[1][2]);
|
||||||
if (!isset($params[1])) {
|
if(!isset($params[1])) {
|
||||||
$this->maniaControl->chat->sendUsageInfo("No Login given! Example: '//forcered login'", $player->login);
|
$this->maniaControl->chat->sendUsageInfo("No Login given! Example: '//forcered login'", $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$targetLogin = $params[1];
|
$targetLogin = $params[1];
|
||||||
|
|
||||||
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_RED);
|
$this->maniaControl->playerManager->playerActions->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_RED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle //addfakeplayers command
|
* Handle //addfakeplayers command
|
||||||
*
|
*
|
||||||
* @param array $chatCallback
|
* @param array $chatCallback
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_AddFakePlayers(array $chatCallback, Player $player) {
|
public function command_AddFakePlayers(array $chatCallback, Player $player) {
|
||||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$amount = 1;
|
$amount = 1;
|
||||||
$messageParts = explode(' ', $chatCallback[1][2]);
|
$messageParts = explode(' ', $chatCallback[1][2]);
|
||||||
if (isset($messageParts[1]) && is_numeric($messageParts[1])) {
|
if(isset($messageParts[1]) && is_numeric($messageParts[1])) {
|
||||||
$amount = intval($messageParts[1]);
|
$amount = intval($messageParts[1]);
|
||||||
}
|
}
|
||||||
$success = true;
|
$success = true;
|
||||||
for ($i = 0; $i < $amount; $i++) {
|
for($i = 0; $i < $amount; $i++) {
|
||||||
if (!$this->maniaControl->client->query('ConnectFakePlayer')) {
|
if(!$this->maniaControl->client->query('ConnectFakePlayer')) {
|
||||||
$success = false;
|
$success = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$success) {
|
if(!$success) {
|
||||||
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
|
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -286,16 +255,16 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
|||||||
/**
|
/**
|
||||||
* Handle //removefakeplayers command
|
* Handle //removefakeplayers command
|
||||||
*
|
*
|
||||||
* @param array $chatCallback
|
* @param array $chatCallback
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_RemoveFakePlayers(array $chatCallback, Player $player) {
|
public function command_RemoveFakePlayers(array $chatCallback, Player $player) {
|
||||||
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$success = $this->maniaControl->client->query('DisconnectFakePlayer', '*');
|
$success = $this->maniaControl->client->query('DisconnectFakePlayer', '*');
|
||||||
if (!$success) {
|
if(!$success) {
|
||||||
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
|
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -305,12 +274,12 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
|||||||
/**
|
/**
|
||||||
* Handle //mute Command
|
* Handle //mute Command
|
||||||
*
|
*
|
||||||
* @param array $chatCallback
|
* @param array $chatCallback
|
||||||
* @param Player $admin
|
* @param Player $admin
|
||||||
*/
|
*/
|
||||||
public function command_MutePlayer(array $chatCallback, Player $admin) {
|
public function command_MutePlayer(array $chatCallback, Player $admin) {
|
||||||
$commandParts = explode(' ', $chatCallback[1][2]);
|
$commandParts = explode(' ', $chatCallback[1][2]);
|
||||||
if (count($commandParts) <= 1) {
|
if(count($commandParts) <= 1) {
|
||||||
$this->maniaControl->chat->sendUsageInfo("No login specified! Example: '//mute login'");
|
$this->maniaControl->chat->sendUsageInfo("No login specified! Example: '//mute login'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -321,12 +290,12 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
|||||||
/**
|
/**
|
||||||
* Handle //unmute Command
|
* Handle //unmute Command
|
||||||
*
|
*
|
||||||
* @param array $chatCallback
|
* @param array $chatCallback
|
||||||
* @param Player $admin
|
* @param Player $admin
|
||||||
*/
|
*/
|
||||||
public function command_UnmutePlayer(array $chatCallback, Player $admin) {
|
public function command_UnmutePlayer(array $chatCallback, Player $admin) {
|
||||||
$commandParts = explode(' ', $chatCallback[1][2]);
|
$commandParts = explode(' ', $chatCallback[1][2]);
|
||||||
if (count($commandParts) <= 1) {
|
if(count($commandParts) <= 1) {
|
||||||
$this->maniaControl->chat->sendUsageInfo("No login specified! Example: '//unmute login'");
|
$this->maniaControl->chat->sendUsageInfo("No login specified! Example: '//unmute login'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -337,7 +306,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
|
|||||||
/**
|
/**
|
||||||
* Handle Player list command
|
* Handle Player list command
|
||||||
*
|
*
|
||||||
* @param array $chatCallback
|
* @param array $chatCallback
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_playerList(array $chatCallback, Player $player) {
|
public function command_playerList(array $chatCallback, Player $player) {
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
namespace ManiaControl\Server;
|
namespace ManiaControl\Server;
|
||||||
|
|
||||||
use FML\Controls\Quads\Quad_Icons128x32_1;
|
use FML\Controls\Quads\Quad_Icons128x32_1;
|
||||||
|
use FML\Controls\Quads\Quad_Icons64x64_1;
|
||||||
use ManiaControl\Admin\AuthenticationManager;
|
use ManiaControl\Admin\AuthenticationManager;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
@ -20,8 +21,8 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const ACTION_SET_PAUSE = 'ServerCommands.SetPause';
|
const ACTION_SET_PAUSE = 'ServerCommands.SetPause';
|
||||||
|
const ACTION_CANCEL_VOTE = 'ServerCommands.CancelVote';
|
||||||
/**
|
/**
|
||||||
* Private properties
|
* Private properties
|
||||||
*/
|
*/
|
||||||
@ -55,16 +56,40 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
$this->maniaControl->commandManager->registerCommandListener('enablehorns', $this, 'command_EnableHorns', true);
|
$this->maniaControl->commandManager->registerCommandListener('enablehorns', $this, 'command_EnableHorns', true);
|
||||||
$this->maniaControl->commandManager->registerCommandListener('disablehorns', $this, 'command_DisableHorns', true);
|
$this->maniaControl->commandManager->registerCommandListener('disablehorns', $this, 'command_DisableHorns', true);
|
||||||
|
|
||||||
|
$this->maniaControl->commandManager->registerCommandListener('cancel', $this, 'command_CancelVote', true);
|
||||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_SET_PAUSE, $this, 'setPause');
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_SET_PAUSE, $this, 'setPause');
|
||||||
|
|
||||||
//TODO correct class?
|
|
||||||
// Set Pause
|
// Set Pause
|
||||||
$itemQuad = new Quad_Icons128x32_1(); //TODO check if mode supports it
|
$itemQuad = new Quad_Icons128x32_1(); //TODO check if mode supports it
|
||||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ManiaLinkSwitch);
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ManiaLinkSwitch);
|
||||||
$itemQuad->setAction(self::ACTION_SET_PAUSE);
|
$itemQuad->setAction(self::ACTION_SET_PAUSE);
|
||||||
$this->maniaControl->actionsMenu->addAdminMenuItem($itemQuad, 1, 'Pauses the current game.');
|
$this->maniaControl->actionsMenu->addAdminMenuItem($itemQuad, 1, 'Pauses the current game.');
|
||||||
|
|
||||||
|
// Action cancel Vote
|
||||||
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CANCEL_VOTE, $this, 'command_cancelVote');
|
||||||
|
$itemQuad = new Quad_Icons64x64_1();
|
||||||
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ArrowRed);
|
||||||
|
$itemQuad->setAction(self::ACTION_CANCEL_VOTE);
|
||||||
|
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 6, 'Cancel Vote');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle //cancelvote command
|
||||||
|
*
|
||||||
|
* @param array $chatCallback
|
||||||
|
* @param Player $player
|
||||||
|
*/
|
||||||
|
public function command_CancelVote(array $chatCallback, Player $player) {
|
||||||
|
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||||
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$success = $this->maniaControl->client->query('CancelVote');
|
||||||
|
if(!$success) {
|
||||||
|
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->maniaControl->chat->sendInformation('$<' . $player->nickname . '$> canceled the Vote!');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user