Refactoring of Code, Comments and Spelling

This commit is contained in:
Steffen Schröder 2013-12-09 13:45:58 +01:00
parent 5339b6766f
commit c97b4166f2
26 changed files with 1834 additions and 1833 deletions

View File

@ -4,7 +4,6 @@ namespace ManiaControl\Admin;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use FML\ManiaLink; use FML\ManiaLink;
use FML\Controls\Control; use FML\Controls\Control;
use FML\Controls\Frame; use FML\Controls\Frame;
@ -136,7 +135,7 @@ class AdminMenu implements CallbackListener {
// Add items // Add items
$x = 0.5 * $itemSize * $itemMarginFactorX; $x = 0.5 * $itemSize * $itemMarginFactorX;
foreach ($this->menuItems as $itemOrder => $menuItems) { foreach ($this->menuItems as $menuItems) {
foreach ($menuItems as $menuItem) { foreach ($menuItems as $menuItem) {
$menuItem->setSize($itemSize, $itemSize); $menuItem->setSize($itemSize, $itemSize);
$itemsFrame->add($menuItem); $itemsFrame->add($menuItem);

View File

@ -6,6 +6,11 @@ use ManiaControl\ManiaControl;
use ManiaControl\Commands\CommandListener; use ManiaControl\Commands\CommandListener;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
/**
* Class offering commands to grant authorizations to players
*
* @author steeffeen & kremsy
*/
class AuthCommands implements CommandListener { class AuthCommands implements CommandListener {
/** /**
* Private properties * Private properties
@ -50,7 +55,7 @@ class AuthCommands implements CommandListener {
} }
$success = $this->maniaControl->authenticationManager->grantAuthLevel($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN); $success = $this->maniaControl->authenticationManager->grantAuthLevel($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured.', $player->login); $this->maniaControl->chat->sendError('Error occurred.', $player->login);
return; return;
} }
$message = '$<' . $player->nickname . '$> added $<' . $target->nickname . '$> as SuperAdmin!'; $message = '$<' . $player->nickname . '$> added $<' . $target->nickname . '$> as SuperAdmin!';
@ -81,7 +86,7 @@ class AuthCommands implements CommandListener {
} }
$success = $this->maniaControl->authenticationManager->grantAuthLevel($player, AuthenticationManager::AUTH_LEVEL_ADMIN); $success = $this->maniaControl->authenticationManager->grantAuthLevel($player, AuthenticationManager::AUTH_LEVEL_ADMIN);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured.', $player->login); $this->maniaControl->chat->sendError('Error occurred.', $player->login);
return; return;
} }
$message = '$<' . $player->nickname . '$> added $<' . $target->nickname . '$> as Admin!'; $message = '$<' . $player->nickname . '$> added $<' . $target->nickname . '$> as Admin!';
@ -112,7 +117,7 @@ class AuthCommands implements CommandListener {
} }
$success = $this->maniaControl->authenticationManager->grantAuthLevel($player, AuthenticationManager::AUTH_LEVEL_OPERATOR); $success = $this->maniaControl->authenticationManager->grantAuthLevel($player, AuthenticationManager::AUTH_LEVEL_OPERATOR);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured.', $player->login); $this->maniaControl->chat->sendError('Error occurred.', $player->login);
return; return;
} }
$message = '$<' . $player->nickname . '$> added $<' . $target->nickname . '$> as Operator!'; $message = '$<' . $player->nickname . '$> added $<' . $target->nickname . '$> as Operator!';
@ -127,7 +132,7 @@ class AuthCommands implements CommandListener {
*/ */
private function sendAddSuperAdminUsageInfo(Player $player) { private function sendAddSuperAdminUsageInfo(Player $player) {
$message = "Usage Example: '//addsuperadmin login'"; $message = "Usage Example: '//addsuperadmin login'";
return $this->maniaControl->chat->sendUsageInfo($message); return $this->maniaControl->chat->sendUsageInfo($message, $player->login);
} }
/** /**
@ -138,7 +143,7 @@ class AuthCommands implements CommandListener {
*/ */
private function sendAddAdminUsageInfo(Player $player) { private function sendAddAdminUsageInfo(Player $player) {
$message = "Usage Example: '//addadmin login'"; $message = "Usage Example: '//addadmin login'";
return $this->maniaControl->chat->sendUsageInfo($message); return $this->maniaControl->chat->sendUsageInfo($message, $player->login);
} }
/** /**
@ -149,7 +154,7 @@ class AuthCommands implements CommandListener {
*/ */
private function sendAddOperatorUsageInfo(Player $player) { private function sendAddOperatorUsageInfo(Player $player) {
$message = "Usage Example: '//addop login'"; $message = "Usage Example: '//addop login'";
return $this->maniaControl->chat->sendUsageInfo($message); return $this->maniaControl->chat->sendUsageInfo($message, $player->login);
} }
} }

View File

@ -133,9 +133,9 @@ class AuthenticationManager {
} }
/** /**
* Sends an error message to the login * Sends an error message to the player
* *
* @param string $login * @param Player $player
* @return bool * @return bool
*/ */
public function sendNotAllowed(Player $player) { public function sendNotAllowed(Player $player) {
@ -148,7 +148,7 @@ class AuthenticationManager {
/** /**
* Check if the player has enough rights * Check if the player has enough rights
* *
* @param \ManiaControl\Players\Player $login * @param Player $player
* @param int $neededAuthLevel * @param int $neededAuthLevel
* @return bool * @return bool
*/ */

View File

@ -115,7 +115,7 @@ class CallbackManager {
* Trigger a specific callback * Trigger a specific callback
* *
* @param string $callbackName * @param string $callbackName
* @param array $data * @param array $callback
*/ */
public function triggerCallback($callbackName, array $callback) { public function triggerCallback($callbackName, array $callback) {
if (!array_key_exists($callbackName, $this->callbackListeners)) { if (!array_key_exists($callbackName, $this->callbackListeners)) {
@ -159,7 +159,7 @@ class CallbackManager {
} }
// Handle callbacks // Handle callbacks
foreach ($callbacks as $index => $callback) { foreach ($callbacks as $callback) {
$callbackName = $callback[0]; $callbackName = $callback[0];
switch ($callbackName) { switch ($callbackName) {
case 'ManiaPlanet.BeginMap': case 'ManiaPlanet.BeginMap':

View File

@ -3,7 +3,7 @@
namespace ManiaControl; namespace ManiaControl;
/** /**
* Utitlity class offering methods to convert and use ManiaPlanet colors * Utility class offering methods to convert and use ManiaPlanet colors
* *
* @author steeffeen * @author steeffeen
*/ */
@ -45,7 +45,7 @@ abstract class ColorUtil {
$value = 1.; $value = 1.;
} }
$value *= 15.; $value *= 15.;
$value = round($value); $value = (int) round($value);
if ($value < 10) { if ($value < 10) {
return (string) $value; return (string) $value;
} }

View File

@ -3,10 +3,8 @@
namespace ManiaControl\Commands; namespace ManiaControl\Commands;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Admin\AuthenticationManager;
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Players\Player;
/** /**
* Class for handling chat commands * Class for handling chat commands

View File

@ -8,7 +8,6 @@ use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
use FML\ManiaLink; use FML\ManiaLink;
use FML\Controls\Control;
use FML\Controls\Frame; use FML\Controls\Frame;
use FML\Controls\Label; use FML\Controls\Label;
use FML\Controls\Labels\Label_Text; use FML\Controls\Labels\Label_Text;

View File

@ -8,7 +8,6 @@ use FML\Controls\Label;
use FML\Script\Pages; use FML\Script\Pages;
use FML\Script\Tooltips; use FML\Script\Tooltips;
use FML\Controls\Control; use FML\Controls\Control;
use FML\Controls\Quad;
use FML\Controls\Quads\Quad_Icons64x64_1; use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\Controls\Labels\Label_Text; use FML\Controls\Labels\Label_Text;
use FML\Controls\Entry; use FML\Controls\Entry;
@ -99,6 +98,7 @@ class ScriptSettings implements ConfiguratorMenu {
// Setting pages // Setting pages
$pageFrames = array(); $pageFrames = array();
$y = 0.;
foreach ($scriptParams as $index => $scriptParam) { foreach ($scriptParams as $index => $scriptParam) {
$settingName = $scriptParam['Name']; $settingName = $scriptParam['Name'];
if (!isset($scriptSettings[$settingName])) continue; if (!isset($scriptSettings[$settingName])) continue;
@ -135,16 +135,16 @@ class ScriptSettings implements ConfiguratorMenu {
} }
$entry->setDefault($settingValue); $entry->setDefault($settingValue);
$decriptionLabel = new Label(); $descriptionLabel = new Label();
$pageFrame->add($decriptionLabel); $pageFrame->add($descriptionLabel);
$decriptionLabel->setHAlign(Control::LEFT); $descriptionLabel->setHAlign(Control::LEFT);
$decriptionLabel->setPosition($width * -0.45, $height * -0.44); $descriptionLabel->setPosition($width * -0.45, $height * -0.44);
$decriptionLabel->setSize($width * 0.7, $settingHeight); $descriptionLabel->setSize($width * 0.7, $settingHeight);
$decriptionLabel->setStyle($labelStyleDescription); $descriptionLabel->setStyle($labelStyleDescription);
$decriptionLabel->setTranslate(true); $descriptionLabel->setTranslate(true);
$decriptionLabel->setTextPrefix('Desc: '); $descriptionLabel->setTextPrefix('Desc: ');
$decriptionLabel->setText($scriptParam['Desc']); $descriptionLabel->setText($scriptParam['Desc']);
$tooltips->add($nameLabel, $decriptionLabel); $tooltips->add($nameLabel, $descriptionLabel);
$y -= $settingHeight; $y -= $settingHeight;
if ($index % $pageMaxCount == $pageMaxCount - 1) { if ($index % $pageMaxCount == $pageMaxCount - 1) {

View File

@ -76,15 +76,15 @@ class Database {
* @return bool * @return bool
*/ */
private function initDatabase() { private function initDatabase() {
$dbname = $this->config->xpath('database'); $dbName = $this->config->xpath('database');
if (!$dbname) { if (!$dbName) {
trigger_error("Invalid database configuration (database).", E_USER_ERROR); trigger_error("Invalid database configuration (database).", E_USER_ERROR);
return false; return false;
} }
$dbname = (string) $dbname[0]; $dbName = (string) $dbName[0];
// Try to connect // Try to connect
$result = $this->mysqli->select_db($dbname); $result = $this->mysqli->select_db($dbName);
if ($result) { if ($result) {
return true; return true;
} }
@ -96,7 +96,7 @@ class Database {
trigger_error($this->mysqli->error, E_USER_ERROR); trigger_error($this->mysqli->error, E_USER_ERROR);
return false; return false;
} }
$databaseStatement->bind_param('s', $dbname); $databaseStatement->bind_param('s', $dbName);
$databaseStatement->execute(); $databaseStatement->execute();
if ($databaseStatement->error) { if ($databaseStatement->error) {
trigger_error($databaseStatement->error, E_USER_ERROR); trigger_error($databaseStatement->error, E_USER_ERROR);
@ -105,9 +105,9 @@ class Database {
$databaseStatement->close(); $databaseStatement->close();
// Connect to new database // Connect to new database
$this->mysqli->select_db($dbname); $this->mysqli->select_db($dbName);
if ($this->mysqli->error) { if ($this->mysqli->error) {
trigger_error("Couldn't select database '{$dbname}'. " . $this->mysqli->error, E_USER_ERROR); trigger_error("Couldn't select database '{$dbName}'. " . $this->mysqli->error, E_USER_ERROR);
return false; return false;
} }
return true; return true;

View File

@ -260,7 +260,7 @@ class GBXBaseFetcher
// XML parser functions // XML parser functions
private function startTag($parser, $name, $attribs) private function startTag($parser, $name, $attribs)
{ {
foreach ($attribs as $key => &$val) foreach ($attribs as &$val)
$val = utf8_decode($val); $val = utf8_decode($val);
//echo 'startTag: ' . $name . "\n"; print_r($attribs); //echo 'startTag: ' . $name . "\n"; print_r($attribs);
array_push($this->_parsestack, $name); array_push($this->_parsestack, $name);

View File

@ -119,7 +119,8 @@ class ManiaControl implements CommandListener {
/** /**
* Send ManiaControl version * Send ManiaControl version
* *
* @param array $chat * @param array $chat
* @param Player $player
* @return bool * @return bool
*/ */
public function command_Version(array $chat, Player $player) { public function command_Version(array $chat, Player $player) {
@ -129,10 +130,10 @@ class ManiaControl implements CommandListener {
/** /**
* Quit ManiaControl and log the given message * Quit ManiaControl and log the given message
*test *
* @param string $message * @param string $message
*/ */
public function quit($message = false) { public function quit($message = '') {
if ($this->client) { if ($this->client) {
// Announce quit // Announce quit
$this->chat->sendInformation('ManiaControl shutting down.'); $this->chat->sendInformation('ManiaControl shutting down.');
@ -248,7 +249,7 @@ class ManiaControl implements CommandListener {
} }
// Connect finished // Connect finished
error_log("Server connection succesfully established!"); error_log("Server connection successfully established!");
// Enable script callbacks if needed // Enable script callbacks if needed
if ($this->server->getGameMode() === 0) { if ($this->server->getGameMode() === 0) {

View File

@ -52,7 +52,7 @@ class Map {
if (!$rpc_infos) { if (!$rpc_infos) {
return; return;
} }
$this->name = $rpc_infos['Name']; // in aseco stripped new lines on name $this->name = $rpc_infos['Name'];
$this->uid = $rpc_infos['UId']; $this->uid = $rpc_infos['UId'];
$this->fileName = $rpc_infos['FileName']; $this->fileName = $rpc_infos['FileName'];
$this->authorLogin = $rpc_infos['Author']; $this->authorLogin = $rpc_infos['Author'];
@ -69,7 +69,7 @@ class Map {
try { try {
$this->mapFetcher->processFile($mapsDirectory . $this->fileName); $this->mapFetcher->processFile($mapsDirectory . $this->fileName);
} }
catch (Exception $e) { catch (\Exception $e) {
trigger_error($e->getMessage(), E_USER_WARNING); trigger_error($e->getMessage(), E_USER_WARNING);
} }
$this->authorNick = $this->mapFetcher->authorNick; $this->authorNick = $this->mapFetcher->authorNick;

View File

@ -73,7 +73,7 @@ class MapCommands implements CommandListener {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return false; return false;
} }
// TODO: mx fetcher nutzen? // TODO: user mx fetcher
$params = explode(' ', $chatCallback[1][2], 2); $params = explode(' ', $chatCallback[1][2], 2);
if (count($params) < 2) { if (count($params) < 2) {
$this->maniaControl->chat->sendUsageInfo('Usage example: //addmap 1234', $player->login); $this->maniaControl->chat->sendUsageInfo('Usage example: //addmap 1234', $player->login);
@ -138,7 +138,7 @@ class MapCommands implements CommandListener {
} }
$response = $this->maniaControl->client->getResponse(); $response = $this->maniaControl->client->getResponse();
if (!$response) { if (!$response) {
// Inalid map type // Invalid map type
$this->maniaControl->chat->sendError("Invalid map type.", $player->login); $this->maniaControl->chat->sendError("Invalid map type.", $player->login);
return false; return false;
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,6 @@ namespace ManiaControl\Players;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Admin\AuthenticationManager;
use ManiaControl\Commands\CommandListener; use ManiaControl\Commands\CommandListener;
use ManiaControl\Players\Player;
/** /**
* Class offering various admin commands related to players * Class offering various admin commands related to players
@ -51,7 +50,7 @@ class PlayerCommands implements CommandListener {
} }
$success = $this->maniaControl->client->query('AutoTeamBalance'); $success = $this->maniaControl->client->query('AutoTeamBalance');
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
$this->maniaControl->chat->sendInformation('$<' . $player->nickname . '$> balanced Teams!'); $this->maniaControl->chat->sendInformation('$<' . $player->nickname . '$> balanced Teams!');
@ -85,7 +84,7 @@ class PlayerCommands implements CommandListener {
} }
$success = $this->maniaControl->client->query('Kick', $target->login, $message); $success = $this->maniaControl->client->query('Kick', $target->login, $message);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
$this->maniaControl->chat->sendInformation('$<' . $player->nickname . '$> kicked $<' . $target->nickname . '$>!'); $this->maniaControl->chat->sendInformation('$<' . $player->nickname . '$> kicked $<' . $target->nickname . '$>!');
@ -119,7 +118,7 @@ class PlayerCommands implements CommandListener {
} }
$success = $this->maniaControl->client->query('ForceSpectator', $target->login, $type); $success = $this->maniaControl->client->query('ForceSpectator', $target->login, $type);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
if ($type != 1) { if ($type != 1) {
@ -156,7 +155,7 @@ class PlayerCommands implements CommandListener {
} }
$success = $this->maniaControl->client->query('ForceSpectator', $target->login, 2); $success = $this->maniaControl->client->query('ForceSpectator', $target->login, 2);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
if ($type != 1) { if ($type != 1) {
@ -188,7 +187,7 @@ class PlayerCommands implements CommandListener {
} }
} }
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
$this->maniaControl->chat->sendSuccess('Fake players connected!', $player->login); $this->maniaControl->chat->sendSuccess('Fake players connected!', $player->login);
@ -207,7 +206,7 @@ class PlayerCommands implements CommandListener {
} }
$success = $this->maniaControl->client->query('DisconnectFakePlayer', '*'); $success = $this->maniaControl->client->query('DisconnectFakePlayer', '*');
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
$this->maniaControl->chat->sendSuccess('Fake players disconnected!', $player->login); $this->maniaControl->chat->sendSuccess('Fake players disconnected!', $player->login);

View File

@ -122,7 +122,7 @@ class PlayerManager implements CallbackListener {
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES)) { if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES)) {
$string = array(0 => 'New Player', 1 => '$0f0Operator', 2 => '$0f0Admin', 3 => '$0f0MasterAdmin', 4 => '$0f0MasterAdmin'); $string = array(0 => 'New Player', 1 => '$0f0Operator', 2 => '$0f0Admin', 3 => '$0f0MasterAdmin', 4 => '$0f0MasterAdmin');
$nickname = Formatter::stripCodes($player->nickname); //TODO strip codes without colour codes like in serverviewer $nickname = Formatter::stripCodes($player->nickname); // TODO: strip codes without colour codes like in serverviewer
$this->maniaControl->chat->sendChat( $this->maniaControl->chat->sendChat(
'$ff0' . $string[$player->authLevel] . ': $fff' . $nickname . '$z $ff0Nation:$fff ' . $player->getCountry() . '$ff0' . $string[$player->authLevel] . ': $fff' . $nickname . '$z $ff0Nation:$fff ' . $player->getCountry() .
' $ff0Ladder: $fff' . $player->ladderRank); ' $ff0Ladder: $fff' . $player->ladderRank);

View File

@ -4,6 +4,7 @@ namespace ManiaControl\Server;
use ManiaControl\FileUtil; use ManiaControl\FileUtil;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
require_once __DIR__ . '/ServerCommands.php'; require_once __DIR__ . '/ServerCommands.php';
@ -159,7 +160,7 @@ class Server {
*/ */
public function getSystemInfo() { public function getSystemInfo() {
if (!$this->maniaControl->client->query('GetSystemInfo')) { if (!$this->maniaControl->client->query('GetSystemInfo')) {
trigger_error("Couldn't fetch server system info. " . $this->maniaControl->getClientErrorText($client)); trigger_error("Couldn't fetch server system info. " . $this->maniaControl->getClientErrorText($this->maniaControl->client));
return null; return null;
} }
return $this->maniaControl->client->getResponse(); return $this->maniaControl->client->getResponse();
@ -252,7 +253,7 @@ class Server {
$map = $this->getMap(); $map = $this->getMap();
$gameMode = $this->getGameMode(); $gameMode = $this->getGameMode();
$time = time(); $time = time();
$fileName = "GhostReplays/Ghost.{$login}.{$gameMode}.{$time}.{$map['UId']}.Replay.Gbx"; $fileName = "GhostReplays/Ghost.{$player->login}.{$gameMode}.{$time}.{$map['UId']}.Replay.Gbx";
// Save ghost replay // Save ghost replay
if (!$this->maniaControl->client->query('SaveBestGhostsReplay', $player->login, $fileName)) { if (!$this->maniaControl->client->query('SaveBestGhostsReplay', $player->login, $fileName)) {

View File

@ -161,7 +161,7 @@ class ServerCommands implements CallbackListener, CommandListener {
} }
$serverName = $params[1]; $serverName = $params[1];
if (!$this->maniaControl->client->query('SetServerName', $serverName)) { if (!$this->maniaControl->client->query('SetServerName', $serverName)) {
$this->maniaControl->chat->sendError('Error occured: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
$this->maniaControl->chat->sendSuccess("Server name changed to: '{$serverName}'!", $player->login); $this->maniaControl->chat->sendSuccess("Server name changed to: '{$serverName}'!", $player->login);
@ -187,7 +187,7 @@ class ServerCommands implements CallbackListener, CommandListener {
} }
$success = $this->maniaControl->client->query('SetServerPassword', $password); $success = $this->maniaControl->client->query('SetServerPassword', $password);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
$this->maniaControl->chat->sendSuccess($successMessage, $player->login); $this->maniaControl->chat->sendSuccess($successMessage, $player->login);
@ -213,7 +213,7 @@ class ServerCommands implements CallbackListener, CommandListener {
} }
$success = $this->maniaControl->client->query('SetServerPasswordForSpectator', $password); $success = $this->maniaControl->client->query('SetServerPasswordForSpectator', $password);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
$this->maniaControl->chat->sendSuccess($successMessage, $player->login); $this->maniaControl->chat->sendSuccess($successMessage, $player->login);
@ -246,7 +246,7 @@ class ServerCommands implements CallbackListener, CommandListener {
} }
$success = $this->maniaControl->client->query('SetMaxPlayers', $amount); $success = $this->maniaControl->client->query('SetMaxPlayers', $amount);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
$this->maniaControl->chat->sendSuccess("Changed max players to: {$amount}", $player->login); $this->maniaControl->chat->sendSuccess("Changed max players to: {$amount}", $player->login);
@ -279,7 +279,7 @@ class ServerCommands implements CallbackListener, CommandListener {
} }
$success = $this->maniaControl->client->query('SetMaxSpectators', $amount); $success = $this->maniaControl->client->query('SetMaxSpectators', $amount);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
$this->maniaControl->chat->sendSuccess("Changed max spectators to: {$amount}", $player->login); $this->maniaControl->chat->sendSuccess("Changed max spectators to: {$amount}", $player->login);
@ -298,7 +298,7 @@ class ServerCommands implements CallbackListener, CommandListener {
} }
$success = $this->maniaControl->client->query('SetHideServer', 1); $success = $this->maniaControl->client->query('SetHideServer', 1);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
$this->maniaControl->chat->sendSuccess('Server is now hidden!', $player->login); $this->maniaControl->chat->sendSuccess('Server is now hidden!', $player->login);
@ -317,7 +317,7 @@ class ServerCommands implements CallbackListener, CommandListener {
} }
$success = $this->maniaControl->client->query('SetHideServer', 0); $success = $this->maniaControl->client->query('SetHideServer', 0);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
$this->maniaControl->chat->sendSuccess('Server is now visible!', $player->login); $this->maniaControl->chat->sendSuccess('Server is now visible!', $player->login);
@ -336,7 +336,7 @@ class ServerCommands implements CallbackListener, CommandListener {
} }
$success = $this->maniaControl->client->query('AllowMapDownload', true); $success = $this->maniaControl->client->query('AllowMapDownload', true);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
$this->maniaControl->chat->sendSuccess('Map Download is now enabled!', $player->login); $this->maniaControl->chat->sendSuccess('Map Download is now enabled!', $player->login);
@ -355,7 +355,7 @@ class ServerCommands implements CallbackListener, CommandListener {
} }
$success = $this->maniaControl->client->query('AllowMapDownload', false); $success = $this->maniaControl->client->query('AllowMapDownload', false);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
$this->maniaControl->chat->sendSuccess('Map Download is now disabled!', $player->login); $this->maniaControl->chat->sendSuccess('Map Download is now disabled!', $player->login);
@ -374,7 +374,7 @@ class ServerCommands implements CallbackListener, CommandListener {
} }
$success = $this->maniaControl->client->query('DisableHorns', false); $success = $this->maniaControl->client->query('DisableHorns', false);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
$this->maniaControl->chat->sendSuccess('Horns enabled!', $player->login); $this->maniaControl->chat->sendSuccess('Horns enabled!', $player->login);
@ -393,7 +393,7 @@ class ServerCommands implements CallbackListener, CommandListener {
} }
$success = $this->maniaControl->client->query('DisableHorns', true); $success = $this->maniaControl->client->query('DisableHorns', true);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
$this->maniaControl->chat->sendSuccess('Horns disabled!', $player->login); $this->maniaControl->chat->sendSuccess('Horns disabled!', $player->login);

View File

@ -282,7 +282,7 @@ class SettingManager {
* Reset a setting to its default value * Reset a setting to its default value
* *
* @param object $object * @param object $object
* @param string $settingname * @param string $settingName
* @return bool * @return bool
*/ */
public function resetSetting($object, $settingName) { public function resetSetting($object, $settingName) {
@ -312,7 +312,7 @@ class SettingManager {
* Delete a setting from the database * Delete a setting from the database
* *
* @param object $object * @param object $object
* @param string $settingname * @param string $settingName
* @return bool * @return bool
*/ */
public function deleteSetting($object, $settingName) { public function deleteSetting($object, $settingName) {

View File

@ -28,7 +28,7 @@ class ChatlogPlugin implements CallbackListener, Plugin {
private $logServerMessages = true; private $logServerMessages = true;
/** /**
* Constuct chatlog plugin * Construct chatlog plugin
* *
* @param ManiaControl $maniaControl * @param ManiaControl $maniaControl
*/ */
@ -129,7 +129,7 @@ class ChatlogPlugin implements CallbackListener, Plugin {
/** /**
* Log the given message * Log the given message
* *
* @param string $message * @param string $text
* @param string $login * @param string $login
*/ */
private function logText($text, $login = null) { private function logText($text, $login = null) {

View File

@ -168,7 +168,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
/** /**
* Handle //getplanets command * Handle //getplanets command
* *
* @param array $chat * @param array $chatCallback
* @param Player $player * @param Player $player
* @return bool * @return bool
*/ */

View File

@ -3,12 +3,10 @@ use ManiaControl\ColorUtil;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Manialinks\ManialinkUtil;
use ManiaControl\Maps\Map; use ManiaControl\Maps\Map;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
use ManiaControl\Plugins\Plugin; use ManiaControl\Plugins\Plugin;
use FML\ManiaLink; use FML\ManiaLink;
use FML\Controls\Control;
use FML\Controls\Frame; use FML\Controls\Frame;
use FML\Controls\Label; use FML\Controls\Label;
use FML\Controls\Quad; use FML\Controls\Quad;
@ -226,7 +224,7 @@ class KarmaPlugin implements CallbackListener, Plugin {
$vote -= substr_count($message, '-'); $vote -= substr_count($message, '-');
$success = $this->handleVote($player, $vote); $success = $this->handleVote($player, $vote);
if (!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occured.', $player->login); $this->maniaControl->chat->sendError('Error occurred.', $player->login);
return; return;
} }
$this->maniaControl->chat->sendSuccess('Vote updated!', $player->login); $this->maniaControl->chat->sendSuccess('Vote updated!', $player->login);
@ -296,7 +294,7 @@ class KarmaPlugin implements CallbackListener, Plugin {
PRIMARY KEY (`index`), PRIMARY KEY (`index`),
UNIQUE KEY `player_map_vote` (`mapIndex`, `playerIndex`) UNIQUE KEY `player_map_vote` (`mapIndex`, `playerIndex`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Save players map votes' AUTO_INCREMENT=1;"; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Save players map votes' AUTO_INCREMENT=1;";
$result = $mysqli->query($query); $mysqli->query($query);
if ($mysqli->error) { if ($mysqli->error) {
trigger_error($mysqli->error, E_USER_ERROR); trigger_error($mysqli->error, E_USER_ERROR);
} }
@ -361,7 +359,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
*/ */
private function getMapKarma(Map $map) { private function getMapKarma(Map $map) {
$mysqli = $this->maniaControl->database->mysqli; $mysqli = $this->maniaControl->database->mysqli;
@ -387,9 +386,10 @@ class KarmaPlugin implements CallbackListener, Plugin {
} }
/** /**
* Get the current votings for the map * Get the current Votes for the Map
* *
* @param Map $map * @param Map $map
* @return array
*/ */
private function getMapVotes(Map $map) { private function getMapVotes(Map $map) {
$mysqli = $this->maniaControl->database->mysqli; $mysqli = $this->maniaControl->database->mysqli;

View File

@ -1,5 +1,4 @@
<?php <?php
use ManiaControl\Database;
use ManiaControl\Formatter; use ManiaControl\Formatter;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
@ -13,7 +12,6 @@ use FML\Controls\Control;
use FML\Controls\Frame; use FML\Controls\Frame;
use FML\Controls\Label; use FML\Controls\Label;
use FML\Controls\Quad; use FML\Controls\Quad;
use FML\Controls\Labels\Label_Text;
/** /**
* ManiaControl Local Records Plugin * ManiaControl Local Records Plugin
@ -214,7 +212,7 @@ class LocalRecordsPlugin implements CallbackListener, Plugin {
{$time} {$time}
) ON DUPLICATE KEY UPDATE ) ON DUPLICATE KEY UPDATE
`time` = VALUES(`time`);"; `time` = VALUES(`time`);";
$result = $mysqli->query($query); $mysqli->query($query);
if ($mysqli->error) { if ($mysqli->error) {
trigger_error($mysqli->error); trigger_error($mysqli->error);
return; return;
@ -222,8 +220,8 @@ class LocalRecordsPlugin implements CallbackListener, Plugin {
$this->updateManialink = true; $this->updateManialink = true;
// Announce record // Announce record
// TODO: setting für nur-zum-spieler senden // TODO: setting to send notification only to the player
// TODO: setting für nur-besten-x-announcen // TODO: setting to send notifications only for x best records
$newRecord = $this->getLocalRecord($map, $player); $newRecord = $this->getLocalRecord($map, $player);
if (!$oldRecord || $newRecord->rank < $oldRecord->rank) { if (!$oldRecord || $newRecord->rank < $oldRecord->rank) {
$improvement = 'gained the'; $improvement = 'gained the';
@ -257,7 +255,7 @@ class LocalRecordsPlugin implements CallbackListener, Plugin {
/** /**
* Handle ClientUpdated callback * Handle ClientUpdated callback
* *
* @param array $data * @param array $callback
*/ */
public function handleClientUpdated(array $callback) { public function handleClientUpdated(array $callback) {
$this->updateManialink = true; $this->updateManialink = true;

View File

@ -84,7 +84,8 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
/** /**
* Handle JumpTo command * Handle JumpTo command
* *
* @param array $chatCallback * @param array $chatCallback
* @param Player $player
* @return bool * @return bool
*/ */
public function command_JumpTo(array $chatCallback, Player $player) { public function command_JumpTo(array $chatCallback, Player $player) {
@ -133,7 +134,7 @@ class ObstaclePlugin implements CallbackListener, CommandListener, Plugin {
return; return;
} }
$time = $data->Run->Time; $time = $data->Run->Time;
// Trigger trackmania player finish callback // Trigger Trackmania player finish callback
$finishCallback = array($player->pid, $player->login, $time); $finishCallback = array($player->pid, $player->login, $time);
$finishCallback = array(CallbackManager::CB_TM_PLAYERCHECKPOINT, $finishCallback); $finishCallback = array(CallbackManager::CB_TM_PLAYERCHECKPOINT, $finishCallback);
$this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERCHECKPOINT, $finishCallback); $this->maniaControl->callbackManager->triggerCallback(CallbackManager::CB_TM_PLAYERCHECKPOINT, $finishCallback);

View File

@ -22,7 +22,7 @@ SETUP:
Enter your mysql server information. Enter your mysql server information.
2.3 Open the file 'configs/authentication.xml'. 2.3 Open the file 'configs/authentication.xml'.
Add the player logins of administrators. Add the Player Logins of Administrators.
3. Run the tool via the shell script 'ManiaControl.sh' (UNIX) or the batch file 'ManiaControl.bat' (Windows) 3. Run the tool via the shell script 'ManiaControl.sh' (UNIX) or the batch file 'ManiaControl.bat' (Windows)