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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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
|
|
||||||
*
|
*
|
||||||
* @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 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()
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,9 +24,15 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
|
|||||||
const SETTING_JUMPTOAUTHLEVEL = 'Authentication level for JumpTo commands';
|
const SETTING_JUMPTOAUTHLEVEL = 'Authentication level for JumpTo commands';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new obstacle plugin
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
public function __construct(ManiaControl $maniaControl) {
|
private $maniaControl = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @see \ManiaControl\Plugins\Plugin::load()
|
||||||
|
*/
|
||||||
|
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()
|
||||||
|
Loading…
Reference in New Issue
Block a user