Plugin load and unload methods
This commit is contained in:
parent
fd3a3056f1
commit
f4cbace654
@ -16,11 +16,17 @@ interface Plugin {
|
|||||||
const PLUGIN_INTERFACE = __CLASS__;
|
const PLUGIN_INTERFACE = __CLASS__;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new plugin
|
* Load the plugin
|
||||||
*
|
*
|
||||||
* @param \ManiaControl\ManiaControl $maniaControl
|
* @param \ManiaControl\ManiaControl $maniaControl
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function __construct(ManiaControl $maniaControl);
|
public function load(ManiaControl $maniaControl);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unload the plugin and its resources
|
||||||
|
*/
|
||||||
|
public function unload();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get plugin id
|
* Get plugin id
|
||||||
|
@ -24,15 +24,15 @@ class ChatlogPlugin implements CallbackListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Private properties
|
* Private properties
|
||||||
*/
|
*/
|
||||||
|
private $maniaControl = null;
|
||||||
private $fileName = null;
|
private $fileName = null;
|
||||||
private $logServerMessages = true;
|
private $logServerMessages = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct chatlog plugin
|
|
||||||
*
|
*
|
||||||
* @param ManiaControl $maniaControl
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
*/
|
*/
|
||||||
public function __construct(ManiaControl $maniaControl) {
|
public function load(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
// Init settings
|
// Init settings
|
||||||
@ -70,6 +70,17 @@ class ChatlogPlugin implements CallbackListener, Plugin {
|
|||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this,
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this,
|
||||||
'handlePlayerChatCallback');
|
'handlePlayerChatCallback');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||||
|
*/
|
||||||
|
public function unload() {
|
||||||
|
$this->maniaControl->callbackManager->unregisterCallbackListener($this);
|
||||||
|
unset($this->maniaControl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,7 +140,7 @@ class ChatlogPlugin implements CallbackListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Log the given message
|
* Log the given message
|
||||||
*
|
*
|
||||||
* @param string $text
|
* @param string $text
|
||||||
* @param string $login
|
* @param string $login
|
||||||
*/
|
*/
|
||||||
private function logText($text, $login = null) {
|
private function logText($text, $login = null) {
|
||||||
|
@ -23,23 +23,35 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Private properties
|
* Private properties
|
||||||
*/
|
*/
|
||||||
|
private $maniaControl = null;
|
||||||
private $openBills = array();
|
private $openBills = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct donation plugin
|
|
||||||
*
|
*
|
||||||
* @param \ManiaControl\ManiaControl $maniaControl
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
*/
|
*/
|
||||||
public function __construct(ManiaControl $maniaControl) {
|
public function load(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
// Register for commands
|
// Register for commands
|
||||||
$this->maniaControl->commandManager->registerCommandListener('donate', $this, 'command_Donate');
|
$this->maniaControl->commandManager->registerCommandListener('donate', $this, 'command_Donate');
|
||||||
$this->maniaControl->commandManager->registerCommandListener('/pay', $this, 'command_Pay');
|
$this->maniaControl->commandManager->registerCommandListener('pay', $this, 'command_Pay', true);
|
||||||
$this->maniaControl->commandManager->registerCommandListener('/getplanets', $this, 'command_GetPlanets');
|
$this->maniaControl->commandManager->registerCommandListener('getplanets', $this, 'command_GetPlanets', true);
|
||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_BILLUPDATED, $this, 'handleBillUpdated');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_BILLUPDATED, $this, 'handleBillUpdated');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||||
|
*/
|
||||||
|
public function unload() {
|
||||||
|
$this->maniaControl->callbackManager->unregisterCallbackListener($this);
|
||||||
|
$this->maniaControl->commandManager->unregisterCommandListener($this);
|
||||||
|
unset($this->maniaControl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -168,7 +180,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Handle //getplanets command
|
* Handle //getplanets command
|
||||||
*
|
*
|
||||||
* @param array $chatCallback
|
* @param array $chatCallback
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
@ -20,23 +20,34 @@ class EndurancePlugin implements CallbackListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Private properties
|
* Private properties
|
||||||
*/
|
*/
|
||||||
|
private $maniaControl = null;
|
||||||
private $currentMap = null;
|
private $currentMap = null;
|
||||||
private $playerLapTimes = array();
|
private $playerLapTimes = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new endurance plugin instance
|
|
||||||
*
|
*
|
||||||
* @param ManiaControl $maniaControl
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
*/
|
*/
|
||||||
public function __construct(ManiaControl $maniaControl) {
|
public function load(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'callback_OnInit');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'callback_OnInit');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'callback_BeginMap');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'callback_BeginMap');
|
||||||
$this->maniaControl->callbackManager->registerScriptCallbackListener(self::CB_CHECKPOINT, $this, 'callback_Checkpoint');
|
$this->maniaControl->callbackManager->registerScriptCallbackListener(self::CB_CHECKPOINT, $this, 'callback_Checkpoint');
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||||
|
*/
|
||||||
|
public function unload() {
|
||||||
|
$this->maniaControl->callbackManager->unregisterCallbackListener($this);
|
||||||
|
$this->maniaControl->callbackManager->unregisterScriptCallbackListener($this);
|
||||||
|
unset($this->maniaControl);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -45,6 +56,7 @@ class EndurancePlugin implements CallbackListener, Plugin {
|
|||||||
public static function getId() {
|
public static function getId() {
|
||||||
return self::ID;
|
return self::ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @see \ManiaControl\Plugins\Plugin::getName()
|
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||||
|
@ -32,26 +32,18 @@ class KarmaPlugin implements CallbackListener, Plugin {
|
|||||||
const SETTING_WIDGET_WIDTH = 'Widget-Size: Width';
|
const SETTING_WIDGET_WIDTH = 'Widget-Size: Width';
|
||||||
const SETTING_WIDGET_HEIGHT = 'Widget-Size: Height';
|
const SETTING_WIDGET_HEIGHT = 'Widget-Size: Height';
|
||||||
|
|
||||||
/**
|
|
||||||
* Plugin metadata
|
|
||||||
*/
|
|
||||||
public static $name = 'Karma Plugin';
|
|
||||||
public static $author = 'steeffeen';
|
|
||||||
public static $version = '1.0';
|
|
||||||
public static $description = 'Plugin offering Karma Voting for Maps.';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private properties
|
* Private properties
|
||||||
*/
|
*/
|
||||||
|
private $maniaControl = null;
|
||||||
private $updateManialink = false;
|
private $updateManialink = false;
|
||||||
private $manialink = null;
|
private $manialink = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new karma plugin instance
|
*
|
||||||
*
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
* @param ManiaControl $maniaControl
|
|
||||||
*/
|
*/
|
||||||
public function __construct(ManiaControl $maniaControl) {
|
public function load(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
// Init database
|
// Init database
|
||||||
@ -72,8 +64,18 @@ class KarmaPlugin implements CallbackListener, Plugin {
|
|||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCONNECT, $this,
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCONNECT, $this,
|
||||||
'handlePlayerConnect');
|
'handlePlayerConnect');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'handlePlayerChat');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'handlePlayerChat');
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||||
|
*/
|
||||||
|
public function unload() {
|
||||||
|
$this->maniaControl->callbackManager->unregisterCallbackListener($this);
|
||||||
|
unset($this->maniaControl);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -82,6 +84,7 @@ class KarmaPlugin implements CallbackListener, Plugin {
|
|||||||
public static function getId() {
|
public static function getId() {
|
||||||
return self::ID;
|
return self::ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @see \ManiaControl\Plugins\Plugin::getName()
|
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||||
@ -359,8 +362,8 @@ class KarmaPlugin implements CallbackListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Get the current karma of the map
|
* Get the current karma of the map
|
||||||
*
|
*
|
||||||
* @param Map $map
|
* @param Map $map
|
||||||
* @return float | bool
|
* @return float | bool
|
||||||
*/
|
*/
|
||||||
private function getMapKarma(Map $map) {
|
private function getMapKarma(Map $map) {
|
||||||
$mysqli = $this->maniaControl->database->mysqli;
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
@ -388,8 +391,8 @@ class KarmaPlugin implements CallbackListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Get the current Votes for the Map
|
* Get the current Votes for the Map
|
||||||
*
|
*
|
||||||
* @param Map $map
|
* @param Map $map
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function getMapVotes(Map $map) {
|
private function getMapVotes(Map $map) {
|
||||||
$mysqli = $this->maniaControl->database->mysqli;
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
|
@ -36,12 +36,14 @@ class LocalRecordsPlugin implements CallbackListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Private properties
|
* Private properties
|
||||||
*/
|
*/
|
||||||
|
private $maniaControl = null;
|
||||||
private $updateManialink = false;
|
private $updateManialink = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new local records plugin
|
*
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
*/
|
*/
|
||||||
public function __construct(ManiaControl $maniaControl) {
|
public function load(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
$this->initTables();
|
$this->initTables();
|
||||||
|
|
||||||
@ -61,6 +63,17 @@ class LocalRecordsPlugin implements CallbackListener, Plugin {
|
|||||||
'handleClientUpdated');
|
'handleClientUpdated');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_TM_PLAYERFINISH, $this,
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_TM_PLAYERFINISH, $this,
|
||||||
'handlePlayerFinish');
|
'handlePlayerFinish');
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||||
|
*/
|
||||||
|
public function unload() {
|
||||||
|
$this->maniaControl->callbackManager->unregisterCallbackListener($this);
|
||||||
|
unset($this->maniaControl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -255,7 +268,7 @@ class LocalRecordsPlugin implements CallbackListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Handle ClientUpdated callback
|
* Handle ClientUpdated callback
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function handleClientUpdated(array $callback) {
|
public function handleClientUpdated(array $callback) {
|
||||||
$this->updateManialink = true;
|
$this->updateManialink = true;
|
||||||
|
@ -22,11 +22,17 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
const SCB_ONFINISH = 'OnFinish';
|
const SCB_ONFINISH = 'OnFinish';
|
||||||
const SCB_ONCHECKPOINT = 'OnCheckpoint';
|
const SCB_ONCHECKPOINT = 'OnCheckpoint';
|
||||||
const SETTING_JUMPTOAUTHLEVEL = 'Authentication level for JumpTo commands';
|
const SETTING_JUMPTOAUTHLEVEL = 'Authentication level for JumpTo commands';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private Properties
|
||||||
|
*/
|
||||||
|
private $maniaControl = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new obstacle plugin
|
*
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
*/
|
*/
|
||||||
public function __construct(ManiaControl $maniaControl) {
|
public function load(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
// Init settings
|
// Init settings
|
||||||
@ -39,8 +45,19 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->callbackManager->registerScriptCallbackListener(self::SCB_ONFINISH, $this, 'callback_OnFinish');
|
$this->maniaControl->callbackManager->registerScriptCallbackListener(self::SCB_ONFINISH, $this, 'callback_OnFinish');
|
||||||
$this->maniaControl->callbackManager->registerScriptCallbackListener(self::SCB_ONCHECKPOINT, $this, 'callback_OnCheckpoint');
|
$this->maniaControl->callbackManager->registerScriptCallbackListener(self::SCB_ONCHECKPOINT, $this, 'callback_OnCheckpoint');
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::unload()
|
||||||
|
*/
|
||||||
|
public function unload() {
|
||||||
|
$this->maniaControl->commandManager->unregisterCommandListener($this);
|
||||||
|
$this->maniaControl->callbackManager->unregisterScriptCallbackListener($this);
|
||||||
|
unset($this->maniaControl);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -49,6 +66,7 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
public static function getId() {
|
public static function getId() {
|
||||||
return self::ID;
|
return self::ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @see \ManiaControl\Plugins\Plugin::getName()
|
* @see \ManiaControl\Plugins\Plugin::getName()
|
||||||
@ -84,8 +102,8 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Handle JumpTo command
|
* Handle JumpTo command
|
||||||
*
|
*
|
||||||
* @param array $chatCallback
|
* @param array $chatCallback
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function command_JumpTo(array $chatCallback, Player $player) {
|
public function command_JumpTo(array $chatCallback, Player $player) {
|
||||||
|
Loading…
Reference in New Issue
Block a user