EOD; /** * @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 "Simple plugin to reload gamemode or maniacontrol with F5"; } /** * @see \ManiaControl\Plugins\Plugin::load() */ public function load(ManiaControl $maniaControl) { $this->maniaControl = $maniaControl; $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_RELOAD_GAMEMODE, false, "", 10); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_GAMEMODE_TO_LOAD, "", 'File to load in UserData/Scripts/Modes/', 11); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_RELOAD_PLUGIN, false, "", 20); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PLUGIN_TO_LOAD, "", 'File to load in UserData/Scripts', 21); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_RESTART_MANIACONTROL, false, "", 30); $this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); $this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener("ReloadDevTool_Reload", $this, 'handleReload'); $admins = $this->maniaControl->getAuthenticationManager()->getAdmins(); if (!empty($admins)) { $this->maniaControl->getManialinkManager()->sendManialink($this->manialink,$admins); } } /** * Handle when a player connects * * @param Player $player */ public function handlePlayerConnect(Player $player) { if ($player->authLevel > 0) { $this->maniaControl->getManialinkManager()->sendManialink($this->manialink,$player->login); } } public function handleReload(array $callback, Player $player) { if ($player->authLevel <= 0) { Logger::logError('Wrong authlevel'); return; } Logger::log('handleReload'); $this->maniaControl->getChat()->sendSuccess("Handle Reload"); if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_RELOAD_GAMEMODE)) { $file = $this->maniaControl->getServer()->getDirectory()->getUserDataFolder() . "Scripts" . DIRECTORY_SEPARATOR . "Modes" . DIRECTORY_SEPARATOR . $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_GAMEMODE_TO_LOAD); if ($file && is_file($file)) { try { $this->maniaControl->getChat()->sendSuccess("Loading In-Dev Script"); $this->maniaControl->getClient()->setModeScriptText(file_get_contents($file)); } catch (\Exception $e) { Logger::logError($e->getMessage()); $this->maniaControl->getChat()->sendErrorToAdmins($e->getMessage()); } } else { Logger::logError('No Game mode to load'); $this->maniaControl->getChat()->sendErrorToAdmins("No Game mode to load"); } } if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_RELOAD_PLUGIN)) { $file = $this->maniaControl->getServer()->getDirectory()->getUserDataFolder() . "Scripts" . DIRECTORY_SEPARATOR . $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_PLUGIN_TO_LOAD); if ($file && is_file($file)) { try { $this->maniaControl->getChat()->sendSuccess("Loading Script Plugin"); $this->maniaControl->getClient()->execute("SetServerPlugin", [true, $file]); } catch (\Exception $e) { Logger::logError($e->getMessage()); $this->maniaControl->getChat()->sendErrorToAdmins($e->getMessage()); } } else { Logger::logError('No Script Plugin to load'); $this->maniaControl->getChat()->sendErrorToAdmins("No Script Plugin to load"); } } if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_RESTART_MANIACONTROL)) { $this->maniaControl->reboot(); } } /** * Unload the plugin and its Resources */ public function unload() { } }