Compare commits
7 Commits
8d01340d22
...
master
Author | SHA1 | Date | |
---|---|---|---|
787964a8ed
|
|||
af10e1678a
|
|||
33cc10b6c1
|
|||
5d2c6c4627
|
|||
36280769bb
|
|||
803b58eb08
|
|||
6928fe2ce2
|
@ -31,7 +31,7 @@ class BeuCustomConfig implements CallbackListener, Plugin {
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 193;
|
||||
const PLUGIN_VERSION = 1.2;
|
||||
const PLUGIN_VERSION = 1.3;
|
||||
const PLUGIN_NAME = 'BeuCustomConfig';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
@ -149,7 +149,7 @@ class BeuCustomConfig implements CallbackListener, Plugin {
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateSettings(Setting $setting = null) {
|
||||
public function updateSettings(?Setting $setting = null) {
|
||||
if ($setting !== null && $setting->belongsToClass($this)) {
|
||||
$this->changeManiacontrolSettings();
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class BeuDonationButton implements ManialinkPageAnswerListener, CallbackListener
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 169;
|
||||
const PLUGIN_VERSION = 1.0;
|
||||
const PLUGIN_VERSION = 1.1;
|
||||
const PLUGIN_NAME = 'Beu Donation Button';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
@ -103,7 +103,7 @@ class BeuDonationButton implements ManialinkPageAnswerListener, CallbackListener
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($this->manialink,$player->login);
|
||||
}
|
||||
|
||||
public function updateSettings(Setting $setting = null) {
|
||||
public function updateSettings(?Setting $setting = null) {
|
||||
$this->generateManialink();
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($this->manialink);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ class SmallTextOverlay implements TimerListener, CallbackListener, Plugin {
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 195;
|
||||
const PLUGIN_VERSION = 1.0;
|
||||
const PLUGIN_VERSION = 1.4;
|
||||
const PLUGIN_NAME = 'SmallTextOverlay';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
@ -115,7 +115,7 @@ class SmallTextOverlay implements TimerListener, CallbackListener, Plugin {
|
||||
* @param Setting $setting
|
||||
* @return void
|
||||
*/
|
||||
public function updateSettings(Setting $setting = null) {
|
||||
public function updateSettings(?Setting $setting = null) {
|
||||
if ($setting !== null && !$setting->belongsToClass($this)) {
|
||||
return;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ use ManiaControl\Settings\Setting;
|
||||
use ManiaControl\Settings\SettingManager;
|
||||
use ManiaControl\Callbacks\TimerListener;
|
||||
use ManiaControl\Callbacks\Callbacks;
|
||||
use ManiaControl\Logger;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Players\PlayerManager;
|
||||
|
||||
@ -31,10 +32,12 @@ class MatchManagerAdminUI implements CallbackListener, ManialinkPageAnswerListen
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 174;
|
||||
const PLUGIN_VERSION = 2.1;
|
||||
const PLUGIN_VERSION = 2.3;
|
||||
const PLUGIN_NAME = 'MatchManager Admin UI';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
const LOG_PREFIX = '[MatchManagerAdminUI] ';
|
||||
|
||||
const MLID_ADMINUI_SIDEMENU = 'Matchmanager.AdminUI';
|
||||
|
||||
const SETTING_POSX = 'Position X of the plugin';
|
||||
@ -123,6 +126,23 @@ class MatchManagerAdminUI implements CallbackListener, ManialinkPageAnswerListen
|
||||
public function unload() {
|
||||
$this->maniaControl->getManialinkManager()->hideManialink(self::MLID_ADMINUI_SIDEMENU);
|
||||
}
|
||||
/**
|
||||
* Custom log function to add prefix
|
||||
*
|
||||
* @param mixed $message
|
||||
*/
|
||||
private function log(mixed $message) {
|
||||
Logger::log(self::LOG_PREFIX . $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom logError function to add prefix
|
||||
*
|
||||
* @param mixed $message
|
||||
*/
|
||||
private function logError(mixed $message) {
|
||||
Logger::logError(self::LOG_PREFIX . $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* afterPluginInit
|
||||
@ -178,6 +198,8 @@ class MatchManagerAdminUI implements CallbackListener, ManialinkPageAnswerListen
|
||||
* @return void
|
||||
*/
|
||||
public function generateManialink() {
|
||||
$this->log("Generating interface with ". count($this->menuItems) . " items");
|
||||
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle();
|
||||
$itemMarginFactorX = 1.3;
|
||||
@ -272,7 +294,7 @@ class MatchManagerAdminUI implements CallbackListener, ManialinkPageAnswerListen
|
||||
}
|
||||
|
||||
class MatchManagerAdminUI_MenuItem {
|
||||
private string $actionId ;
|
||||
private string $actionId;
|
||||
private int $order = 100;
|
||||
private string $description = '';
|
||||
private string $text = '';
|
||||
|
@ -28,7 +28,7 @@ class MatchManagerAutomaticLauncher implements CallbackListener, TimerListener,
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 172;
|
||||
const PLUGIN_VERSION = 1.1;
|
||||
const PLUGIN_VERSION = 1.2;
|
||||
const PLUGIN_NAME = 'MatchManager Automatic Launcher';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
|
@ -43,7 +43,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
* MARK: Constants
|
||||
*/
|
||||
const PLUGIN_ID = 152;
|
||||
const PLUGIN_VERSION = 5.8;
|
||||
const PLUGIN_VERSION = 5.9;
|
||||
const PLUGIN_NAME = 'MatchManager Core';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
@ -701,9 +701,20 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
/*
|
||||
* MARK: Internal Functions
|
||||
*/
|
||||
/**
|
||||
* Custom log function to add prefix
|
||||
*
|
||||
* @param mixed $message
|
||||
*/
|
||||
private function log(mixed $message) {
|
||||
Logger::log(self::LOG_PREFIX . $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom logError function to add prefix
|
||||
*
|
||||
* @param mixed $message
|
||||
*/
|
||||
private function logError(mixed $message) {
|
||||
Logger::logError(self::LOG_PREFIX . $message);
|
||||
}
|
||||
@ -1187,6 +1198,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
}
|
||||
|
||||
// Define Gamemode
|
||||
$scriptName = '-';
|
||||
if ($this->currentsettingmode != 'All from file') {
|
||||
if (empty($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_CUSTOM_GAMEMODE))) {
|
||||
$scriptName = "Trackmania/TM_" ;
|
||||
@ -1293,7 +1305,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$maplist = 'MatchSettings' . DIRECTORY_SEPARATOR . $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_POST_MATCH_MAPLIST);
|
||||
if (is_file($this->maniaControl->getServer()->getDirectory()->getMapsFolder() . $maplist)) {
|
||||
$this->maniaControl->getClient()->loadMatchSettings($maplist);
|
||||
} else {
|
||||
} else if ($this->currentmap !== null) {
|
||||
if ($this->currentmap->mapType == "TrackMania\TM_Race") {
|
||||
$scriptname = "Trackmania/TM_TimeAttack_Online.Script.txt" ;
|
||||
} else if ($this->currentmap->mapType == "TrackMania\TM_Royal") {
|
||||
@ -1403,7 +1415,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$maplist = 'MatchSettings' . DIRECTORY_SEPARATOR . $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_POST_MATCH_MAPLIST);
|
||||
if (is_file($this->maniaControl->getServer()->getDirectory()->getMapsFolder() . $maplist)) {
|
||||
$this->maniaControl->getClient()->loadMatchSettings($maplist);
|
||||
} else {
|
||||
} else if ($this->currentmap !== null) {
|
||||
if ($this->currentmap->mapType == "TrackMania\TM_Race") {
|
||||
$scriptname = "Trackmania/TM_TimeAttack_Online.Script.txt" ;
|
||||
} else if ($this->currentmap->mapType == "TrackMania\TM_Royal") {
|
||||
@ -1985,10 +1997,9 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
* @param OnScoresStructure $structure
|
||||
*/
|
||||
public function handleTrackmaniaScore(OnScoresStructure $structure) {
|
||||
$this->log("handleTrackmaniaScore-" . $structure->getSection());
|
||||
$this->log("handleTrackmaniaScore - Section: " . $structure->getSection());
|
||||
|
||||
if ($this->matchStarted && $this->settingsloaded && !$this->postmatch) {
|
||||
$this->log("Section: " . $structure->getSection());
|
||||
if ($structure->getSection() == "EndMatchEarly" || $structure->getSection() == "EndMatch") {
|
||||
$this->computeCurrentScores($structure);
|
||||
$this->MatchEnd();
|
||||
@ -1998,6 +2009,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$this->preendroundscore = $structure;
|
||||
} elseif ($structure->getSection() == "EndRound") {
|
||||
if ($this->nbmaps != 0 && ($this->nbrounds <= $this->settings_nbroundsbymap || $this->settings_nbroundsbymap <= 0)) {
|
||||
$this->log("Computing current scores");
|
||||
$this->computeCurrentScores($structure);
|
||||
|
||||
$timestamp = time();
|
||||
|
@ -34,7 +34,7 @@ class MatchManagerECircuitMania implements CallbackListener, ManialinkPageAnswer
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 213;
|
||||
const PLUGIN_VERSION = 1.0;
|
||||
const PLUGIN_VERSION = 1.1;
|
||||
const PLUGIN_NAME = 'MatchManager eCircuitMania';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
|
@ -39,7 +39,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 156;
|
||||
const PLUGIN_VERSION = 2.3;
|
||||
const PLUGIN_VERSION = 2.4;
|
||||
const PLUGIN_NAME = 'MatchManager GSheet';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
@ -195,9 +195,9 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
|
||||
$this->access_token = $this->getSecretSetting("access_token");
|
||||
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('To use the MatchManagerGSheet plugin, $<$l[https://github.com/AmazingBeu/ManiacontrolPlugins/wiki/MatchManager-GSheet]check the doc$>');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'To use the MatchManagerGSheet plugin, $<$l[https://github.com/AmazingBeu/ManiacontrolPlugins/wiki/MatchManager-GSheet]check the doc$>');
|
||||
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Since MatchManagerGSheet 2.0, Player names are in the results and no more in a separated list');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Since MatchManagerGSheet 2.0, Player names are in the results and no more in a separated list');
|
||||
|
||||
$this->updateAdminUIMenuItems();
|
||||
|
||||
@ -473,7 +473,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
}
|
||||
|
||||
private function refreshTokenIfNeeded() {
|
||||
$this->Log('refreshTokenIfNeeded');
|
||||
$this->log('Refresh Google API token if needed');
|
||||
$this->access_token = $this->getSecretSetting("access_token");
|
||||
$expire = $this->getSecretSetting("expire");
|
||||
$refreshtoken = $this->getSecretSetting("refresh_token");
|
||||
@ -505,6 +505,8 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
$this->access_token = $data->access_token;
|
||||
$this->saveSecretSetting("access_token", $data->access_token);
|
||||
$this->saveSecretSetting("expire", time() + $data->expires_in);
|
||||
|
||||
$this->log('Successfully updated Google API token');
|
||||
} elseif (isset($data->error_description)) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Google refused the request: ' . $data->error_description);
|
||||
} else {
|
||||
@ -670,6 +672,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
}
|
||||
|
||||
if ($this->currentdatamode == "All Rounds Data" && $matchstatus == "running") {
|
||||
$this->log('Successfully sent Info data');
|
||||
$newcurrentscore = [];
|
||||
foreach ($currentscore as $score) {
|
||||
array_push($newcurrentscore, array_merge([$nbmaps, $nbrounds], $score));
|
||||
@ -702,10 +705,12 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
return;
|
||||
}
|
||||
|
||||
$this->log('Successfully appending Player Scores data');
|
||||
|
||||
if (!empty($currentteamsscore)) {
|
||||
$newcurrentteamsscore = [];
|
||||
foreach ($currentteamsscore as $score) {
|
||||
array_push($newcurrentteamsscore,array_merge([$nbmaps, $nbrounds], $score));
|
||||
array_push($newcurrentteamsscore, array_merge([$nbmaps, $nbrounds], $score));
|
||||
}
|
||||
|
||||
$data = new \stdClass;
|
||||
@ -734,11 +739,15 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->log('Successfully appending Team Scores data');
|
||||
});
|
||||
$asyncHttpRequest->postData(1000);
|
||||
}
|
||||
});
|
||||
$asyncHttpRequest->postData(1000);
|
||||
} else {
|
||||
$this->log('Successfully sent Info and Scores data');
|
||||
}
|
||||
});
|
||||
$asyncHttpRequest->postData(1000);
|
||||
@ -748,12 +757,12 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
}
|
||||
|
||||
function onCallbackEndRound(String $matchid, Array $currentscore, Array $currentteamsscore) {
|
||||
$this->Log('onCallbackEndRound');
|
||||
$this->log('onCallbackEndRound');
|
||||
$this->matchstatus = "running";
|
||||
$this->UpdateGSheetData($matchid, $currentscore, $currentteamsscore);
|
||||
}
|
||||
function onCallbackEndMatch(String $matchid, Array $currentscore, Array $currentteamsscore) {
|
||||
$this->Log('onCallbackEndMatch');
|
||||
$this->log('onCallbackEndMatch');
|
||||
$this->matchstatus = "ended";
|
||||
|
||||
$this->maniaControl->getTimerManager()->registerOneTimeListening($this, function () use ($matchid, $currentscore, $currentteamsscore) {
|
||||
@ -761,7 +770,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
}, 1000); // Wait a sec before sending last data to avoid collision
|
||||
}
|
||||
function onCallbackStopMatch(String $matchid, Array $currentscore, Array $currentteamsscore) {
|
||||
$this->Log('onCallbackStopMatch');
|
||||
$this->log('onCallbackStopMatch');
|
||||
$this->matchstatus = "stopped";
|
||||
$this->UpdateGSheetData($matchid, $currentscore, $currentteamsscore);
|
||||
}
|
||||
@ -833,7 +842,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
$i = 0;
|
||||
|
||||
if (!$sheetexists) {
|
||||
$this->Log("Creating new Sheet: " . $sheetname);
|
||||
$this->log("Creating new Sheet: " . $sheetname);
|
||||
$sheetid = rand(1000,2147483646);
|
||||
while (in_array($sheetid, $sheetsid)) {
|
||||
$sheetid = rand(1000,2147483646);
|
||||
@ -944,6 +953,8 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
return;
|
||||
}
|
||||
|
||||
$this->log('Successfully created sheet with formatting');
|
||||
|
||||
// Clear Scoreboards data
|
||||
$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, 'https://sheets.googleapis.com/v4/spreadsheets/' . $spreadsheetid . '/values/' . urlencode("'". $sheetname . "'") . '!A1:Z300:clear');
|
||||
$asyncHttpRequest->setHeaders(array("Authorization: Bearer " . $this->access_token));
|
||||
@ -965,6 +976,8 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
return;
|
||||
}
|
||||
|
||||
$this->log('Successfully cleared all the data');
|
||||
|
||||
// Add headers data
|
||||
$data = new \stdClass;
|
||||
$data->valueInputOption = "RAW";
|
||||
@ -1002,6 +1015,8 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('$this->MatchManagerCore->getChatPrefix() .Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->log('Successfully added headers data');
|
||||
});
|
||||
$asyncHttpRequest->postData(1000);
|
||||
});
|
||||
|
@ -44,7 +44,7 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 171;
|
||||
const PLUGIN_VERSION = 1.6;
|
||||
const PLUGIN_VERSION = 1.7;
|
||||
const PLUGIN_NAME = 'MatchManager Multiple Config Manager';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
|
@ -38,7 +38,7 @@ class MatchManagerPlayersPause implements ManialinkPageAnswerListener, CommandLi
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 159;
|
||||
const PLUGIN_VERSION = 1.5;
|
||||
const PLUGIN_VERSION = 1.6;
|
||||
const PLUGIN_NAME = 'MatchManager Players Pause';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
|
@ -37,7 +37,7 @@ class MatchManagerReadyButton implements ManialinkPageAnswerListener, CommandLis
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 158;
|
||||
const PLUGIN_VERSION = 1.5;
|
||||
const PLUGIN_VERSION = 1.6;
|
||||
const PLUGIN_NAME = 'MatchManager Ready Button';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
|
@ -37,7 +37,7 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 211;
|
||||
const PLUGIN_VERSION = 1.1;
|
||||
const PLUGIN_VERSION = 1.2;
|
||||
const PLUGIN_NAME = 'MatchManager TMWT Duo Integration';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
|
@ -38,7 +38,7 @@ class MatchManagerWidget implements ManialinkPageAnswerListener, CallbackListene
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 153;
|
||||
const PLUGIN_VERSION = 1.8;
|
||||
const PLUGIN_VERSION = 1.9;
|
||||
const PLUGIN_NAME = 'MatchManager Widget';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
|
Reference in New Issue
Block a user