Compare commits

..

8 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
beu
c4ab2e06eb add TMWT 2025 mode 2025-07-25 21:51:16 +02:00
beu
21ad912a38 fix comment 2025-07-25 21:49:52 +02:00
beu
7c54565845 add message chen saving guestlist 2025-07-25 17:41:03 +02:00
4 changed files with 130 additions and 99 deletions

View File

@@ -23,7 +23,7 @@ class GuestlistManager implements CommandListener, CallbackListener, TimerListen
* Constants * Constants
*/ */
const PLUGIN_ID = 154; const PLUGIN_ID = 154;
const PLUGIN_VERSION = 2.3; const PLUGIN_VERSION = 2.5;
const PLUGIN_NAME = 'Guestlist Manager'; const PLUGIN_NAME = 'Guestlist Manager';
const PLUGIN_AUTHOR = 'Beu'; const PLUGIN_AUTHOR = 'Beu';
@@ -288,7 +288,7 @@ class GuestlistManager implements CommandListener, CallbackListener, TimerListen
public function handleLoad(Array $chat, Player $player) { public function handleLoad(Array $chat, Player $player) {
$guestlist = ''; $guestlist = '';
$text = explode(" ",$chat[1][2]); $text = explode(" ", $chat[1][2]);
if (count($text) > 1 && $text[1] != "") { if (count($text) > 1 && $text[1] != "") {
$guestlist = $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); $this->maniaControl->getChat()->sendError("Can't load guestlist: ". $th->getMessage(), $player);
Logger::logError("Can't load guestlist: ". $th->getMessage()); Logger::logError("Can't load guestlist: ". $th->getMessage());
} }
$this->addAdminsToGuestlist();
} }
/** /**
@@ -348,6 +350,8 @@ class GuestlistManager implements CommandListener, CallbackListener, TimerListen
} }
try { try {
$this->maniaControl->getChat()->sendSuccess("Saving guestlist...", $player);
$filepath = $this->maniaControl->getServer()->getDirectory()->getUserDataFolder() . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . $guestlist; $filepath = $this->maniaControl->getServer()->getDirectory()->getUserDataFolder() . DIRECTORY_SEPARATOR . "Config" . DIRECTORY_SEPARATOR . $guestlist;
$directory = dirname($filepath); $directory = dirname($filepath);
@@ -537,7 +541,7 @@ class GuestlistManager implements CommandListener, CallbackListener, TimerListen
if (!in_array($player->login, $guests)) { if (!in_array($player->login, $guests)) {
try { try {
Logger::log('Player "'. $player->nickname .'" kicked from the server as not guestlisted'); 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++; $kicked++;
} catch (\Throwable $th) { } catch (\Throwable $th) {
Logger::logError("Can't kick ". $player->nickname .": ". $th->getMessage()); Logger::logError("Can't kick ". $player->nickname .": ". $th->getMessage());

View File

@@ -43,7 +43,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
* MARK: Constants * MARK: Constants
*/ */
const PLUGIN_ID = 152; const PLUGIN_ID = 152;
const PLUGIN_VERSION = 5.9; const PLUGIN_VERSION = 6.1;
const PLUGIN_NAME = 'MatchManager Core'; const PLUGIN_NAME = 'MatchManager Core';
const PLUGIN_AUTHOR = 'Beu'; const PLUGIN_AUTHOR = 'Beu';
@@ -61,6 +61,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
// Other MatchManager plugin // Other MatchManager plugin
const MATCHMANAGERADMINUI_PLUGIN = 'MatchManagerSuite\MatchManagerAdminUI'; const MATCHMANAGERADMINUI_PLUGIN = 'MatchManagerSuite\MatchManagerAdminUI';
const MATCHMANAGERTMWTDUOINTEGRATION_PLUGIN = 'MatchManagerSuite\MatchManagerTMWTDuoIntegration';
// Actions // Actions
const ML_ACTION_OPENSETTINGS = 'MatchManagerSuite\MatchManagerCore.OpenSettings'; const ML_ACTION_OPENSETTINGS = 'MatchManagerSuite\MatchManagerCore.OpenSettings';
@@ -100,13 +101,17 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
const SETTING_MATCH_S_CUMULATEPOINTS = 'S_CumulatePoints'; const SETTING_MATCH_S_CUMULATEPOINTS = 'S_CumulatePoints';
const SETTING_MATCH_S_DISABLEGIVEUP = 'S_DisableGiveUp'; const SETTING_MATCH_S_DISABLEGIVEUP = 'S_DisableGiveUp';
const SETTING_MATCH_S_DISABLEGOTOMAP = 'S_DisableGoToMap'; const SETTING_MATCH_S_DISABLEGOTOMAP = 'S_DisableGoToMap';
const SETTING_MATCH_S_DISABLEMATCHINTRO = 'S_DisableMatchIntro';
const SETTING_MATCH_S_EARLYENDMATCHCALLBACK = 'S_EarlyEndMatchCallback'; const SETTING_MATCH_S_EARLYENDMATCHCALLBACK = 'S_EarlyEndMatchCallback';
const SETTING_MATCH_S_ELIMINATEDPLAYERSNBRANKS = 'S_EliminatedPlayersNbRanks'; const SETTING_MATCH_S_ELIMINATEDPLAYERSNBRANKS = 'S_EliminatedPlayersNbRanks';
const SETTING_MATCH_S_ENABLEDOSSARDCOLOR = 'S_EnableDossardColor'; const SETTING_MATCH_S_ENABLEDOSSARDCOLOR = 'S_EnableDossardColor';
const SETTING_MATCH_S_FINISHTIMEOUT = 'S_FinishTimeout'; const SETTING_MATCH_S_FINISHTIMEOUT = 'S_FinishTimeout';
const SETTING_MATCH_S_FORCELAPSNB = 'S_ForceLapsNb'; const SETTING_MATCH_S_FORCELAPSNB = 'S_ForceLapsNb';
const SETTING_MATCH_S_FORCEROADSPECTATORSNB = 'S_ForceRoadSpectatorsNb'; const SETTING_MATCH_S_FORCEROADSPECTATORSNB = 'S_ForceRoadSpectatorsNb';
const SETTING_MATCH_S_HEADERLOGOURL = 'S_HeaderLogoUrl';
const SETTING_MATCH_S_INFINITELAPS = 'S_InfiniteLaps'; const SETTING_MATCH_S_INFINITELAPS = 'S_InfiniteLaps';
const SETTING_MATCH_S_INTROBACKGROUNDURL = 'S_IntroBackgroundUrl';
const SETTING_MATCH_S_INTROLOGOURL = 'S_IntroLogoUrl';
const SETTING_MATCH_S_LOADINGSCREENIMAGEURL = 'S_LoadingScreenImageUrl'; const SETTING_MATCH_S_LOADINGSCREENIMAGEURL = 'S_LoadingScreenImageUrl';
const SETTING_MATCH_S_MAPPOINTSLIMIT = 'S_MapPointsLimit'; const SETTING_MATCH_S_MAPPOINTSLIMIT = 'S_MapPointsLimit';
const SETTING_MATCH_S_MAPSPERMATCH = 'S_MapsPerMatch'; const SETTING_MATCH_S_MAPSPERMATCH = 'S_MapsPerMatch';
@@ -139,7 +144,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
'default' => 10, 'default' => 10,
'description' => 'Time before loading the next map' ], 'description' => 'Time before loading the next map' ],
self::SETTING_MATCH_S_CRASHDETECTIONTHRESHOLD => [ self::SETTING_MATCH_S_CRASHDETECTIONTHRESHOLD => [
'gamemode' => ['TMWC2023'], 'gamemode' => ['TMWC2023', 'TMWT2025'],
'type' => 'integer', 'type' => 'integer',
'default' => 2000, 'default' => 2000,
'description' => 'Time delta in ms with the first player that will be considered as a crash' ], 'description' => 'Time delta in ms with the first player that will be considered as a crash' ],
@@ -158,8 +163,13 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
'type' => 'boolean', 'type' => 'boolean',
'default' => false, 'default' => false,
'description' => 'Disable the "Go To Map" in the Pause Menu' ], 'description' => 'Disable the "Go To Map" in the Pause Menu' ],
self::SETTING_MATCH_S_DISABLEMATCHINTRO => [
'gamemode' => ['TMWT2025'],
'type' => 'boolean',
'default' => false,
'description' => 'Disable match intro' ],
self::SETTING_MATCH_S_EARLYENDMATCHCALLBACK => [ self::SETTING_MATCH_S_EARLYENDMATCHCALLBACK => [
'gamemode' => ['Knockout', 'TMWC2023', 'TMWTTeams'], 'gamemode' => ['Knockout', 'TMWC2023', 'TMWT2025', 'TMWTTeams'],
'type' => 'boolean', 'type' => 'boolean',
'default' => true, 'default' => true,
'description' => 'Send End Match Callback early (expert user only)' ], 'description' => 'Send End Match Callback early (expert user only)' ],
@@ -169,12 +179,12 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
'default' => '4', 'default' => '4',
'description' => 'Rank at which one more player is eliminated per round (use coma to add more values. Ex COTD: 8,16,16)' ], 'description' => 'Rank at which one more player is eliminated per round (use coma to add more values. Ex COTD: 8,16,16)' ],
self::SETTING_MATCH_S_ENABLEDOSSARDCOLOR => [ self::SETTING_MATCH_S_ENABLEDOSSARDCOLOR => [
'gamemode' => ['TMWC2023', 'TMWTTeams'], 'gamemode' => ['TMWC2023', 'TMWT2025', 'TMWTTeams'],
'type' => 'boolean', 'type' => 'boolean',
'default' => true, 'default' => true,
'description' => 'Apply color team on the dossard' ], 'description' => 'Apply color team on the dossard' ],
self::SETTING_MATCH_S_FINISHTIMEOUT => [ self::SETTING_MATCH_S_FINISHTIMEOUT => [
'gamemode' => ['Cup', 'Knockout', 'Laps', 'Teams', 'TMWC2023', 'TMWTTeams', 'Rounds'], 'gamemode' => ['Cup', 'Knockout', 'Laps', 'Teams', 'TMWC2023', 'TMWT2025', 'TMWTTeams', 'Rounds'],
'type' => 'integer', 'type' => 'integer',
'default' => 10, 'default' => 10,
'description' => 'Time after the first finished (-1 = based on Author time)' ], 'description' => 'Time after the first finished (-1 = based on Author time)' ],
@@ -184,22 +194,37 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
'default' => -1, 'default' => -1,
'description' => 'Force number of laps for laps maps (-1 = author, 0 for unlimited in TA)' ], 'description' => 'Force number of laps for laps maps (-1 = author, 0 for unlimited in TA)' ],
self::SETTING_MATCH_S_FORCEROADSPECTATORSNB => [ self::SETTING_MATCH_S_FORCEROADSPECTATORSNB => [
'gamemode' => ['TMWC2023', 'TMWTTeams'], 'gamemode' => ['TMWC2023', 'TMWT2025', 'TMWTTeams'],
'type' => 'integer', 'type' => 'integer',
'default' => -1, 'default' => -1,
'description' => 'Force the number of spectators displayed on the border of the road' ], 'description' => 'Force the number of spectators displayed on the border of the road' ],
self::SETTING_MATCH_S_HEADERLOGOURL => [
'gamemode' => ['TMWT2025'],
'type' => 'string',
'default' => '',
'description' => 'Header logo URL' ],
self::SETTING_MATCH_S_INFINITELAPS => [ self::SETTING_MATCH_S_INFINITELAPS => [
'gamemode' => ['Global'], 'gamemode' => ['Global'],
'type' => 'boolean', 'type' => 'boolean',
'default' => false, 'default' => false,
'description' => 'Never end a race in laps (override S_ForceLapsNb)' ], 'description' => 'Never end a race in laps (override S_ForceLapsNb)' ],
self::SETTING_MATCH_S_INTROBACKGROUNDURL => [
'gamemode' => ['TMWT2025'],
'type' => 'string',
'default' => '',
'description' => 'Intro background URL' ],
self::SETTING_MATCH_S_INTROLOGOURL => [
'gamemode' => ['TMWT2025'],
'type' => 'string',
'default' => '',
'description' => 'Intro logo URL' ],
self::SETTING_MATCH_S_LOADINGSCREENIMAGEURL => [ self::SETTING_MATCH_S_LOADINGSCREENIMAGEURL => [
'gamemode' => ['Global'], 'gamemode' => ['Global'],
'type' => 'string', 'type' => 'string',
'default' => "", 'default' => "",
'description' => 'Image URL of the Loading Screen during the map change' ], 'description' => 'Image URL of the Loading Screen during the map change' ],
self::SETTING_MATCH_S_MAPPOINTSLIMIT => [ self::SETTING_MATCH_S_MAPPOINTSLIMIT => [
'gamemode' => ['TMWC2023', 'TMWTTeams'], 'gamemode' => ['TMWC2023', 'TMWT2025', 'TMWTTeams'],
'type' => 'integer', 'type' => 'integer',
'default' => 10, 'default' => 10,
'description' => 'Track points limit' ], 'description' => 'Track points limit' ],
@@ -209,12 +234,12 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
'default' => 3, 'default' => 3,
'description' => 'Number of maps maximum in the match' ], 'description' => 'Number of maps maximum in the match' ],
self::SETTING_MATCH_S_MATCHINFO => [ self::SETTING_MATCH_S_MATCHINFO => [
'gamemode' => ['TMWC2023', 'TMWTTeams'], 'gamemode' => ['TMWC2023', 'TMWT2025', 'TMWTTeams'],
'type' => 'string', 'type' => 'string',
'default' => "", 'default' => "",
'description' => 'Match info displayed in the UI' ], 'description' => 'Match info displayed in the UI' ],
self::SETTING_MATCH_S_MATCHPOINTSLIMIT => [ self::SETTING_MATCH_S_MATCHPOINTSLIMIT => [
'gamemode' => ['TMWC2023', 'TMWTTeams'], 'gamemode' => ['TMWC2023', 'TMWT2025', 'TMWTTeams'],
'type' => 'integer', 'type' => 'integer',
'default' => 4, 'default' => 4,
'description' => 'Match points limit' ], 'description' => 'Match points limit' ],
@@ -244,7 +269,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
'default' => 100, 'default' => 100,
'description' => 'Limit number of points (0 = unlimited for Ch & R)' ], 'description' => 'Limit number of points (0 = unlimited for Ch & R)' ],
self::SETTING_MATCH_S_POINTSREPARTITION => [ self::SETTING_MATCH_S_POINTSREPARTITION => [
'gamemode' => ['Cup', 'Knockout', 'Teams', 'TMWC2023', 'TMWTTeams', 'Rounds'], 'gamemode' => ['Cup', 'Knockout', 'Teams', 'TMWC2023', 'TMWT2025', 'TMWTTeams', 'Rounds'],
'type' => 'string', 'type' => 'string',
'default' => '10,6,4,3,2,1', 'default' => '10,6,4,3,2,1',
'description' => 'Point repartition from first to last' ], 'description' => 'Point repartition from first to last' ],
@@ -264,12 +289,12 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
'default' => 1, 'default' => 1,
'description' => 'Rounds without elimination (like a Warmup, but just for the first map)' ], 'description' => 'Rounds without elimination (like a Warmup, but just for the first map)' ],
self::SETTING_MATCH_S_SPONSORSURL => [ self::SETTING_MATCH_S_SPONSORSURL => [
'gamemode' => ['TMWC2023', 'TMWTTeams'], 'gamemode' => ['TMWC2023', 'TMWT2025', 'TMWTTeams'],
'type' => 'string', 'type' => 'string',
'default' => "", 'default' => "",
'description' => 'URLs separated by a space' ], 'description' => 'URLs separated by a space' ],
self::SETTING_MATCH_S_TEAMSURL => [ self::SETTING_MATCH_S_TEAMSURL => [
'gamemode' => ['TMWC2023', 'TMWTTeams'], 'gamemode' => ['TMWC2023', 'TMWT2025', 'TMWTTeams'],
'type' => 'string', 'type' => 'string',
'default' => "", 'default' => "",
'description' => 'URL where to get the teams info' ], 'description' => 'URL where to get the teams info' ],
@@ -294,17 +319,17 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
'default' => false, 'default' => false,
'description' => 'Use Tie Break (Only available when S_MapsPerMatch > 1)' ], 'description' => 'Use Tie Break (Only available when S_MapsPerMatch > 1)' ],
self::SETTING_MATCH_S_WARMUPDURATION => [ self::SETTING_MATCH_S_WARMUPDURATION => [
'gamemode' => ['Cup', 'Knockout', 'Laps', 'Teams', 'TimeAttack', 'TMWC2023', 'TMWTTeams', 'Rounds'], 'gamemode' => ['Cup', 'Knockout', 'Laps', 'Teams', 'TimeAttack', 'TMWC2023', 'TMWT2025', 'TMWTTeams', 'Rounds'],
'type' => 'integer', 'type' => 'integer',
'default' => -1, 'default' => -1,
'description' => 'Duration of 1 Warm Up in sec (-1 = one round, 0 = based on Author time)' ], 'description' => 'Duration of 1 Warm Up in sec (-1 = one round, 0 = based on Author time)' ],
self::SETTING_MATCH_S_WARMUPNB => [ self::SETTING_MATCH_S_WARMUPNB => [
'gamemode' => ['Cup', 'Knockout', 'Laps', 'Teams', 'TimeAttack', 'TMWC2023', 'TMWTTeams', 'Rounds'], 'gamemode' => ['Cup', 'Knockout', 'Laps', 'Teams', 'TimeAttack', 'TMWC2023', 'TMWT2025', 'TMWTTeams', 'Rounds'],
'type' => 'integer', 'type' => 'integer',
'default' => 1, 'default' => 1,
'description' => 'Number of Warm Up' ], 'description' => 'Number of Warm Up' ],
self::SETTING_MATCH_S_WARMUPTIMEOUT => [ self::SETTING_MATCH_S_WARMUPTIMEOUT => [
'gamemode' => ['Cup', 'Knockout', 'Laps', 'Teams', 'TimeAttack', 'TMWC2023', 'TMWTTeams', 'Rounds'], 'gamemode' => ['Cup', 'Knockout', 'Laps', 'Teams', 'TimeAttack', 'TMWC2023', 'TMWT2025', 'TMWTTeams', 'Rounds'],
'type' => 'integer', 'type' => 'integer',
'default' => -1, 'default' => -1,
'description' => 'Time after the first finished the WarmUP (-1 = based on Author time, only when S_WarmUpDuration = -1)' ] 'description' => 'Time after the first finished the WarmUP (-1 = based on Author time, only when S_WarmUpDuration = -1)' ]
@@ -448,7 +473,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MATCH_PAUSE_POSY, 43, "Position of the Pause Countdown (on Y axis)", 15); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MATCH_PAUSE_POSY, 43, "Position of the Pause Countdown (on Y axis)", 15);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MATCH_SETTINGS_MODE, array('All from the plugin', 'Maps from file & Settings from plugin', 'All from file'), "Loading mode for maps and match settings, depending on your needs", 20); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MATCH_SETTINGS_MODE, array('All from the plugin', 'Maps from file & Settings from plugin', 'All from file'), "Loading mode for maps and match settings, depending on your needs", 20);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MATCH_POST_MATCH_MAPLIST, "", "Load Mapfile after the match (empty to just load TA on the same maps) (can be unstable)", 20); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MATCH_POST_MATCH_MAPLIST, "", "Load Mapfile after the match (empty to just load TA on the same maps) (can be unstable)", 20);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MATCH_GAMEMODE_BASE, array("Cup", "Knockout", "Laps", "Teams", "TimeAttack", "TMWC2023", "TMWTTeams", "Rounds", "RoyalTimeAttack"), "Gamemode to launch for the match", 25); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MATCH_GAMEMODE_BASE, array("Cup", "Knockout", "Laps", "Teams", "TimeAttack", "TMWC2023", "TMWT2025", "TMWTTeams", "Rounds", "RoyalTimeAttack"), "Gamemode to launch for the match", 25);
// Init dynamics settings // Init dynamics settings
$this->updateSettings(); $this->updateSettings();
@@ -815,72 +840,75 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
* @param Setting $setting * @param Setting $setting
*/ */
public function updateSettings(?Setting $setting = null) { public function updateSettings(?Setting $setting = null) {
if (isset($setting) && $setting->belongsToClass($this) && $this->matchStarted) { if ($setting !== null && $setting->belongsToClass($this)) {
if ($setting->setting == self::SETTING_MATCH_GAMEMODE_BASE && $setting->value != $this->currentgmbase) { if ($this->matchStarted) {
$setting->value = $this->currentgmbase; if ($setting->setting == self::SETTING_MATCH_GAMEMODE_BASE && $setting->value != $this->currentgmbase) {
$this->maniaControl->getSettingManager()->saveSetting($setting); $setting->value = $this->currentgmbase;
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'You can\'t change Gamemode during a Match'); $this->maniaControl->getSettingManager()->saveSetting($setting);
} else if ($setting->setting == self::SETTING_MATCH_CUSTOM_GAMEMODE && $setting->value != $this->currentcustomgm) { $this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'You can\'t change Gamemode during a Match');
$setting->value = $this->currentcustomgm; } else if ($setting->setting == self::SETTING_MATCH_CUSTOM_GAMEMODE && $setting->value != $this->currentcustomgm) {
$this->maniaControl->getSettingManager()->saveSetting($setting); $setting->value = $this->currentcustomgm;
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'You can\'t change the Custom Gamemode during a Match'); $this->maniaControl->getSettingManager()->saveSetting($setting);
} else if ($setting->setting == self::SETTING_MATCH_SETTINGS_MODE && $setting->value != $this->currentsettingmode) { $this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'You can\'t change the Custom Gamemode during a Match');
$setting->value = $this->currentsettingmode; } else if ($setting->setting == self::SETTING_MATCH_SETTINGS_MODE && $setting->value != $this->currentsettingmode) {
$this->maniaControl->getSettingManager()->saveSetting($setting); $setting->value = $this->currentsettingmode;
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'You can\'t change the Setting Mode during a Match'); $this->maniaControl->getSettingManager()->saveSetting($setting);
} else if ($setting->setting == self::SETTING_MODE_HIDENEXTMAPS && $setting->value != $this->hidenextmaps) { $this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'You can\'t change the Setting Mode during a Match');
$setting->value = $this->hidenextmaps; } else if ($setting->setting == self::SETTING_MODE_HIDENEXTMAPS && $setting->value != $this->hidenextmaps) {
$this->maniaControl->getSettingManager()->saveSetting($setting); $setting->value = $this->hidenextmaps;
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'It\'s not possible to choose to hide or display the maps during a match'); $this->maniaControl->getSettingManager()->saveSetting($setting);
} else { $this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'It\'s not possible to choose to hide or display the maps during a match');
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 { } 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 {
} else if (isset($setting) && $setting->belongsToClass($this)) { if ($setting->setting == self::SETTING_MATCH_GAMEMODE_BASE && in_array($setting->value, ['TMWC2023', 'TMWT2025', 'TMWTTeams']) && $this->maniaControl->getPluginManager()->getPlugin(self::MATCHMANAGERTMWTDUOINTEGRATION_PLUGIN) === null) {
if ($setting->setting == self::SETTING_MATCH_CUSTOM_GAMEMODE && $setting->value != "") { $this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . "It's highly recommanded to use the \"MatchManager TMWT Duo Integration\" plugin with TMWT based gamemodes.");
$scriptfile = $this->maniaControl->getServer()->getDirectory()->getUserDataFolder() . DIRECTORY_SEPARATOR . "Scripts" . DIRECTORY_SEPARATOR . "Modes" . DIRECTORY_SEPARATOR . $setting->value; } else if ($setting->setting == self::SETTING_MATCH_CUSTOM_GAMEMODE && $setting->value != "") {
if (!file_exists($scriptfile)) { $scriptfile = $this->maniaControl->getServer()->getDirectory()->getUserDataFolder() . DIRECTORY_SEPARATOR . "Scripts" . DIRECTORY_SEPARATOR . "Modes" . DIRECTORY_SEPARATOR . $setting->value;
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Unable to find the gamemode file: "' . $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; } else if ($setting->setting == self::SETTING_MODE_MAPLIST_FILE && $setting->value != "") {
if (!file_exists($scriptfile)) { $scriptfile = $this->maniaControl->getServer()->getDirectory()->getMapsFolder() ."MatchSettings" . DIRECTORY_SEPARATOR . $setting->value;
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Unable to find the Maplist file: "' . $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; } else if ($setting->setting == self::SETTING_MATCH_POST_MATCH_MAPLIST && $setting->value != "") {
if (!file_exists($scriptfile)) { $scriptfile = $this->maniaControl->getServer()->getDirectory()->getMapsFolder() ."MatchSettings" . DIRECTORY_SEPARATOR . $setting->value;
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Unable to find the Post match Maplist file: "' . $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); } else if ($setting->setting == self::SETTING_MODE_MAPS && $setting->value != "") {
foreach ($maps as $map) { $maps = explode(',', $setting->value);
try { foreach ($maps as $map) {
$this->maniaControl->getClient()->getMapInfo($map); try {
} catch (\Exception $e) { $this->maniaControl->getClient()->getMapInfo($map);
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Unable to find the map: "' . $map . '"'); } catch (\Exception $e) {
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Unable to find the map: "' . $map . '"');
}
} }
} }
} }
} }
if ($setting === null || $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)) { 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); $deletesettings = !$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_DONT_DELETE_SETTINGS);
} else {
$deletesettings = true;
} }
$allsettings = $this->maniaControl->getSettingManager()->getSettingsByClass($this); $allsettings = $this->maniaControl->getSettingManager()->getSettingsByClass($this);
$settingsmode = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_SETTINGS_MODE); $settingsmode = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_SETTINGS_MODE);

