started with plugin class

This commit is contained in:
kremsy
2013-11-09 12:20:38 +01:00
parent 40b5e94ec3
commit 1abbbdb9eb
15 changed files with 444 additions and 17 deletions

View File

@ -36,7 +36,7 @@ class Database {
// Load config
$this->config = Tools::loadConfig('database.ManiaControl.xml');
$this->iControl->checkConfig($this->config, array("host", "user"), 'database.ManiaControl.xml');
$this->mControl->checkConfig($this->config, array("host", "user"), 'database.ManiaControl.xml');
// Get mysql server information
$host = $this->config->xpath('host');
@ -73,8 +73,8 @@ class Database {
$this->initTables();
// Register for callbacks
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_5_SECOND, $this, 'handle5Second');
$this->iControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_BEGINMAP, $this, 'handleBeginMap');
$this->mControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_5_SECOND, $this, 'handle5Second');
$this->mControl->callbacks->registerCallbackHandler(Callbacks::CB_IC_BEGINMAP, $this, 'handleBeginMap');
}
/**
@ -227,7 +227,7 @@ class Database {
*/
public function handle5Second($callback = null) {
// Save current players in database
$players = $this->iControl->server->getPlayers();
$players = $this->mControl->server->getPlayers();
if ($players) {
$query = "";
foreach ($players as $player) {

View File

@ -1,6 +1,6 @@
<?php
namespace mControl;
namespace ManiaControl;
/**
* Class manialinkidHandler handles manialink id's
@ -10,7 +10,30 @@ namespace mControl;
class ManialinkIdHandler {
/**
* Private properties
*/
private $maniaLinkIdCount;
public function __construct(){
$maniaLinkIdCount = 0;
}
/**
* Reservses manialinks for a plugin
*
* @param int $count
* @return array with manialink Ids
*/
public function reserveManiaLinkIds($count){
$mlIds = array();
for($i = 0; $i < $count; $i++){
$mlIds[0] = $i + $this->maniaLinkIdCount;
}
$this->maniaLinkIdCount += $count;
return $mlIds;
}
}
?>

View File

@ -1,6 +1,6 @@
<?php
namespace mControl;
namespace ManiaControl;
/**
* Class plugin parent class for all plugins
@ -30,14 +30,6 @@ namespace mControl;
$this->updateUrl = '';
}
/*
public function __construct($mControl, $name, $version, $author, $updateUrl = ''){
$this->mControl = $mControl;
$this->name = $name;
$this->version = $version;
$this->author = $author;
$this->updateUrl = $updateUrl;
}*/
/**
* Reserves manialinks on the ManialinkIdHandler

View File

@ -1,6 +1,6 @@
<?php
namespace mControl;
namespace ManiaControl;
/**
* Class handles plugins