load score if possible when enabled after the match start + minor fixes
This commit is contained in:
parent
ca343567f2
commit
0b8dbfbb8b
@ -27,7 +27,6 @@ use ManiaControl\Configurator\GameModeSettings;
|
|||||||
use ManiaControl\Utils\Formatter;
|
use ManiaControl\Utils\Formatter;
|
||||||
use Maniaplanet\DedicatedServer\InvalidArgumentException;
|
use Maniaplanet\DedicatedServer\InvalidArgumentException;
|
||||||
use ManiaControl\Callbacks\TimerListener; // for pause
|
use ManiaControl\Callbacks\TimerListener; // for pause
|
||||||
use ManiaControl\Maps\Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MatchManager Core
|
* MatchManager Core
|
||||||
@ -324,7 +323,6 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
private $chatprefix = '$<$fc3$w🏆$m$> '; // Would like to create a setting but MC database doesn't support utf8mb4
|
private $chatprefix = '$<$fc3$w🏆$m$> '; // Would like to create a setting but MC database doesn't support utf8mb4
|
||||||
private $nbmaps = 0;
|
private $nbmaps = 0;
|
||||||
private $nbrounds = 0;
|
private $nbrounds = 0;
|
||||||
private $nbspectators = 0;
|
|
||||||
private $currentgmbase = "";
|
private $currentgmbase = "";
|
||||||
private $currentcustomgm = "";
|
private $currentcustomgm = "";
|
||||||
private $currentsettingmode = "";
|
private $currentsettingmode = "";
|
||||||
@ -334,17 +332,13 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
|
|
||||||
// Settings to keep in memory
|
// Settings to keep in memory
|
||||||
private $settings_nbroundsbymap = 5;
|
private $settings_nbroundsbymap = 5;
|
||||||
private $settings_nbwinner = 2;
|
private $settings_nbwinners = 2;
|
||||||
private $settings_nbmapsbymatch = 0;
|
private $settings_nbmapsbymatch = 0;
|
||||||
private $settings_pointlimit = 100;
|
private $settings_pointlimit = 100;
|
||||||
|
|
||||||
private $nbwinners = 0;
|
|
||||||
private $scriptSettings = array();
|
|
||||||
|
|
||||||
private $currentscore = array();
|
private $currentscore = array();
|
||||||
private $preendroundscore = array();
|
private $preendroundscore = array();
|
||||||
private $currentteamsscore = array();
|
private $currentteamsscore = array();
|
||||||
private $playerpause = array();
|
|
||||||
private $pausetimer = 0;
|
private $pausetimer = 0;
|
||||||
private $pauseon = false;
|
private $pauseon = false;
|
||||||
|
|
||||||
@ -559,6 +553,10 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
return $this->matchStarted;
|
return $this->matchStarted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCurrentGamemodeBase() {
|
||||||
|
return $this->currentgmbase;
|
||||||
|
}
|
||||||
|
|
||||||
public function getCountRound() {
|
public function getCountRound() {
|
||||||
return $this->nbrounds . "/" . $this->settings_nbroundsbymap;
|
return $this->nbrounds . "/" . $this->settings_nbroundsbymap;
|
||||||
}
|
}
|
||||||
@ -852,6 +850,10 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
* Function called to start the match
|
* Function called to start the match
|
||||||
*/
|
*/
|
||||||
public function MatchStart() {
|
public function MatchStart() {
|
||||||
|
if ($this->matchStarted) {
|
||||||
|
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . " a match is already launched");
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
$this->matchid = $this->maniaControl->getServer()->login . "-" . time();
|
$this->matchid = $this->maniaControl->getServer()->login . "-" . time();
|
||||||
$this->currentgmbase = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_GAMEMODE_BASE);
|
$this->currentgmbase = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_GAMEMODE_BASE);
|
||||||
@ -1027,7 +1029,10 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
|||||||
*/
|
*/
|
||||||
public function MatchStop() {
|
public function MatchStop() {
|
||||||
Logger::log("Match stop");
|
Logger::log("Match stop");
|
||||||
|
if (!$this->matchStarted) {
|
||||||
|
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . " No match launched");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Trigger Callback
|
// Trigger Callback
|
||||||
|
@ -9,23 +9,19 @@ use FML\Controls\Quads\Quad_Bgs1InRace;
|
|||||||
use FML\ManiaLink;
|
use FML\ManiaLink;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
use ManiaControl\Callbacks\Callbacks;
|
|
||||||
use ManiaControl\Callbacks\Structures\Common\BasePlayerTimeStructure;
|
|
||||||
use ManiaControl\Callbacks\Structures\TrackMania\OnScoresStructure;
|
|
||||||
use ManiaControl\Callbacks\Structures\TrackMania\OnWayPointEventStructure;
|
|
||||||
use ManiaControl\Logger;
|
use ManiaControl\Logger;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
use ManiaControl\Players\PlayerManager;
|
use ManiaControl\Players\PlayerManager;
|
||||||
use ManiaControl\Plugins\Plugin;
|
use ManiaControl\Plugins\Plugin;
|
||||||
|
use ManiaControl\Plugins\PluginManager;
|
||||||
use ManiaControl\Settings\Setting;
|
use ManiaControl\Settings\Setting;
|
||||||
use ManiaControl\Settings\SettingManager;
|
use ManiaControl\Settings\SettingManager;
|
||||||
use ManiaControl\Utils\Formatter;
|
|
||||||
|
|
||||||
if (! class_exists('MatchManagerSuite\MatchManagerCore')) {
|
if (!class_exists('MatchManagerSuite\MatchManagerCore')) {
|
||||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is needed to use MatchManager Widget plugin. Install it and restart Maniacontrol');
|
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol');
|
||||||
Logger::logError('MatchManager Core is needed to use MatchManager Widget plugin. Install it and restart Maniacontrol');
|
Logger::logError('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
use MatchManagerSuite\MatchManagerCore;
|
use MatchManagerSuite\MatchManagerCore;
|
||||||
@ -127,10 +123,11 @@ class MatchManagerWidget implements ManialinkPageAnswerListener, CallbackListene
|
|||||||
$this->MatchManagerCore = $this->maniaControl->getPluginManager()->getPlugin(self::MATCHMANAGERCORE_PLUGIN);
|
$this->MatchManagerCore = $this->maniaControl->getPluginManager()->getPlugin(self::MATCHMANAGERCORE_PLUGIN);
|
||||||
|
|
||||||
if ($this->MatchManagerCore == Null) {
|
if ($this->MatchManagerCore == Null) {
|
||||||
throw new \Exception('MatchManager Core is needed to use MatchManager Widget plugin');
|
throw new \Exception('MatchManager Core is needed to use ' . self::PLUGIN_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callbacks
|
// Callbacks
|
||||||
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(PluginManager::CB_PLUGIN_UNLOADED, $this, 'handlePluginUnloaded');
|
||||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings');
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings');
|
||||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(MatchManagerCore::CB_MATCHMANAGER_STARTMATCH, $this, 'InitMatch');
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(MatchManagerCore::CB_MATCHMANAGER_STARTMATCH, $this, 'InitMatch');
|
||||||
@ -151,6 +148,15 @@ class MatchManagerWidget implements ManialinkPageAnswerListener, CallbackListene
|
|||||||
|
|
||||||
if ($this->MatchManagerCore->getMatchStatus()) {
|
if ($this->MatchManagerCore->getMatchStatus()) {
|
||||||
$this->gmbase = $this->MatchManagerCore->getCurrentGamemodeBase();
|
$this->gmbase = $this->MatchManagerCore->getCurrentGamemodeBase();
|
||||||
|
|
||||||
|
if ($this->gmbase == "Teams") {
|
||||||
|
$currentscore = $this->MatchManagerCore->getCurrentTeamsScore();
|
||||||
|
} else {
|
||||||
|
$currentscore = $this->MatchManagerCore->getCurrentScore();
|
||||||
|
}
|
||||||
|
if (count($currentscore) > 0) {
|
||||||
|
$this->generateMatchLiveWidgetData($currentscore);
|
||||||
|
}
|
||||||
$this->displayManialinks(false);
|
$this->displayManialinks(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,6 +170,20 @@ class MatchManagerWidget implements ManialinkPageAnswerListener, CallbackListene
|
|||||||
$this->closeWidgets();
|
$this->closeWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* handlePluginUnloaded
|
||||||
|
*
|
||||||
|
* @param string $pluginClass
|
||||||
|
* @param Plugin $plugin
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handlePluginUnloaded(string $pluginClass, Plugin $plugin) {
|
||||||
|
$this->maniaControl->getChat()->sendErrorToAdmins(self::PLUGIN_NAME . " disabled because MatchManager Core is now disabled");
|
||||||
|
if ($pluginClass == self::MATCHMANAGERCORE_PLUGIN) {
|
||||||
|
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update Widgets on Setting Changes
|
* Update Widgets on Setting Changes
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user