Compare commits
5 Commits
129053e951
...
bad5ecd70f
Author | SHA1 | Date | |
---|---|---|---|
bad5ecd70f | |||
bff16f6441 | |||
0f55bff6c2 | |||
d947337c9c | |||
0ad0d06f85 |
@ -154,7 +154,7 @@ class AuthCommands implements CommandListener, UsageInformationAble {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($target->authLevel >= AuthenticationManager::AUTH_LEVEL_MASTERADMIN) {
|
if ($player !== $target && $target->authLevel >= AuthenticationManager::AUTH_LEVEL_MASTERADMIN) {
|
||||||
$this->maniaControl->getChat()->sendError('You cannot remove rights of a MasterAdmin!', $player);
|
$this->maniaControl->getChat()->sendError('You cannot remove rights of a MasterAdmin!', $player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -164,7 +164,7 @@ class AuthCommands implements CommandListener, UsageInformationAble {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($player->authLevel <= $target->authLevel) {
|
if ($player !== $target && $player->authLevel <= $target->authLevel) {
|
||||||
$this->maniaControl->getChat()->sendError('You cannot remove rights of a higher privileged player!', $player);
|
$this->maniaControl->getChat()->sendError('You cannot remove rights of a higher privileged player!', $player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ abstract class FileUtil {
|
|||||||
public static function getClearedFileName($fileName) {
|
public static function getClearedFileName($fileName) {
|
||||||
$fileName = Formatter::stripCodes($fileName);
|
$fileName = Formatter::stripCodes($fileName);
|
||||||
$fileName = Formatter::utf8($fileName);
|
$fileName = Formatter::utf8($fileName);
|
||||||
$fileName = preg_replace('/[^0-9A-Za-z\-\+\.\_\ ]/', null, $fileName);
|
$fileName = preg_replace('/[^0-9A-Za-z\-\+\.\_\ ]/', '', $fileName);
|
||||||
$fileName = preg_replace('/ /', '_', $fileName);
|
$fileName = preg_replace('/ /', '_', $fileName);
|
||||||
return $fileName;
|
return $fileName;
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
* @param array $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function handleManialinkPageAnswer(array $callback) {
|
public function handleManialinkPageAnswer(array $callback) {
|
||||||
|
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||||
$actionId = $callback[1][2];
|
$actionId = $callback[1][2];
|
||||||
$actionArray = explode('.', $actionId);
|
$actionArray = explode('.', $actionId);
|
||||||
if (count($actionArray) <= 2) {
|
if (count($actionArray) <= 2) {
|
||||||
@ -101,6 +102,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function showListCommand(array $chatCallback, Player $player) {
|
public function showListCommand(array $chatCallback, Player $player) {
|
||||||
|
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||||
$this->mapListShown[$player->login] = true;
|
$this->mapListShown[$player->login] = true;
|
||||||
$params = explode(' ', $chatCallback[1][2]);
|
$params = explode(' ', $chatCallback[1][2]);
|
||||||
$searchString = '';
|
$searchString = '';
|
||||||
@ -141,6 +143,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
* @param string $searchString
|
* @param string $searchString
|
||||||
*/
|
*/
|
||||||
private function getMXMapsAndShowList(Player $player, $author = '', $environment = '', $searchString = '') {
|
private function getMXMapsAndShowList(Player $player, $author = '', $environment = '', $searchString = '') {
|
||||||
|
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||||
//TODO do more clean solution
|
//TODO do more clean solution
|
||||||
if($environment == ""){
|
if($environment == ""){
|
||||||
$titleId = $this->maniaControl->getServer()->titleId;
|
$titleId = $this->maniaControl->getServer()->titleId;
|
||||||
@ -191,6 +194,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
* @internal param array $chatCallback
|
* @internal param array $chatCallback
|
||||||
*/
|
*/
|
||||||
private function showManiaExchangeList(array $maps, Player $player) {
|
private function showManiaExchangeList(array $maps, Player $player) {
|
||||||
|
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||||
// Start offsets
|
// Start offsets
|
||||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||||
@ -340,6 +344,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
* @param $openedWidget
|
* @param $openedWidget
|
||||||
*/
|
*/
|
||||||
public function handleWidgetOpened(Player $player, $openedWidget) {
|
public function handleWidgetOpened(Player $player, $openedWidget) {
|
||||||
|
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||||
//unset when another main widget got opened
|
//unset when another main widget got opened
|
||||||
if ($openedWidget !== 'ManiaExchangeList') {
|
if ($openedWidget !== 'ManiaExchangeList') {
|
||||||
unset($this->mapListShown[$player->login]);
|
unset($this->mapListShown[$player->login]);
|
||||||
@ -355,5 +360,4 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
public function closeWidget(Player $player) {
|
public function closeWidget(Player $player) {
|
||||||
unset($this->mapListShown[$player->login]);
|
unset($this->mapListShown[$player->login]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
|||||||
*/
|
*/
|
||||||
/** @var ManiaControl $maniaControl */
|
/** @var ManiaControl $maniaControl */
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
|
private $enabled = true;
|
||||||
private $mxIdUidVector = array();
|
private $mxIdUidVector = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,6 +68,22 @@ class ManiaExchangeManager implements UsageInformationAble {
|
|||||||
//$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MX_KEY, "");
|
//$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MX_KEY, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the status of the plugin
|
||||||
|
*
|
||||||
|
* @param bool $status
|
||||||
|
*/
|
||||||
|
public function setStatus(bool $status) {
|
||||||
|
$this->enabled = $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the status of the plugin
|
||||||
|
*/
|
||||||
|
public function getStatus() {
|
||||||
|
return $this->enabled;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unset Map by Mx Id
|
* Unset Map by Mx Id
|
||||||
*
|
*
|
||||||
@ -84,6 +101,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
|||||||
* @param mixed $maps
|
* @param mixed $maps
|
||||||
*/
|
*/
|
||||||
public function fetchManiaExchangeMapInformation($maps = null) {
|
public function fetchManiaExchangeMapInformation($maps = null) {
|
||||||
|
if (!$this->enabled) return;
|
||||||
if ($maps) {
|
if ($maps) {
|
||||||
// Fetch Information for a single map
|
// Fetch Information for a single map
|
||||||
$maps = array($maps);
|
$maps = array($maps);
|
||||||
@ -160,7 +178,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
|||||||
* @param string $string
|
* @param string $string
|
||||||
*/
|
*/
|
||||||
public function fetchMaplistByMixedUidIdString($string) {
|
public function fetchMaplistByMixedUidIdString($string) {
|
||||||
|
if (!$this->enabled) return;
|
||||||
// For TM2020
|
// For TM2020
|
||||||
if ($this->maniaControl->getServer()->titleId == "Trackmania") {
|
if ($this->maniaControl->getServer()->titleId == "Trackmania") {
|
||||||
// Get Title Prefix
|
// Get Title Prefix
|
||||||
@ -217,6 +235,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
|||||||
* @param array $mxMapInfos
|
* @param array $mxMapInfos
|
||||||
*/
|
*/
|
||||||
public function updateMapObjectsWithManiaExchangeIds(array $mxMapInfos) {
|
public function updateMapObjectsWithManiaExchangeIds(array $mxMapInfos) {
|
||||||
|
if (!$this->enabled) return;
|
||||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||||
// Save map data
|
// Save map data
|
||||||
$saveMapQuery = "UPDATE `" . MapManager::TABLE_MAPS . "`
|
$saveMapQuery = "UPDATE `" . MapManager::TABLE_MAPS . "`
|
||||||
@ -269,6 +288,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
|||||||
* @param callable $function
|
* @param callable $function
|
||||||
*/
|
*/
|
||||||
public function fetchMapInfo($mapId, callable $function) {
|
public function fetchMapInfo($mapId, callable $function) {
|
||||||
|
if (!$this->enabled) return;
|
||||||
// For TM2020
|
// For TM2020
|
||||||
if ($this->maniaControl->getServer()->titleId == "Trackmania") {
|
if ($this->maniaControl->getServer()->titleId == "Trackmania") {
|
||||||
// Get Title Prefix
|
// Get Title Prefix
|
||||||
@ -335,6 +355,7 @@ class ManiaExchangeManager implements UsageInformationAble {
|
|||||||
* @see \ManiaControl\ManiaExchange\ManiaExchangeMapSearch
|
* @see \ManiaControl\ManiaExchange\ManiaExchangeMapSearch
|
||||||
*/
|
*/
|
||||||
public function fetchMapsAsync(callable $function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $sortOrder = ManiaExchangeMapSearch::SEARCH_ORDER_UPDATED_NEWEST) {
|
public function fetchMapsAsync(callable $function, $name = '', $author = '', $env = '', $maxMapsReturned = 100, $sortOrder = ManiaExchangeMapSearch::SEARCH_ORDER_UPDATED_NEWEST) {
|
||||||
|
if (!$this->enabled) return;
|
||||||
$mapSearch = new ManiaExchangeMapSearch($this->maniaControl);
|
$mapSearch = new ManiaExchangeMapSearch($this->maniaControl);
|
||||||
$mapSearch->setMapName($name);
|
$mapSearch->setMapName($name);
|
||||||
$mapSearch->setAuthorName($author);
|
$mapSearch->setAuthorName($author);
|
||||||
|
@ -140,6 +140,8 @@ class ManiaExchangeMapSearch implements UsageInformationAble {
|
|||||||
* @param callable $function
|
* @param callable $function
|
||||||
*/
|
*/
|
||||||
public function fetchMapsAsync(callable $function) {
|
public function fetchMapsAsync(callable $function) {
|
||||||
|
if (!$this->maniaControl->getMapManager()->getMXManager()->getStatus()) return;
|
||||||
|
|
||||||
// compile search URL
|
// compile search URL
|
||||||
$parameters = "";
|
$parameters = "";
|
||||||
|
|
||||||
|
@ -506,7 +506,7 @@ class DirectoryBrowser implements ManialinkPageAnswerListener {
|
|||||||
|
|
||||||
if ($filename !== null) {
|
if ($filename !== null) {
|
||||||
if ($isUtf8 && strpos($filename, "utf-8''") === 0 && $filename = substr($filename, strlen("utf-8''"))) {
|
if ($isUtf8 && strpos($filename, "utf-8''") === 0 && $filename = substr($filename, strlen("utf-8''"))) {
|
||||||
$filePath = $folderPath . rawurldecode($filename);
|
$filePath = $folderPath . FileUtil::getClearedFileName(rawurldecode($filename));
|
||||||
}
|
}
|
||||||
if (substr($filename, 0, 1) === '"' && substr($filename, -1, 1) === '"') {
|
if (substr($filename, 0, 1) === '"' && substr($filename, -1, 1) === '"') {
|
||||||
$filePath = $folderPath . substr($filename, 1, -1);
|
$filePath = $folderPath . substr($filename, 1, -1);
|
||||||
|
@ -8,6 +8,7 @@ use FML\Controls\Quads\Quad_UIConstruction_Buttons;
|
|||||||
use ManiaControl\Admin\AuthenticationManager;
|
use ManiaControl\Admin\AuthenticationManager;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
|
use ManiaControl\Callbacks\Callbacks;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
use ManiaControl\Logger;
|
use ManiaControl\Logger;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
@ -49,7 +50,6 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
*/
|
*/
|
||||||
public function __construct(ManiaControl $maniaControl) {
|
public function __construct(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
$this->initActionsMenuButtons();
|
|
||||||
|
|
||||||
// Admin commands
|
// Admin commands
|
||||||
$this->maniaControl->getCommandManager()->registerCommandListener(array('nextmap', 'next', 'skip'), $this, 'command_NextMap', true, 'Skips to the next map.');
|
$this->maniaControl->getCommandManager()->registerCommandListener(array('nextmap', 'next', 'skip'), $this, 'command_NextMap', true, 'Skips to the next map.');
|
||||||
@ -68,6 +68,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
$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.');
|
||||||
|
|
||||||
// Callbacks
|
// Callbacks
|
||||||
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
|
||||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_OPEN_XLIST, $this, 'command_xList');
|
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_OPEN_XLIST, $this, 'command_xList');
|
||||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_OPEN_MAPLIST, $this, 'command_List');
|
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_OPEN_MAPLIST, $this, 'command_List');
|
||||||
@ -75,16 +76,22 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb
|
|||||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SKIP_MAP, $this, 'command_NextMap');
|
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SKIP_MAP, $this, 'command_NextMap');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function handleAfterInit() {
|
||||||
|
$this->initActionsMenuButtons();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add all Actions Menu Buttons
|
* Add all Actions Menu Buttons
|
||||||
*/
|
*/
|
||||||
private function initActionsMenuButtons() {
|
private function initActionsMenuButtons() {
|
||||||
// Menu Open xList
|
// Menu Open xList
|
||||||
$itemQuad = new Quad();
|
if ($this->maniaControl->getMapManager()->getMXManager()->getStatus()) {
|
||||||
$itemQuad->setImageUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON));
|
$itemQuad = new Quad();
|
||||||
$itemQuad->setImageFocusUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_MOVER));
|
$itemQuad->setImageUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON));
|
||||||
$itemQuad->setAction(self::ACTION_OPEN_XLIST);
|
$itemQuad->setImageFocusUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_MOVER));
|
||||||
$this->maniaControl->getActionsMenu()->addPlayerMenuItem($itemQuad, 5, 'Open MX List');
|
$itemQuad->setAction(self::ACTION_OPEN_XLIST);
|
||||||
|
$this->maniaControl->getActionsMenu()->addPlayerMenuItem($itemQuad, 5, 'Open MX List');
|
||||||
|
}
|
||||||
|
|
||||||
// Menu Open List
|
// Menu Open List
|
||||||
$itemQuad = new Quad_Icons64x64_1();
|
$itemQuad = new Quad_Icons64x64_1();
|
||||||
|
@ -111,6 +111,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
*/
|
*/
|
||||||
public function checkUpdates(array $chatCallback, Player $player) {
|
public function checkUpdates(array $chatCallback, Player $player) {
|
||||||
// Update Mx Infos
|
// Update Mx Infos
|
||||||
|
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_CHECK_UPDATE)) return;
|
||||||
|
|
||||||
$this->maniaControl->getMapManager()->getMXManager()->fetchManiaExchangeMapInformation();
|
$this->maniaControl->getMapManager()->getMXManager()->fetchManiaExchangeMapInformation();
|
||||||
|
|
||||||
// Reshow the Maplist
|
// Reshow the Maplist
|
||||||
@ -340,7 +342,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$description = $map->getEscapedName() . ' is on Map-Queue Position: ' . $queuedMaps[$map->uid];
|
$description = $map->getEscapedName() . ' is on Map-Queue Position: ' . $queuedMaps[$map->uid];
|
||||||
$label->addTooltipLabelFeature($descriptionLabel, $description);
|
$label->addTooltipLabelFeature($descriptionLabel, $description);
|
||||||
}
|
}
|
||||||
} else {
|
} else if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapQueue::SETTING_PERMISSION_ADD_TO_QUEUE)) {
|
||||||
// Map-Queue-Map-Button
|
// Map-Queue-Map-Button
|
||||||
$queueLabel = new Label_Button();
|
$queueLabel = new Label_Button();
|
||||||
$mapFrame->addChild($queueLabel);
|
$mapFrame->addChild($queueLabel);
|
||||||
@ -584,6 +586,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case self::ACTION_SWITCH_MAP:
|
case self::ACTION_SWITCH_MAP:
|
||||||
|
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_SKIP_MAP)) return;
|
||||||
|
|
||||||
// Don't queue on Map-Change
|
// Don't queue on Map-Change
|
||||||
$this->maniaControl->getMapManager()->getMapQueue()->dontQueueNextMapChange();
|
$this->maniaControl->getMapManager()->getMapQueue()->dontQueueNextMapChange();
|
||||||
try {
|
try {
|
||||||
|
@ -19,6 +19,8 @@ use ManiaControl\ManiaExchange\ManiaExchangeList;
|
|||||||
use ManiaControl\ManiaExchange\ManiaExchangeManager;
|
use ManiaControl\ManiaExchange\ManiaExchangeManager;
|
||||||
use ManiaControl\ManiaExchange\MXMapInfo;
|
use ManiaControl\ManiaExchange\MXMapInfo;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
|
use ManiaControl\Settings\Setting;
|
||||||
|
use ManiaControl\Settings\SettingManager;
|
||||||
use ManiaControl\Utils\Formatter;
|
use ManiaControl\Utils\Formatter;
|
||||||
use Maniaplanet\DedicatedServer\InvalidArgumentException;
|
use Maniaplanet\DedicatedServer\InvalidArgumentException;
|
||||||
use Maniaplanet\DedicatedServer\Xmlrpc\AlreadyInListException;
|
use Maniaplanet\DedicatedServer\Xmlrpc\AlreadyInListException;
|
||||||
@ -56,6 +58,7 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
|||||||
const SETTING_AUTOSAVE_MAPLIST = 'Autosave Maplist file';
|
const SETTING_AUTOSAVE_MAPLIST = 'Autosave Maplist file';
|
||||||
const SETTING_MAPLIST_FILE = 'File to write Maplist in';
|
const SETTING_MAPLIST_FILE = 'File to write Maplist in';
|
||||||
const SETTING_WRITE_OWN_MAPLIST_FILE = 'Write a own Maplist File for every Server called serverlogin.txt';
|
const SETTING_WRITE_OWN_MAPLIST_FILE = 'Write a own Maplist File for every Server called serverlogin.txt';
|
||||||
|
const SETTING_ENABLE_MX = 'Enable MX features';
|
||||||
|
|
||||||
const SEARCH_BY_AUTHOR = 'Author';
|
const SEARCH_BY_AUTHOR = 'Author';
|
||||||
const SEARCH_BY_MAP_NAME = 'Mapname';
|
const SEARCH_BY_MAP_NAME = 'Mapname';
|
||||||
@ -116,6 +119,7 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
|||||||
// Callbacks
|
// Callbacks
|
||||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
|
||||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit');
|
||||||
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings');
|
||||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_MAPLISTMODIFIED, $this, 'mapsModified');
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_MAPLISTMODIFIED, $this, 'mapsModified');
|
||||||
|
|
||||||
// Permissions
|
// Permissions
|
||||||
@ -131,6 +135,9 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
|||||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_AUTOSAVE_MAPLIST, true);
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_AUTOSAVE_MAPLIST, true);
|
||||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAPLIST_FILE, "MatchSettings/tracklist.txt");
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAPLIST_FILE, "MatchSettings/tracklist.txt");
|
||||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WRITE_OWN_MAPLIST_FILE, false);
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WRITE_OWN_MAPLIST_FILE, false);
|
||||||
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_ENABLE_MX, true);
|
||||||
|
|
||||||
|
$this->mxManager->setStatus($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_ENABLE_MX, true));
|
||||||
|
|
||||||
//Initlaize Communication Listenings
|
//Initlaize Communication Listenings
|
||||||
$this->initalizeCommunicationListenings();
|
$this->initalizeCommunicationListenings();
|
||||||
@ -188,6 +195,8 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
|||||||
* @param string $uid
|
* @param string $uid
|
||||||
*/
|
*/
|
||||||
public function updateMap($admin, $uid) {
|
public function updateMap($admin, $uid) {
|
||||||
|
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_ADD_MAP)) return;
|
||||||
|
|
||||||
$this->updateMapTimestamp($uid);
|
$this->updateMapTimestamp($uid);
|
||||||
|
|
||||||
if (!isset($uid) || !isset($this->maps[$uid])) {
|
if (!isset($uid) || !isset($this->maps[$uid])) {
|
||||||
@ -213,6 +222,19 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Settings
|
||||||
|
*
|
||||||
|
* @param ?Setting $setting
|
||||||
|
*/
|
||||||
|
public function updateSettings(Setting $setting = null) {
|
||||||
|
if (!isset($setting) || !$setting->belongsToClass($this)) return;
|
||||||
|
|
||||||
|
if ($setting->setting === self::SETTING_ENABLE_MX) {
|
||||||
|
$this->mxManager->setStatus($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_ENABLE_MX, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the Timestamp of a Map
|
* Update the Timestamp of a Map
|
||||||
*
|
*
|
||||||
@ -252,6 +274,8 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function removeMap($admin, $uid, $eraseFile = false, $message = true) {
|
public function removeMap($admin, $uid, $eraseFile = false, $message = true) {
|
||||||
|
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_REMOVE_MAP)) return;
|
||||||
|
|
||||||
if (!isset($this->maps[$uid])) {
|
if (!isset($this->maps[$uid])) {
|
||||||
if ($admin) {
|
if ($admin) {
|
||||||
$this->maniaControl->getChat()->sendError('Map does not exist!', $admin);
|
$this->maniaControl->getChat()->sendError('Map does not exist!', $admin);
|
||||||
|
@ -36,6 +36,7 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
|||||||
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_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_ADD_TO_QUEUE = 'Add map to queue';
|
||||||
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';
|
||||||
|
|
||||||
@ -74,6 +75,7 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
|||||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_BUFFERSIZE, 10);
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_BUFFERSIZE, 10);
|
||||||
|
|
||||||
// Permissions
|
// Permissions
|
||||||
|
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_ADD_TO_QUEUE, AuthenticationManager::AUTH_LEVEL_PLAYER, AuthenticationManager::AUTH_LEVEL_PLAYER);
|
||||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_CLEAR_MAPQUEUE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_CLEAR_MAPQUEUE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_QUEUE_BUFFER, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_QUEUE_BUFFER, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||||
|
|
||||||
@ -283,6 +285,8 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_ADD_TO_QUEUE)) return;
|
||||||
|
|
||||||
// Check if the Player is muted
|
// Check if the Player is muted
|
||||||
if ($player->isMuted()) {
|
if ($player->isMuted()) {
|
||||||
$this->maniaControl->getChat()->sendError('Muted Players are not allowed to queue a map.', $player);
|
$this->maniaControl->getChat()->sendError('Muted Players are not allowed to queue a map.', $player);
|
||||||
@ -369,6 +373,10 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl
|
|||||||
if (!isset($this->queuedMaps[$uid])) {
|
if (!isset($this->queuedMaps[$uid])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$queuer = $this->maniaControl->getMapManager()->getMapQueue()->getQueuer($uid);
|
||||||
|
if (($queuer === null || $queuer->login !== $player->login) && !$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)) return;
|
||||||
|
|
||||||
/** @var Map $map */
|
/** @var Map $map */
|
||||||
$map = $this->queuedMaps[$uid][1];
|
$map = $this->queuedMaps[$uid][1];
|
||||||
unset($this->queuedMaps[$uid]);
|
unset($this->queuedMaps[$uid]);
|
||||||
|
Loading…
Reference in New Issue
Block a user