2013-12-05 00:30:10 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace ManiaControl\Players;
|
|
|
|
|
2014-01-05 00:02:13 +01:00
|
|
|
use FML\Controls\Quads\Quad_Icons128x32_1;
|
2014-01-05 00:43:46 +01:00
|
|
|
use FML\Controls\Quads\Quad_UIConstruction_Buttons;
|
2013-12-05 00:30:10 +01:00
|
|
|
use ManiaControl\Admin\AuthenticationManager;
|
2014-02-01 19:06:21 +01:00
|
|
|
use ManiaControl\Callbacks\CallbackListener;
|
2013-12-05 00:30:10 +01:00
|
|
|
use ManiaControl\Commands\CommandListener;
|
2014-01-04 18:49:33 +01:00
|
|
|
use ManiaControl\ManiaControl;
|
2014-01-04 18:18:46 +01:00
|
|
|
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
2014-05-11 16:02:29 +02:00
|
|
|
use ManiaControl\Server\Server;
|
2014-06-22 18:42:40 +02:00
|
|
|
use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException;
|
2014-07-04 09:58:49 +02:00
|
|
|
use Maniaplanet\DedicatedServer\Xmlrpc\UnavailableFeatureException;
|
2013-12-05 00:30:10 +01:00
|
|
|
|
|
|
|
/**
|
2014-01-06 16:14:49 +01:00
|
|
|
* Class offering various Admin Commands related to Players
|
2013-12-05 00:30:10 +01:00
|
|
|
*
|
2014-05-02 17:50:30 +02:00
|
|
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
|
|
|
* @copyright 2014 ManiaControl Team
|
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
2013-12-05 00:30:10 +01:00
|
|
|
*/
|
2014-02-01 19:06:21 +01:00
|
|
|
class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, CallbackListener {
|
2014-04-12 12:14:37 +02:00
|
|
|
/*
|
2014-01-04 18:18:46 +01:00
|
|
|
* Constants
|
|
|
|
*/
|
2014-01-31 16:55:01 +01:00
|
|
|
const ACTION_BALANCE_TEAMS = 'PlayerCommands.BalanceTeams';
|
|
|
|
const ACTION_OPEN_PLAYERLIST = 'PlayerCommands.OpenPlayerList';
|
|
|
|
const SETTING_PERMISSION_ADD_BOT = 'Add Bot';
|
|
|
|
const SETTING_PERMISSION_TEAM_BALANCE = 'Balance Teams';
|
2014-01-10 13:28:48 +01:00
|
|
|
|
2014-04-12 12:14:37 +02:00
|
|
|
/*
|
2014-08-02 22:31:46 +02:00
|
|
|
* Private properties
|
2013-12-05 00:30:10 +01:00
|
|
|
*/
|
2014-08-02 22:31:46 +02:00
|
|
|
/** @var ManiaControl $maniaControl */
|
2013-12-05 00:30:10 +01:00
|
|
|
private $maniaControl = null;
|
2014-01-04 18:49:33 +01:00
|
|
|
|
2013-12-05 00:30:10 +01:00
|
|
|
/**
|
2014-01-06 16:14:49 +01:00
|
|
|
* Create a new Player Commands Instance
|
2013-12-05 00:30:10 +01:00
|
|
|
*
|
2014-01-04 18:49:33 +01:00
|
|
|
* @param ManiaControl $maniaControl
|
2013-12-05 00:30:10 +01:00
|
|
|
*/
|
|
|
|
public function __construct(ManiaControl $maniaControl) {
|
|
|
|
$this->maniaControl = $maniaControl;
|
2014-01-10 13:28:48 +01:00
|
|
|
|
2014-08-03 01:34:18 +02:00
|
|
|
// Admin commands
|
2014-08-05 02:17:41 +02:00
|
|
|
$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).');
|
2014-08-03 01:34:18 +02:00
|
|
|
|
|
|
|
// Player commands
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getCommandManager()
|
|
|
|
->registerCommandListener(array('player', 'players'), $this, 'command_playerList', false, 'Shows players currently on the server.');
|
2014-08-03 01:34:18 +02:00
|
|
|
|
|
|
|
// Permissions
|
2014-08-05 02:17:41 +02:00
|
|
|
$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);
|
2014-08-03 01:34:18 +02:00
|
|
|
|
|
|
|
// Callbacks
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getCallbackManager()
|
|
|
|
->registerCallbackListener(Server::CB_TEAM_MODE_CHANGED, $this, 'teamStatusChanged');
|
2014-01-10 13:28:48 +01:00
|
|
|
|
2014-05-20 14:59:17 +02:00
|
|
|
// Action Open PlayerList
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getManialinkManager()
|
|
|
|
->registerManialinkPageAnswerListener(self::ACTION_OPEN_PLAYERLIST, $this, 'command_playerList');
|
2014-01-05 00:43:46 +01:00
|
|
|
$itemQuad = new Quad_UIConstruction_Buttons();
|
|
|
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Author);
|
2014-01-04 18:49:33 +01:00
|
|
|
$itemQuad->setAction(self::ACTION_OPEN_PLAYERLIST);
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getActionsMenu()
|
|
|
|
->addMenuItem($itemQuad, true, 15, 'Open PlayerList');
|
2014-01-04 18:49:33 +01:00
|
|
|
}
|
|
|
|
|
2014-02-01 19:06:21 +01:00
|
|
|
/**
|
|
|
|
* Handle TeamStatusChanged
|
2014-05-02 17:50:30 +02:00
|
|
|
*
|
2014-02-19 15:44:00 +01:00
|
|
|
* @param bool $teamMode
|
2014-02-01 19:06:21 +01:00
|
|
|
*/
|
2014-02-19 15:44:00 +01:00
|
|
|
public function teamStatusChanged($teamMode) {
|
2014-02-01 19:06:21 +01:00
|
|
|
//Add Balance Team Icon if it's a teamMode
|
2014-02-19 15:44:00 +01:00
|
|
|
if ($teamMode) {
|
2014-02-01 19:06:21 +01:00
|
|
|
// Action Balance Teams
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getManialinkManager()
|
|
|
|
->registerManialinkPageAnswerListener(self::ACTION_BALANCE_TEAMS, $this, 'command_TeamBalance');
|
2014-02-01 19:06:21 +01:00
|
|
|
$itemQuad = new Quad_Icons128x32_1();
|
|
|
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_RT_Team);
|
|
|
|
$itemQuad->setAction(self::ACTION_BALANCE_TEAMS);
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getActionsMenu()
|
|
|
|
->addMenuItem($itemQuad, false, 40, 'Balance Teams');
|
2014-02-01 19:06:21 +01:00
|
|
|
}
|
|
|
|
}
|
2013-12-05 00:30:10 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle //teambalance command
|
|
|
|
*
|
2014-01-10 13:28:48 +01:00
|
|
|
* @param array $chatCallback
|
2014-01-04 18:49:33 +01:00
|
|
|
* @param Player $player
|
2013-12-05 00:30:10 +01:00
|
|
|
*/
|
|
|
|
public function command_TeamBalance(array $chatCallback, Player $player) {
|
2014-08-05 02:17:41 +02:00
|
|
|
if (!$this->maniaControl->getAuthenticationManager()
|
|
|
|
->checkPermission($player, self::SETTING_PERMISSION_TEAM_BALANCE)
|
|
|
|
) {
|
|
|
|
$this->maniaControl->getAuthenticationManager()
|
|
|
|
->sendNotAllowed($player);
|
2013-12-05 00:30:10 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-01-20 20:51:03 +01:00
|
|
|
|
|
|
|
try {
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getClient()
|
|
|
|
->autoTeamBalance();
|
2014-06-22 18:42:40 +02:00
|
|
|
} catch (GameModeException $exception) {
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getChat()
|
|
|
|
->sendException($exception, $player);
|
2013-12-05 00:30:10 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-01-20 20:51:03 +01:00
|
|
|
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getChat()
|
|
|
|
->sendInformation($player->getEscapedNickname() . ' balanced Teams!');
|
2013-12-05 00:30:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle //kick command
|
|
|
|
*
|
2014-01-10 13:28:48 +01:00
|
|
|
* @param array $chat
|
2014-01-04 18:49:33 +01:00
|
|
|
* @param Player $player
|
2013-12-05 00:30:10 +01:00
|
|
|
*/
|
|
|
|
public function command_Kick(array $chat, Player $player) {
|
2014-08-05 02:17:41 +02:00
|
|
|
if (!$this->maniaControl->getAuthenticationManager()
|
|
|
|
->checkPermission($player, PlayerActions::SETTING_PERMISSION_KICK_PLAYER)
|
|
|
|
) {
|
|
|
|
$this->maniaControl->getAuthenticationManager()
|
|
|
|
->sendNotAllowed($player);
|
2013-12-05 00:30:10 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$params = explode(' ', $chat[1][2], 3);
|
2014-01-31 16:55:01 +01:00
|
|
|
if (count($params) <= 1) {
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getChat()
|
|
|
|
->sendUsageInfo("No Login given! Example: '//kick login'", $player->login);
|
2013-12-05 00:30:10 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-01-06 17:33:45 +01:00
|
|
|
$targetLogin = $params[1];
|
2014-01-10 13:28:48 +01:00
|
|
|
$message = '';
|
2014-01-31 16:55:01 +01:00
|
|
|
if (isset($params[2])) {
|
2013-12-05 00:30:10 +01:00
|
|
|
$message = $params[2];
|
|
|
|
}
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getPlayerManager()
|
|
|
|
->getPlayerActions()
|
|
|
|
->kickPlayer($player->login, $targetLogin, $message);
|
2014-01-06 17:33:45 +01:00
|
|
|
}
|
|
|
|
|
2014-04-27 01:56:23 +02:00
|
|
|
/**
|
|
|
|
* Handle //ban command
|
|
|
|
*
|
|
|
|
* @param array $chat
|
|
|
|
* @param Player $player
|
|
|
|
*/
|
|
|
|
public function command_Ban(array $chat, Player $player) {
|
2014-08-05 02:17:41 +02:00
|
|
|
if (!$this->maniaControl->getAuthenticationManager()
|
|
|
|
->checkPermission($player, PlayerActions::SETTING_PERMISSION_BAN_PLAYER)
|
|
|
|
) {
|
|
|
|
$this->maniaControl->getAuthenticationManager()
|
|
|
|
->sendNotAllowed($player);
|
2014-04-27 01:56:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$params = explode(' ', $chat[1][2], 3);
|
|
|
|
if (count($params) <= 1) {
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getChat()
|
|
|
|
->sendUsageInfo("No Login given! Example: '//ban login'", $player->login);
|
2014-04-27 01:56:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$targetLogin = $params[1];
|
|
|
|
$message = '';
|
|
|
|
if (isset($params[2])) {
|
|
|
|
$message = $params[2];
|
|
|
|
}
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getPlayerManager()
|
|
|
|
->getPlayerActions()
|
|
|
|
->banPlayer($player->login, $targetLogin, $message);
|
2014-04-27 01:56:23 +02:00
|
|
|
}
|
|
|
|
|
2014-01-06 17:33:45 +01:00
|
|
|
/**
|
|
|
|
* Handle //warn Command
|
|
|
|
*
|
2014-01-10 13:28:48 +01:00
|
|
|
* @param array $chatCallback
|
2014-01-06 17:33:45 +01:00
|
|
|
* @param Player $player
|
|
|
|
*/
|
2014-05-02 16:13:45 +02:00
|
|
|
public function command_Warn(array $chatCallback, Player $player) {
|
|
|
|
$params = explode(' ', $chatCallback[1][2], 3);
|
2014-01-31 16:55:01 +01:00
|
|
|
if (count($params) <= 1) {
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getChat()
|
|
|
|
->sendUsageInfo("No Login given! Example: '//warn login'", $player->login);
|
2014-01-06 17:33:45 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$targetLogin = $params[1];
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getPlayerManager()
|
|
|
|
->getPlayerActions()
|
|
|
|
->warnPlayer($player->login, $targetLogin);
|
2013-12-05 00:30:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle //forcespec command
|
|
|
|
*
|
2014-01-10 13:28:48 +01:00
|
|
|
* @param array $chat
|
2014-01-04 18:49:33 +01:00
|
|
|
* @param Player $player
|
2013-12-05 00:30:10 +01:00
|
|
|
*/
|
|
|
|
public function command_ForceSpectator(array $chat, Player $player) {
|
2014-08-05 02:17:41 +02:00
|
|
|
if (!$this->maniaControl->getAuthenticationManager()
|
|
|
|
->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_SPEC)
|
|
|
|
) {
|
|
|
|
$this->maniaControl->getAuthenticationManager()
|
|
|
|
->sendNotAllowed($player);
|
2013-12-05 00:30:10 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$params = explode(' ', $chat[1][2]);
|
2014-01-31 16:55:01 +01:00
|
|
|
if (count($params) <= 1) {
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getChat()
|
|
|
|
->sendUsageInfo("No Login given! Example: '//forcespec login'", $player->login);
|
2013-12-05 00:30:10 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-01-06 17:33:45 +01:00
|
|
|
$targetLogin = $params[1];
|
2014-01-10 13:28:48 +01:00
|
|
|
|
2014-01-31 16:55:01 +01:00
|
|
|
if (isset($params[2]) && is_numeric($params[2])) {
|
2014-01-10 13:28:48 +01:00
|
|
|
$type = (int)$params[2];
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getPlayerManager()
|
|
|
|
->getPlayerActions()
|
|
|
|
->forcePlayerToSpectator($player->login, $targetLogin, $type);
|
2014-01-10 13:28:48 +01:00
|
|
|
} else {
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getPlayerManager()
|
|
|
|
->getPlayerActions()
|
|
|
|
->forcePlayerToSpectator($player->login, $targetLogin);
|
2013-12-05 00:30:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle //forceplay command
|
|
|
|
*
|
2014-01-10 13:28:48 +01:00
|
|
|
* @param array $chat
|
2014-01-04 18:49:33 +01:00
|
|
|
* @param Player $player
|
2013-12-05 00:30:10 +01:00
|
|
|
*/
|
2014-01-06 18:09:47 +01:00
|
|
|
public function command_ForcePlay(array $chat, Player $player) {
|
2014-08-05 02:17:41 +02:00
|
|
|
if (!$this->maniaControl->getAuthenticationManager()
|
|
|
|
->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_PLAY)
|
|
|
|
) {
|
|
|
|
$this->maniaControl->getAuthenticationManager()
|
|
|
|
->sendNotAllowed($player);
|
2013-12-05 00:30:10 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$params = explode(' ', $chat[1][2]);
|
2014-01-31 16:55:01 +01:00
|
|
|
if (!isset($params[1])) {
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getChat()
|
|
|
|
->sendUsageInfo("No Login given! Example: '//forceplay login'", $player->login);
|
2013-12-05 00:30:10 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-01-06 18:09:47 +01:00
|
|
|
$targetLogin = $params[1];
|
2014-01-10 13:28:48 +01:00
|
|
|
|
2013-12-05 00:30:10 +01:00
|
|
|
$type = 2;
|
2014-01-31 16:55:01 +01:00
|
|
|
if (isset($params[2]) && is_numeric($params[2])) {
|
2014-06-14 14:32:29 +02:00
|
|
|
$type = (int)$params[2];
|
2014-01-14 14:37:31 +01:00
|
|
|
}
|
2014-06-14 14:32:29 +02:00
|
|
|
$selectable = ($type === 2);
|
2014-01-14 14:37:31 +01:00
|
|
|
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getPlayerManager()
|
|
|
|
->getPlayerActions()
|
|
|
|
->forcePlayerToPlay($player->login, $targetLogin, $selectable);
|
2014-01-06 18:09:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle //forceblue command
|
|
|
|
*
|
2014-01-10 13:28:48 +01:00
|
|
|
* @param array $chat
|
2014-01-06 18:09:47 +01:00
|
|
|
* @param Player $player
|
|
|
|
*/
|
|
|
|
public function command_ForceBlue(array $chat, Player $player) {
|
2014-08-05 02:17:41 +02:00
|
|
|
if (!$this->maniaControl->getAuthenticationManager()
|
|
|
|
->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)
|
|
|
|
) {
|
|
|
|
$this->maniaControl->getAuthenticationManager()
|
|
|
|
->sendNotAllowed($player);
|
2013-12-05 00:30:10 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-01-06 18:09:47 +01:00
|
|
|
$params = explode(' ', $chat[1][2]);
|
2014-01-31 16:55:01 +01:00
|
|
|
if (!isset($params[1])) {
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getChat()
|
|
|
|
->sendUsageInfo("No Login given! Example: '//forceblue login'", $player->login);
|
2014-01-06 18:09:47 +01:00
|
|
|
return;
|
2013-12-05 00:30:10 +01:00
|
|
|
}
|
2014-01-06 18:09:47 +01:00
|
|
|
$targetLogin = $params[1];
|
2014-01-10 13:28:48 +01:00
|
|
|
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getPlayerManager()
|
|
|
|
->getPlayerActions()
|
|
|
|
->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_BLUE);
|
2014-01-06 18:09:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle //forcered command
|
|
|
|
*
|
2014-01-10 13:28:48 +01:00
|
|
|
* @param array $chat
|
2014-01-06 18:09:47 +01:00
|
|
|
* @param Player $player
|
|
|
|
*/
|
|
|
|
public function command_ForceRed(array $chat, Player $player) {
|
2014-08-05 02:17:41 +02:00
|
|
|
if (!$this->maniaControl->getAuthenticationManager()
|
|
|
|
->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)
|
|
|
|
) {
|
|
|
|
$this->maniaControl->getAuthenticationManager()
|
|
|
|
->sendNotAllowed($player);
|
2014-01-06 18:09:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$params = explode(' ', $chat[1][2]);
|
2014-01-31 16:55:01 +01:00
|
|
|
if (!isset($params[1])) {
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getChat()
|
|
|
|
->sendUsageInfo("No Login given! Example: '//forcered login'", $player->login);
|
2014-01-06 18:09:47 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$targetLogin = $params[1];
|
2014-01-10 13:28:48 +01:00
|
|
|
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getPlayerManager()
|
|
|
|
->getPlayerActions()
|
|
|
|
->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_RED);
|
2013-12-05 00:30:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle //addfakeplayers command
|
|
|
|
*
|
2014-01-10 13:28:48 +01:00
|
|
|
* @param array $chatCallback
|
2014-01-04 18:49:33 +01:00
|
|
|
* @param Player $player
|
2013-12-05 00:30:10 +01:00
|
|
|
*/
|
|
|
|
public function command_AddFakePlayers(array $chatCallback, Player $player) {
|
2014-08-05 02:17:41 +02:00
|
|
|
if (!$this->maniaControl->getAuthenticationManager()
|
|
|
|
->checkPermission($player, self::SETTING_PERMISSION_ADD_BOT)
|
|
|
|
) {
|
|
|
|
$this->maniaControl->getAuthenticationManager()
|
|
|
|
->sendNotAllowed($player);
|
2013-12-05 00:30:10 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-01-10 13:28:48 +01:00
|
|
|
$amount = 1;
|
2013-12-05 00:30:10 +01:00
|
|
|
$messageParts = explode(' ', $chatCallback[1][2]);
|
2014-01-31 16:55:01 +01:00
|
|
|
if (isset($messageParts[1]) && is_numeric($messageParts[1])) {
|
2013-12-05 00:30:10 +01:00
|
|
|
$amount = intval($messageParts[1]);
|
|
|
|
}
|
2014-07-04 09:58:49 +02:00
|
|
|
|
|
|
|
try {
|
|
|
|
for ($i = 0; $i < $amount; $i++) {
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getClient()
|
|
|
|
->connectFakePlayer();
|
2014-07-04 09:58:49 +02:00
|
|
|
}
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getChat()
|
|
|
|
->sendSuccess('Fake players connected!', $player);
|
2014-07-04 09:58:49 +02:00
|
|
|
} catch (UnavailableFeatureException $e) {
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getChat()
|
|
|
|
->sendSuccess('Error while connecting a Fake-Player.', $player);
|
2013-12-05 00:30:10 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle //removefakeplayers command
|
|
|
|
*
|
2014-01-10 13:28:48 +01:00
|
|
|
* @param array $chatCallback
|
2014-01-04 18:49:33 +01:00
|
|
|
* @param Player $player
|
2013-12-05 00:30:10 +01:00
|
|
|
*/
|
|
|
|
public function command_RemoveFakePlayers(array $chatCallback, Player $player) {
|
2014-08-05 02:17:41 +02:00
|
|
|
if (!$this->maniaControl->getAuthenticationManager()
|
|
|
|
->checkPermission($player, self::SETTING_PERMISSION_ADD_BOT)
|
|
|
|
) {
|
|
|
|
$this->maniaControl->getAuthenticationManager()
|
|
|
|
->sendNotAllowed($player);
|
2013-12-05 00:30:10 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getClient()
|
|
|
|
->disconnectFakePlayer('*');
|
|
|
|
$this->maniaControl->getChat()
|
|
|
|
->sendSuccess('Fake players disconnected!', $player);
|
2013-12-05 00:30:10 +01:00
|
|
|
}
|
2013-12-18 15:48:33 +01:00
|
|
|
|
2014-01-06 17:33:45 +01:00
|
|
|
/**
|
|
|
|
* Handle //mute Command
|
|
|
|
*
|
2014-01-10 13:28:48 +01:00
|
|
|
* @param array $chatCallback
|
2014-01-06 17:33:45 +01:00
|
|
|
* @param Player $admin
|
|
|
|
*/
|
|
|
|
public function command_MutePlayer(array $chatCallback, Player $admin) {
|
|
|
|
$commandParts = explode(' ', $chatCallback[1][2]);
|
2014-01-31 16:55:01 +01:00
|
|
|
if (count($commandParts) <= 1) {
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getChat()
|
|
|
|
->sendUsageInfo("No login specified! Example: '//mute login'", $admin);
|
2014-01-06 17:33:45 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$targetLogin = $commandParts[1];
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getPlayerManager()
|
|
|
|
->getPlayerActions()
|
|
|
|
->mutePlayer($admin->login, $targetLogin);
|
2014-01-06 17:33:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle //unmute Command
|
|
|
|
*
|
2014-01-10 13:28:48 +01:00
|
|
|
* @param array $chatCallback
|
2014-01-06 17:33:45 +01:00
|
|
|
* @param Player $admin
|
|
|
|
*/
|
|
|
|
public function command_UnmutePlayer(array $chatCallback, Player $admin) {
|
|
|
|
$commandParts = explode(' ', $chatCallback[1][2]);
|
2014-01-31 16:55:01 +01:00
|
|
|
if (count($commandParts) <= 1) {
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getChat()
|
|
|
|
->sendUsageInfo("No login specified! Example: '//unmute login'", $admin);
|
2014-01-06 17:33:45 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
$targetLogin = $commandParts[1];
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getPlayerManager()
|
|
|
|
->getPlayerActions()
|
|
|
|
->unMutePlayer($admin->login, $targetLogin);
|
2014-01-06 17:33:45 +01:00
|
|
|
}
|
|
|
|
|
2013-12-18 15:48:33 +01:00
|
|
|
/**
|
|
|
|
* Handle Player list command
|
2014-01-04 18:49:33 +01:00
|
|
|
*
|
2014-01-10 13:28:48 +01:00
|
|
|
* @param array $chatCallback
|
2013-12-18 15:48:33 +01:00
|
|
|
* @param Player $player
|
|
|
|
*/
|
|
|
|
public function command_playerList(array $chatCallback, Player $player) {
|
2014-08-05 02:17:41 +02:00
|
|
|
$this->maniaControl->getPlayerManager()
|
|
|
|
->getPlayerList()
|
|
|
|
->addPlayerToShownList($player, PlayerList::SHOWN_MAIN_WINDOW);
|
|
|
|
$this->maniaControl->getPlayerManager()
|
|
|
|
->getPlayerList()
|
|
|
|
->showPlayerList($player);
|
2013-12-18 15:48:33 +01:00
|
|
|
}
|
2013-12-05 00:30:10 +01:00
|
|
|
}
|