148 lines
3.9 KiB
PHP
148 lines
3.9 KiB
PHP
|
<?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);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|