Compare commits
No commits in common. "a1cdbe93e2bbe5e07c674b2a9972fd54caa0cd7c" and "c664cc08ce65b7750919a5f9e20c73304b6e5bdf" have entirely different histories.
a1cdbe93e2
...
c664cc08ce
@ -442,6 +442,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_SCORES, $this, 'handleTrackmaniaScore');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::MP_STARTROUNDSTART, $this, 'handleBeginRoundCallback');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::MP_ENDROUNDEND, $this, 'handleEndRoundCallback');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_WARMUPSTARTROUND, $this, 'handleStartWarmUpCallback');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::MP_STARTMATCHSTART, $this, 'handleStartMatchStartCallback');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_BEGINMAP, $this, 'handleBeginMapCallback');
|
||||
@ -455,6 +456,21 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$this->maniaControl->getCommunicationManager()->registerCommunicationListener("Match.GetMatchOptions", $this, function () { return new CommunicationAnswer($this->getGMSettings($this->currentgmbase,$this->currentcustomgm)); });
|
||||
}
|
||||
|
||||
public function handleEndRoundCallback(StartEndStructure $structure) {
|
||||
Logger::log("handleEndRoundCallback");
|
||||
|
||||
if (defined("\ManiaControl\ManiaControl::ISTRACKMANIACONTROL") && method_exists($structure, "getValidRoundCount")) {
|
||||
$this->nbrounds = $structure->getValidRoundCount();
|
||||
} else if (property_exists($structure->getPlainJsonObject(), "valid")) {
|
||||
$this->nbrounds = $structure->getPlainJsonObject()->valid;
|
||||
} else {
|
||||
$this->nbrounds = $structure->getCount();
|
||||
}
|
||||
|
||||
Logger::log("Rounds finished: " . $this->nbrounds);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MATCHMANAGER_ENDROUND, $this->matchid, $this->currentscore, $this->currentteamsscore);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||
*/
|
||||
@ -1507,19 +1523,10 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
/**
|
||||
* Handle callback "BeginRound"
|
||||
*/
|
||||
public function handleBeginRoundCallback(StartEndStructure $structure) {
|
||||
public function handleBeginRoundCallback() {
|
||||
Logger::log("handleBeginRoundCallback");
|
||||
|
||||
if ($this->matchStarted && $this->nbmaps > 0) {
|
||||
|
||||
if (defined("\ManiaControl\ManiaControl::ISTRACKMANIACONTROL") && method_exists($structure, "getValidRoundCount")) {
|
||||
$this->nbrounds = $structure->getValidRoundCount();
|
||||
} else if (property_exists($structure->getPlainJsonObject(), "valid")) {
|
||||
$this->nbrounds = $structure->getPlainJsonObject()->valid;
|
||||
} else {
|
||||
$this->nbrounds = $structure->getCount();
|
||||
}
|
||||
|
||||
if (in_array($this->currentgmbase, ["Cup", "Teams", "Rounds"])) {
|
||||
$this->maniaControl->getModeScriptEventManager()->getPauseStatus()->setCallable(function (StatusCallbackStructure $structure) {
|
||||
if ($structure->getActive()) {
|
||||
@ -1527,8 +1534,8 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
Logger::log("Pause");
|
||||
} else {
|
||||
if ($this->settings_nbroundsbymap > 1) {
|
||||
$this->maniaControl->getChat()->sendInformation($this->chatprefix . '$o$iRound: ' . $this->nbrounds . ' / ' . $this->settings_nbroundsbymap);
|
||||
Logger::log("Round: " . $this->nbrounds . ' / ' . $this->settings_nbroundsbymap);
|
||||
$this->maniaControl->getChat()->sendInformation($this->chatprefix . '$o$iRound: ' . ($this->nbrounds + 1) . ' / ' . $this->settings_nbroundsbymap);
|
||||
Logger::log("Round: " . ($this->nbrounds + 1) . ' / ' . $this->settings_nbroundsbymap);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -1697,9 +1704,6 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
trigger_error($mysqli->error);
|
||||
}
|
||||
}
|
||||
|
||||
Logger::log("Rounds finished: " . $this->nbrounds);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MATCHMANAGER_ENDROUND, $this->matchid, $this->currentscore, $this->currentteamsscore);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -35,7 +35,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 156;
|
||||
const PLUGIN_VERSION = 1.6;
|
||||
const PLUGIN_VERSION = 1.5;
|
||||
const PLUGIN_NAME = 'MatchManager GSheet';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
@ -95,7 +95,6 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
private $maniaControl = null;
|
||||
private $MatchManagerCore = null;
|
||||
private $matchstatus = "";
|
||||
private $chatprefix = '$<$fc3$w🏆$m$> '; // Would like to create a setting but MC database doesn't support utf8mb4
|
||||
private $device_code = "";
|
||||
private $access_token = "";
|
||||
private $matchid = "";
|
||||
@ -510,16 +509,13 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
$data->data[3] = new \stdClass;
|
||||
$data->data[3]->range = "'" . $sheetname . "'!" . self::MODE_SPECIFICS_SETTINGS[$this->currentdatamode]["TeamsScoreTable_BeginLetter"] . "2";
|
||||
$data->data[3]->values = $currentteamsscore;
|
||||
} else {
|
||||
$nbmaps = $this->MatchManagerCore->getMapNumber();
|
||||
$nbrounds = $this->MatchManagerCore->getRoundNumber();
|
||||
}
|
||||
|
||||
$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, 'https://sheets.googleapis.com/v4/spreadsheets/' . $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERGSHEET_SPREADSHEET) . '/values:batchUpdate');
|
||||
$asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON);
|
||||
$asyncHttpRequest->setHeaders(array("Authorization: Bearer " . $this->access_token));
|
||||
$asyncHttpRequest->setContent(json_encode($data));
|
||||
$asyncHttpRequest->setCallable(function ($json, $error) use ($sheetname, $currentscore, $currentteamsscore, $matchstatus, $nbmaps, $nbrounds) {
|
||||
$asyncHttpRequest->setCallable(function ($json, $error) use ($sheetname, $currentscore, $currentteamsscore, $matchstatus) {
|
||||
if (!$json || $error) {
|
||||
Logger::logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Error from Google API: ' . $error);
|
||||
@ -535,7 +531,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
if ($this->currentdatamode == "All Rounds Data" && $matchstatus == "running") {
|
||||
$newcurrentscore = [];
|
||||
foreach ($currentscore as $score) {
|
||||
array_push($newcurrentscore,array_merge([$nbmaps, $nbrounds], $score));
|
||||
array_push($newcurrentscore,array_merge([$this->MatchManagerCore->getMapNumber() , $this->MatchManagerCore->getRoundNumber()], $score));
|
||||
}
|
||||
|
||||
$data = new \stdClass;
|
||||
@ -547,7 +543,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
$asyncHttpRequest->setContentType(AsyncHttpRequest::CONTENT_TYPE_JSON);
|
||||
$asyncHttpRequest->setHeaders(array("Authorization: Bearer " . $this->access_token));
|
||||
$asyncHttpRequest->setContent(json_encode($data));
|
||||
$asyncHttpRequest->setCallable(function ($json, $error) use ($sheetname, $currentteamsscore, $nbmaps, $nbrounds) {
|
||||
$asyncHttpRequest->setCallable(function ($json, $error) use ($sheetname, $currentscore, $currentteamsscore) {
|
||||
if (!$json || $error) {
|
||||
Logger::logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Error from Google API: ' . $error);
|
||||
@ -563,7 +559,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
if (!empty($currentteamsscore)) {
|
||||
$newcurrentteamsscore = [];
|
||||
foreach ($currentteamsscore as $score) {
|
||||
array_push($newcurrentteamsscore,array_merge([$nbmaps, $nbrounds], $score));
|
||||
array_push($newcurrentteamsscore,array_merge([$this->MatchManagerCore->getMapNumber() , $this->MatchManagerCore->getRoundNumber()], $score));
|
||||
}
|
||||
|
||||
$data = new \stdClass;
|
||||
|
Loading…
Reference in New Issue
Block a user