Compare commits
14 Commits
8e632d5057
...
master
Author | SHA1 | Date | |
---|---|---|---|
787964a8ed
|
|||
af10e1678a
|
|||
33cc10b6c1
|
|||
5d2c6c4627
|
|||
36280769bb
|
|||
803b58eb08
|
|||
6928fe2ce2
|
|||
8d01340d22
|
|||
6887384578
|
|||
f8c8ff6269
|
|||
0352d96fdf
|
|||
ebecb7da73
|
|||
9efa66ac5d
|
|||
0fe9dc3e14
|
@ -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 = '';
|
||||
|
@ -12,8 +12,8 @@ use ManiaControl\Settings\SettingManager;
|
||||
use ManiaControl\Callbacks\TimerListener;
|
||||
|
||||
if (!class_exists('MatchManagerSuite\MatchManagerCore')) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol');
|
||||
Logger::logError('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is required to use MatchManagerAutomaticLauncher plugin. Install it and restart Maniacontrol');
|
||||
Logger::logError('MatchManager Core is required to use MatchManagerAutomaticLauncher plugin. Install it and restart Maniacontrol');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -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';
|
||||
|
||||
@ -42,6 +42,7 @@ class MatchManagerAutomaticLauncher implements CallbackListener, TimerListener,
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
/** @var MatchManagerCore $MatchManagerCore */
|
||||
private $MatchManagerCore = null;
|
||||
|
||||
|
||||
@ -101,7 +102,7 @@ class MatchManagerAutomaticLauncher implements CallbackListener, TimerListener,
|
||||
$this->MatchManagerCore = $this->maniaControl->getPluginManager()->getPlugin(self::MATCHMANAGERCORE_PLUGIN);
|
||||
if ($this->MatchManagerCore == null) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is needed to use ' . self::PLUGIN_NAME . ' plugin.');
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class()));
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class($this)));
|
||||
} else {
|
||||
$this->createTimers();
|
||||
}
|
||||
@ -146,7 +147,7 @@ class MatchManagerAutomaticLauncher implements CallbackListener, TimerListener,
|
||||
public function handlePluginUnloaded(string $pluginClass, Plugin $plugin) {
|
||||
if ($pluginClass == self::MATCHMANAGERCORE_PLUGIN) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::PLUGIN_NAME . " disabled because MatchManager Core is now disabled");
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class()));
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,6 +171,6 @@ class MatchManagerAutomaticLauncher implements CallbackListener, TimerListener,
|
||||
$newtimers++;
|
||||
}
|
||||
}
|
||||
$this->maniaControl->getChat()->sendSuccessToAdmins($newtimers . " matches are planned");
|
||||
$this->maniaControl->getChat()->sendSuccessToAdmins($this->MatchManagerCore->getChatPrefix() . $newtimers . " matches are planned");
|
||||
}
|
||||
}
|
@ -43,10 +43,13 @@ 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';
|
||||
|
||||
const LOG_PREFIX = '[MatchManagerCore] ';
|
||||
const CHAT_PREFIX = '$<$fc3$w🏆$m$> ';
|
||||
|
||||
// Specific const
|
||||
const DB_MATCHESINDEX = 'MatchManager_MatchesIndex';
|
||||
const DB_ROUNDSINDEX = 'MatchManager_RoundsIndex';
|
||||
@ -346,7 +349,6 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
private $matchStarted = false;
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
private $chatprefix = '$<$fc3$w🏆$m$> '; // Would like to create a setting but MC database doesn't support utf8mb4
|
||||
private $nbmaps = 0;
|
||||
private $nbrounds = 0;
|
||||
private $currentgmbase = "";
|
||||
@ -693,12 +695,29 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
}
|
||||
|
||||
public function getChatPrefix() {
|
||||
return $this->chatprefix;
|
||||
return self::CHAT_PREFIX;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset match variables
|
||||
@ -706,18 +725,20 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
* @param Setting $setting
|
||||
*/
|
||||
public function resetMatchVariables() {
|
||||
$this->log("Reset match variables");
|
||||
$this->matchStarted = false;
|
||||
$this->matchrecover = false;
|
||||
$this->pauseon = false;
|
||||
$this->pointstorecover = array();
|
||||
$this->currentscore = array(); // TODO CHECK
|
||||
$this->currentscore = array();
|
||||
$this->currentteamsscore = array();
|
||||
$this->preendroundscore = null;
|
||||
$this->settingsloaded = false;
|
||||
$this->mapsshuffled = false;
|
||||
$this->mapshidden = false;
|
||||
$this->hidenextmaps = false;
|
||||
$this->maps = array();
|
||||
$this->postmatch = true;
|
||||
$this->postmatch = false;
|
||||
$this->matchid = "";
|
||||
|
||||
$this->settings_nbroundsbymap = -1;
|
||||
@ -775,7 +796,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$stmt->bind_param('i', $limit);
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
Logger::logError('Error executing MySQL query: '. $stmt->error);
|
||||
$this->logError('Error executing MySQL query: '. $stmt->error);
|
||||
}
|
||||
|
||||
$result = $stmt->get_result();
|
||||
@ -798,58 +819,58 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
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($this->chatprefix . 'You can\'t change Gamemode during a Match');
|
||||
$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($this->chatprefix . 'You can\'t change the Custom Gamemode during a Match');
|
||||
$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($this->chatprefix . 'You can\'t change the Setting Mode during a Match');
|
||||
$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($this->chatprefix . 'It\'s not possible to choose to hide or display the maps during a match');
|
||||
$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') {
|
||||
Logger::log("Load Script Settings");
|
||||
$this->log("Load Script Settings");
|
||||
try {
|
||||
$this->loadGMSettings($this->getGMSettings($this->currentgmbase,$this->currentcustomgm));
|
||||
Logger::log("Parameters updated");
|
||||
$this->maniaControl->getChat()->sendSuccessToAdmins($this->chatprefix . 'Parameters updated');
|
||||
$this->log("Parameters updated");
|
||||
$this->maniaControl->getChat()->sendSuccessToAdmins(self::CHAT_PREFIX . 'Parameters updated');
|
||||
} catch (InvalidArgumentException $e) {
|
||||
Logger::log("Parameters not updated");
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . 'Parameters not updated');
|
||||
$this->log("Parameters not updated");
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Parameters not updated');
|
||||
}
|
||||
$this->updateGMvariables();
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . 'Settings are loaded by Matchsettings file only.');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Settings are loaded by Matchsettings file only.');
|
||||
}
|
||||
}
|
||||
} else if (isset($setting) && $setting->belongsToClass($this)) {
|
||||
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($this->chatprefix . 'Unable to find the gamemode file: "' . $setting->value . '"');
|
||||
$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($this->chatprefix . 'Unable to find the Maplist file: "' . $setting->value . '"');
|
||||
$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($this->chatprefix . 'Unable to find the Post match Maplist file: "' . $setting->value . '"');
|
||||
$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(',', $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MODE_MAPS));
|
||||
$maps = explode(',', $setting->value);
|
||||
foreach ($maps as $map) {
|
||||
try {
|
||||
$this->maniaControl->getClient()->getMapInfo($map);
|
||||
} catch (\Exception $e) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . 'Unable to find the map: "' . $map . '"');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Unable to find the map: "' . $map . '"');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -863,6 +884,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
}
|
||||
$allsettings = $this->maniaControl->getSettingManager()->getSettingsByClass($this);
|
||||
$settingsmode = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_SETTINGS_MODE);
|
||||
if ($allsettings !== null && $settingsmode !== null) {
|
||||
$modesettings = $this->getModeSettings($settingsmode);
|
||||
foreach ($allsettings as $key => $value) {
|
||||
$name = $value->setting;
|
||||
@ -898,6 +920,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Gamemode settings excluding not used settings in custom gamemodes
|
||||
@ -1010,8 +1033,8 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Logger::logError("Impossible to read custom gamemode file");
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . " Impossible to read custom gamemode file");
|
||||
$this->logError("Impossible to read custom gamemode file");
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . " Impossible to read custom gamemode file");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1050,7 +1073,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
* Load functionnal variables
|
||||
*/
|
||||
public function updateGMvariables() {
|
||||
Logger::log("Updating internal variables");
|
||||
$this->log("Updating internal variables");
|
||||
$this->currentgmsettings = $this->maniaControl->getClient()->getModeScriptSettings();
|
||||
|
||||
if (isset($this->currentgmsettings[self::SETTING_MATCH_S_POINTSLIMIT])) {
|
||||
@ -1106,7 +1129,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
*/
|
||||
private function canStartMatch() {
|
||||
if ($this->matchStarted) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . " a match is already launched");
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . " a match is already launched");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1127,6 +1150,8 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
if (!$this->canStartMatch()) return;
|
||||
|
||||
try {
|
||||
$this->resetMatchVariables();
|
||||
|
||||
$this->matchid = $this->maniaControl->getServer()->login . "-" . time();
|
||||
$this->currentgmbase = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_GAMEMODE_BASE);
|
||||
$this->currentcustomgm = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_CUSTOM_GAMEMODE);
|
||||
@ -1134,8 +1159,8 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$maplist = "";
|
||||
|
||||
if ($this->currentgmbase == "RoyalTimeAttack") {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . "No data are save in RoyalTimeAttack for the moment, it's not implemented on server side. Waiting a fix from NADEO");
|
||||
Logger::Log("No data are save in RoyalTimeAttack for the moment, it's not implemented on server side. Waiting a fix from NADEO");
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . "No data are save in RoyalTimeAttack for the moment, it's not implemented on server side. Waiting a fix from NADEO");
|
||||
$this->log("No data are save in RoyalTimeAttack for the moment, it's not implemented on server side. Waiting a fix from NADEO");
|
||||
}
|
||||
|
||||
// Prepare maps in case of "All from the plugin" mode
|
||||
@ -1145,7 +1170,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
try {
|
||||
$mapInfo = $this->maniaControl->getMapManager()->initializeMap($this->maniaControl->getClient()->getMapInfo($map));
|
||||
} catch (Exception $e) {
|
||||
throw new \Exception("Error with the map " . $map . ": " . $e->getMessage());
|
||||
throw new \Exception('Error with the Map to play "' . $map . '": ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1161,7 +1186,11 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
|
||||
// Remove all maps
|
||||
foreach ($this->maniaControl->getMapManager()->getMaps() as $map) {
|
||||
try {
|
||||
$this->maniaControl->getClient()->removeMap($map->fileName);
|
||||
} catch (Exception $e) {
|
||||
throw new \Exception('Error when removing map "' . $map->getEscapedName() . '" from the playlist: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$this->maps = $maps;
|
||||
@ -1169,24 +1198,25 @@ 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_" ;
|
||||
$scriptName .= $this->currentgmbase;
|
||||
$scriptName .= "_Online.Script.txt";
|
||||
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . 'Match start in ' . $this->currentgmbase . ' mode!');
|
||||
$this->maniaControl->getChat()->sendSuccess(self::CHAT_PREFIX . 'Match start in ' . $this->currentgmbase . ' mode!');
|
||||
} else {
|
||||
$scriptName = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_CUSTOM_GAMEMODE);
|
||||
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . 'Match start with script ' . $scriptName . ' (based on ' . $this->currentgmbase . ')');
|
||||
$this->maniaControl->getChat()->sendSuccess(self::CHAT_PREFIX . 'Match start with script ' . $scriptName . ' (based on ' . $this->currentgmbase . ')');
|
||||
}
|
||||
|
||||
Logger::log("Match start with script " . $scriptName . '!');
|
||||
$this->log("Match start with script " . $scriptName . '!');
|
||||
$this->maniaControl->getClient()->setScriptName($scriptName);
|
||||
}
|
||||
|
||||
// Must be after loading the script in case of different MapType
|
||||
if ($this->currentsettingmode != 'All from the plugin') {
|
||||
Logger::log("Loading maplist + matchsettings");
|
||||
$this->log("Loading maplist + matchsettings");
|
||||
$maplist = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MODE_MAPLIST_FILE);
|
||||
if (empty($maplist)) {
|
||||
$server = $this->maniaControl->getServer()->login;
|
||||
@ -1194,7 +1224,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
} else {
|
||||
$maplist = 'MatchSettings' . DIRECTORY_SEPARATOR . $maplist;
|
||||
}
|
||||
Logger::log("Load matchsettings: " . $maplist);
|
||||
$this->log("Load matchsettings: " . $maplist);
|
||||
if (!is_file($this->maniaControl->getServer()->getDirectory()->getMapsFolder() . $maplist)) {
|
||||
throw new \Exception("The Maplist file is not accessible or does not exist (the match has not started)");
|
||||
}
|
||||
@ -1215,17 +1245,17 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
}
|
||||
}
|
||||
|
||||
Logger::log("Restructure maplist");
|
||||
$this->log("Restructure maplist");
|
||||
$this->maniaControl->getMapManager()->restructureMapList();
|
||||
|
||||
$this->matchStarted = true;
|
||||
$this->nbmaps = 0;
|
||||
$this->nbrounds = 0;
|
||||
|
||||
Logger::log("Get Players");
|
||||
$this->log("Get Players");
|
||||
$players = $this->maniaControl->getPlayerManager()->getPlayers();
|
||||
|
||||
Logger::log("Player State");
|
||||
$this->log("Player State");
|
||||
foreach ($players as $player) {
|
||||
$this->handlePlayerConnect($player);
|
||||
}
|
||||
@ -1240,7 +1270,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$stmt->bind_param('sssi', $this->matchid, $serverlogin, $this->currentgmbase, $timestamp);
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
Logger::logError('Error executing MySQL query: '. $stmt->error);
|
||||
$this->logError('Error executing MySQL query: '. $stmt->error);
|
||||
}
|
||||
|
||||
// Trigger Callback
|
||||
@ -1254,12 +1284,12 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MATCHMANAGER_STARTMATCH, $this->matchid, $settings);
|
||||
$this->updateAdminUIMenuItems();
|
||||
|
||||
Logger::log("Skip map");
|
||||
$this->log("Skip map");
|
||||
$this->maniaControl->getMapManager()->getMapActions()->skipMap();
|
||||
} catch (Exception $e) {
|
||||
$this->resetMatchVariables();
|
||||
Logger::log($e->getMessage());
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . $e->getMessage());
|
||||
$this->logError("Can't start the match: ". $e->getMessage());
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . "Can't start the match: ". $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1275,14 +1305,14 @@ 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") {
|
||||
$scriptname = "Trackmania/TM_RoyalTimeAttack_Online.Script.txt" ;
|
||||
}
|
||||
if (isset($scriptname)) {
|
||||
Logger::log("Loading script: " . $scriptname);
|
||||
$this->log("Loading script: " . $scriptname);
|
||||
$this->maniaControl->getClient()->setScriptName($scriptname);
|
||||
}
|
||||
}
|
||||
@ -1297,7 +1327,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$stmt->bind_param('is', $timestamp, $this->matchid);
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
Logger::logError('Error executing MySQL query: '. $stmt->error);
|
||||
$this->logError('Error executing MySQL query: '. $stmt->error);
|
||||
}
|
||||
|
||||
// Match Result
|
||||
@ -1317,7 +1347,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
list($rank, $login, $matchpoints, $mappoints, $roundpoints, $bestracetime, $bestracecheckpoints, $bestlaptime, $bestlapcheckpoints, $prevracetime, $prevracecheckpoints, $teamid) = $score;
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
Logger::logError('Error executing MySQL query: '. $stmt->error);
|
||||
$this->logError('Error executing MySQL query: '. $stmt->error);
|
||||
}
|
||||
}
|
||||
$stmt->close();
|
||||
@ -1333,7 +1363,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
list($rank, $teamid, $teamname, $matchpoints) = $score;
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
Logger::logError('Error executing MySQL query: '. $stmt->error);
|
||||
$this->logError('Error executing MySQL query: '. $stmt->error);
|
||||
}
|
||||
}
|
||||
$stmt->close();
|
||||
@ -1344,17 +1374,16 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MATCHMANAGER_ENDMATCH, $this->matchid, $this->currentscore, $this->currentteamsscore);
|
||||
|
||||
// End notifications
|
||||
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . "Match finished");
|
||||
Logger::log("Match finished");
|
||||
$this->maniaControl->getChat()->sendSuccess(self::CHAT_PREFIX . "Match finished");
|
||||
$this->log("Match finished");
|
||||
|
||||
$this->resetMatchVariables();
|
||||
$this->postmatch = true;
|
||||
|
||||
$this->updateAdminUIMenuItems();
|
||||
|
||||
// Teams Specifics variables
|
||||
$this->currentteamsscore = [];
|
||||
|
||||
} catch (Exception $e) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . 'Can not finish match: ' . $e->getMessage());
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . "Can't finish the match: " . $e->getMessage());
|
||||
$this->logError("Can't finish the match: ". $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1362,9 +1391,9 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
* Function called to stop the match
|
||||
*/
|
||||
public function MatchStop() {
|
||||
Logger::log("Match stop");
|
||||
$this->log("Match stop");
|
||||
if (!$this->matchStarted) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . " No match launched");
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . " No match launched");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1375,7 +1404,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
// Trigger Callback
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MATCHMANAGER_STOPMATCH, $this->matchid, $this->currentscore, $this->currentteamsscore);
|
||||
|
||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Match stopped by an Admin!');
|
||||
$this->maniaControl->getChat()->sendError(self::CHAT_PREFIX . 'Match stopped by an Admin!');
|
||||
|
||||
// Cancel pause if match stopped during a pause
|
||||
if ($this->pauseon) {
|
||||
@ -1386,24 +1415,27 @@ 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") {
|
||||
$scriptname = "Trackmania/TM_RoyalTimeAttack_Online.Script.txt" ;
|
||||
}
|
||||
if (isset($scriptname)) {
|
||||
Logger::log("Loading script: " . $scriptname);
|
||||
$this->log("Loading script: " . $scriptname);
|
||||
$this->maniaControl->getClient()->setScriptName($scriptname);
|
||||
}
|
||||
}
|
||||
|
||||
$this->resetMatchVariables();
|
||||
$this->postmatch = true;
|
||||
|
||||
$this->updateAdminUIMenuItems();
|
||||
} catch (Exception $e) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . 'Can not stop match: ' . $e->getMessage());
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . "Can't stop the match: " . $e->getMessage());
|
||||
$this->logError("Can't stop the match: ". $e->getMessage());
|
||||
}
|
||||
Logger::log("Restarting map to load Gamemode");
|
||||
$this->log("Restarting map to load Gamemode");
|
||||
$this->maniaControl->getClient()->restartMap();
|
||||
}
|
||||
|
||||
@ -1412,14 +1444,14 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
* @param integer $index
|
||||
*/
|
||||
public function MatchRecover(int $index): bool {
|
||||
Logger::log("Match Recover");
|
||||
$this->log("Match Recover");
|
||||
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$stmt = $mysqli->prepare('SELECT `matchid`,`gamemodebase` FROM `' . self::DB_MATCHESINDEX . '` ORDER BY `started` DESC LIMIT ? , 1');
|
||||
$stmt->bind_param('i', $index);
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
Logger::logError('Error executing MySQL query: '. $stmt->error);
|
||||
$this->logError('Error executing MySQL query: '. $stmt->error);
|
||||
return false;
|
||||
}
|
||||
$result = $stmt->get_result();
|
||||
@ -1436,7 +1468,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$stmt->bind_param('s', $matchid);
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
Logger::logError('Error executing MySQL query: '. $stmt->error);
|
||||
$this->logError('Error executing MySQL query: '. $stmt->error);
|
||||
return false;
|
||||
}
|
||||
$result = $stmt->get_result();
|
||||
@ -1458,7 +1490,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$stmt->bind_param('si', $matchid, $timestamp);
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
Logger::logError('Error executing MySQL query: '. $stmt->error);
|
||||
$this->logError('Error executing MySQL query: '. $stmt->error);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1474,18 +1506,18 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$this->pointstorecover[$value['login']] = $value['matchpoints'];
|
||||
}
|
||||
}
|
||||
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . 'Recovering the match: ' . $matchid );
|
||||
Logger::log('Recovering the match: ' . $matchid);
|
||||
$this->maniaControl->getChat()->sendSuccess(self::CHAT_PREFIX . 'Recovering the match: ' . $matchid );
|
||||
$this->log('Recovering the match: ' . $matchid);
|
||||
$this->MatchStart();
|
||||
return true;
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . 'No data found from the last round');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'No data found from the last round');
|
||||
}
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . 'No Rounds found for this match');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'No Rounds found for this match');
|
||||
}
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . 'Match not found');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Match not found');
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -1499,11 +1531,11 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
if ($this->currentgmbase == "Teams") {
|
||||
// Blue Team
|
||||
$this->maniaControl->getModeScriptEventManager()->setTrackmaniaTeamPoints("0", "", $this->pointstorecover[0], $this->pointstorecover[0]);
|
||||
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . '$<$ff0' . $this->pointstorecover[0] . '$> points recovered for the $<$00fBlue$> Team');
|
||||
$this->maniaControl->getChat()->sendSuccess(self::CHAT_PREFIX . '$<$ff0' . $this->pointstorecover[0] . '$> points recovered for the $<$00fBlue$> Team');
|
||||
// Red Team
|
||||
$this->maniaControl->getModeScriptEventManager()->setTrackmaniaTeamPoints("1", "", $this->pointstorecover[1], $this->pointstorecover[1]);
|
||||
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . '$<$ff0' . $this->pointstorecover[1] . '$> points recovered for the $<$f00Red$> Team');
|
||||
Logger::log("Point recovered: Blue " . $this->pointstorecover[0] . " - Red " . $this->pointstorecover[1]);
|
||||
$this->maniaControl->getChat()->sendSuccess(self::CHAT_PREFIX . '$<$ff0' . $this->pointstorecover[1] . '$> points recovered for the $<$f00Red$> Team');
|
||||
$this->log("Point recovered: Blue " . $this->pointstorecover[0] . " - Red " . $this->pointstorecover[1]);
|
||||
$this->pointstorecover = [];
|
||||
} else {
|
||||
foreach ($this->pointstorecover as $index => $value) {
|
||||
@ -1520,9 +1552,9 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$points = $value;
|
||||
}
|
||||
$this->maniaControl->getModeScriptEventManager()->setTrackmaniaPlayerPoints($player, "", "", $points);
|
||||
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . 'Your $<$ff0' . $value . '$> points have been recovered', $player);
|
||||
$this->maniaControl->getChat()->sendSuccess(self::CHAT_PREFIX . 'Your $<$ff0' . $value . '$> points have been recovered', $player);
|
||||
unset($this->pointstorecover[$index]);
|
||||
Logger::log("Point recovered: " . $index . " " . $points . "(+" . $value . ")");
|
||||
$this->log("Point recovered: " . $index . " " . $points . "(+" . $value . ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1543,8 +1575,8 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$results = $structure->getPlayerScores();
|
||||
|
||||
if ($this->currentgmbase == "RoyalTimeAttack") {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . "No data are save in RoyalTimeAttack for the moment, it's not implemented on server side. Waiting a fix from NADEO");
|
||||
Logger::Log("No data are save in RoyalTimeAttack for the moment, it's not implemented on server side. Waiting a fix from NADEO");
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . "No data are save in RoyalTimeAttack for the moment, it's not implemented on server side. Waiting a fix from NADEO");
|
||||
$this->logError("No data are save in RoyalTimeAttack for the moment, it's not implemented on server side. Waiting a fix from NADEO");
|
||||
}
|
||||
|
||||
$preendroundplayersscore = [];
|
||||
@ -1642,11 +1674,11 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
*/
|
||||
public function setNadeoPause($admin = false, $time = null) {
|
||||
if ($this->pauseon) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->chatprefix . 'Can\'t launch pause, already running');
|
||||
Logger::logError('Can\'t launch pause, already running');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::CHAT_PREFIX . 'Can\'t launch pause, already running');
|
||||
$this->logError('Can\'t launch pause, already running');
|
||||
return;
|
||||
}
|
||||
Logger::log("Launching Pause");
|
||||
$this->log("Launching Pause");
|
||||
|
||||
if ($time === null) {
|
||||
$this->pausetimer = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_PAUSE_DURATION);
|
||||
@ -1657,7 +1689,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$this->pauseon = true;
|
||||
|
||||
$this->maniaControl->getModeScriptEventManager()->startPause();
|
||||
$this->maniaControl->getChat()->sendSuccessToAdmins($this->chatprefix . 'You can interrupt the pause with the command //matchendpause');
|
||||
$this->maniaControl->getChat()->sendSuccessToAdmins(self::CHAT_PREFIX . 'You can interrupt the pause with the command //matchendpause');
|
||||
|
||||
if ($this->pausetimer > 0) {
|
||||
$this->displayPauseWidget();
|
||||
@ -1672,7 +1704,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
*/
|
||||
private function unsetNadeoPause() {
|
||||
if ($this->pauseon) {
|
||||
Logger::log("End Pause");
|
||||
$this->log("End Pause");
|
||||
$this->closePauseWidget();
|
||||
$this->pauseon = false;
|
||||
$this->maniaControl->getModeScriptEventManager()->endPause();
|
||||
@ -1763,14 +1795,14 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
* Handle XMLRPC callback "Maniaplanet.StartMatch_Start"
|
||||
*/
|
||||
public function handleStartMatchStartCallback() {
|
||||
Logger::log("handleStartMatchStartCallback");
|
||||
$this->log("handleStartMatchStartCallback");
|
||||
|
||||
if ($this->matchStarted) {
|
||||
Logger::log("Loading settings");
|
||||
$this->log("Loading settings");
|
||||
$this->settingsloaded = true;
|
||||
|
||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_SETTINGS_MODE) != 'All from file') {
|
||||
Logger::log("Load Script Settings");
|
||||
$this->log("Load Script Settings");
|
||||
$this->loadGMSettings($this->getGMSettings($this->currentgmbase, $this->currentcustomgm));
|
||||
}
|
||||
|
||||
@ -1778,7 +1810,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
} else if ($this->postmatch) {
|
||||
$this->postmatch = false;
|
||||
|
||||
Logger::log("Load PostMatch Gamemode Settings");
|
||||
$this->log("Load PostMatch Gamemode Settings");
|
||||
$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);
|
||||
@ -1805,18 +1837,18 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
* Handle Maniacontrol callback "BeginMatch"
|
||||
*/
|
||||
public function handleBeginMatchCallback() {
|
||||
Logger::log("handleBeginMatchCallback");
|
||||
$this->log("handleBeginMatchCallback");
|
||||
if ($this->matchStarted && !$this->settingsloaded) {
|
||||
Logger::log("Restarting map to restart match data");
|
||||
$this->log("Restarting map to restart match data");
|
||||
$this->maniaControl->getClient()->restartMap();
|
||||
} else if ($this->matchStarted && $this->settingsloaded && $this->nbrounds == 0) {
|
||||
Logger::Log("Check if Points Repartition need to be re-applied");
|
||||
$this->log("Check if Points Repartition need to be re-applied");
|
||||
$this->maniaControl->getModeScriptEventManager()->getTrackmaniaPointsRepartition()->setCallable(function (OnPointsRepartitionStructure $structure) {
|
||||
$currentgmsettings = $this->maniaControl->getClient()->getModeScriptSettings();
|
||||
if (!is_null($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_S_POINTSREPARTITION)) && isset($currentgmsettings[self::SETTING_MATCH_S_POINTSREPARTITION])) {
|
||||
$pointrepartitionarray = explode(",", $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_S_POINTSREPARTITION));
|
||||
if ($structure->getPointsRepartition() != $pointrepartitionarray) {
|
||||
Logger::Log("re-applying Points Repartition for workaround");
|
||||
$this->log("re-applying Points Repartition for workaround");
|
||||
$newpoints = array(self::SETTING_MATCH_S_POINTSREPARTITION => $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_S_POINTSREPARTITION) . ',' . end($pointrepartitionarray));
|
||||
$this->maniaControl->getClient()->setModeScriptSettings($newpoints);
|
||||
}
|
||||
@ -1829,7 +1861,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
* Handle Maniacontrol callback "BeginMap"
|
||||
*/
|
||||
public function handleBeginMapCallback() {
|
||||
Logger::log("handleBeginMapCallback");
|
||||
$this->log("handleBeginMapCallback");
|
||||
if ($this->matchStarted) {
|
||||
$this->nbmaps++;
|
||||
$this->nbrounds = 0;
|
||||
@ -1839,8 +1871,8 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$totalnbmaps = $this->maniaControl->getMapManager()->getMapsCount();
|
||||
|
||||
$this->currentmap = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||
Logger::log("Current Map: " . Formatter::stripCodes($this->currentmap->name));
|
||||
$message = $this->chatprefix . '$<$o$iCurrent Map:$>' . "\n";
|
||||
$this->log("Current Map: " . Formatter::stripCodes($this->currentmap->name));
|
||||
$message = self::CHAT_PREFIX . '$<$o$iCurrent Map:$>' . "\n";
|
||||
$message .= Formatter::stripCodes($this->currentmap->name);
|
||||
$this->maniaControl->getChat()->sendInformation($message);
|
||||
|
||||
@ -1854,7 +1886,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$i++;
|
||||
}
|
||||
if (($this->settings_nbmapsbymatch > 0 && $i < $this->settings_nbmapsbymatch - 1 && $this->nbmaps < $this->settings_nbmapsbymatch) || ($this->settings_nbmapsbymatch <= 0 && ($totalnbmaps >= 2 || count($this->maps) >= 2))) { // TODO manage maps in queue added by an admin
|
||||
$message = $this->chatprefix . '$<$o$iNext Maps:$>';
|
||||
$message = self::CHAT_PREFIX . '$<$o$iNext Maps:$>';
|
||||
|
||||
$nbhiddenmaps = 0;
|
||||
if ($this->hidenextmaps) {
|
||||
@ -1865,7 +1897,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$nbhiddenmaps = count($this->maps) - $totalnbmaps;
|
||||
}
|
||||
$message .= "\nThen " . $nbhiddenmaps . " hidden maps";
|
||||
Logger::log("Then " . $nbhiddenmaps . " hidden maps");
|
||||
$this->log("Then " . $nbhiddenmaps . " hidden maps");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1878,10 +1910,10 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
|
||||
if ($index != $i) {
|
||||
$message .= "\n" . $j . ": " . Formatter::stripCodes($maps[$index]->name);
|
||||
Logger::log(Formatter::stripCodes($index . ": " . $maps[$index]->name));
|
||||
$this->log(Formatter::stripCodes($index . ": " . $maps[$index]->name));
|
||||
} else {
|
||||
$message .= "\nThen we will return to this map";
|
||||
Logger::log("Then we will return to this map");
|
||||
$this->log("Then we will return to this map");
|
||||
$j = 0;
|
||||
break;
|
||||
}
|
||||
@ -1889,11 +1921,11 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
if ($j + $nbhiddenmaps >= 4) {
|
||||
if ($this->settings_nbmapsbymatch > 0 && $this->settings_nbmapsbymatch - $j - $nbhiddenmaps - $this->nbmaps + 1 > 0) {
|
||||
$message .= "\n" . "And " . ($this->settings_nbmapsbymatch - $j - $nbhiddenmaps - $this->nbmaps + 1) . " more maps";
|
||||
Logger::log("And " . ($this->settings_nbmapsbymatch - $j - $nbhiddenmaps - $this->nbmaps + 1) . " more maps");
|
||||
$this->log("And " . ($this->settings_nbmapsbymatch - $j - $nbhiddenmaps - $this->nbmaps + 1) . " more maps");
|
||||
} elseif ($this->settings_nbmapsbymatch <= 0 && ($totalnbmaps - $j - $nbhiddenmaps > 0 || count($this->maps) - $j - $nbhiddenmaps > 0)) {
|
||||
$n = max($totalnbmaps - $j - $nbhiddenmaps, count($this->maps) - $j - $nbhiddenmaps);
|
||||
$message .= "\n" . "And " . $n . " more maps";
|
||||
Logger::log("And " . $n . " more maps");
|
||||
$this->log("And " . $n . " more maps");
|
||||
}
|
||||
}
|
||||
$this->maniaControl->getChat()->sendInformation($message);
|
||||
@ -1913,7 +1945,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
* Handle callback "WarmUp.StartRound"
|
||||
*/
|
||||
public function handleStartWarmUpCallback() {
|
||||
Logger::log("handleStartWarmUpCallback");
|
||||
$this->log("handleStartWarmUpCallback");
|
||||
|
||||
// Match Recover
|
||||
if ($this->matchrecover) {
|
||||
@ -1925,7 +1957,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
* Handle callback "BeginRound"
|
||||
*/
|
||||
public function handleBeginRoundCallback(StartEndStructure $structure) {
|
||||
Logger::log("handleBeginRoundCallback");
|
||||
$this->log("handleBeginRoundCallback");
|
||||
|
||||
if ($this->matchStarted && $this->nbmaps > 0) {
|
||||
|
||||
@ -1940,12 +1972,12 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
if (in_array($this->currentgmbase, ["Cup", "Teams", "Rounds"])) {
|
||||
$this->maniaControl->getModeScriptEventManager()->getPauseStatus()->setCallable(function (StatusCallbackStructure $structure) {
|
||||
if ($structure->getActive()) {
|
||||
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . 'The match is currently on $<$F00pause$>!');
|
||||
Logger::log("Pause");
|
||||
$this->maniaControl->getChat()->sendSuccess(self::CHAT_PREFIX . 'The match is currently on $<$F00pause$>!');
|
||||
$this->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(self::CHAT_PREFIX . '$o$iRound: ' . $this->nbrounds . ' / ' . $this->settings_nbroundsbymap);
|
||||
$this->log("Round: " . $this->nbrounds . ' / ' . $this->settings_nbroundsbymap);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -1965,10 +1997,9 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
* @param OnScoresStructure $structure
|
||||
*/
|
||||
public function handleTrackmaniaScore(OnScoresStructure $structure) {
|
||||
Logger::log("handleTrackmaniaScore-" . $structure->getSection());
|
||||
$this->log("handleTrackmaniaScore - Section: " . $structure->getSection());
|
||||
|
||||
if ($this->matchStarted && $this->settingsloaded && !$this->postmatch) {
|
||||
Logger::log("Section: " . $structure->getSection());
|
||||
if ($structure->getSection() == "EndMatchEarly" || $structure->getSection() == "EndMatch") {
|
||||
$this->computeCurrentScores($structure);
|
||||
$this->MatchEnd();
|
||||
@ -1978,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();
|
||||
@ -1994,7 +2026,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)');
|
||||
$stmt->bind_param('siiissii', $this->matchid, $timestamp, $this->nbmaps, $this->nbrounds, $settings, $this->currentmap->uid, $playercount, $spectatorcount);
|
||||
if (!$stmt->execute()) {
|
||||
Logger::logError('Error executing MySQL query: '. $stmt->error);
|
||||
$this->logError('Error executing MySQL query: '. $stmt->error);
|
||||
}
|
||||
$stmt->close();
|
||||
|
||||
@ -2023,7 +2055,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
list($rank, $login, $matchpoints, $mappoints, $roundpoints, $bestracetime, $bestracecheckpoints, $bestlaptime, $bestlapcheckpoints, $prevracetime, $prevracecheckpoints, $teamid) = $score;
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
Logger::logError('Error executing MySQL query: '. $stmt->error);
|
||||
$this->logError('Error executing MySQL query: '. $stmt->error);
|
||||
}
|
||||
}
|
||||
$stmt->close();
|
||||
@ -2039,14 +2071,14 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
list($rank, $teamid, $teamname, $matchpoints, $mappoints, $roundpoints) = $score;
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
Logger::logError('Error executing MySQL query: '. $stmt->error);
|
||||
$this->logError('Error executing MySQL query: '. $stmt->error);
|
||||
}
|
||||
}
|
||||
$stmt->close();
|
||||
}
|
||||
$mysqli->commit();
|
||||
|
||||
Logger::log("Rounds finished: " . $this->nbrounds);
|
||||
$this->log("Rounds finished: " . $this->nbrounds);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MATCHMANAGER_ENDROUND, $this->matchid, $this->currentscore, $this->currentteamsscore);
|
||||
}
|
||||
}
|
||||
@ -2088,7 +2120,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
if ($this->pauseon == false) {
|
||||
$this->MatchStop();
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Impossible to stop a match during a pause' ,$player);
|
||||
$this->maniaControl->getChat()->sendError(self::CHAT_PREFIX . 'Impossible to stop a match during a pause' ,$player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2114,7 +2146,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
} else {
|
||||
$lastmatches = $this->getMatchesList(3);
|
||||
|
||||
$message = $this->chatprefix . '$<run this command with an index or "latest"$>' . "\n";
|
||||
$message = self::CHAT_PREFIX . '$<run this command with an index or "latest"$>' . "\n";
|
||||
|
||||
foreach ($lastmatches as $index => $value) {
|
||||
if ($index >= 3) {
|
||||
@ -2128,7 +2160,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
}
|
||||
}
|
||||
$this->maniaControl->getChat()->sendSuccess($message, $player);
|
||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'For the moment, only point recovery is supported, you have to manage maps and rounds manually');
|
||||
$this->maniaControl->getChat()->sendError(self::CHAT_PREFIX . 'For the moment, only point recovery is supported, you have to manage maps and rounds manually');
|
||||
|
||||
}
|
||||
}
|
||||
@ -2173,7 +2205,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
* @param \ManiaControl\Players\Player $player
|
||||
*/
|
||||
public function onCommandSetPause(array $chatCallback, Player $player) {
|
||||
Logger::log("Pause asked by admin");
|
||||
$this->log("Pause asked by admin");
|
||||
$authLevel = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_AUTHLEVEL);
|
||||
if (!$this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::getAuthLevel($authLevel))) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
@ -2181,30 +2213,30 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
}
|
||||
|
||||
if (!$this->getMatchIsRunning()) {
|
||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Can\'t start Pause: Match not started', $player);
|
||||
$this->maniaControl->getChat()->sendError(self::CHAT_PREFIX . 'Can\'t start Pause: Match not started', $player);
|
||||
} else if ($this->pauseon) {
|
||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Can\'t start Pause: Pause already running', $player);
|
||||
$this->maniaControl->getChat()->sendError(self::CHAT_PREFIX . 'Can\'t start Pause: Pause already running', $player);
|
||||
} else if (in_array($this->currentgmbase, ["Laps", "TimeAttack", "RoyalTimeAttack"])) {
|
||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Can\'t start Pause: Invalid gamemode base', $player);
|
||||
$this->maniaControl->getChat()->sendError(self::CHAT_PREFIX . 'Can\'t start Pause: Invalid gamemode base', $player);
|
||||
} else {
|
||||
$text = $chatCallback[1][2];
|
||||
$text = explode(" ", $text);
|
||||
if (isset($text[1]) && $text[1] != "") {
|
||||
if (is_numeric($text[1]) && $text[1] > 0) {
|
||||
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . 'Admin force a pause for $<$ff0' . $text[1] . '$> seconds!');
|
||||
$this->maniaControl->getChat()->sendSuccess(self::CHAT_PREFIX . 'Admin force a pause for $<$ff0' . $text[1] . '$> seconds!');
|
||||
$this->setNadeoPause(true, $text[1]);
|
||||
} elseif (is_numeric($text[1]) && $text[1] == 0) {
|
||||
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . 'Admin force an unlimited pause');
|
||||
$this->maniaControl->getChat()->sendSuccess(self::CHAT_PREFIX . 'Admin force an unlimited pause');
|
||||
$this->setNadeoPause(true, $text[1]);
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Pause time sent is invalid', $player);
|
||||
$this->maniaControl->getChat()->sendError(self::CHAT_PREFIX . 'Pause time sent is invalid', $player);
|
||||
}
|
||||
} else {
|
||||
$duration = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_PAUSE_DURATION);
|
||||
if ($duration > 0) {
|
||||
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . 'Admin force a pause for ' . $duration . ' seconds!');
|
||||
$this->maniaControl->getChat()->sendSuccess(self::CHAT_PREFIX . 'Admin force a pause for ' . $duration . ' seconds!');
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . 'Admin force a pause');
|
||||
$this->maniaControl->getChat()->sendSuccess(self::CHAT_PREFIX . 'Admin force a pause');
|
||||
}
|
||||
|
||||
$this->setNadeoPause(true);
|
||||
@ -2225,7 +2257,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
return;
|
||||
}
|
||||
if (($this->matchStarted) && (!in_array($this->currentgmbase, ["Laps", "TimeAttack", "RoyalTimeAttack"]) || ( $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_SETTINGS_MODE) != 'All from file' && !empty($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_CUSTOM_GAMEMODE)))) && $this->pauseon) {
|
||||
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . 'Admin stopped the break');
|
||||
$this->maniaControl->getChat()->sendSuccess(self::CHAT_PREFIX . 'Admin stopped the break');
|
||||
$this->unsetNadeoPause();
|
||||
}
|
||||
}
|
||||
@ -2247,7 +2279,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$text = explode(" ", $text);
|
||||
|
||||
if (count($text) < 3) {
|
||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Missing parameters. Eg: //matchsetpoints <Player Name or Login> <Match points> <Map Points (optional)> <Round Points (optional)>', $adminplayer);
|
||||
$this->maniaControl->getChat()->sendError(self::CHAT_PREFIX . 'Missing parameters. Eg: //matchsetpoints <Player Name or Login> <Match points> <Map Points (optional)> <Round Points (optional)>', $adminplayer);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2257,14 +2289,14 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$roundpoints = '';
|
||||
|
||||
if (!is_numeric($matchpoints)) {
|
||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Invalid argument: Match points', $adminplayer);
|
||||
$this->maniaControl->getChat()->sendError(self::CHAT_PREFIX . 'Invalid argument: Match points', $adminplayer);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($text[3])) {
|
||||
$mappoints = $text[3];
|
||||
if (!is_numeric($mappoints)) {
|
||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Invalid argument: Map points', $adminplayer);
|
||||
$this->maniaControl->getChat()->sendError(self::CHAT_PREFIX . 'Invalid argument: Map points', $adminplayer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2272,7 +2304,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
if (isset($text[4])) {
|
||||
$roundpoints = $text[4];
|
||||
if (!is_numeric($roundpoints)) {
|
||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Invalid argument: Round points', $adminplayer);
|
||||
$this->maniaControl->getChat()->sendError(self::CHAT_PREFIX . 'Invalid argument: Round points', $adminplayer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2282,7 +2314,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$stmt->bind_param('s', $target);
|
||||
|
||||
if (!$stmt->execute()) {
|
||||
Logger::logError('Error executing MySQL query: '. $stmt->error);
|
||||
$this->logError('Error executing MySQL query: '. $stmt->error);
|
||||
}
|
||||
|
||||
$result = $stmt->get_result();
|
||||
@ -2301,12 +2333,12 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($login,true);
|
||||
if ($player) {
|
||||
$this->maniaControl->getModeScriptEventManager()->setTrackmaniaPlayerPoints($player, $roundpoints, $mappoints, $matchpoints);
|
||||
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . 'Player $<$ff0' . $player->nickname . '$> now has $<$ff0' . $matchpoints . '$> points!');
|
||||
$this->maniaControl->getChat()->sendSuccess(self::CHAT_PREFIX . 'Player $<$ff0' . $player->nickname . '$> now has $<$ff0' . $matchpoints . '$> points!');
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Player ' . $target . " isn't connected", $adminplayer);
|
||||
$this->maniaControl->getChat()->sendError(self::CHAT_PREFIX . 'Player ' . $target . " isn't connected", $adminplayer);
|
||||
}
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Player ' . $target . " doesn't exist", $adminplayer);
|
||||
$this->maniaControl->getChat()->sendError(self::CHAT_PREFIX . 'Player ' . $target . " doesn't exist", $adminplayer);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2321,7 +2353,7 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$text = explode(" ", $text);
|
||||
|
||||
if (count($text) < 3) {
|
||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Missing parameters. Eg: //matchsetteampoints <Team Name or Id> <Match points> <Map Points (optional)> <Round Points (optional)>', $adminplayer);
|
||||
$this->maniaControl->getChat()->sendError(self::CHAT_PREFIX . 'Missing parameters. Eg: //matchsetteampoints <Team Name or Id> <Match points> <Map Points (optional)> <Round Points (optional)>', $adminplayer);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2331,14 +2363,14 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
$roundpoints = '';
|
||||
|
||||
if (!is_numeric($matchpoints)) {
|
||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Invalid argument: Match points', $adminplayer);
|
||||
$this->maniaControl->getChat()->sendError(self::CHAT_PREFIX . 'Invalid argument: Match points', $adminplayer);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($text[3])) {
|
||||
$mappoints = $text[3];
|
||||
if (!is_numeric($mappoints)) {
|
||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Invalid argument: Map points', $adminplayer);
|
||||
$this->maniaControl->getChat()->sendError(self::CHAT_PREFIX . 'Invalid argument: Map points', $adminplayer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -2346,22 +2378,22 @@ class MatchManagerCore implements CallbackListener, CommandListener, TimerListen
|
||||
if (isset($text[4])) {
|
||||
$roundpoints = $text[4];
|
||||
if (!is_numeric($roundpoints)) {
|
||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Invalid argument: Round points', $adminplayer);
|
||||
$this->maniaControl->getChat()->sendError(self::CHAT_PREFIX . 'Invalid argument: Round points', $adminplayer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (strcasecmp($target, "Blue") == 0 || $target == "0") {
|
||||
$this->maniaControl->getModeScriptEventManager()->setTrackmaniaTeamPoints("0", $roundpoints, $mappoints, $matchpoints);
|
||||
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . '$<$00fBlue$> Team now has $<$ff0' . $matchpoints . '$> points!');
|
||||
$this->maniaControl->getChat()->sendSuccess(self::CHAT_PREFIX . '$<$00fBlue$> Team now has $<$ff0' . $matchpoints . '$> points!');
|
||||
} elseif (strcasecmp($target, "Red") == 0 || $target == "1") {
|
||||
$this->maniaControl->getModeScriptEventManager()->setTrackmaniaTeamPoints("1", $roundpoints, $mappoints, $matchpoints);
|
||||
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . '$<$f00Red$> Team now has $<$ff0' . $matchpoints . '$> points!');
|
||||
$this->maniaControl->getChat()->sendSuccess(self::CHAT_PREFIX . '$<$f00Red$> Team now has $<$ff0' . $matchpoints . '$> points!');
|
||||
} elseif (is_numeric($target)) { //TODO: add support of name of teams (need update from NADEO)
|
||||
$this->maniaControl->getModeScriptEventManager()->setTrackmaniaTeamPoints($target, $roundpoints, $mappoints, $matchpoints);
|
||||
$this->maniaControl->getChat()->sendSuccess($this->chatprefix . 'Team ' . $target . ' now has $<$ff0' . $matchpoints . '$> points!');
|
||||
$this->maniaControl->getChat()->sendSuccess(self::CHAT_PREFIX . 'Team ' . $target . ' now has $<$ff0' . $matchpoints . '$> points!');
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendError($this->chatprefix . 'Can\'t find team: ' . $target, $adminplayer);
|
||||
$this->maniaControl->getChat()->sendError(self::CHAT_PREFIX . 'Can\'t find team: ' . $target, $adminplayer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ use ManiaControl\Callbacks\Structures\TrackMania\OnWayPointEventStructure;
|
||||
use ManiaControl\Callbacks\TimerListener;
|
||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Plugins\PluginManager;
|
||||
use ManiaControl\Plugins\PluginMenu;
|
||||
|
||||
if (!class_exists('MatchManagerSuite\MatchManagerCore')) {
|
||||
@ -33,10 +34,12 @@ 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';
|
||||
|
||||
const LOG_PREFIX = '[MatchManagerECircuitMania] ';
|
||||
|
||||
const MATCHMANAGERCORE_PLUGIN = 'MatchManagerSuite\MatchManagerCore';
|
||||
const MATCHMANAGERADMINUI_PLUGIN = 'MatchManagerSuite\MatchManagerAdminUI';
|
||||
|
||||
@ -108,10 +111,12 @@ class MatchManagerECircuitMania implements CallbackListener, ManialinkPageAnswer
|
||||
$this->MatchManagerCore = $this->maniaControl->getPluginManager()->getPlugin(self::MATCHMANAGERCORE_PLUGIN);
|
||||
if ($this->MatchManagerCore === null) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is needed to use ' . self::PLUGIN_NAME . ' plugin.');
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class()));
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class($this)));
|
||||
return;
|
||||
}
|
||||
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PluginManager::CB_PLUGIN_LOADED, $this, 'handlePluginLoaded');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PluginManager::CB_PLUGIN_UNLOADED, $this, 'handlePluginUnloaded');
|
||||
$this->maniaControl->getCallbackManager()->registerScriptCallbackListener(self::CB_STARTMAP, $this, 'handleStartMap');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::MP_STARTROUNDSTART, $this, 'handleStartRound');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_ONWAYPOINT, $this, 'handleOnWaypoint');
|
||||
@ -130,6 +135,24 @@ class MatchManagerECircuitMania implements CallbackListener, ManialinkPageAnswer
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ML_ACTION_OPENSETTINGS, $this, 'handleActionOpenSettings');
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* handle Plugin Loaded
|
||||
*
|
||||
@ -141,6 +164,22 @@ class MatchManagerECircuitMania implements CallbackListener, ManialinkPageAnswer
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* handlePluginUnloaded
|
||||
*
|
||||
* @param string $pluginClass
|
||||
* @param Plugin $plugin
|
||||
* @return void
|
||||
*/
|
||||
public function handlePluginUnloaded(string $pluginClass, Plugin $plugin) {
|
||||
if ($pluginClass == self::MATCHMANAGERCORE_PLUGIN) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::PLUGIN_NAME . " disabled because MatchManager Core is now disabled");
|
||||
$this->log(self::PLUGIN_NAME . " disabled because MatchManager Core is now disabled");
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add items in AdminUI plugin
|
||||
*/
|
||||
@ -214,7 +253,7 @@ class MatchManagerECircuitMania implements CallbackListener, ManialinkPageAnswer
|
||||
if ($request !== null) {
|
||||
$request->setContent($payload)->setCallable(function ($content, $error, $headers) use ($payload) {
|
||||
if ($content !== "Created" || $error !== null) {
|
||||
Logger::logWarning("Error on the 'addRoundTime' request. answer: " . $content . " / error: " . $error . " / payload: " . $payload);
|
||||
$this->logError("Error on the 'addRoundTime' request. answer: " . $content . " / error: " . $error . " / payload: " . $payload);
|
||||
}
|
||||
})->postData();
|
||||
}
|
||||
@ -226,7 +265,6 @@ class MatchManagerECircuitMania implements CallbackListener, ManialinkPageAnswer
|
||||
|
||||
$scores = [];
|
||||
foreach ($structure->getPlayerScores() as $playerscore) {
|
||||
if ($playerscore->getMatchPoints() <= -2000) continue;
|
||||
$scores[] = $playerscore;
|
||||
}
|
||||
|
||||
@ -284,7 +322,7 @@ class MatchManagerECircuitMania implements CallbackListener, ManialinkPageAnswer
|
||||
if ($request !== null) {
|
||||
$request->setContent($payload)->setCallable(function ($content, $error, $headers) use ($payload) {
|
||||
if ($content !== "Created" || $error !== null) {
|
||||
Logger::logWarning("Error on the 'addRound' request. answer: " . $content . " / error: " . $error . " / payload: " . $payload);
|
||||
$this->logError("Error on the 'addRound' request. answer: " . $content . " / error: " . $error . " / payload: " . $payload);
|
||||
}
|
||||
})->postData();
|
||||
}
|
||||
@ -304,7 +342,7 @@ class MatchManagerECircuitMania implements CallbackListener, ManialinkPageAnswer
|
||||
if ($request !== null) {
|
||||
$request->setContent($payload)->setCallable(function ($content, $error, $headers) use ($payload) {
|
||||
if ($content !== "Created" || $error !== null) {
|
||||
Logger::logWarning("Error on the 'removeRound' request. answer: " . $content . " / error: " . $error . " / payload: " . $payload);
|
||||
$this->logError("Error on the 'removeRound' request. answer: " . $content . " / error: " . $error . " / payload: " . $payload);
|
||||
}
|
||||
})->postData();
|
||||
}
|
||||
@ -334,5 +372,11 @@ class MatchManagerECircuitMania implements CallbackListener, ManialinkPageAnswer
|
||||
/**
|
||||
* Unload the plugin and its Resources
|
||||
*/
|
||||
public function unload() {}
|
||||
public function unload() {
|
||||
/** @var \MatchManagerSuite\MatchManagerAdminUI|null */
|
||||
$adminUIPlugin = $this->maniaControl->getPluginManager()->getPlugin(self::MATCHMANAGERADMINUI_PLUGIN);
|
||||
if ($adminUIPlugin !== null) {
|
||||
$adminUIPlugin->removeMenuItem(self::ML_ACTION_OPENSETTINGS);
|
||||
}
|
||||
}
|
||||
}
|
@ -21,8 +21,8 @@ use ManiaControl\Plugins\PluginMenu;
|
||||
use ManiaControl\Utils\WebReader;
|
||||
|
||||
if (!class_exists('MatchManagerSuite\MatchManagerCore')) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol');
|
||||
Logger::logError('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is required to use MatchManagerGSheet plugin. Install it and restart Maniacontrol');
|
||||
Logger::logError('MatchManager Core is required to use MatchManagerGSheet plugin. Install it and restart Maniacontrol');
|
||||
return false;
|
||||
}
|
||||
use MatchManagerSuite\MatchManagerCore;
|
||||
@ -39,10 +39,12 @@ 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';
|
||||
|
||||
const LOG_PREFIX = '[MatchManagerGSheet] ';
|
||||
|
||||
// Other MatchManager plugin
|
||||
const MATCHMANAGERADMINUI_PLUGIN = 'MatchManagerSuite\MatchManagerAdminUI';
|
||||
|
||||
@ -193,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();
|
||||
|
||||
@ -213,6 +215,24 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* handle Plugin Loaded
|
||||
*
|
||||
@ -243,7 +263,8 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
public function handlePluginUnloaded(string $pluginClass, Plugin $plugin) {
|
||||
if ($pluginClass == self::MATCHMANAGERCORE_PLUGIN) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::PLUGIN_NAME . " disabled because MatchManager Core is now disabled");
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class()));
|
||||
$this->log(self::PLUGIN_NAME . " disabled because MatchManager Core is now disabled");
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,7 +293,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
if ($setting->belongsToClass($this)) {
|
||||
if (($setting->setting == self::SETTING_MATCHMANAGERGSHEET_CLIENT_SECRET && $setting->value == "hidden") || $setting->setting == self::SETTING_MATCHMANAGERGSHEET_CLIENT_ID) {
|
||||
// (Check when hidden = true to avoid double message)
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Google API Session cleared. You must revalidate a session with //matchgsheet step1');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Google API Session cleared. You must revalidate a session with //matchgsheet step1');
|
||||
|
||||
$this->saveSecretSetting("access_token");
|
||||
$this->saveSecretSetting("expire");
|
||||
@ -292,7 +313,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
|
||||
public function handlePlayerConnect(Player $player) {
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
$this->maniaControl->getChat()->sendError('Since MatchManagerGSheet 2.0, Player names are in the results and no more in a separated list', $player->login);
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() .'Since MatchManagerGSheet 2.0, Player names are in the results and no more in a separated list', $player->login);
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,15 +367,15 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
} elseif (isset($text[1]) && $text[1] == 'check') {
|
||||
$this->CheckSpeadsheetAccess($player);
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendError('use argument "step1", "step2" or "check"', $player);
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() .'use argument "step1", "step2" or "check"', $player);
|
||||
}
|
||||
}
|
||||
|
||||
private function OAuth2Step1(Player $player) {
|
||||
$clientid = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERGSHEET_CLIENT_ID);
|
||||
if (empty($clientid)) {
|
||||
Logger::logError('Client ID empty');
|
||||
$this->maniaControl->getChat()->sendError('Client ID empty', $player);
|
||||
$this->logError('Client ID empty');
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() .'Client ID empty', $player);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -362,29 +383,29 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
$asyncHttpRequest->setContentType("application/x-www-form-urlencoded");
|
||||
$asyncHttpRequest->setCallable(function ($json, $error) use ($player) {
|
||||
if (!$json || $error) {
|
||||
Logger::logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendError('Error from Google API: ' . $error, $player);
|
||||
$this->logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() .'Error from Google API: ' . $error, $player);
|
||||
return;
|
||||
}
|
||||
$data = json_decode($json);
|
||||
if (!$data) {
|
||||
Logger::logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendError('Json parse error: ' . $json, $player);
|
||||
$this->logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() .'Json parse error: ' . $json, $player);
|
||||
return;
|
||||
}
|
||||
if (property_exists($data, "error")) {
|
||||
Logger::logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
return;
|
||||
}
|
||||
if (isset($data->device_code)) {
|
||||
$this->device_code = $data->device_code;
|
||||
$this->maniaControl->getChat()->sendSuccess('Open $<$l['. $data->verification_url .'?user_code=' . $data->user_code . ']this link$> and type this code: "' . $data->user_code .'"' , $player);
|
||||
$this->maniaControl->getChat()->sendSuccess('After have validate the App, type the commande "//matchgsheet step2"' , $player);
|
||||
$this->maniaControl->getChat()->sendSuccess($this->MatchManagerCore->getChatPrefix() .'Open $<$l['. $data->verification_url .'?user_code=' . $data->user_code . ']this link$> and type this code: "' . $data->user_code .'"' , $player);
|
||||
$this->maniaControl->getChat()->sendSuccess($this->MatchManagerCore->getChatPrefix() .'After have validate the App, type the commande "//matchgsheet step2"' , $player);
|
||||
} elseif (isset($data->error_code)) {
|
||||
$this->maniaControl->getChat()->sendError('Google refused the request: ' . $data->error_code, $player);
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() .'Google refused the request: ' . $data->error_code, $player);
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendError('Unkown error' , $player);
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() .'Unkown error' , $player);
|
||||
}
|
||||
});
|
||||
|
||||
@ -394,21 +415,21 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
private function OAuth2Step2(Player $player) {
|
||||
$clientid = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERGSHEET_CLIENT_ID);
|
||||
if (empty($clientid)) {
|
||||
Logger::logError('Client ID empty');
|
||||
$this->maniaControl->getChat()->sendError('Client ID empty', $player);
|
||||
$this->logError('Client ID empty');
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() .'Client ID empty', $player);
|
||||
return;
|
||||
}
|
||||
|
||||
$clientsecret = $this->getSecretSetting("client_secret");
|
||||
if (empty($clientsecret)) {
|
||||
Logger::logError('Client Secret empty');
|
||||
$this->maniaControl->getChat()->sendError('Client Secret empty', $player);
|
||||
$this->logError('Client Secret empty');
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() .'Client Secret empty', $player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($this->device_code)) {
|
||||
Logger::logError('No device_code. Have you run the step 1?');
|
||||
$this->maniaControl->getChat()->sendError('No device_code. Have you run the step 1?', $player);
|
||||
$this->logError('No device_code. Have you run the step 1?');
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() .'No device_code. Have you run the step 1?', $player);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -417,19 +438,19 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
$asyncHttpRequest->setHeaders(array("Content-Length: 0"));
|
||||
$asyncHttpRequest->setCallable(function ($json, $error) use ($player) {
|
||||
if (!$json || $error) {
|
||||
Logger::logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendError('Error from Google API: ' . $error, $player);
|
||||
$this->logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() .'Error from Google API: ' . $error, $player);
|
||||
return;
|
||||
}
|
||||
$data = json_decode($json);
|
||||
if (!$data) {
|
||||
Logger::logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendError('Json parse error: ' . $json, $player);
|
||||
$this->logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() .'Json parse error: ' . $json, $player);
|
||||
return;
|
||||
}
|
||||
if (property_exists($data, "error")) {
|
||||
Logger::logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -438,13 +459,13 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
$this->saveSecretSetting("access_token", $data->access_token);
|
||||
$this->saveSecretSetting("expire", time() + $data->expires_in);
|
||||
$this->saveSecretSetting("refresh_token", $data->refresh_token);
|
||||
$this->maniaControl->getChat()->sendSuccess('Maniacontrol is registered' , $player);
|
||||
$this->maniaControl->getChat()->sendSuccess($this->MatchManagerCore->getChatPrefix() .'Maniacontrol is registered' , $player);
|
||||
} elseif (isset($data->error_description)) {
|
||||
Logger::logError('Google refused the request: ' . $data->error_description);
|
||||
$this->maniaControl->getChat()->sendError('Google refused the request: ' . $data->error_description , $player);
|
||||
$this->logError('Google refused the request: ' . $data->error_description);
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() .'Google refused the request: ' . $data->error_description , $player);
|
||||
} else {
|
||||
Logger::logError('Unkown error' . $data->error_description);
|
||||
$this->maniaControl->getChat()->sendError('Unkown error' , $player);
|
||||
$this->logError('Unkown error' . $data->error_description);
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() .'Unkown error' , $player);
|
||||
}
|
||||
});
|
||||
|
||||
@ -452,7 +473,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
}
|
||||
|
||||
private function refreshTokenIfNeeded() {
|
||||
Logger::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");
|
||||
@ -465,18 +486,18 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
$json = $response->getContent();
|
||||
$error = $response->getError();
|
||||
if (!$json || $error) {
|
||||
Logger::logError('Error during token refresh: ' . $error);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Error during token refresh: ' . $error);
|
||||
$this->logError('Error during token refresh: ' . $error);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Error during token refresh: ' . $error);
|
||||
return;
|
||||
}
|
||||
$data = json_decode($json);
|
||||
if (!$data) {
|
||||
Logger::logError('Json parse error: ' . $json);
|
||||
$this->logError('Json parse error: ' . $json);
|
||||
return;
|
||||
}
|
||||
if (property_exists($data, "error")) {
|
||||
Logger::logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -484,10 +505,12 @@ 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('Google refused the request: ' . $data->error_description);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Google refused the request: ' . $data->error_description);
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Unkown error');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Unkown error');
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -530,7 +553,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
private function CheckSpeadsheetAccess(Player $player) {
|
||||
$spreadsheetid = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERGSHEET_SPREADSHEET);
|
||||
if ($spreadsheetid === "") {
|
||||
$this->maniaControl->getChat()->sendError('Empty Spreadsheet Id', $player);
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() .'Empty Spreadsheet Id', $player);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -540,32 +563,32 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
$asyncHttpRequest->setHeaders(array("Authorization: Bearer " . $this->access_token));
|
||||
$asyncHttpRequest->setCallable(function ($json, $error) use ($player) {
|
||||
if (!$json || $error) {
|
||||
Logger::logError('Error: ' . $error);
|
||||
$this->maniaControl->getChat()->sendError('Error: ' . $error, $player);
|
||||
$this->logError('Error: ' . $error);
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() .'Error: ' . $error, $player);
|
||||
return;
|
||||
}
|
||||
$data = json_decode($json);
|
||||
if (!$data) {
|
||||
Logger::logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendError('Json parse error: ' . $json, $player);
|
||||
$this->logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() .'Json parse error: ' . $json, $player);
|
||||
return;
|
||||
}
|
||||
if (property_exists($data, "error")) {
|
||||
Logger::logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($data->properties->title)) {
|
||||
$this->maniaControl->getChat()->sendSuccess('Speadsheet name: ' . $data->properties->title, $player);
|
||||
$this->maniaControl->getChat()->sendSuccess($this->MatchManagerCore->getChatPrefix() .'Speadsheet name: ' . $data->properties->title, $player);
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendError("Can't access to the Spreadsheet: " . $data->error->message, $player);
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() ."Can't access to the Spreadsheet: " . $data->error->message, $player);
|
||||
}
|
||||
});
|
||||
|
||||
$asyncHttpRequest->getData(1000);
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendError("Can't have access to Google API service", $player);
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() ."Can't have access to Google API service", $player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -632,23 +655,24 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
$asyncHttpRequest->setContent(json_encode($data));
|
||||
$asyncHttpRequest->setCallable(function ($json, $error) use ($sheetname, $spreadsheetid, $currentscore, $currentteamsscore, $matchstatus, $nbmaps, $nbrounds) {
|
||||
if (!$json || $error) {
|
||||
Logger::logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Error from Google API: ' . $error);
|
||||
$this->logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Error from Google API: ' . $error);
|
||||
return;
|
||||
}
|
||||
$data = json_decode($json);
|
||||
if (!$data) {
|
||||
Logger::logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Json parse error: ' . $json);
|
||||
$this->logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Json parse error: ' . $json);
|
||||
return;
|
||||
}
|
||||
if (property_exists($data, "error")) {
|
||||
Logger::logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
return;
|
||||
}
|
||||
|
||||
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));
|
||||
@ -665,26 +689,28 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
$asyncHttpRequest->setContent(json_encode($data));
|
||||
$asyncHttpRequest->setCallable(function ($json, $error) use ($sheetname, $spreadsheetid, $currentteamsscore, $nbmaps, $nbrounds) {
|
||||
if (!$json || $error) {
|
||||
Logger::logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Error from Google API: ' . $error);
|
||||
$this->logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Error from Google API: ' . $error);
|
||||
return;
|
||||
}
|
||||
$data = json_decode($json);
|
||||
if (!$data) {
|
||||
Logger::logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Json parse error: ' . $json);
|
||||
$this->logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Json parse error: ' . $json);
|
||||
return;
|
||||
}
|
||||
if (property_exists($data, "error")) {
|
||||
Logger::logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
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;
|
||||
@ -698,41 +724,45 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
$asyncHttpRequest->setContent(json_encode($data));
|
||||
$asyncHttpRequest->setCallable(function ($json, $error) {
|
||||
if (!$json || $error) {
|
||||
Logger::logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Error from Google API: ' . $error);
|
||||
$this->logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Error from Google API: ' . $error);
|
||||
return;
|
||||
}
|
||||
$data = json_decode($json);
|
||||
if (!$data) {
|
||||
Logger::logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Json parse error: ' . $json);
|
||||
$this->logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Json parse error: ' . $json);
|
||||
return;
|
||||
}
|
||||
if (property_exists($data, "error")) {
|
||||
Logger::logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
return;
|
||||
}
|
||||
});
|
||||
$asyncHttpRequest->postData(1000);
|
||||
}
|
||||
|
||||
$this->log('Successfully appending Team Scores data');
|
||||
});
|
||||
$asyncHttpRequest->postData(1000);
|
||||
}
|
||||
});
|
||||
$asyncHttpRequest->postData(1000);
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Impossible to update the Google Sheet');
|
||||
$this->log('Successfully sent Info and Scores data');
|
||||
}
|
||||
});
|
||||
$asyncHttpRequest->postData(1000);
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Impossible to update the Google Sheet');
|
||||
}
|
||||
}
|
||||
|
||||
function onCallbackEndRound(String $matchid, Array $currentscore, Array $currentteamsscore) {
|
||||
Logger::Log('onCallbackEndRound');
|
||||
$this->log('onCallbackEndRound');
|
||||
$this->matchstatus = "running";
|
||||
$this->UpdateGSheetData($matchid, $currentscore, $currentteamsscore);
|
||||
}
|
||||
function onCallbackEndMatch(String $matchid, Array $currentscore, Array $currentteamsscore) {
|
||||
Logger::Log('onCallbackEndMatch');
|
||||
$this->log('onCallbackEndMatch');
|
||||
$this->matchstatus = "ended";
|
||||
|
||||
$this->maniaControl->getTimerManager()->registerOneTimeListening($this, function () use ($matchid, $currentscore, $currentteamsscore) {
|
||||
@ -740,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) {
|
||||
Logger::Log('onCallbackStopMatch');
|
||||
$this->log('onCallbackStopMatch');
|
||||
$this->matchstatus = "stopped";
|
||||
$this->UpdateGSheetData($matchid, $currentscore, $currentteamsscore);
|
||||
}
|
||||
@ -759,19 +789,19 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
$asyncHttpRequest->setHeaders(array("Authorization: Bearer " . $this->access_token));
|
||||
$asyncHttpRequest->setCallable(function ($json, $error) use ($sheetname) {
|
||||
if (!$json || $error) {
|
||||
Logger::logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Error from Google API: ' . $error);
|
||||
$this->logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Error from Google API: ' . $error);
|
||||
return;
|
||||
}
|
||||
$data = json_decode($json);
|
||||
if (!$data) {
|
||||
Logger::logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Json parse error: ' . $json);
|
||||
$this->logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Json parse error: ' . $json);
|
||||
return;
|
||||
}
|
||||
if (property_exists($data, "error")) {
|
||||
Logger::logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -812,7 +842,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
$i = 0;
|
||||
|
||||
if (!$sheetexists) {
|
||||
Logger::Log("Creating new Sheet: " . $sheetname);
|
||||
$this->log("Creating new Sheet: " . $sheetname);
|
||||
$sheetid = rand(1000,2147483646);
|
||||
while (in_array($sheetid, $sheetsid)) {
|
||||
$sheetid = rand(1000,2147483646);
|
||||
@ -907,43 +937,47 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
$asyncHttpRequest->setContent(json_encode($data));
|
||||
$asyncHttpRequest->setCallable(function ($json, $error) use ($sheetname, $spreadsheetid) {
|
||||
if (!$json || $error) {
|
||||
Logger::logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Error from Google API: ' . $error);
|
||||
$this->logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Error from Google API: ' . $error);
|
||||
return;
|
||||
}
|
||||
$data = json_decode($json);
|
||||
if (!$data) {
|
||||
Logger::logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Json parse error: ' . $json);
|
||||
$this->logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Json parse error: ' . $json);
|
||||
return;
|
||||
}
|
||||
if (property_exists($data, "error")) {
|
||||
Logger::logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
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));
|
||||
$asyncHttpRequest->setCallable(function ($json, $error) use ($sheetname, $spreadsheetid) {
|
||||
if (!$json || $error) {
|
||||
Logger::logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Error from Google API: ' . $error);
|
||||
$this->logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Error from Google API: ' . $error);
|
||||
return;
|
||||
}
|
||||
$data = json_decode($json);
|
||||
if (!$data) {
|
||||
Logger::logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Json parse error: ' . $json);
|
||||
$this->logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Json parse error: ' . $json);
|
||||
return;
|
||||
}
|
||||
if (property_exists($data, "error")) {
|
||||
Logger::logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->log('Successfully cleared all the data');
|
||||
|
||||
// Add headers data
|
||||
$data = new \stdClass;
|
||||
$data->valueInputOption = "RAW";
|
||||
@ -966,21 +1000,23 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
$asyncHttpRequest->setContent(json_encode($data));
|
||||
$asyncHttpRequest->setCallable(function ($json, $error) {
|
||||
if (!$json || $error) {
|
||||
Logger::logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Error from Google API: ' . $error);
|
||||
$this->logError('Error from Google API: ' . $error);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Error from Google API: ' . $error);
|
||||
return;
|
||||
}
|
||||
$data = json_decode($json);
|
||||
if (!$data) {
|
||||
Logger::logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Json parse error: ' . $json);
|
||||
$this->logError('Json parse error: ' . $json);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Json parse error: ' . $json);
|
||||
return;
|
||||
}
|
||||
if (property_exists($data, "error")) {
|
||||
Logger::logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$this->logError('Request error: ' . $data->error->code . " ". $data->error->message);
|
||||
$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);
|
||||
});
|
||||
|
@ -27,8 +27,8 @@ use ManiaControl\Commands\CommandListener;
|
||||
use ManiaControl\Plugins\PluginMenu;
|
||||
|
||||
if (!class_exists('MatchManagerSuite\MatchManagerCore')) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol');
|
||||
Logger::logError('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is required to use MatchManagerMultipleConfigManager plugin. Install it and restart Maniacontrol');
|
||||
Logger::logError('MatchManager Core is required to use MatchManagerMultipleConfigManager plugin. Install it and restart Maniacontrol');
|
||||
return false;
|
||||
}
|
||||
use MatchManagerSuite\MatchManagerCore;
|
||||
@ -44,10 +44,13 @@ 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';
|
||||
|
||||
const LOG_PREFIX = '[MatchManagerMultipleConfigManager] ';
|
||||
|
||||
|
||||
// MatchManagerWidget Properties
|
||||
const MATCHMANAGERCORE_PLUGIN = 'MatchManagerSuite\MatchManagerCore';
|
||||
const MATCHMANAGERADMINUI_PLUGIN = 'MatchManagerSuite\MatchManagerAdminUI';
|
||||
@ -71,6 +74,7 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
/** @var MatchManagerCore $MatchManagerCore */
|
||||
private $MatchManagerCore = null;
|
||||
|
||||
/**
|
||||
@ -152,6 +156,24 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* handle Plugin Loaded
|
||||
*
|
||||
@ -182,7 +204,8 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
|
||||
public function handlePluginUnloaded(string $pluginClass, Plugin $plugin) {
|
||||
if ($pluginClass == self::MATCHMANAGERCORE_PLUGIN) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::PLUGIN_NAME . " disabled because MatchManager Core is now disabled");
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class()));
|
||||
$this->log(self::PLUGIN_NAME . " disabled because MatchManager Core is now disabled");
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -248,7 +271,7 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
|
||||
break;
|
||||
case self::ML_ACTION_REMOVE_CONFIG:
|
||||
$id = intval($actionArray[2]);
|
||||
Logger::log("[MatchManagerMultipleConfigManager] Removing config: " . $id);
|
||||
$this->log("Removing config: " . $id);
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
|
||||
$query = $mysqli->prepare('DELETE FROM `'. self::DB_MATCHCONFIG .'` WHERE id = ?;');
|
||||
@ -288,8 +311,8 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
|
||||
*/
|
||||
public function loadConfig(int $id) {
|
||||
if ($this->MatchManagerCore->getMatchStatus()) {
|
||||
Logger::logError("Impossible to load config during a match");
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Impossible to load config during a match');
|
||||
$this->logError("Impossible to load config during a match");
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Impossible to load config during a match');
|
||||
return;
|
||||
}
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
@ -310,7 +333,7 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
|
||||
if ($result[0] && $result[0]["config"]) {
|
||||
$allconfigs = json_decode($result[0]["config"],true);
|
||||
if ($allconfigs != null) {
|
||||
Logger::log("[MatchManagerMultipleConfigManager] Loading config: " . $id);
|
||||
$this->log("Loading config: " . $id);
|
||||
$someconfignotloaded = false;
|
||||
foreach ($allconfigs as $plugin => $configs) {
|
||||
$pluginclass = $this->maniaControl->getPluginManager()->getPlugin($plugin);
|
||||
@ -321,22 +344,22 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
|
||||
$setting = $this->maniaControl->getSettingManager()->getSettingObject($pluginclass, $name);
|
||||
if ($setting != null) {
|
||||
if ($setting->value != $value) {
|
||||
Logger::log("Saving new setting " . $name);
|
||||
$this->log("Saving new setting " . $name);
|
||||
$setting->value = $value;
|
||||
$this->maniaControl->getSettingManager()->saveSetting($setting);
|
||||
}
|
||||
} else {
|
||||
$someconfignotloaded = true;
|
||||
Logger::log("Unable to load setting: " . $name);
|
||||
$this->log("Unable to load setting: " . $name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($someconfignotloaded) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('One or more settings could not be imported');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'One or more settings could not be imported');
|
||||
}
|
||||
$this->maniaControl->getSettingManager()->clearStorage();
|
||||
$this->maniaControl->getChat()->sendSuccessToAdmins('MatchManager Config "' . $result[0]["name"] . '" loaded');
|
||||
$this->maniaControl->getChat()->sendSuccessToAdmins($this->MatchManagerCore->getChatPrefix() .'MatchManager Config "' . $result[0]["name"] . '" loaded');
|
||||
}
|
||||
}
|
||||
|
||||
@ -350,7 +373,7 @@ class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener,
|
||||
* @return void
|
||||
*/
|
||||
public function saveCurrentConfig(array $fields) {
|
||||
Logger::log("[MatchManagerMultipleConfigManager] Saving current config");
|
||||
$this->log("Saving current config");
|
||||
$result = array();
|
||||
$configname = "";
|
||||
$gamemodebase = "";
|
||||
|
@ -21,8 +21,8 @@ use ManiaControl\Commands\CommandListener;
|
||||
|
||||
|
||||
if (!class_exists('MatchManagerSuite\MatchManagerCore')) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol');
|
||||
Logger::logError('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is required to use MatchManagerPlayersPause plugin. Install it and restart Maniacontrol');
|
||||
Logger::logError('MatchManager Core is required to use MatchManagerPlayersPause plugin. Install it and restart Maniacontrol');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -38,10 +38,12 @@ 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';
|
||||
|
||||
const LOG_PREFIX = '[MatchManagerPlayersPause] ';
|
||||
|
||||
// MatchManagerWidget Properties
|
||||
const MATCHMANAGERCORE_PLUGIN = 'MatchManagerSuite\MatchManagerCore';
|
||||
|
||||
@ -58,6 +60,7 @@ class MatchManagerPlayersPause implements ManialinkPageAnswerListener, CommandLi
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
/** @var MatchManagerCore $MatchManagerCore */
|
||||
private $MatchManagerCore = null;
|
||||
|
||||
private $playerspausestate = array();
|
||||
@ -160,6 +163,24 @@ class MatchManagerPlayersPause implements ManialinkPageAnswerListener, CommandLi
|
||||
$this->closePauseWidget();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* handlePluginUnloaded
|
||||
*
|
||||
@ -170,7 +191,8 @@ class MatchManagerPlayersPause implements ManialinkPageAnswerListener, CommandLi
|
||||
public function handlePluginUnloaded(string $pluginClass, Plugin $plugin) {
|
||||
if ($pluginClass == self::MATCHMANAGERCORE_PLUGIN) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::PLUGIN_NAME . " disabled because MatchManager Core is now disabled");
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class()));
|
||||
$this->log(self::PLUGIN_NAME . " disabled because MatchManager Core is now disabled");
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,7 +233,7 @@ class MatchManagerPlayersPause implements ManialinkPageAnswerListener, CommandLi
|
||||
if ($nbpause >= $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_PAUSE_NBPLAYERS)) {
|
||||
$this->playerspausestate = array();
|
||||
$this->closePauseWidget();
|
||||
Logger::log('Pause requested by players');
|
||||
$this->log('Pause requested by players');
|
||||
if (!$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_PAUSE_WAIT_END_ROUND)) {
|
||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl, MatchManagerCore::SETTING_MATCH_PAUSE_DURATION) <= 0) {
|
||||
$this->maniaControl->getChat()->sendInformation($this->MatchManagerCore->getChatPrefix() . 'Ask the admins to resume the match');
|
||||
|
@ -20,8 +20,8 @@ use ManiaControl\Commands\CommandListener;
|
||||
use Maniaplanet\DedicatedServer\InvalidArgumentException;
|
||||
|
||||
if (!class_exists('MatchManagerSuite\MatchManagerCore')) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol');
|
||||
Logger::logError('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is required to use MatchManagerReadyButton plugin. Install it and restart Maniacontrol');
|
||||
Logger::logError('MatchManager Core is required to use MatchManagerReadyButton plugin. Install it and restart Maniacontrol');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -37,10 +37,12 @@ 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';
|
||||
|
||||
const LOG_PREFIX = '[MatchManagerReadyButton] ';
|
||||
|
||||
// MatchManagerWidget Properties
|
||||
const MATCHMANAGERCORE_PLUGIN = 'MatchManagerSuite\MatchManagerCore';
|
||||
|
||||
@ -57,6 +59,7 @@ class MatchManagerReadyButton implements ManialinkPageAnswerListener, CommandLis
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
/** @var MatchManagerCore $MatchManagerCore */
|
||||
private $MatchManagerCore = null;
|
||||
|
||||
private $playersreadystate = array();
|
||||
@ -154,6 +157,24 @@ class MatchManagerReadyButton implements ManialinkPageAnswerListener, CommandLis
|
||||
$this->closeReadyWidget();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* handlePluginUnloaded
|
||||
*
|
||||
@ -164,7 +185,7 @@ class MatchManagerReadyButton implements ManialinkPageAnswerListener, CommandLis
|
||||
public function handlePluginUnloaded(string $pluginClass, Plugin $plugin) {
|
||||
if ($pluginClass == self::MATCHMANAGERCORE_PLUGIN) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::PLUGIN_NAME . " disabled because MatchManager Core is now disabled");
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class()));
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,7 +226,7 @@ class MatchManagerReadyButton implements ManialinkPageAnswerListener, CommandLis
|
||||
if ($nbready >= $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCH_READY_NBPLAYERS)) {
|
||||
$this->playersreadystate = array();
|
||||
$this->closeReadyWidget();
|
||||
Logger::log('Start Match via Ready Button');
|
||||
$this->log('Start Match via Ready Button');
|
||||
$this->MatchManagerCore->MatchStart();
|
||||
return;
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ use ManiaControl\Utils\WebReader;
|
||||
|
||||
|
||||
if (!class_exists('MatchManagerSuite\MatchManagerCore')) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol');
|
||||
Logger::logError('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is required to use MatchManagerTMWTDuoIntegration plugin. Install it and restart Maniacontrol');
|
||||
Logger::logError('MatchManager Core is required to use MatchManagerTMWTDuoIntegration plugin. Install it and restart Maniacontrol');
|
||||
return false;
|
||||
}
|
||||
use MatchManagerSuite\MatchManagerCore;
|
||||
@ -37,10 +37,12 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 211;
|
||||
const PLUGIN_VERSION = 1.0;
|
||||
const PLUGIN_VERSION = 1.2;
|
||||
const PLUGIN_NAME = 'MatchManager TMWT Duo Integration';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
const LOG_PREFIX = '[MatchManagerTMWTDuoIntegration] ';
|
||||
|
||||
// Other MatchManager plugin
|
||||
const MATCHMANAGERCORE_PLUGIN = 'MatchManagerSuite\MatchManagerCore';
|
||||
const MATCHMANAGERADMINUI_PLUGIN = 'MatchManagerSuite\MatchManagerAdminUI';
|
||||
@ -62,6 +64,7 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
|
||||
const SETTING_PICKANDBAN_ENABLE = 'Enable Pick & Ban';
|
||||
const SETTING_PICKANDBAN_STEPCONFIG = 'Pick & Ban: Step config';
|
||||
const SETTING_PICKANDBAN_STEPDURATION = 'Pick & Ban: Step duration';
|
||||
const SETTING_PICKANDBAN_OVERRIDEMAPORDER = 'Pick & Ban: Override Map Order';
|
||||
const SETTING_PICKANDBAN_RESULTDURATION = 'Pick & Ban: Result duration';
|
||||
|
||||
const STATE_NOTHING = 0;
|
||||
@ -74,6 +77,7 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
/** @var MatchManagerCore $MatchManagerCore */
|
||||
private $MatchManagerCore = null;
|
||||
private $state = 0;
|
||||
|
||||
@ -139,7 +143,8 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PICKANDBAN_ENABLE, false, '', 20);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PICKANDBAN_STEPCONFIG, '', 'Similar syntax as the ofiicial Competition Tool. e.g: b:1,b:0,p:0,p:1,p:1,p:0,b:0,b:1,p:r');
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PICKANDBAN_STEPDURATION, 60000, 'Each step duration in ms', 110);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PICKANDBAN_RESULTDURATION, 10000, 'result duration in ms', 120);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PICKANDBAN_OVERRIDEMAPORDER, '', 'Override map order received by the server. e.g: 1,2,4,3,5', 120);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PICKANDBAN_RESULTDURATION, 10000, 'result duration in ms', 130);
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ML_ACTION_OPENSETTINGS, $this, 'handleActionOpenSettings');
|
||||
@ -157,6 +162,24 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
|
||||
$this->updateAdminUIMenuItems();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* handle Plugin Loaded
|
||||
*
|
||||
@ -221,20 +244,20 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
|
||||
*/
|
||||
public function canStartMatch() {
|
||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this->MatchManagerCore, 'S_TeamsUrl') === '') {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() . " S_TeamsUrl must be defined");
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() . "S_TeamsUrl must be defined");
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_TEAM1) === '' ||
|
||||
$this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_TEAM2) === ''
|
||||
) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() . " Team Id must be defined");
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() . "Team Id must be defined");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_PICKANDBAN_ENABLE)) {
|
||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this->MatchManagerCore, $this->MatchManagerCore::SETTING_MATCH_SETTINGS_MODE) !== "All from the plugin") {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('TMWT Pick and bans are only supported in Match Manager Core "All from the plugin" mode');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'TMWT Pick and bans are only supported in MatchManagerCore "All from the plugin" mode');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -254,8 +277,8 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
|
||||
if ($setting !== null && !$setting->value) {
|
||||
$setting->value = true;
|
||||
$this->maniaControl->getSettingManager()->saveSetting($setting);
|
||||
Logger::logWarning('Remplacing S_IsMatchmaking setting value in MatchManagerCore for TMWT integration');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Remplacing S_IsMatchmaking setting value in MatchManagerCore for TMWT integration');
|
||||
$this->logError('Remplacing S_IsMatchmaking setting value in MatchManagerCore for TMWT integration');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Remplacing S_IsMatchmaking setting value in MatchManagerCore for TMWT integration');
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_PICKANDBAN_ENABLE)) {
|
||||
@ -263,8 +286,8 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
|
||||
if ($setting !== null && !$setting->value) {
|
||||
$setting->value = true;
|
||||
$this->maniaControl->getSettingManager()->saveSetting($setting);
|
||||
Logger::logWarning('Remplacing S_PickAndBan_Enable setting value in MatchManagerCore for TMWT integration');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Remplacing S_PickAndBan_Enable setting value in MatchManagerCore for TMWT integration');
|
||||
$this->logError('Remplacing S_PickAndBan_Enable setting value in MatchManagerCore for TMWT integration');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'Remplacing S_PickAndBan_Enable setting value in MatchManagerCore for TMWT integration');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -317,14 +340,14 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
|
||||
if ($team->Id === $team1) {
|
||||
$team1 = null;
|
||||
foreach ($team->Players as $player) {
|
||||
Logger::log($player->AccountId ." added to team 1");
|
||||
$this->log($player->AccountId ." added to team 1");
|
||||
$this->maniaControl->getClient()->triggerModeScriptEvent(self::XMLRPC_METHOD_ADDPLAYER, [$player->AccountId, "1"], true);
|
||||
}
|
||||
}
|
||||
if ($team->Id === $team2) {
|
||||
$team2 = null;
|
||||
foreach ($team->Players as $player) {
|
||||
Logger::log($player->AccountId ." added to team 2");
|
||||
$this->log($player->AccountId ." added to team 2");
|
||||
$this->maniaControl->getClient()->triggerModeScriptEvent(self::XMLRPC_METHOD_ADDPLAYER, [$player->AccountId, "2"], true);
|
||||
}
|
||||
}
|
||||
@ -333,8 +356,8 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
|
||||
}
|
||||
|
||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_PICKANDBAN_ENABLE)) {
|
||||
Logger::log('Starting Pick & ban in 10 seconds');
|
||||
$this->maniaControl->getChat()->sendSuccess('Starting pick & ban in 10 seconds');
|
||||
$this->log('Starting Pick & ban in 10 seconds');
|
||||
$this->maniaControl->getChat()->sendSuccess($this->MatchManagerCore->getChatPrefix() .'Starting pick & ban in 10 seconds');
|
||||
$this->maniaControl->getTimerManager()->registerOneTimeListening($this, function () {
|
||||
$payload = [
|
||||
'stepDuration' => $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_PICKANDBAN_STEPDURATION),
|
||||
@ -364,12 +387,12 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
|
||||
|
||||
$json = json_encode($payload);
|
||||
|
||||
Logger::log('Starting Pick & ban: '. $json);
|
||||
$this->log('Starting Pick & ban: '. $json);
|
||||
$this->maniaControl->getClient()->triggerModeScriptEvent(self::XMLRPC_METHOD_STARTPICKANDBAN, [$json], true);
|
||||
}, 5000);
|
||||
} else {
|
||||
$this->state = self::STATE_MATCH;
|
||||
Logger::log('Sending match start callback');
|
||||
$this->log('Sending match start callback');
|
||||
$this->maniaControl->getClient()->triggerModeScriptEvent(self::XMLRPC_METHOD_MATCHSTARTED, [], true);
|
||||
}
|
||||
}
|
||||
@ -385,13 +408,30 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
|
||||
*/
|
||||
public function handlePickAndBanComplete(array $structure) {
|
||||
if (!$this->MatchManagerCore->getMatchStatus()) return;
|
||||
Logger::log('Received picks: '. $structure[1][0]);
|
||||
$this->log('Received picks: '. $structure[1][0]);
|
||||
|
||||
$this->maniaControl->getTimerManager()->registerOneTimeListening($this, function () use ($structure) {
|
||||
try {
|
||||
$json = json_decode($structure[1][0]);
|
||||
|
||||
$mapUids = array_column($json->playlist, 'uid');
|
||||
|
||||
$order = explode(',', $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];
|
||||
}
|
||||
$mapUids = $orderedMapUid;
|
||||
} catch (\Throwable $th) {
|
||||
$this->logError("Invalid Map order setting");
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() ."Invalid Map order setting");
|
||||
}
|
||||
}
|
||||
|
||||
$mapList = [];
|
||||
foreach ($this->maniaControl->getMapManager()->getMaps() as $map) {
|
||||
$index = array_search($map->uid, $mapUids);
|
||||
@ -404,19 +444,19 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
|
||||
}
|
||||
|
||||
if (count($mapUids) !== count($mapList)) {
|
||||
Logger::logError("Missing maps: ". implode(' ', array_diff($mapUids, $mapList)));
|
||||
$this->logError("Missing maps: ". implode(' ', array_diff($mapUids, $mapList)));
|
||||
}
|
||||
|
||||
ksort($mapList);
|
||||
|
||||
$this->maniaControl->getClient()->chooseNextMapList(array_values($mapList));
|
||||
} catch (\Throwable $th) {
|
||||
Logger::logError("Can't apply map list: ". $th->getMessage());
|
||||
$this->maniaControl->getChat()->sendError("Can't apply map list: ". $th->getMessage());
|
||||
$this->logError("Can't apply map list: ". $th->getMessage());
|
||||
$this->maniaControl->getChat()->sendError($this->MatchManagerCore->getChatPrefix() ."Can't apply map list: ". $th->getMessage());
|
||||
}
|
||||
|
||||
$this->state = self::STATE_MATCH;
|
||||
Logger::log('Sending match start callback');
|
||||
$this->log('Sending match start callback');
|
||||
$this->maniaControl->getClient()->triggerModeScriptEvent(self::XMLRPC_METHOD_MATCHSTARTED, [], true);
|
||||
$this->maniaControl->getMapManager()->getMapActions()->skipMap();
|
||||
}, $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_PICKANDBAN_RESULTDURATION));
|
||||
@ -431,8 +471,8 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
|
||||
*/
|
||||
public function handlePluginUnloaded(string $pluginClass, Plugin $plugin) {
|
||||
if ($pluginClass == self::MATCHMANAGERCORE_PLUGIN) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::PLUGIN_NAME . " disabled because MatchManager Core is now disabled");
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class()));
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .self::PLUGIN_NAME . " disabled because MatchManager Core is now disabled");
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -446,7 +486,7 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
|
||||
if ($setting->setting === self::SETTING_PICKANDBAN_ENABLE || $setting->setting === $this->MatchManagerCore::SETTING_MATCH_SETTINGS_MODE) {
|
||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_PICKANDBAN_ENABLE)) {
|
||||
if ($this->maniaControl->getSettingManager()->getSettingValue($this->MatchManagerCore, $this->MatchManagerCore::SETTING_MATCH_SETTINGS_MODE) !== "All from the plugin") {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('TMWT Pick and bans are only supported in Match Manager Core "All from the plugin" mode');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins($this->MatchManagerCore->getChatPrefix() .'TMWT Pick and bans are only supported in Match Manager Core "All from the plugin" mode');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -456,7 +496,7 @@ class MatchManagerTMWTDuoIntegration implements CallbackListener, ManialinkPageA
|
||||
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||
*/
|
||||
public function unload() {
|
||||
$this->MatchManagerCore->removeCanStartFunction($this, 'canStartMatch');
|
||||
if ($this->MatchManagerCore !== null) $this->MatchManagerCore->removeCanStartFunction($this, 'canStartMatch');
|
||||
/** @var \MatchManagerSuite\MatchManagerAdminUI|null */
|
||||
$adminUIPlugin = $this->maniaControl->getPluginManager()->getPlugin(self::MATCHMANAGERADMINUI_PLUGIN);
|
||||
if ($adminUIPlugin !== null) {
|
||||
|
@ -20,8 +20,8 @@ use ManiaControl\Settings\Setting;
|
||||
use ManiaControl\Settings\SettingManager;
|
||||
|
||||
if (!class_exists('MatchManagerSuite\MatchManagerCore')) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol');
|
||||
Logger::logError('MatchManager Core is required to use one of MatchManager plugin. Install it and restart Maniacontrol');
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is required to use MatchManagerWidget plugin. Install it and restart Maniacontrol');
|
||||
$this->logError('MatchManager Core is required to use MatchManagerWidget plugin. Install it and restart Maniacontrol');
|
||||
return false;
|
||||
}
|
||||
use MatchManagerSuite\MatchManagerCore;
|
||||
@ -38,10 +38,12 @@ 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';
|
||||
|
||||
const LOG_PREFIX = '[MatchManagerWidget] ';
|
||||
|
||||
// MatchManagerWidget Properties
|
||||
const MATCHMANAGERWIDGET_COMPATIBLE_GM = ["Cup", "Teams", "Rounds"];
|
||||
const MATCHMANAGERCORE_PLUGIN = 'MatchManagerSuite\MatchManagerCore';
|
||||
@ -64,6 +66,7 @@ class MatchManagerWidget implements ManialinkPageAnswerListener, CallbackListene
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
/** @var MatchManagerCore $MatchManagerCore */
|
||||
private $MatchManagerCore = null;
|
||||
private $gmbase = "";
|
||||
private $manialinkData = null;
|
||||
@ -171,6 +174,24 @@ class MatchManagerWidget implements ManialinkPageAnswerListener, CallbackListene
|
||||
$this->closeWidgets();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* handlePluginUnloaded
|
||||
*
|
||||
@ -181,7 +202,7 @@ class MatchManagerWidget implements ManialinkPageAnswerListener, CallbackListene
|
||||
public function handlePluginUnloaded(string $pluginClass, Plugin $plugin) {
|
||||
if ($pluginClass == self::MATCHMANAGERCORE_PLUGIN) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::PLUGIN_NAME . " disabled because MatchManager Core is now disabled");
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class()));
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,7 +236,7 @@ class MatchManagerWidget implements ManialinkPageAnswerListener, CallbackListene
|
||||
* @param array $settings
|
||||
*/
|
||||
public function InitMatch(string $matchid, array $settings) {
|
||||
Logger::Log("InitMatch");
|
||||
$this->log("InitMatch");
|
||||
$this->gmbase = $settings['currentgmbase'];
|
||||
$this->displayManialinks(false);
|
||||
}
|
||||
@ -224,7 +245,7 @@ class MatchManagerWidget implements ManialinkPageAnswerListener, CallbackListene
|
||||
* Clear variables and hide widget
|
||||
*/
|
||||
public function ClearMatch() {
|
||||
Logger::Log("ClearMatch");
|
||||
$this->log("ClearMatch");
|
||||
$this->gmbase = "";
|
||||
$this->manialinkData = "";
|
||||
$this->closeWidgets();
|
||||
@ -295,7 +316,7 @@ class MatchManagerWidget implements ManialinkPageAnswerListener, CallbackListene
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handlePlayerConnect(Player $player) {
|
||||
Logger::Log("handlePlayerConnect");
|
||||
$this->log("handlePlayerConnect");
|
||||
|
||||
if (strlen($this->gmbase) > 0) {
|
||||
$this->displayManialinks($player->login);
|
||||
@ -405,7 +426,7 @@ class MatchManagerWidget implements ManialinkPageAnswerListener, CallbackListene
|
||||
* Generate the manilink of the background of the widget
|
||||
*/
|
||||
public function generateMatchLiveWidgetBackground() {
|
||||
Logger::Log("generateMatchLiveWidgetBackground");
|
||||
$this->log("generateMatchLiveWidgetBackground");
|
||||
|
||||
$posX = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERWIDGET_LIVE_POSX);
|
||||
$posY = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MATCHMANAGERWIDGET_LIVE_POSY);
|
||||
@ -448,7 +469,7 @@ class MatchManagerWidget implements ManialinkPageAnswerListener, CallbackListene
|
||||
* @param array $currentscore
|
||||
*/
|
||||
public function generateMatchLiveWidgetData(array $currentscore) {
|
||||
Logger::Log("generateMatchLiveWidgetData");
|
||||
$this->log("generateMatchLiveWidgetData");
|
||||
|
||||
if ($this->gmbase == "Cup") {
|
||||
$pointlimit = $this->MatchManagerCore->getMatchPointsLimit();
|
||||
|
Reference in New Issue
Block a user