Compare commits

...

5 Commits

Author SHA1 Message Date
beu
1ea9abfcda fix error when having one map and no re-order setting value 2025-09-03 09:03:41 +02:00
beu
8796898167 fix error when using only #NAME# only 2025-08-27 21:53:02 +02:00
beu
35495dd547 fix admin not added when loading guestlist 2025-08-27 21:41:01 +02:00
beu
bad46e207f fix kick player 2025-08-27 21:38:22 +02:00
beu
381c91d5e9 fix setting initialization 2025-08-11 22:31:05 +02:00
4 changed files with 87 additions and 85 deletions

View File

@@ -23,7 +23,7 @@ class GuestlistManager implements CommandListener, CallbackListener, TimerListen
* Constants
*/
const PLUGIN_ID = 154;
const PLUGIN_VERSION = 2.4;
const PLUGIN_VERSION = 2.5;
const PLUGIN_NAME = 'Guestlist Manager';
const PLUGIN_AUTHOR = 'Beu';
@@ -288,7 +288,7 @@ class GuestlistManager implements CommandListener, CallbackListener, TimerListen
public function handleLoad(Array $chat, Player $player) {
$guestlist = '';
$text = explode(" ",$chat[1][2]);
$text = explode(" ", $chat[1][2]);
if (count($text) > 1 && $text[1] != "") {
$guestlist = $text[1];
@@ -321,6 +321,8 @@ class GuestlistManager implements CommandListener, CallbackListener, TimerListen
$this->maniaControl->getChat()->sendError("Can't load guestlist: ". $th->getMessage(), $player);
Logger::logError("Can't load guestlist: ". $th->getMessage());
}
$this->addAdminsToGuestlist();
}
/**
@@ -539,7 +541,7 @@ class GuestlistManager implements CommandListener, CallbackListener, TimerListen
if (!in_array($player->login, $guests)) {
try {
Logger::log('Player "'. $player->nickname .'" kicked from the server as not guestlisted');
$this->maniaControl->getClient()->kick($player->nickname, "You are not guestlisted on the server");
$this->maniaControl->getClient()->kick($player->login, "You are not guestlisted on the server");
$kicked++;
} catch (\Throwable $th) {
Logger::logError("Can't kick ". $player->nickname .": ". $th->getMessage());

View File

@@ -43,7 +43,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
* MARK: Constants
*/
const PLUGIN_ID = 152;
const PLUGIN_VERSION = 6.0;
const PLUGIN_VERSION = 6.1;
const PLUGIN_NAME = 'MatchManager Core';
const PLUGIN_AUTHOR = 'Beu';
@@ -840,71 +840,72 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
* @param Setting $setting
*/
public function updateSettings(?Setting $setting = null) {
if ($setting === null || !$setting->belongsToClass($this)) return;
if ($this->matchStarted) {
if ($setting->setting == self::SETTING_MATCH_GAMEMODE_BASE && $setting->value != $this->currentgmbase) {
$setting->value = $this->currentgmbase;
$this->maniaControl->getSettingManager()->saveSetting($setting);
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'You can\'t change Gamemode during a Match');
} else if ($setting->setting == self::SETTING_MATCH_CUSTOM_GAMEMODE && $setting->value != $this->currentcustomgm) {
$setting->value = $this->currentcustomgm;
$this->maniaControl->getSettingManager()->saveSetting($setting);
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'You can\'t change the Custom Gamemode during a Match');
} else if ($setting->setting == self::SETTING_MATCH_SETTINGS_MODE && $setting->value != $this->currentsettingmode) {
$setting->value = $this->currentsettingmode;
$this->maniaControl->getSettingManager()->saveSetting($setting);
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'You can\'t change the Setting Mode during a Match');
} else if ($setting->setting == self::SETTING_MODE_HIDENEXTMAPS && $setting->value != $this->hidenextmaps) {
$setting->value = $this->hidenextmaps;
$this->maniaControl->getSettingManager()->saveSetting($setting);
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'It\'s not possible to choose to hide or display the maps during a match');
} else {
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_SETTINGS_MODE) != 'All from file') {
$this->log("Load Script Settings");
try {
$this->loadGMSettings($this->getGMSettings($this->currentgmbase,$this->currentcustomgm));
$this->log("Parameters updated");
$this->maniaControl->getChat()->sendSuccessToAdmins(self::CHAT_PREFIX . 'Parameters updated');
} catch (InvalidArgumentException $e) {
$this->log("Parameters not updated");
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Parameters not updated');
}
$this->updateGMvariables();
if ($setting !== null && $setting->belongsToClass($this)) {
if ($this->matchStarted) {
if ($setting->setting == self::SETTING_MATCH_GAMEMODE_BASE && $setting->value != $this->currentgmbase) {
$setting->value = $this->currentgmbase;
$this->maniaControl->getSettingManager()->saveSetting($setting);
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'You can\'t change Gamemode during a Match');
} else if ($setting->setting == self::SETTING_MATCH_CUSTOM_GAMEMODE && $setting->value != $this->currentcustomgm) {
$setting->value = $this->currentcustomgm;
$this->maniaControl->getSettingManager()->saveSetting($setting);
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'You can\'t change the Custom Gamemode during a Match');
} else if ($setting->setting == self::SETTING_MATCH_SETTINGS_MODE && $setting->value != $this->currentsettingmode) {
$setting->value = $this->currentsettingmode;
$this->maniaControl->getSettingManager()->saveSetting($setting);
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'You can\'t change the Setting Mode during a Match');
} else if ($setting->setting == self::SETTING_MODE_HIDENEXTMAPS && $setting->value != $this->hidenextmaps) {
$setting->value = $this->hidenextmaps;
$this->maniaControl->getSettingManager()->saveSetting($setting);
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'It\'s not possible to choose to hide or display the maps during a match');
} else {
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Settings are loaded by Matchsettings file only.');
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_SETTINGS_MODE) != 'All from file') {
$this->log("Load Script Settings");
try {
$this->loadGMSettings($this->getGMSettings($this->currentgmbase,$this->currentcustomgm));
$this->log("Parameters updated");
$this->maniaControl->getChat()->sendSuccessToAdmins(self::CHAT_PREFIX . 'Parameters updated');
} catch (InvalidArgumentException $e) {
$this->log("Parameters not updated");
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Parameters not updated');
}
$this->updateGMvariables();
} else {
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Settings are loaded by Matchsettings file only.');
}
}
}
} else {
if ($setting->setting == self::SETTING_MATCH_GAMEMODE_BASE && in_array($setting->value, ['TMWC2023', 'TMWT2025', 'TMWTTeams']) && $this->maniaControl->getPluginManager()->getPlugin(self::MATCHMANAGERTMWTDUOINTEGRATION_PLUGIN) === null) {
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . "It's highly recommanded to use the \"MatchManager TMWT Duo Integration\" plugin with TMWT based gamemodes.");
} else if ($setting->setting == self::SETTING_MATCH_CUSTOM_GAMEMODE && $setting->value != "") {
$scriptfile = $this->maniaControl->getServer()->getDirectory()->getUserDataFolder() . DIRECTORY_SEPARATOR . "Scripts" . DIRECTORY_SEPARATOR . "Modes" . DIRECTORY_SEPARATOR . $setting->value;
if (!file_exists($scriptfile)) {
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Unable to find the gamemode file: "' . $setting->value . '"');
}
} else if ($setting->setting == self::SETTING_MODE_MAPLIST_FILE && $setting->value != "") {
$scriptfile = $this->maniaControl->getServer()->getDirectory()->getMapsFolder() ."MatchSettings" . DIRECTORY_SEPARATOR . $setting->value;
if (!file_exists($scriptfile)) {
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Unable to find the Maplist file: "' . $setting->value . '"');
}
} else if ($setting->setting == self::SETTING_MATCH_POST_MATCH_MAPLIST && $setting->value != "") {
$scriptfile = $this->maniaControl->getServer()->getDirectory()->getMapsFolder() ."MatchSettings" . DIRECTORY_SEPARATOR . $setting->value;
if (!file_exists($scriptfile)) {
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Unable to find the Post match Maplist file: "' . $setting->value . '"');
}
} else if ($setting->setting == self::SETTING_MODE_MAPS && $setting->value != "") {
$maps = explode(',', $setting->value);
foreach ($maps as $map) {
try {
$this->maniaControl->getClient()->getMapInfo($map);
} catch (\Exception $e) {
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Unable to find the map: "' . $map . '"');
} else {
if ($setting->setting == self::SETTING_MATCH_GAMEMODE_BASE && in_array($setting->value, ['TMWC2023', 'TMWT2025', 'TMWTTeams']) && $this->maniaControl->getPluginManager()->getPlugin(self::MATCHMANAGERTMWTDUOINTEGRATION_PLUGIN) === null) {
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . "It's highly recommanded to use the \"MatchManager TMWT Duo Integration\" plugin with TMWT based gamemodes.");
} else if ($setting->setting == self::SETTING_MATCH_CUSTOM_GAMEMODE && $setting->value != "") {
$scriptfile = $this->maniaControl->getServer()->getDirectory()->getUserDataFolder() . DIRECTORY_SEPARATOR . "Scripts" . DIRECTORY_SEPARATOR . "Modes" . DIRECTORY_SEPARATOR . $setting->value;
if (!file_exists($scriptfile)) {
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Unable to find the gamemode file: "' . $setting->value . '"');
}
} else if ($setting->setting == self::SETTING_MODE_MAPLIST_FILE && $setting->value != "") {
$scriptfile = $this->maniaControl->getServer()->getDirectory()->getMapsFolder() ."MatchSettings" . DIRECTORY_SEPARATOR . $setting->value;
if (!file_exists($scriptfile)) {
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Unable to find the Maplist file: "' . $setting->value . '"');
}
} else if ($setting->setting == self::SETTING_MATCH_POST_MATCH_MAPLIST && $setting->value != "") {
$scriptfile = $this->maniaControl->getServer()->getDirectory()->getMapsFolder() ."MatchSettings" . DIRECTORY_SEPARATOR . $setting->value;
if (!file_exists($scriptfile)) {
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Unable to find the Post match Maplist file: "' . $setting->value . '"');
}
} else if ($setting->setting == self::SETTING_MODE_MAPS && $setting->value != "") {
$maps = explode(',', $setting->value);
foreach ($maps as $map) {
try {
$this->maniaControl->getClient()->getMapInfo($map);
} catch (\Exception $e) {
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Unable to find the map: "' . $map . '"');
}
}
}
}
}
if ($setting->setting === self::SETTING_MATCH_SETTINGS_MODE || $setting->setting === self::SETTING_MATCH_GAMEMODE_BASE || $setting->setting === self::SETTING_MATCH_CUSTOM_GAMEMODE) {
if ($setting === null || $setting->setting === self::SETTING_MATCH_SETTINGS_MODE || $setting->setting === self::SETTING_MATCH_GAMEMODE_BASE || $setting->setting === self::SETTING_MATCH_CUSTOM_GAMEMODE) {
$deletesettings = true;
if (defined("\ManiaControl\ManiaControl::ISTRACKMANIACONTROL") && $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getSettingManager(), SettingManager::SETTING_ALLOW_UNLINK_SERVER)) {
$deletesettings = !$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_DONT_DELETE_SETTINGS);

View File

@@ -39,7 +39,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
* Constants
*/
const PLUGIN_ID = 156;
const PLUGIN_VERSION = 2.4;
const PLUGIN_VERSION = 2.5;
const PLUGIN_NAME = 'MatchManager GSheet';
const PLUGIN_AUTHOR = 'Beu';
@@ -110,11 +110,8 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
private $matchstatus = "";
private $device_code = "";
private $access_token = "";
private $matchid = "";
private $currentdatamode = "";
private $playerlist = array();
/**
* @param \ManiaControl\ManiaControl $maniaControl
* @see \ManiaControl\Plugins\Plugin::prepare()
@@ -592,12 +589,12 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
}
}
private function getSheetName() {
private function getSheetName(string $matchid) {
$sheetname = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERGSHEET_SHEETNAME);
$login = $this->maniaControl->getServer()->login;
$server_name = $this->maniaControl->getClient()->getServerName();
$sheetname = str_replace("#MATCHID#", $this->matchid, $sheetname);
$sheetname = str_replace("#MATCHID#", $matchid, $sheetname);
$sheetname = str_replace("#LOGIN#", $login, $sheetname);
$sheetname = str_replace("#NAME#", $server_name, $sheetname);
$sheetname = str_replace("#DATE#", date("Y-m-d"), $sheetname);
@@ -611,7 +608,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
$spreadsheetid = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERGSHEET_SPREADSHEET);
if ($spreadsheetid === "") return;
$sheetname = $this->getSheetName();
$sheetname = $this->getSheetName($matchid);
if ($sheetname === "") return;
foreach ($currentscore as $key => $score) {
@@ -779,11 +776,10 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
$spreadsheetid = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERGSHEET_SPREADSHEET);
if ($spreadsheetid === "") return;
$sheetname = $this->getSheetName();
$sheetname = $this->getSheetName($matchid);
if ($sheetname === "") return;
if ($this->refreshTokenIfNeeded()) {
$this->matchid = $matchid;
$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, 'https://sheets.googleapis.com/v4/spreadsheets/' . $spreadsheetid);
$asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON);
$asyncHttpRequest->setHeaders(array("Authorization: Bearer " . $this->access_token));

View File

@@ -37,7 +37,7 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
* Constants
*/
const PLUGIN_ID = 211;
const PLUGIN_VERSION = 1.2;
const PLUGIN_VERSION = 1.3;
const PLUGIN_NAME = 'MatchManager TMWT Duo Integration';
const PLUGIN_AUTHOR = 'Beu';
@@ -326,9 +326,8 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
$this->maniaControl->getClient()->setModeScriptSettings(['S_IsMatchmaking' => true], false);
$this->maniaControl->getClient()->restartMap();
} else if ($this->state === self::STATE_PREMATCH) {
$teamsUrl = $this->maniaControl->getSettingManager()->getSettingValue($this->MatchManagerCore, 'S_TeamsUrl');
if ($teamsUrl !== '') {
if ($teamsUrl !== null && $teamsUrl !== '') {
$response = WebReader::getUrl($teamsUrl);
$content = $response->getContent();
$json = json_decode($content);
@@ -416,19 +415,23 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
$mapUids = array_column($json->playlist, 'uid');
$order = explode(',', $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_PICKANDBAN_OVERRIDEMAPORDER));
$mapOrderSetting = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_PICKANDBAN_OVERRIDEMAPORDER);
if (count($order) === count($mapUids)) {
$this->log("Re-ordering maps");
try {
$orderedMapUid = [];
foreach ($order as $number) {
$orderedMapUid[] = $mapUids[$number - 1];
if ($mapOrderSetting !== '') {
$order = array_map('trim', explode(',', $mapOrderSetting));
if (count($order) === count($mapUids)) {
$this->log("Re-ordering maps");
try {
$orderedMapUid = [];
foreach ($order as $number) {
$orderedMapUid[] = $mapUids[$number - 1];
}
$mapUids = $orderedMapUid;
} catch (\Throwable $th) {
$this->logError("Invalid Map order setting");
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() ."Invalid Map order setting");
}
$mapUids = $orderedMapUid;
} catch (\Throwable $th) {
$this->logError("Invalid Map order setting");
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() ."Invalid Map order setting");
}
}