update plugins to publish it

This commit is contained in:
Beu 2022-02-16 00:20:20 +01:00
parent 67efa23387
commit 2a0ee2316a
3 changed files with 52 additions and 34 deletions

2
.gitignore vendored
View File

@ -6,7 +6,7 @@
!MatchManagerSuite/* !MatchManagerSuite/*
!Beu !Beu
!Beu/ChatAdminColorer.php !Beu/ChatAdminColorer.php
!Beu/GameModeDevTools.php !Beu/ReloadDevTool.php
!Beu/GuestlistManager.php !Beu/GuestlistManager.php
!Beu/MoreModesTools.php !Beu/MoreModesTools.php
!Beu/SimpleChatColorer.php !Beu/SimpleChatColorer.php

View File

@ -68,7 +68,7 @@ class MoreModesTools implements CommandListener, Plugin {
* @see \ManiaControl\Plugins\Plugin::getDescription() * @see \ManiaControl\Plugins\Plugin::getDescription()
*/ */
public static function getDescription() { public static function getDescription() {
return 'Tool to manage the Guestlist'; return 'Simple tool to send XmlRpc Callbacks';
} }
/** /**

View File

@ -15,22 +15,24 @@ use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use \Exception; use \Exception;
/** /**
* ManiaControl Profanity filter * ReloadDevTool
* *
* @author Beu * @author Beu
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class GameModeDevTools implements ManialinkPageAnswerListener, CallbackListener, Plugin { class ReloadDevTool implements ManialinkPageAnswerListener, CallbackListener, Plugin {
/* /*
* Constants * Constants
*/ */
const PLUGIN_ID = 165; const PLUGIN_ID = 165;
const PLUGIN_VERSION = 1.0; const PLUGIN_VERSION = 1.0;
const PLUGIN_NAME = 'GameModeDevTools'; const PLUGIN_NAME = 'ReloadDevTool';
const PLUGIN_AUTHOR = 'Beu'; const PLUGIN_AUTHOR = 'Beu';
const SETTING_RELOAD_GAMEMODE = 'Reload Gamemode';
const SETTING_GAMEMODE_TO_LOAD = 'Gamemode to load';
const SETTING_RESTART_MANIACONTROL = 'Restart Maniacontrol';
const GAMEMODE_TO_LOAD = 'Gamemode to load';
/* /*
* Private properties * Private properties
*/ */
@ -38,7 +40,7 @@ class GameModeDevTools implements ManialinkPageAnswerListener, CallbackListener,
private $maniaControl = null; private $maniaControl = null;
private $manialink = <<<'EOD' private $manialink = <<<'EOD'
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<manialink id="DEBUG_ReloadGamemode" version="3"> <manialink id="ReloadDevTool" version="3">
<script><!-- <script><!--
main () { main () {
log("DEBUG_ReloadGamemode loaded"); log("DEBUG_ReloadGamemode loaded");
@ -46,7 +48,7 @@ class GameModeDevTools implements ManialinkPageAnswerListener, CallbackListener,
yield; yield;
foreach(Event in PendingEvents) { foreach(Event in PendingEvents) {
if (Event.Type == CMlScriptEvent::Type::KeyPress && Event.KeyName == "F5") { if (Event.Type == CMlScriptEvent::Type::KeyPress && Event.KeyName == "F5") {
TriggerPageAction("DEBUG_ReloadGamemode"); TriggerPageAction("ReloadDevTool_Reload");
} }
} }
} }
@ -93,7 +95,7 @@ class GameModeDevTools implements ManialinkPageAnswerListener, CallbackListener,
* @see \ManiaControl\Plugins\Plugin::getDescription() * @see \ManiaControl\Plugins\Plugin::getDescription()
*/ */
public static function getDescription() { public static function getDescription() {
return ""; return "Simple plugin to reload gamemode or maniacontrol with F5";
} }
/** /**
@ -102,28 +104,41 @@ class GameModeDevTools implements ManialinkPageAnswerListener, CallbackListener,
public function load(ManiaControl $maniaControl) { public function load(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl; $this->maniaControl = $maniaControl;
$this->maniaControl->getSettingManager()->initSetting($this, self::GAMEMODE_TO_LOAD, "", ""); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_RELOAD_GAMEMODE, false, "");
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_GAMEMODE_TO_LOAD, "", 'File to load in UserData/Scripts/Modes/');
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener("DEBUG_ReloadGamemode", $this, 'LoadGamemode'); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_RESTART_MANIACONTROL, false, "");
$players = $this->maniaControl->getPlayerManager()->getPlayers(); $this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
if (!empty($players)) { $this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener("ReloadDevTool_Reload", $this, 'handleReload');
$this->maniaControl->getManialinkManager()->sendManialink($this->manialink,$players);
$admins = $this->maniaControl->getAuthenticationManager()->getAdmins();
if (!empty($admins)) {
$this->maniaControl->getManialinkManager()->sendManialink($this->manialink,$admins);
} }
$this->LoadGamemode();
} }
/** /**
* Handle when a player connects * Handle when a player connects
* *
* @param Player $player * @param Player $player
*/ */
public function handlePlayerConnect(Player $player) { public function handlePlayerConnect(Player $player) {
if ($player->authLevel > 0) {
$this->maniaControl->getManialinkManager()->sendManialink($this->manialink,$player->login); $this->maniaControl->getManialinkManager()->sendManialink($this->manialink,$player->login);
} }
}
public function LoadGamemode() { public function handleReload(array $callback, Player $player) {
Logger::log('Load Gamemode'); if ($player->authLevel <= 0) {
$file = $this->maniaControl->getServer()->getDirectory()->getUserDataFolder() . "Scripts/Modes" . DIRECTORY_SEPARATOR . $this->maniaControl->getSettingManager()->getSettingValue($this, self::GAMEMODE_TO_LOAD); 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)) { if ($file && is_file($file)) {
try { try {
$this->maniaControl->getChat()->sendSuccess("Loading In-Dev Script"); $this->maniaControl->getChat()->sendSuccess("Loading In-Dev Script");
@ -137,7 +152,10 @@ class GameModeDevTools implements ManialinkPageAnswerListener, CallbackListener,
$this->maniaControl->getChat()->sendErrorToAdmins("No Game mode to load"); $this->maniaControl->getChat()->sendErrorToAdmins("No Game mode to load");
} }
} }
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_RESTART_MANIACONTROL)) {
$this->maniaControl->reboot();
}
}
/** /**
* Unload the plugin and its Resources * Unload the plugin and its Resources