dedimania update
This commit is contained in:
parent
bcd8a9de67
commit
dc248a69ed
@ -5,10 +5,6 @@ namespace ManiaControl\Server;
|
|||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Players\Player;
|
|
||||||
use Maniaplanet\DedicatedServer\Structures\ServerOptions;
|
|
||||||
use Maniaplanet\DedicatedServer\Structures\SystemInfos;
|
|
||||||
use Maniaplanet\DedicatedServer\Structures\Version;
|
|
||||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -124,6 +120,29 @@ class Server implements CallbackListener {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all Servers from the Database
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getAllServers() {
|
||||||
|
$mysqli = $this->maniaControl->database->mysqli;
|
||||||
|
$query = "SELECT * FROM `" . self::TABLE_SERVERS . "`";
|
||||||
|
$result = $mysqli->query($query);
|
||||||
|
if (!$result) {
|
||||||
|
trigger_error($mysqli->error);
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$servers = array();
|
||||||
|
while($row = $result->fetch_object()) {
|
||||||
|
array_push($servers, $row);
|
||||||
|
}
|
||||||
|
$result->close();
|
||||||
|
|
||||||
|
return $servers;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle OnInit Callback
|
* Handle OnInit Callback
|
||||||
*/
|
*/
|
||||||
|
@ -39,8 +39,7 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
const SETTING_WIDGET_WIDTH = 'Widget Width';
|
const SETTING_WIDGET_WIDTH = 'Widget Width';
|
||||||
const SETTING_WIDGET_LINESCOUNT = 'Widget Displayed Lines Count';
|
const SETTING_WIDGET_LINESCOUNT = 'Widget Displayed Lines Count';
|
||||||
const SETTING_WIDGET_LINEHEIGHT = 'Widget Line Height';
|
const SETTING_WIDGET_LINEHEIGHT = 'Widget Line Height';
|
||||||
const SETTING_SERVER_LOGINS = 'Serverlogins, splitted by ;';
|
const SETTING_DEDIMANIA_CODE = 'Dedimania Code for ';
|
||||||
const SETTING_DEDIMANIA_CODES = 'Dedimania Codes, splitted by ;';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private Properties
|
* Private Properties
|
||||||
@ -60,8 +59,10 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public static function prepare(ManiaControl $maniaControl) {
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
$maniaControl->settingManager->initSetting(get_class(), self::SETTING_SERVER_LOGINS, '');
|
$servers = $maniaControl->server->getAllServers();
|
||||||
$maniaControl->settingManager->initSetting(get_class(), self::SETTING_DEDIMANIA_CODES, '');
|
foreach($servers as $server) {
|
||||||
|
$maniaControl->settingManager->initSetting(get_class(), self::SETTING_DEDIMANIA_CODE . $server->login, '');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,28 +101,9 @@ class Dedimania implements CallbackListener, TimerListener, Plugin {
|
|||||||
$serverVersion = $this->maniaControl->client->getVersion();
|
$serverVersion = $this->maniaControl->client->getVersion();
|
||||||
$packMask = substr($this->maniaControl->server->titleId, 2);
|
$packMask = substr($this->maniaControl->server->titleId, 2);
|
||||||
|
|
||||||
$logins = $this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVER_LOGINS);
|
$dedimaniaCode = $this->maniaControl->settingManager->getSetting($this, self::SETTING_DEDIMANIA_CODE . $serverInfo->login);
|
||||||
$codes = $this->maniaControl->settingManager->getSetting($this, self::SETTING_DEDIMANIA_CODES);
|
|
||||||
|
|
||||||
if ($logins == '' || $codes == '') {
|
|
||||||
throw new \Exception("No Dedimania Data Specified, check the settings!");
|
|
||||||
}
|
|
||||||
|
|
||||||
$logins = explode(";", $logins);
|
|
||||||
$codes = explode(";", $codes);
|
|
||||||
|
|
||||||
$dedimaniaCode = "";
|
|
||||||
foreach($logins as $key => $login) {
|
|
||||||
if ($login == $serverInfo->login) {
|
|
||||||
if (!isset($codes[$key])) {
|
|
||||||
throw new \Exception("No Dedimania Code Specified, check the settings!");
|
|
||||||
}
|
|
||||||
$dedimaniaCode = $codes[$key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($dedimaniaCode == '') {
|
if ($dedimaniaCode == '') {
|
||||||
throw new \Exception("No Valid Serverlogin Specified, check the settings!");
|
throw new \Exception("No Dedimania Code Specified, check the settings!");
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->dedimaniaData = new DedimaniaData($serverInfo->login, $dedimaniaCode, $serverInfo->path, $packMask, $serverVersion);
|
$this->dedimaniaData = new DedimaniaData($serverInfo->login, $dedimaniaCode, $serverInfo->path, $packMask, $serverVersion);
|
||||||
|
88
application/plugins/KarmaTest.php
Normal file
88
application/plugins/KarmaTest.php
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
<?php
|
||||||
|
use ManiaControl\ManiaControl;
|
||||||
|
use ManiaControl\Plugins\Plugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: Lukas
|
||||||
|
* Date: 23.02.14
|
||||||
|
* Time: 14:03
|
||||||
|
*/
|
||||||
|
class KarmaTest implements Plugin {
|
||||||
|
private $maniaControl = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares the Plugin
|
||||||
|
*
|
||||||
|
* @param ManiaControl $maniaControl
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function prepare(ManiaControl $maniaControl) {
|
||||||
|
// TODO: Implement prepare() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the plugin
|
||||||
|
*
|
||||||
|
* @param \ManiaControl\ManiaControl $maniaControl
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function load(ManiaControl $maniaControl) {
|
||||||
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
|
$serverLogin = $this->maniaControl->server->login;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unload the plugin and its resources
|
||||||
|
*/
|
||||||
|
public function unload() {
|
||||||
|
unset($this->maniaControl);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get plugin id
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function getId() {
|
||||||
|
// TODO: Implement getId() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Plugin Name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getName() {
|
||||||
|
return "karmatest";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Plugin Version
|
||||||
|
*
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public static function getVersion() {
|
||||||
|
// TODO: Implement getVersion() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Plugin Author
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getAuthor() {
|
||||||
|
// TODO: Implement getAuthor() method.
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Plugin Description
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getDescription() {
|
||||||
|
// TODO: Implement getDescription() method.
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user