Use Chat::formatMessage in Configurator/*, ManiaExchange/* and Maps/*
This commit is contained in:
parent
1d0215df52
commit
06f24a1bfb
@ -33,7 +33,8 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA
|
|||||||
const SETTING_FORMAT_SUCCESS = 'Success Format';
|
const SETTING_FORMAT_SUCCESS = 'Success Format';
|
||||||
const SETTING_FORMAT_USAGEINFO = 'UsageInfo Format';
|
const SETTING_FORMAT_USAGEINFO = 'UsageInfo Format';
|
||||||
const SETTING_FORMAT_MESSAGE_INPUT_COLOR = 'Format Message Input Color';
|
const SETTING_FORMAT_MESSAGE_INPUT_COLOR = 'Format Message Input Color';
|
||||||
const SETTING_FORMAT_MESSAGE_MAP_AUTHOR = 'Format Message Add Map Author';
|
const SETTING_FORMAT_MESSAGE_MAP_AUTHOR_LOGIN = 'Format Message Add Map Author Login';
|
||||||
|
const SETTING_FORMAT_MESSAGE_MAP_AUTHOR_NICKNAME = 'Format Message Add Map Author Nickname';
|
||||||
const SETTING_FORMAT_MESSAGE_PLAYER_LOGIN = 'Format Message Add Player Login';
|
const SETTING_FORMAT_MESSAGE_PLAYER_LOGIN = 'Format Message Add Player Login';
|
||||||
const SETTING_PUBLIC_PREFIX = 'Public Messages Prefix';
|
const SETTING_PUBLIC_PREFIX = 'Public Messages Prefix';
|
||||||
const SETTING_PRIVATE_PREFIX = 'Private Messages Prefix';
|
const SETTING_PRIVATE_PREFIX = 'Private Messages Prefix';
|
||||||
@ -60,7 +61,8 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA
|
|||||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_SUCCESS, '$0f0');
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_SUCCESS, '$0f0');
|
||||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_USAGEINFO, '$f80');
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_USAGEINFO, '$f80');
|
||||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_MESSAGE_INPUT_COLOR, '$fff');
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_MESSAGE_INPUT_COLOR, '$fff');
|
||||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_MESSAGE_MAP_AUTHOR, false);
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_MESSAGE_MAP_AUTHOR_LOGIN, false);
|
||||||
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_MESSAGE_MAP_AUTHOR_NICKNAME, true);
|
||||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_MESSAGE_PLAYER_LOGIN, false);
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_MESSAGE_PLAYER_LOGIN, false);
|
||||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PUBLIC_PREFIX, '» ');
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PUBLIC_PREFIX, '» ');
|
||||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PRIVATE_PREFIX, '»» ');
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PRIVATE_PREFIX, '»» ');
|
||||||
@ -171,7 +173,8 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA
|
|||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function formatMessage($message, ...$inputs) {
|
public function formatMessage($message, ...$inputs) {
|
||||||
$addMapAuthor = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_MESSAGE_MAP_AUTHOR);
|
$addMapAuthorLogin = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_MESSAGE_MAP_AUTHOR_LOGIN);
|
||||||
|
$addMapAuthorNickname = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_MESSAGE_MAP_AUTHOR_NICKNAME);
|
||||||
$addPlayerLogin = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_MESSAGE_PLAYER_LOGIN);
|
$addPlayerLogin = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_MESSAGE_PLAYER_LOGIN);
|
||||||
$formatInputColor = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_MESSAGE_INPUT_COLOR);
|
$formatInputColor = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_MESSAGE_INPUT_COLOR);
|
||||||
|
|
||||||
@ -183,12 +186,18 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA
|
|||||||
$strInput = $input ? 'true' : 'false';
|
$strInput = $input ? 'true' : 'false';
|
||||||
} elseif ($input instanceof Map) {
|
} elseif ($input instanceof Map) {
|
||||||
$strInput = $input->getEscapedName();
|
$strInput = $input->getEscapedName();
|
||||||
if ($addMapAuthor) {
|
if ($addMapAuthorNickname && $input->authorNick) {
|
||||||
|
$strInput .= " (by {$input->authorNick}";
|
||||||
|
if ($addMapAuthorLogin && $input->authorLogin) {
|
||||||
|
$strInput .= " ({$input->authorLogin})";
|
||||||
|
}
|
||||||
|
$strInput .= ")";
|
||||||
|
} elseif ($addMapAuthorLogin && $input->authorLogin) {
|
||||||
$strInput .= " (by {$input->authorLogin})";
|
$strInput .= " (by {$input->authorLogin})";
|
||||||
}
|
}
|
||||||
} elseif ($input instanceof Player) {
|
} elseif ($input instanceof Player) {
|
||||||
$strInput = $input->getEscapedNickname();
|
$strInput = $input->getEscapedNickname();
|
||||||
if ($addPlayerLogin) {
|
if ($addPlayerLogin && $input->login) {
|
||||||
$strInput .= " ({$input->login})";
|
$strInput .= " ({$input->login})";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -281,6 +281,7 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns
|
|||||||
* @param string $method
|
* @param string $method
|
||||||
*/
|
*/
|
||||||
public function registerCommand($name, $adminCommand = false, $description = '', $method) {
|
public function registerCommand($name, $adminCommand = false, $description = '', $method) {
|
||||||
|
// TODO replace with new class Command
|
||||||
if ($adminCommand) {
|
if ($adminCommand) {
|
||||||
array_push($this->adminCommands, array("Name" => $name, "Description" => $description, "Method" => $method));
|
array_push($this->adminCommands, array("Name" => $name, "Description" => $description, "Method" => $method));
|
||||||
} else {
|
} else {
|
||||||
|
@ -563,10 +563,16 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
|
|||||||
$settingsCount = count($newSettings);
|
$settingsCount = count($newSettings);
|
||||||
$settingIndex = 0;
|
$settingIndex = 0;
|
||||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($player);
|
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($player);
|
||||||
$chatMessage = '$ff0' . $title . ' ' . $player->getEscapedNickname() . ' set GameMode-Setting' . ($settingsCount > 1 ? 's' : '') . ' ';
|
$chatMessage = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
"\$ff0{$title} %s set GameMode-Setting" . ($settingsCount > 1 ? "s" : "") . " ",
|
||||||
|
$player
|
||||||
|
);
|
||||||
foreach ($newSettings as $settingName => $settingValue) {
|
foreach ($newSettings as $settingName => $settingValue) {
|
||||||
$chatMessage .= '$<' . '$fff' . preg_replace('/^S_/', '', $settingName) . '$z$ff0 ';
|
$chatMessage .= $this->maniaControl->getChat()->formatMessage(
|
||||||
$chatMessage .= 'to $fff' . $this->parseSettingValue($settingValue) . '$>';
|
'%s to %s',
|
||||||
|
preg_replace('/^S_/', '', $settingName),
|
||||||
|
$this->parseSettingValue($settingValue)
|
||||||
|
);
|
||||||
|
|
||||||
if ($settingIndex <= $settingsCount - 2) {
|
if ($settingIndex <= $settingsCount - 2) {
|
||||||
$chatMessage .= ', ';
|
$chatMessage .= ', ';
|
||||||
|
@ -160,7 +160,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
|
|
||||||
$mxSearch->fetchMapsAsync(function (array $maps) use (&$player) {
|
$mxSearch->fetchMapsAsync(function (array $maps) use (&$player) {
|
||||||
if (!$maps) {
|
if (!$maps) {
|
||||||
$this->maniaControl->getChat()->sendError('No maps found, or MX is down!', $player->login);
|
$this->maniaControl->getChat()->sendError('No maps found, or MX is down!', $player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->showManiaExchangeList($maps, $player);
|
$this->showManiaExchangeList($maps, $player);
|
||||||
|
@ -371,7 +371,11 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
|||||||
$this->maniaControl->getMapManager()->updateMapTimestamp($map->uid);
|
$this->maniaControl->getMapManager()->updateMapTimestamp($map->uid);
|
||||||
|
|
||||||
// Message
|
// Message
|
||||||
$message = $player->getEscapedNickname() . ' added ' . $map->getEscapedName() . '!';
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'%s added %s!',
|
||||||
|
$player,
|
||||||
|
$map
|
||||||
|
);
|
||||||
$this->maniaControl->getChat()->sendSuccess($message);
|
$this->maniaControl->getChat()->sendSuccess($message);
|
||||||
Logger::logInfo($message, true);
|
Logger::logInfo($message, true);
|
||||||
|
|
||||||
@ -391,10 +395,18 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
|||||||
$folderPath = $player->getCache($this, self::CACHE_FOLDER_PATH);
|
$folderPath = $player->getCache($this, self::CACHE_FOLDER_PATH);
|
||||||
$filePath = $folderPath . $fileName;
|
$filePath = $folderPath . $fileName;
|
||||||
if (@unlink($filePath)) {
|
if (@unlink($filePath)) {
|
||||||
$this->maniaControl->getChat()->sendSuccess("Erased {$fileName}!");
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'Erased %s!',
|
||||||
|
$fileName
|
||||||
|
);
|
||||||
|
$this->maniaControl->getChat()->sendSuccess($message, $player);
|
||||||
$this->showManiaLink($player);
|
$this->showManiaLink($player);
|
||||||
} else {
|
} else {
|
||||||
$this->maniaControl->getChat()->sendError("Couldn't erase {$fileName}!");
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'Could not erase %s!',
|
||||||
|
$fileName
|
||||||
|
);
|
||||||
|
$this->maniaControl->getChat()->sendError($message, $player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ use ManiaControl\Manialinks\ElementBuilder;
|
|||||||
use ManiaControl\Manialinks\IconManager;
|
use ManiaControl\Manialinks\IconManager;
|
||||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
|
use ManiaControl\Utils\DataUtil;
|
||||||
use Maniaplanet\DedicatedServer\Xmlrpc\ChangeInProgressException;
|
use Maniaplanet\DedicatedServer\Xmlrpc\ChangeInProgressException;
|
||||||
use Maniaplanet\DedicatedServer\Xmlrpc\FaultException;
|
use Maniaplanet\DedicatedServer\Xmlrpc\FaultException;
|
||||||
|
|
||||||
@ -62,7 +63,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('readmaplist', 'rml'), $this, 'command_ReadMapList', true, 'Loads a maplist into the server.');
|
$this->maniaControl->getCommandManager()->registerCommandListener(array('readmaplist', 'rml'), $this, 'command_ReadMapList', true, 'Loads a maplist into the server.');
|
||||||
|
|
||||||
// Player commands
|
// Player commands
|
||||||
$this->maniaControl->getCommandManager()->registerCommandListener('nextmap', $this, 'command_showNextMap', false, 'Shows which map is next.');
|
$this->maniaControl->getCommandManager()->registerCommandListener(array('nextmap', 'next'), $this, 'command_showNextMap', false, 'Shows which map is next.');
|
||||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('maps', 'list'), $this, 'command_List', false, 'Shows the current maplist (or variations).');
|
$this->maniaControl->getCommandManager()->registerCommandListener(array('maps', 'list'), $this, 'command_List', false, 'Shows the current maplist (or variations).');
|
||||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('xmaps', 'xlist'), $this, 'command_xList', false, 'Shows maps from ManiaExchange.');
|
$this->maniaControl->getCommandManager()->registerCommandListener(array('xmaps', 'xlist'), $this, 'command_xList', false, 'Shows maps from ManiaExchange.');
|
||||||
|
|
||||||
@ -117,12 +118,20 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
$requester = $nextQueued[0];
|
$requester = $nextQueued[0];
|
||||||
/** @var Map $map */
|
/** @var Map $map */
|
||||||
$map = $nextQueued[1];
|
$map = $nextQueued[1];
|
||||||
$this->maniaControl->getChat()->sendInformation("Next Map is $<{$map->name}$> from $<{$map->authorNick}$> requested by $<{$requester->nickname}$>.", $player);
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'Next Map is %s, requested by %s.',
|
||||||
|
$map,
|
||||||
|
$requester
|
||||||
|
);
|
||||||
|
$this->maniaControl->getChat()->sendInformation($message, $player);
|
||||||
} else {
|
} else {
|
||||||
$mapIndex = $this->maniaControl->getClient()->getNextMapIndex();
|
$mapIndex = $this->maniaControl->getClient()->getNextMapIndex();
|
||||||
$maps = $this->maniaControl->getMapManager()->getMaps();
|
$map = $this->maniaControl->getMapManager()->getMapByIndex($mapIndex);
|
||||||
$map = $maps[$mapIndex];
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
$this->maniaControl->getChat()->sendInformation("Next Map is $<{$map->name}$> from $<{$map->authorNick}$>.", $player);
|
'Next Map is %s.',
|
||||||
|
$map
|
||||||
|
);
|
||||||
|
$this->maniaControl->getChat()->sendInformation($message, $player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,14 +146,14 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Get map
|
|
||||||
$map = $this->maniaControl->getMapManager()->getCurrentMap();
|
$map = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||||
if (!$map) {
|
if (!$map) {
|
||||||
$this->maniaControl->getChat()->sendError("Couldn't remove map.", $player);
|
$this->maniaControl->getChat()->sendError('Could not fetch current map to remove!', $player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove map
|
// no chat message necessary, the MapManager will do that
|
||||||
$this->maniaControl->getMapManager()->removeMap($player, $map->uid);
|
$this->maniaControl->getMapManager()->removeMap($player, $map->uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,14 +168,14 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Get map
|
|
||||||
$map = $this->maniaControl->getMapManager()->getCurrentMap();
|
$map = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||||
if (!$map) {
|
if (!$map) {
|
||||||
$this->maniaControl->getChat()->sendError("Couldn't erase map.", $player);
|
$this->maniaControl->getChat()->sendError('Could not fetch current map to erase!', $player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Erase map
|
// no chat message necessary, the MapManager will do that
|
||||||
$this->maniaControl->getMapManager()->removeMap($player, $map->uid, true);
|
$this->maniaControl->getMapManager()->removeMap($player, $map->uid, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +191,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shuffles the maps
|
// no chat message necessary, the MapManager will do that
|
||||||
$this->maniaControl->getMapManager()->shuffleMapList($player);
|
$this->maniaControl->getMapManager()->shuffleMapList($player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,13 +206,17 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$params = explode(' ', $chatCallback[1][2], 2);
|
$params = explode(' ', $chatCallback[1][2], 2);
|
||||||
if (count($params) < 2) {
|
if (count($params) < 2) {
|
||||||
$this->maniaControl->getChat()->sendUsageInfo('Usage example: //addmap 1234', $player);
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'Usage example: %s',
|
||||||
|
'//addmap 1234'
|
||||||
|
);
|
||||||
|
$this->maniaControl->getChat()->sendUsageInfo($message, $player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add Map from Mania Exchange
|
|
||||||
$this->maniaControl->getMapManager()->addMapFromMx($params[1], $player->login);
|
$this->maniaControl->getMapManager()->addMapFromMx($params[1], $player->login);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +234,10 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
|
|
||||||
$this->maniaControl->getMapManager()->getMapActions()->skipMap();
|
$this->maniaControl->getMapManager()->getMapActions()->skipMap();
|
||||||
|
|
||||||
$message = $player->getEscapedNickname() . ' skipped the current Map!';
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'%s skipped the current Map!',
|
||||||
|
$player
|
||||||
|
);
|
||||||
$this->maniaControl->getChat()->sendSuccess($message);
|
$this->maniaControl->getChat()->sendSuccess($message);
|
||||||
Logger::logInfo($message, true);
|
Logger::logInfo($message, true);
|
||||||
}
|
}
|
||||||
@ -237,17 +253,21 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$message = $player->getEscapedNickname() . ' restarted the current Map!';
|
|
||||||
$this->maniaControl->getChat()->sendSuccess($message);
|
|
||||||
Logger::logInfo($message, true);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->maniaControl->getClient()->restartMap();
|
$this->maniaControl->getClient()->restartMap();
|
||||||
} catch (ChangeInProgressException $e) {
|
} catch (ChangeInProgressException $e) {
|
||||||
}
|
$this->maniaControl->getChat()->sendException($e, $player);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
////$this->maniaControl->mapManager->mapQueue->addFirstMapToMapQueue($this->currentVote->voter, $this->maniaControl->mapManager->getCurrentMap());
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'%s restarted the current Map!',
|
||||||
|
$player
|
||||||
|
);
|
||||||
|
$this->maniaControl->getChat()->sendSuccess($message);
|
||||||
|
Logger::logInfo($message, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle replaymap command
|
* Handle replaymap command
|
||||||
@ -260,11 +280,15 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$message = $player->getEscapedNickname() . ' replays the current Map!';
|
|
||||||
$this->maniaControl->getChat()->sendSuccess($message);
|
|
||||||
Logger::logInfo($message, true);
|
|
||||||
|
|
||||||
$this->maniaControl->getMapManager()->getMapQueue()->addFirstMapToMapQueue($player, $this->maniaControl->getMapManager()->getCurrentMap());
|
$this->maniaControl->getMapManager()->getMapQueue()->addFirstMapToMapQueue($player, $this->maniaControl->getMapManager()->getCurrentMap());
|
||||||
|
|
||||||
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'%s queued the current Map to replay!',
|
||||||
|
$player
|
||||||
|
);
|
||||||
|
$this->maniaControl->getChat()->sendSuccess($message);
|
||||||
|
Logger::logInfo($message, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -280,26 +304,35 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
}
|
}
|
||||||
|
|
||||||
$chatCommand = explode(' ', $chat[1][2]);
|
$chatCommand = explode(' ', $chat[1][2]);
|
||||||
|
$maplist = 'MatchSettings' . DIRECTORY_SEPARATOR;
|
||||||
if (isset($chatCommand[1])) {
|
if (isset($chatCommand[1])) {
|
||||||
if (strstr($chatCommand[1], '.txt')) {
|
if (!DataUtil::endsWith($chatCommand[1], '.txt')) {
|
||||||
$maplist = $chatCommand[1];
|
$maplist .= $chatCommand[1] . '.txt';
|
||||||
} else {
|
} else {
|
||||||
$maplist = $chatCommand[1] . '.txt';
|
$maplist .= $chatCommand[1];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$maplist = 'maplist.txt';
|
$maplist .= 'maplist.txt';
|
||||||
}
|
}
|
||||||
|
|
||||||
$maplist = 'MatchSettings' . DIRECTORY_SEPARATOR . $maplist;
|
|
||||||
try {
|
try {
|
||||||
$this->maniaControl->getClient()->saveMatchSettings($maplist);
|
$this->maniaControl->getClient()->saveMatchSettings($maplist);
|
||||||
|
} catch (FaultException $e) {
|
||||||
|
$this->maniaControl->getChat()->sendException($e, $player);
|
||||||
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'Cannot write maplist %s!',
|
||||||
|
$maplist
|
||||||
|
);
|
||||||
|
$this->maniaControl->getChat()->sendError($message, $player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$message = 'Maplist $<$fff' . $maplist . '$> written.';
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'Maplist %s written.',
|
||||||
|
$maplist
|
||||||
|
);
|
||||||
$this->maniaControl->getChat()->sendSuccess($message, $player);
|
$this->maniaControl->getChat()->sendSuccess($message, $player);
|
||||||
Logger::logInfo($message, true);
|
Logger::logInfo($message, true);
|
||||||
} catch (FaultException $e) {
|
|
||||||
$this->maniaControl->getChat()->sendError('Cannot write maplist $<$fff' . $maplist . '$>!', $player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -315,27 +348,36 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
}
|
}
|
||||||
|
|
||||||
$chatCommand = explode(' ', $chat[1][2]);
|
$chatCommand = explode(' ', $chat[1][2]);
|
||||||
|
$maplist = 'MatchSettings' . DIRECTORY_SEPARATOR;
|
||||||
if (isset($chatCommand[1])) {
|
if (isset($chatCommand[1])) {
|
||||||
if (strstr($chatCommand[1], '.txt')) {
|
if (!DataUtil::endsWith($chatCommand[1], '.txt')) {
|
||||||
$maplist = $chatCommand[1];
|
$maplist .= $chatCommand[1] . '.txt';
|
||||||
} else {
|
} else {
|
||||||
$maplist = $chatCommand[1] . '.txt';
|
$maplist .= $chatCommand[1];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$maplist = 'maplist.txt';
|
$maplist .= 'maplist.txt';
|
||||||
}
|
}
|
||||||
|
|
||||||
$maplist = 'MatchSettings' . DIRECTORY_SEPARATOR . $maplist;
|
|
||||||
try {
|
try {
|
||||||
$this->maniaControl->getClient()->loadMatchSettings($maplist);
|
$this->maniaControl->getClient()->loadMatchSettings($maplist);
|
||||||
|
} catch (FaultException $e) {
|
||||||
|
$this->maniaControl->getChat()->sendException($e, $player);
|
||||||
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'Cannot load maplist %s!',
|
||||||
|
$maplist
|
||||||
|
);
|
||||||
|
$this->maniaControl->getChat()->sendError($message, $player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$message = 'Maplist $<$fff' . $maplist . '$> loaded.';
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'Maplist %s loaded.',
|
||||||
|
$maplist
|
||||||
|
);
|
||||||
$this->maniaControl->getMapManager()->restructureMapList();
|
$this->maniaControl->getMapManager()->restructureMapList();
|
||||||
$this->maniaControl->getChat()->sendSuccess($message, $player);
|
$this->maniaControl->getChat()->sendSuccess($message, $player);
|
||||||
Logger::logInfo($message, true);
|
Logger::logInfo($message, true);
|
||||||
} catch (FaultException $e) {
|
|
||||||
$this->maniaControl->getChat()->sendError('Cannot load maplist $<$fff' . $maplist . '$>!', $player);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -588,18 +588,22 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$this->maniaControl->getMapManager()->getMapQueue()->dontQueueNextMapChange();
|
$this->maniaControl->getMapManager()->getMapQueue()->dontQueueNextMapChange();
|
||||||
try {
|
try {
|
||||||
$this->maniaControl->getClient()->jumpToMapIdent($mapUid);
|
$this->maniaControl->getClient()->jumpToMapIdent($mapUid);
|
||||||
} catch (NextMapException $exception) {
|
} catch (NextMapException $e) {
|
||||||
$this->maniaControl->getChat()->sendError('Error on Jumping to Map Ident: ' . $exception->getMessage(), $player);
|
$this->maniaControl->getChat()->sendException($e, $player);
|
||||||
break;
|
break;
|
||||||
} catch (NotInListException $exception) {
|
} catch (NotInListException $e) {
|
||||||
// TODO: "Map not found." -> how is that possible?
|
// TODO: "Map not found." -> how is that possible?
|
||||||
$this->maniaControl->getChat()->sendError('Error on Jumping to Map Ident: ' . $exception->getMessage(), $player);
|
$this->maniaControl->getChat()->sendException($e, $player);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$map = $this->maniaControl->getMapManager()->getMapByUid($mapUid);
|
$map = $this->maniaControl->getMapManager()->getMapByUid($mapUid);
|
||||||
|
|
||||||
$message = $player->getEscapedNickname() . ' skipped to Map $z' . $map->getEscapedName() . '!';
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'%s skipped to Map %s!',
|
||||||
|
$player,
|
||||||
|
$map
|
||||||
|
);
|
||||||
$this->maniaControl->getChat()->sendSuccess($message);
|
$this->maniaControl->getChat()->sendSuccess($message);
|
||||||
Logger::logInfo($message, true);
|
Logger::logInfo($message, true);
|
||||||
|
|
||||||
@ -610,11 +614,16 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$votesPlugin = $this->maniaControl->getPluginManager()->getPlugin(self::DEFAULT_CUSTOM_VOTE_PLUGIN);
|
$votesPlugin = $this->maniaControl->getPluginManager()->getPlugin(self::DEFAULT_CUSTOM_VOTE_PLUGIN);
|
||||||
$map = $this->maniaControl->getMapManager()->getMapByUid($mapUid);
|
$map = $this->maniaControl->getMapManager()->getMapByUid($mapUid);
|
||||||
|
|
||||||
$message = $player->getEscapedNickname() . '$s started a vote to switch to ' . $map->getEscapedName() . '!';
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'%s started a vote to switch to Map %s!',
|
||||||
|
$player,
|
||||||
|
$map
|
||||||
|
);
|
||||||
|
|
||||||
$votesPlugin->defineVote('switchmap', 'Goto ' . $map->name, true, $message)->setStopCallback(Callbacks::ENDMAP);
|
$votesPlugin->defineVote('switchmap', 'Goto ' . $map->name, true, $message)->setStopCallback(Callbacks::ENDMAP);
|
||||||
|
|
||||||
$votesPlugin->startVote($player, 'switchmap', function ($result) use (&$votesPlugin, &$map) {
|
$votesPlugin->startVote($player, 'switchmap', function ($result) use (&$votesPlugin, &$map) {
|
||||||
|
// will be only called, if successful
|
||||||
|
|
||||||
$votesPlugin->undefineVote('switchmap');
|
$votesPlugin->undefineVote('switchmap');
|
||||||
|
|
||||||
// Don't queue on Map-Change
|
// Don't queue on Map-Change
|
||||||
@ -631,7 +640,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->maniaControl->getChat()->sendInformation('$sVote Successful -> Map switched!');
|
$this->maniaControl->getChat()->sendSuccess('Vote Successful -> Map switched!');
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case self::ACTION_QUEUED_MAP:
|
case self::ACTION_QUEUED_MAP:
|
||||||
|
@ -192,7 +192,11 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
|||||||
|
|
||||||
if (!isset($uid) || !isset($this->maps[$uid])) {
|
if (!isset($uid) || !isset($this->maps[$uid])) {
|
||||||
if ($admin) {
|
if ($admin) {
|
||||||
$this->maniaControl->getChat()->sendError("Error updating Map: Unknown UID '{$uid}'!", $admin);
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'Error updating Map, unknown UID %s!',
|
||||||
|
$uid
|
||||||
|
);
|
||||||
|
$this->maniaControl->getChat()->sendError($message, $admin);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -278,16 +282,22 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
|||||||
// Check if ManiaControl can even write to the maps dir
|
// Check if ManiaControl can even write to the maps dir
|
||||||
$mapDir = $this->maniaControl->getClient()->getMapsDirectory();
|
$mapDir = $this->maniaControl->getClient()->getMapsDirectory();
|
||||||
if ($this->maniaControl->getServer()->checkAccess($mapDir)) {
|
if ($this->maniaControl->getServer()->checkAccess($mapDir)) {
|
||||||
|
$mapFile = $mapDir . $map->fileName;
|
||||||
|
|
||||||
// Delete map file
|
// Delete map file
|
||||||
if (!@unlink($mapDir . $map->fileName)) {
|
if (!@unlink($mapFile)) {
|
||||||
if ($admin) {
|
if ($admin) {
|
||||||
$this->maniaControl->getChat()->sendError("Couldn't erase the map file.", $admin);
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'Could not erase the map file %s.',
|
||||||
|
$mapFile
|
||||||
|
);
|
||||||
|
$this->maniaControl->getChat()->sendError($message, $admin);
|
||||||
}
|
}
|
||||||
$eraseFile = false;
|
$eraseFile = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($admin) {
|
if ($admin) {
|
||||||
$this->maniaControl->getChat()->sendError("Couldn't erase the map file (no access).", $admin);
|
$this->maniaControl->getChat()->sendError('Could not erase the map file (no access to Maps-Directory).', $admin);
|
||||||
}
|
}
|
||||||
$eraseFile = false;
|
$eraseFile = false;
|
||||||
}
|
}
|
||||||
@ -297,9 +307,16 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
|||||||
if ($message) {
|
if ($message) {
|
||||||
$action = ($eraseFile ? 'erased' : 'removed');
|
$action = ($eraseFile ? 'erased' : 'removed');
|
||||||
if ($admin) {
|
if ($admin) {
|
||||||
$message = $admin->getEscapedNickname() . ' ' . $action . ' ' . $map->getEscapedName() . '!';
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
"%s {$action} %s!",
|
||||||
|
$admin,
|
||||||
|
$map
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
$message = $map->getEscapedName() . ' got ' . $action . '!';
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
"%s got {$action}!",
|
||||||
|
$map
|
||||||
|
);
|
||||||
}
|
}
|
||||||
$this->maniaControl->getChat()->sendSuccess($message);
|
$this->maniaControl->getChat()->sendSuccess($message);
|
||||||
Logger::logInfo($message, true);
|
Logger::logInfo($message, true);
|
||||||
@ -363,7 +380,7 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
|||||||
if (!$file || $error) {
|
if (!$file || $error) {
|
||||||
if ($login) {
|
if ($login) {
|
||||||
// Download error
|
// Download error
|
||||||
$this->maniaControl->getChat()->sendError("Download failed: '{$error}'!", $login);
|
$this->maniaControl->getChat()->sendError("Download failed: {$error}!", $login);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -406,7 +423,11 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
|||||||
if ($this->maniaControl->getServer()->checkAccess($mapDir)) {
|
if ($this->maniaControl->getServer()->checkAccess($mapDir)) {
|
||||||
// Create download directory if necessary
|
// Create download directory if necessary
|
||||||
if (!is_dir($downloadDirectory) && !mkdir($downloadDirectory) || !is_writable($downloadDirectory)) {
|
if (!is_dir($downloadDirectory) && !mkdir($downloadDirectory) || !is_writable($downloadDirectory)) {
|
||||||
$this->maniaControl->getChat()->sendError("ManiaControl doesn't have to rights to save maps in '{$downloadDirectory}'.", $login);
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'ManiaControl does not have to rights to save maps in %s!',
|
||||||
|
$downloadDirectory
|
||||||
|
);
|
||||||
|
$this->maniaControl->getChat()->sendError($message, $login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,12 +442,12 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
|||||||
$this->maniaControl->getClient()->writeFile($relativeMapFileName, $file);
|
$this->maniaControl->getClient()->writeFile($relativeMapFileName, $file);
|
||||||
} catch (InvalidArgumentException $e) {
|
} catch (InvalidArgumentException $e) {
|
||||||
if ($e->getMessage() === 'data are too big') {
|
if ($e->getMessage() === 'data are too big') {
|
||||||
$this->maniaControl->getChat()->sendError("Map is too big for a remote save.", $login);
|
$this->maniaControl->getChat()->sendError('Map is too big for a remote save!', $login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw $e;
|
throw $e;
|
||||||
} catch (FileException $e) {
|
} catch (FileException $e) {
|
||||||
$this->maniaControl->getChat()->sendError("Could not write file", $login);
|
$this->maniaControl->getChat()->sendError('Could not write file!', $login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -434,26 +455,26 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
|||||||
// Check for valid map
|
// Check for valid map
|
||||||
try {
|
try {
|
||||||
$this->maniaControl->getClient()->checkMapForCurrentServerParams($relativeMapFileName);
|
$this->maniaControl->getClient()->checkMapForCurrentServerParams($relativeMapFileName);
|
||||||
} catch (InvalidMapException $exception) {
|
} catch (InvalidMapException $e) {
|
||||||
$this->maniaControl->getChat()->sendException($exception, $login);
|
$this->maniaControl->getChat()->sendException($e, $login);
|
||||||
return;
|
return;
|
||||||
} catch (FileException $exception) {
|
} catch (FileException $e) {
|
||||||
$this->maniaControl->getChat()->sendException($exception, $login);
|
$this->maniaControl->getChat()->sendException($e, $login);
|
||||||
return;
|
return;
|
||||||
}catch (FaultException $exception){
|
}catch (FaultException $e){
|
||||||
$this->maniaControl->getChat()->sendException($exception, $login);
|
$this->maniaControl->getChat()->sendException($e, $login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add map to map list
|
// Add map to map list
|
||||||
try {
|
try {
|
||||||
$this->maniaControl->getClient()->insertMap($relativeMapFileName);
|
$this->maniaControl->getClient()->insertMap($relativeMapFileName);
|
||||||
} catch (AlreadyInListException $exception) {
|
} catch (AlreadyInListException $e) {
|
||||||
$this->maniaControl->getChat()->sendException($exception, $login);
|
$this->maniaControl->getChat()->sendException($e, $login);
|
||||||
return;
|
return;
|
||||||
} catch (InvalidMapException $exception) {
|
} catch (InvalidMapException $e) {
|
||||||
$this->maniaControl->getChat()->sendException($exception, $login);
|
$this->maniaControl->getChat()->sendException($e, $login);
|
||||||
if ($exception->getMessage() != 'Map lightmap is not up to date. (will still load for now)') {
|
if ($e->getMessage() != 'Map lightmap is not up to date. (will still load for now)') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -482,14 +503,21 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
|||||||
if ($login) {
|
if ($login) {
|
||||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
$player = $this->maniaControl->getPlayerManager()->getPlayer($login);
|
||||||
if (!$update) {
|
if (!$update) {
|
||||||
// Message
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
$message = $player->getEscapedNickname() . ' added $<' . $mapInfo->name . '$>!';
|
'%s added %s from MX!',
|
||||||
|
$player,
|
||||||
|
$map
|
||||||
|
);
|
||||||
$this->maniaControl->getChat()->sendSuccess($message);
|
$this->maniaControl->getChat()->sendSuccess($message);
|
||||||
Logger::logInfo($message, true);
|
Logger::logInfo($message, true);
|
||||||
// Queue requested Map
|
|
||||||
$this->maniaControl->getMapManager()->getMapQueue()->addMapToMapQueue($login, $mapInfo->uid);
|
$this->maniaControl->getMapManager()->getMapQueue()->addMapToMapQueue($login, $mapInfo->uid);
|
||||||
} else {
|
} else {
|
||||||
$message = $player->getEscapedNickname() . ' updated $<' . $mapInfo->name . '$>!';
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'%s updated %s from MX!',
|
||||||
|
$player,
|
||||||
|
$map
|
||||||
|
);
|
||||||
$this->maniaControl->getChat()->sendSuccess($message);
|
$this->maniaControl->getChat()->sendSuccess($message);
|
||||||
Logger::logInfo($message, true);
|
Logger::logInfo($message, true);
|
||||||
}
|
}
|
||||||
@ -649,15 +677,18 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
|||||||
$this->maniaControl->getClient()->chooseNextMapList($mapArray);
|
$this->maniaControl->getClient()->chooseNextMapList($mapArray);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
//TODO temp added 19.04.2014
|
//TODO temp added 19.04.2014
|
||||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice("Exception line 331 MapManager" . $e->getMessage());
|
$this->maniaControl->getErrorHandler()->triggerDebugNotice('Exception line 331 MapManager' . $e->getMessage());
|
||||||
trigger_error("Couldn't shuffle mapList. " . $e->getMessage());
|
trigger_error('Could not shuffle mapList. ' . $e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->fetchCurrentMap();
|
$this->fetchCurrentMap();
|
||||||
|
|
||||||
if ($admin) {
|
if ($admin) {
|
||||||
$message = $admin->getEscapedNickname() . ' shuffled the Maplist!';
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'%s shuffled the Maplist!',
|
||||||
|
$admin
|
||||||
|
);
|
||||||
$this->maniaControl->getChat()->sendSuccess($message);
|
$this->maniaControl->getChat()->sendSuccess($message);
|
||||||
Logger::logInfo($message, true);
|
Logger::logInfo($message, true);
|
||||||
}
|
}
|
||||||
@ -725,7 +756,7 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
|||||||
try {
|
try {
|
||||||
$this->maniaControl->getClient()->chooseNextMapList($mapArray);
|
$this->maniaControl->getClient()->chooseNextMapList($mapArray);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
trigger_error("Error restructuring the Maplist. " . $e->getMessage());
|
trigger_error('Error restructuring the Maplist. ' . $e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -34,6 +34,7 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
|||||||
const SETTING_SKIP_MAPQUEUE_ADMIN = 'Skip Map when admin leaves';
|
const SETTING_SKIP_MAPQUEUE_ADMIN = 'Skip Map when admin leaves';
|
||||||
const SETTING_MAPLIMIT_PLAYER = 'Maximum maps per player in the Map-Queue (-1 = unlimited)';
|
const SETTING_MAPLIMIT_PLAYER = 'Maximum maps per player in the Map-Queue (-1 = unlimited)';
|
||||||
const SETTING_MAPLIMIT_ADMIN = 'Maximum maps per admin (Admin+) in the Map-Queue (-1 = unlimited)';
|
const SETTING_MAPLIMIT_ADMIN = 'Maximum maps per admin (Admin+) in the Map-Queue (-1 = unlimited)';
|
||||||
|
const SETTING_MESSAGE_FORMAT = 'Message Format';
|
||||||
const SETTING_BUFFERSIZE = 'Size of the Map-Queue buffer (recently played maps)';
|
const SETTING_BUFFERSIZE = 'Size of the Map-Queue buffer (recently played maps)';
|
||||||
const SETTING_PERMISSION_CLEAR_MAPQUEUE = 'Clear MapQueue';
|
const SETTING_PERMISSION_CLEAR_MAPQUEUE = 'Clear MapQueue';
|
||||||
const SETTING_PERMISSION_QUEUE_BUFFER = 'Queue maps in buffer';
|
const SETTING_PERMISSION_QUEUE_BUFFER = 'Queue maps in buffer';
|
||||||
@ -69,6 +70,7 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
|||||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SKIP_MAPQUEUE_ADMIN, false);
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SKIP_MAPQUEUE_ADMIN, false);
|
||||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAPLIMIT_PLAYER, 1);
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAPLIMIT_PLAYER, 1);
|
||||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAPLIMIT_ADMIN, -1);
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAPLIMIT_ADMIN, -1);
|
||||||
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MESSAGE_FORMAT, '$fa0');
|
||||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_BUFFERSIZE, 10);
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_BUFFERSIZE, 10);
|
||||||
|
|
||||||
// Permissions
|
// Permissions
|
||||||
@ -117,8 +119,9 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$messagePrefix = $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MESSAGE_FORMAT);
|
||||||
if ($admin && empty($this->queuedMaps)) {
|
if ($admin && empty($this->queuedMaps)) {
|
||||||
$this->maniaControl->getChat()->sendError('$fa0There are no maps in the jukebox!', $admin->login);
|
$this->maniaControl->getChat()->sendError($messagePrefix . 'There are no maps in the jukebox!', $admin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,8 +129,12 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
|||||||
$this->queuedMaps = array();
|
$this->queuedMaps = array();
|
||||||
|
|
||||||
if ($admin) {
|
if ($admin) {
|
||||||
$title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel);
|
$title = $admin->getAuthLevelName();
|
||||||
$message = '$fa0' . $title . ' $<$fff' . $admin->nickname . '$> cleared the Map-Queue!';
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
$messagePrefix . '%s %s cleared the Map-Queue!',
|
||||||
|
$title,
|
||||||
|
$admin
|
||||||
|
);
|
||||||
$this->maniaControl->getChat()->sendInformation($message);
|
$this->maniaControl->getChat()->sendInformation($message);
|
||||||
Logger::logInfo($message, true);
|
Logger::logInfo($message, true);
|
||||||
}
|
}
|
||||||
@ -172,15 +179,20 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function showMapQueue(Player $player) {
|
public function showMapQueue(Player $player) {
|
||||||
|
$messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT);
|
||||||
if (empty($this->queuedMaps)) {
|
if (empty($this->queuedMaps)) {
|
||||||
$this->maniaControl->getChat()->sendError('$fa0There are no maps in the jukebox!', $player->login);
|
$this->maniaControl->getChat()->sendInformation($messagePrefix . 'There are no maps in the jukebox!', $player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$message = '$fa0Upcoming maps in the Map-Queue:';
|
$message = $messagePrefix . 'Upcoming maps in the Map-Queue:';
|
||||||
$index = 1;
|
$index = 1;
|
||||||
foreach ($this->queuedMaps as $queuedMap) {
|
foreach ($this->queuedMaps as $queuedMap) {
|
||||||
$message .= ' $<$fff' . $index . '$>. [$<$fff' . Formatter::stripCodes($queuedMap[1]->name) . '$>]';
|
$message .= $this->maniaControl->getChat()->formatMessage(
|
||||||
|
' %s. [%s]',
|
||||||
|
$index,
|
||||||
|
Formatter::stripCodes($queuedMap[1]->name)
|
||||||
|
);
|
||||||
$index++;
|
$index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,8 +205,9 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function showMapQueueManialink(Player $player) {
|
public function showMapQueueManialink(Player $player) {
|
||||||
|
$messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT);
|
||||||
if (empty($this->queuedMaps)) {
|
if (empty($this->queuedMaps)) {
|
||||||
$this->maniaControl->getChat()->sendError('There are no Maps in the Jukebox!', $player);
|
$this->maniaControl->getChat()->sendInformation($messagePrefix . 'There are no Maps in the Jukebox!', $player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,7 +259,12 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
|||||||
|
|
||||||
$this->queuedMaps[$uid] = array(null, $map);
|
$this->queuedMaps[$uid] = array(null, $map);
|
||||||
|
|
||||||
$this->maniaControl->getChat()->sendInformation('$fa0$<$fff' . $map->name . '$> has been added to the Map-Queue by the Server.');
|
$messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT);
|
||||||
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
$messagePrefix . '%s has been added to the Map-Queue by the Server.',
|
||||||
|
$map
|
||||||
|
);
|
||||||
|
$this->maniaControl->getChat()->sendInformation($message);
|
||||||
|
|
||||||
// Trigger callback
|
// Trigger callback
|
||||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $this->queuedMaps[$uid]));
|
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $this->queuedMaps[$uid]));
|
||||||
@ -285,13 +303,21 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
|||||||
if ($isModerator) {
|
if ($isModerator) {
|
||||||
$maxAdmin = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAPLIMIT_ADMIN);
|
$maxAdmin = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAPLIMIT_ADMIN);
|
||||||
if ($maxAdmin >= 0 && $mapsForPlayer >= $maxAdmin) {
|
if ($maxAdmin >= 0 && $mapsForPlayer >= $maxAdmin) {
|
||||||
$this->maniaControl->getChat()->sendError('You already have $<$fff' . $maxAdmin . '$> map(s) in the Map-Queue!', $login);
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'You already have %s map(s) in the Map-Queue!',
|
||||||
|
$maxAdmin
|
||||||
|
);
|
||||||
|
$this->maniaControl->getChat()->sendError($message, $player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$maxPlayer = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAPLIMIT_PLAYER);
|
$maxPlayer = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAPLIMIT_PLAYER);
|
||||||
if ($maxPlayer >= 0 && $mapsForPlayer >= $maxPlayer) {
|
if ($maxPlayer >= 0 && $mapsForPlayer >= $maxPlayer) {
|
||||||
$this->maniaControl->getChat()->sendError('You already have $<$fff' . $maxPlayer . '$> map(s) in the Map-Queue!', $login);
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
'You already have %s map(s) in the Map-Queue!',
|
||||||
|
$maxPlayer
|
||||||
|
);
|
||||||
|
$this->maniaControl->getChat()->sendError($message, $player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,14 +329,15 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
|||||||
$uid = $map->uid;
|
$uid = $map->uid;
|
||||||
}
|
}
|
||||||
if (array_key_exists($uid, $this->queuedMaps)) {
|
if (array_key_exists($uid, $this->queuedMaps)) {
|
||||||
$this->maniaControl->getChat()->sendError('That map is already in the Map-Queue!', $login);
|
$this->maniaControl->getChat()->sendError('This map is already in the Map-Queue!', $player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO recently maps not able to add to queue-amps setting, and management
|
//TODO recently maps not able to add to queue-amps setting, and management
|
||||||
// Check if map is in the buffer
|
// Check if map is in the buffer
|
||||||
|
$messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT);
|
||||||
if (in_array($uid, $this->buffer)) {
|
if (in_array($uid, $this->buffer)) {
|
||||||
$this->maniaControl->getChat()->sendError('That map has recently been played!', $login);
|
$this->maniaControl->getChat()->sendInformation($messagePrefix . 'This map has recently been played!', $player);
|
||||||
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)) {
|
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -322,7 +349,12 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
|||||||
|
|
||||||
$this->queuedMaps[$uid] = array($player, $map);
|
$this->queuedMaps[$uid] = array($player, $map);
|
||||||
|
|
||||||
$this->maniaControl->getChat()->sendInformation('$fa0$<$fff' . $map->name . '$> has been added to the Map-Queue by $<$fff' . $player->nickname . '$>.');
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
$messagePrefix . '%s has been added to the Map-Queue by %s.',
|
||||||
|
$map,
|
||||||
|
$player
|
||||||
|
);
|
||||||
|
$this->maniaControl->getChat()->sendInformation($message);
|
||||||
|
|
||||||
// Trigger callback
|
// Trigger callback
|
||||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $this->queuedMaps[$uid]));
|
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $this->queuedMaps[$uid]));
|
||||||
@ -343,7 +375,13 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
|||||||
unset($this->queuedMaps[$uid]);
|
unset($this->queuedMaps[$uid]);
|
||||||
|
|
||||||
if ($player) {
|
if ($player) {
|
||||||
$this->maniaControl->getChat()->sendInformation('$fa0$<$fff' . $map->name . '$> is removed from the Map-Queue by $<$fff' . $player->nickname . '$>.');
|
$messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT);
|
||||||
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
$messagePrefix . '%s has been removed from the Map-Queue by %s.',
|
||||||
|
$map,
|
||||||
|
$player
|
||||||
|
);
|
||||||
|
$this->maniaControl->getChat()->sendInformation($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trigger callback
|
// Trigger callback
|
||||||
@ -362,11 +400,16 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT);
|
||||||
|
|
||||||
$this->nextMap = null;
|
$this->nextMap = null;
|
||||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SKIP_MAP_ON_LEAVE)) {
|
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SKIP_MAP_ON_LEAVE)) {
|
||||||
// Skip Map if requester has left
|
// Skip Map if requester has left
|
||||||
foreach ($this->queuedMaps as $queuedMap) {
|
foreach ($this->queuedMaps as $queuedMap) {
|
||||||
|
/** @var Player $player */
|
||||||
$player = $queuedMap[0];
|
$player = $queuedMap[0];
|
||||||
|
/** @var Map $map */
|
||||||
|
$map = $queuedMap[1];
|
||||||
|
|
||||||
// Check if map is added via replay vote/command
|
// Check if map is added via replay vote/command
|
||||||
if (isset($queuedMap[2]) && $queuedMap[2] === true) {
|
if (isset($queuedMap[2]) && $queuedMap[2] === true) {
|
||||||
@ -391,7 +434,12 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
|||||||
// Player not found, so remove the map from the mapqueue
|
// Player not found, so remove the map from the mapqueue
|
||||||
array_shift($this->queuedMaps);
|
array_shift($this->queuedMaps);
|
||||||
|
|
||||||
$this->maniaControl->getChat()->sendInformation('$fa0$<$fff' . $queuedMap[0]->name . '$> is skipped because $<' . $player->nickname . '$> left the game!');
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
|
$messagePrefix . '%s will be skipped, because %s left the game!',
|
||||||
|
$map,
|
||||||
|
$player
|
||||||
|
);
|
||||||
|
$this->maniaControl->getChat()->sendInformation($message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -401,12 +449,19 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
|||||||
if (!$this->nextMap || !isset($this->nextMap[1])) {
|
if (!$this->nextMap || !isset($this->nextMap[1])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/** @var Player $player */
|
||||||
|
$player = $this->nextMap[0];
|
||||||
|
/** @var Map $map */
|
||||||
$map = $this->nextMap[1];
|
$map = $this->nextMap[1];
|
||||||
|
|
||||||
// Message only if it's juked by a player (not by the server)
|
// Message only if it's juked by a player (not by the server)
|
||||||
if ($this->nextMap[0]) {
|
if ($player) {
|
||||||
/** @var Map $map */
|
$message = $this->maniaControl->getChat()->formatMessage(
|
||||||
$this->maniaControl->getChat()->sendInformation('$fa0Next map will be $<$fff' . $map->name . '$> as requested by $<' . $this->nextMap[0]->nickname . '$>.');
|
$messagePrefix . 'Next map will be %s as requested by %s.',
|
||||||
|
$map,
|
||||||
|
$player
|
||||||
|
);
|
||||||
|
$this->maniaControl->getChat()->sendInformation($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user