improve the check of MatchManagerCore
This commit is contained in:
parent
0b8dbfbb8b
commit
da894264e0
@ -3,12 +3,11 @@
|
||||
namespace MatchManagerSuite;
|
||||
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Callbacks\Callbacks;
|
||||
use ManiaControl\Logger;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Plugins\Plugin;
|
||||
use ManiaControl\Plugins\PluginManager;
|
||||
use ManiaControl\Settings\Setting;
|
||||
use ManiaControl\Settings\SettingManager;
|
||||
use ManiaControl\Files\AsyncHttpRequest;
|
||||
@ -17,9 +16,9 @@ use ManiaControl\Admin\AuthenticationManager;
|
||||
use ManiaControl\Callbacks\TimerListener;
|
||||
use ManiaControl\Utils\WebReader;
|
||||
|
||||
if (! class_exists('MatchManagerSuite\MatchManagerCore')) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is needed to use MatchManagerGSheet plugin. Install it and restart Maniacontrol');
|
||||
Logger::logError('MatchManager Core is needed to use MatchManager GSheet plugin. Install it and restart Maniacontrol');
|
||||
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');
|
||||
return false;
|
||||
}
|
||||
use MatchManagerSuite\MatchManagerCore;
|
||||
@ -36,7 +35,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 156;
|
||||
const PLUGIN_VERSION = 1.2;
|
||||
const PLUGIN_VERSION = 1.3;
|
||||
const PLUGIN_NAME = 'MatchManager GSheet';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
@ -83,6 +82,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
private $MatchManagerCore = null;
|
||||
private $matchstatus = "";
|
||||
private $device_code = "";
|
||||
private $access_token = "";
|
||||
@ -144,10 +144,11 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
$this->MatchManagerCore = $this->maniaControl->getPluginManager()->getPlugin(self::MATCHMANAGERCORE_PLUGIN);
|
||||
|
||||
if ($this->MatchManagerCore == Null) {
|
||||
throw new \Exception('MatchManager Core is needed to use MatchManager GSheet plugin');
|
||||
throw new \Exception('MatchManager Core is needed to use ' . self::PLUGIN_NAME);
|
||||
}
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PluginManager::CB_PLUGIN_UNLOADED, $this, 'handlePluginUnloaded');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(MatchManagerCore::CB_MATCHMANAGER_STARTMATCH, $this, 'CheckAndPrepareSheet');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(MatchManagerCore::CB_MATCHMANAGER_ENDROUND, $this, 'onCallbackEndRound');
|
||||
@ -177,6 +178,20 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
public function unload() {
|
||||
}
|
||||
|
||||
/**
|
||||
* handlePluginUnloaded
|
||||
*
|
||||
* @param string $pluginClass
|
||||
* @param Plugin $plugin
|
||||
* @return void
|
||||
*/
|
||||
public function handlePluginUnloaded(string $pluginClass, Plugin $plugin) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::PLUGIN_NAME . " disabled because MatchManager Core is now disabled");
|
||||
if ($pluginClass == self::MATCHMANAGERCORE_PLUGIN) {
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize needed database tables
|
||||
*/
|
||||
@ -451,7 +466,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
|
||||
$data->data[0] = new \stdClass;
|
||||
$data->data[0]->range = "'" . $sheetname . "'!B2";
|
||||
if ($this->matchstatus == "ended") {
|
||||
if ($matchstatus == "ended") {
|
||||
$data->data[0]->values = array(array($matchstatus));
|
||||
} else {
|
||||
$data->data[0]->values = array(array($matchstatus),array($this->MatchManagerCore->getCountMap()),array($this->MatchManagerCore->getCountRound()),array($this->maniaControl->getPlayerManager()->getPlayerCount()),array($this->maniaControl->getPlayerManager()->getSpectatorCount()));
|
||||
|
148
MatchManagerSuite/MatchManagerMultipleConfigManager.php
Normal file
148
MatchManagerSuite/MatchManagerMultipleConfigManager.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?php
|
||||
|
||||
namespace MatchManagerSuite;
|
||||
|
||||
use FML\Controls\Frame;
|
||||
use FML\Controls\Labels\Label_Text;
|
||||
use FML\Controls\Label;
|
||||
use FML\Controls\Quad;
|
||||
use FML\ManiaLink;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Callbacks\Callbacks;
|
||||
use ManiaControl\Logger;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Players\PlayerManager;
|
||||
use ManiaControl\Plugins\Plugin;
|
||||
use ManiaControl\Settings\Setting;
|
||||
use ManiaControl\Settings\SettingManager;
|
||||
use ManiaControl\Commands\CommandListener;
|
||||
|
||||
|
||||
if (!class_exists('MatchManagerSuite\MatchManagerCore')) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is needed to use MatchManager Multiple Config Manager plugin. Install it and restart Maniacontrol');
|
||||
Logger::logError('MatchManager Core is needed to use MatchManager Multiple Config Manager plugin. Install it and restart Maniacontrol');
|
||||
return false;
|
||||
}
|
||||
use MatchManagerSuite\MatchManagerCore;
|
||||
|
||||
|
||||
/**
|
||||
* MatchManager Widgets
|
||||
*
|
||||
* @author Beu
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class MatchManagerMultipleConfigManager implements ManialinkPageAnswerListener, CommandListener, CallbackListener, Plugin {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 171;
|
||||
const PLUGIN_VERSION = 1.0;
|
||||
const PLUGIN_NAME = 'MatchManager Multiple Config Manager';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
// MatchManagerWidget Properties
|
||||
const MATCHMANAGERCORE_PLUGIN = 'MatchManagerSuite\MatchManagerCore';
|
||||
|
||||
const DB_MATCHCONFIG = 'MatchManager_MatchConfigs';
|
||||
|
||||
/*
|
||||
* Private properties
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
private $MatchManagerCore = null;
|
||||
|
||||
|
||||
/**
|
||||
* @param \ManiaControl\ManiaControl $maniaControl
|
||||
* @see \ManiaControl\Plugins\Plugin::prepare()
|
||||
*/
|
||||
public static function prepare(ManiaControl $maniaControl) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getId()
|
||||
*/
|
||||
public static function getId() {
|
||||
return self::PLUGIN_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||
*/
|
||||
public static function getName() {
|
||||
return self::PLUGIN_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getVersion()
|
||||
*/
|
||||
public static function getVersion() {
|
||||
return self::PLUGIN_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getAuthor()
|
||||
*/
|
||||
public static function getAuthor() {
|
||||
return self::PLUGIN_AUTHOR;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::getDescription()
|
||||
*/
|
||||
public static function getDescription() {
|
||||
return 'Manage your multiple MatchManager configurations';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \ManiaControl\ManiaControl $maniaControl
|
||||
* @return bool
|
||||
* @see \ManiaControl\Plugins\Plugin::load()
|
||||
*/
|
||||
public function load(ManiaControl $maniaControl) {
|
||||
// Init plugin
|
||||
$this->maniaControl = $maniaControl;
|
||||
$this->MatchManagerCore = $this->maniaControl->getPluginManager()->getPlugin(self::MATCHMANAGERCORE_PLUGIN);
|
||||
|
||||
if ($this->MatchManagerCore == Null) {
|
||||
throw new \Exception('MatchManager Core is needed to use MatchManager Players Pause plugin');
|
||||
}
|
||||
|
||||
$this->initTables();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||
*/
|
||||
public function unload() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize needed database tables
|
||||
*/
|
||||
private function initTables() {
|
||||
$mysqli = $this->maniaControl->getDatabase()->getMysqli();
|
||||
$query = 'CREATE TABLE IF NOT EXISTS `' . self::DB_MATCHCONFIG . '` (
|
||||
`id` int NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`gamemodebase` VARCHAR(32) NOT NULL,
|
||||
`config` TEXT,
|
||||
`date` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;';
|
||||
$mysqli->query($query);
|
||||
if ($mysqli->error) {
|
||||
trigger_error($mysqli->error, E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -4,11 +4,9 @@ namespace MatchManagerSuite;
|
||||
|
||||
use FML\Controls\Frame;
|
||||
use FML\Controls\Labels\Label_Text;
|
||||
use FML\Controls\Label;
|
||||
use FML\Controls\Quad;
|
||||
use FML\ManiaLink;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Callbacks\Callbacks;
|
||||
use ManiaControl\Logger;
|
||||
use ManiaControl\ManiaControl;
|
||||
@ -16,17 +14,17 @@ use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Players\PlayerManager;
|
||||
use ManiaControl\Plugins\Plugin;
|
||||
use ManiaControl\Plugins\PluginManager;
|
||||
use ManiaControl\Settings\Setting;
|
||||
use ManiaControl\Settings\SettingManager;
|
||||
use ManiaControl\Commands\CommandListener;
|
||||
|
||||
|
||||
if (! class_exists('MatchManagerSuite\MatchManagerCore')) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is needed to use MatchManager Players Pause plugin. Install it and restart Maniacontrol');
|
||||
Logger::logError('MatchManager Core is needed to use MatchManager Players Pause plugin. Install it and restart Maniacontrol');
|
||||
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');
|
||||
return false;
|
||||
}
|
||||
use MatchManagerSuite\MatchManagerCore;
|
||||
|
||||
|
||||
/**
|
||||
@ -40,7 +38,7 @@ class MatchManagerPlayersPause implements ManialinkPageAnswerListener, CommandLi
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 159;
|
||||
const PLUGIN_VERSION = 1.0;
|
||||
const PLUGIN_VERSION = 1.1;
|
||||
const PLUGIN_NAME = 'MatchManager Players Pause';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
@ -60,6 +58,7 @@ class MatchManagerPlayersPause implements ManialinkPageAnswerListener, CommandLi
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
private $MatchManagerCore = null;
|
||||
private $chatprefix = '$<$fc3$w🏆$m$> '; // Would like to create a setting but MC database doesn't support utf8mb4
|
||||
|
||||
private $playerspausestate = array();
|
||||
@ -122,7 +121,7 @@ class MatchManagerPlayersPause implements ManialinkPageAnswerListener, CommandLi
|
||||
$this->MatchManagerCore = $this->maniaControl->getPluginManager()->getPlugin(self::MATCHMANAGERCORE_PLUGIN);
|
||||
|
||||
if ($this->MatchManagerCore == Null) {
|
||||
throw new \Exception('MatchManager Core is needed to use MatchManager Players Pause plugin');
|
||||
throw new \Exception('MatchManager Core is needed to use ' . self::PLUGIN_NAME);
|
||||
}
|
||||
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('pause', $this, 'onCommandSetPausePlayer', false, 'Change status to Pause.');
|
||||
@ -133,6 +132,7 @@ class MatchManagerPlayersPause implements ManialinkPageAnswerListener, CommandLi
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MATCH_PAUSE_POSX, 152.5, "Position of the Pause widget (on X axis)");
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MATCH_PAUSE_POSY, 40, "Position of the Pause widget (on Y axis)");
|
||||
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PluginManager::CB_PLUGIN_UNLOADED, $this, 'handlePluginUnloaded');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings');
|
||||
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
|
||||
@ -157,6 +157,20 @@ class MatchManagerPlayersPause implements ManialinkPageAnswerListener, CommandLi
|
||||
$this->closePauseWidget();
|
||||
}
|
||||
|
||||
/**
|
||||
* handlePluginUnloaded
|
||||
*
|
||||
* @param string $pluginClass
|
||||
* @param Plugin $plugin
|
||||
* @return void
|
||||
*/
|
||||
public function handlePluginUnloaded(string $pluginClass, Plugin $plugin) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::PLUGIN_NAME . " disabled because MatchManager Core is now disabled");
|
||||
if ($pluginClass == self::MATCHMANAGERCORE_PLUGIN) {
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Manialinks variables
|
||||
*/
|
||||
@ -284,7 +298,7 @@ class MatchManagerPlayersPause implements ManialinkPageAnswerListener, CommandLi
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Command /pause for players
|
||||
|
@ -4,29 +4,26 @@ namespace MatchManagerSuite;
|
||||
|
||||
use FML\Controls\Frame;
|
||||
use FML\Controls\Labels\Label_Text;
|
||||
use FML\Controls\Label;
|
||||
use FML\Controls\Quad;
|
||||
use FML\ManiaLink;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
use ManiaControl\Callbacks\Callbacks;
|
||||
use ManiaControl\Logger;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Players\PlayerManager;
|
||||
use ManiaControl\Plugins\Plugin;
|
||||
use ManiaControl\Plugins\PluginManager;
|
||||
use ManiaControl\Settings\Setting;
|
||||
use ManiaControl\Settings\SettingManager;
|
||||
use ManiaControl\Commands\CommandListener;
|
||||
|
||||
|
||||
if (! class_exists('MatchManagerSuite\MatchManagerCore')) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is needed to use MatchManager Ready Button plugin. Install it and restart Maniacontrol');
|
||||
Logger::logError('MatchManager Core is needed to use MatchManager Ready Button plugin. Install it and restart Maniacontrol');
|
||||
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');
|
||||
return false;
|
||||
}
|
||||
use MatchManagerSuite\MatchManagerCore;
|
||||
|
||||
|
||||
/**
|
||||
@ -40,7 +37,7 @@ class MatchManagerReadyButton implements ManialinkPageAnswerListener, CommandLis
|
||||
* Constants
|
||||
*/
|
||||
const PLUGIN_ID = 158;
|
||||
const PLUGIN_VERSION = 1.0;
|
||||
const PLUGIN_VERSION = 1.1;
|
||||
const PLUGIN_NAME = 'MatchManager Ready Button';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
@ -59,6 +56,7 @@ class MatchManagerReadyButton implements ManialinkPageAnswerListener, CommandLis
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
private $MatchManagerCore = null;
|
||||
private $chatprefix = '$<$fc3$w🏆$m$> '; // Would like to create a setting but MC database doesn't support utf8mb4
|
||||
|
||||
private $playersreadystate = array();
|
||||
@ -119,7 +117,7 @@ class MatchManagerReadyButton implements ManialinkPageAnswerListener, CommandLis
|
||||
$this->MatchManagerCore = $this->maniaControl->getPluginManager()->getPlugin(self::MATCHMANAGERCORE_PLUGIN);
|
||||
|
||||
if ($this->MatchManagerCore == Null) {
|
||||
throw new \Exception('MatchManager Core is needed to use MatchManager Ready Button plugin');
|
||||
throw new \Exception('MatchManager Core is needed to use ' . self::PLUGIN_NAME);
|
||||
}
|
||||
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('ready', $this, 'onCommandSetReadyPlayer', false, 'Change status to Ready.');
|
||||
@ -129,6 +127,7 @@ class MatchManagerReadyButton implements ManialinkPageAnswerListener, CommandLis
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MATCH_READY_POSX, 152.5, "Position of the Ready widget (on X axis)");
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MATCH_READY_POSY, 40, "Position of the Ready widget (on Y axis)");
|
||||
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PluginManager::CB_PLUGIN_UNLOADED, $this, 'handlePluginUnloaded');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'updateSettings');
|
||||
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect');
|
||||
@ -150,6 +149,20 @@ class MatchManagerReadyButton implements ManialinkPageAnswerListener, CommandLis
|
||||
$this->closeReadyWidget();
|
||||
}
|
||||
|
||||
/**
|
||||
* handlePluginUnloaded
|
||||
*
|
||||
* @param string $pluginClass
|
||||
* @param Plugin $plugin
|
||||
* @return void
|
||||
*/
|
||||
public function handlePluginUnloaded(string $pluginClass, Plugin $plugin) {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins(self::PLUGIN_NAME . " disabled because MatchManager Core is now disabled");
|
||||
if ($pluginClass == self::MATCHMANAGERCORE_PLUGIN) {
|
||||
$this->maniaControl->getPluginManager()->deactivatePlugin((get_class()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Manialinks variables
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user