View File

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

View File

@@ -29,7 +29,7 @@ use MatchManagerSuite\MatchManagerCore;
/** /**
* MatchManager TMWT Duo Integration * MatchManager TMWT Duo Integration
* *
* @author Beu (based on MatchManagerWidget by jonthekiller) * @author Beu
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageAnswerListener, CommandListener, TimerListener, Plugin { class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageAnswerListener, CommandListener, TimerListener, Plugin {
@@ -37,7 +37,7 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
* Constants * Constants
*/ */
const PLUGIN_ID = 211; const PLUGIN_ID = 211;
const PLUGIN_VERSION = 1.2; const PLUGIN_VERSION = 1.3;
const PLUGIN_NAME = 'MatchManager TMWT Duo Integration'; const PLUGIN_NAME = 'MatchManager TMWT Duo Integration';
const PLUGIN_AUTHOR = 'Beu'; const PLUGIN_AUTHOR = 'Beu';
@@ -326,9 +326,8 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
$this->maniaControl->getClient()->setModeScriptSettings(['S_IsMatchmaking' => true], false); $this->maniaControl->getClient()->setModeScriptSettings(['S_IsMatchmaking' => true], false);
$this->maniaControl->getClient()->restartMap(); $this->maniaControl->getClient()->restartMap();
} else if ($this->state === self::STATE_PREMATCH) { } else if ($this->state === self::STATE_PREMATCH) {
$teamsUrl = $this->maniaControl->getSettingManager()->getSettingValue($this->MatchManagerCore, 'S_TeamsUrl'); $teamsUrl = $this->maniaControl->getSettingManager()->getSettingValue($this->MatchManagerCore, 'S_TeamsUrl');
if ($teamsUrl !== '') { if ($teamsUrl !== null && $teamsUrl !== '') {
$response = WebReader::getUrl($teamsUrl); $response = WebReader::getUrl($teamsUrl);
$content = $response->getContent(); $content = $response->getContent();
$json = json_decode($content); $json = json_decode($content);
@@ -416,19 +415,23 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
$mapUids = array_column($json->playlist, 'uid'); $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)) { if ($mapOrderSetting !== '') {
$this->log("Re-ordering maps"); $order = array_map('trim', explode(',', $mapOrderSetting));
try {
$orderedMapUid = []; if (count($order) === count($mapUids)) {
foreach ($order as $number) { $this->log("Re-ordering maps");
$orderedMapUid[] = $mapUids[$number - 1]; 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");
} }
} }