refactored phpdoc, return/break statements, uses

This commit is contained in:
Steffen Schröder 2014-04-27 15:12:09 +02:00
parent b75946e048
commit acf9053117
19 changed files with 48 additions and 53 deletions

View File

@ -213,8 +213,8 @@ class CallbackManager {
case 'ManiaPlanet.BeginMatch': case 'ManiaPlanet.BeginMatch':
if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') { if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') {
$this->triggerCallback($callbackName, $callback); $this->triggerCallback($callbackName, $callback);
break;
} }
break;
case 'ManiaPlanet.BeginMap': case 'ManiaPlanet.BeginMap':
$this->maniaControl->mapManager->handleBeginMap($callback); $this->maniaControl->mapManager->handleBeginMap($callback);
$this->triggerCallback($callbackName, $callback); $this->triggerCallback($callbackName, $callback);
@ -222,8 +222,8 @@ class CallbackManager {
case 'ManiaPlanet.EndMatch': // TODO temporary fix case 'ManiaPlanet.EndMatch': // TODO temporary fix
if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') { if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') {
$this->triggerCallback($callbackName, $callback); $this->triggerCallback($callbackName, $callback);
break;
} }
break;
case 'ManiaPlanet.EndMap': case 'ManiaPlanet.EndMap':
$this->maniaControl->mapManager->handleEndMap($callback); $this->maniaControl->mapManager->handleEndMap($callback);
$this->triggerCallback($callbackName, $callback); $this->triggerCallback($callbackName, $callback);

View File

@ -45,13 +45,13 @@ interface Callbacks {
* param4 int AFKStatus */ * param4 int AFKStatus */
const PLAYERRANKING = 'Callbacks.PlayerRanking'; const PLAYERRANKING = 'Callbacks.PlayerRanking';
//Shootmania Callbacks //ShootMania Callbacks
/** RankingsUpdated Callback, param1 Sorted Rankings */ /** RankingsUpdated Callback, param1 Sorted Rankings */
const RANKINGSUPDATED = 'Callbacks.RankingsUpdated'; const RANKINGSUPDATED = 'Callbacks.RankingsUpdated';
/** RankingsUpdated Callback, returned after LibXmlRpc_PlayerRanking param1 Scores */ /** RankingsUpdated Callback, returned after LibXmlRpc_PlayerRanking param1 Scores */
const SCORES = 'Callbacks.Scores'; const SCORES = 'Callbacks.Scores';
/** Returns the AFKStatus of an Player, returned after param1 Scores */ //returned after TODO /** Returns the AFKStatus of an Player, returned after param1 Scores */ //returned after TODO
const AFKSTATUS = 'Callbacks.AfkStatus'; const AFKSTATUS = 'Callbacks.AfkStatus';
/** Returns if the GameMode has Warmup aktivated, returned after param1 Scores */ //returned after TODO /** Returns if the GameMode has Warmup activated, returned after param1 Scores */ //returned after TODO
const WARMUPSTATUS = 'Callbacks.WarmupStatus'; const WARMUPSTATUS = 'Callbacks.WarmupStatus';
} }

View File

@ -100,7 +100,7 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn
} }
/** /**
* Handle Config Admin Aommand * Handle Config Admin Command
* *
* @param array $callback * @param array $callback
*/ */

View File

@ -111,7 +111,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener {
$y = 0; $y = 0;
$index = 1; $index = 1;
$prevClass = ''; $prevClass = '';
foreach($settings as $id => $setting) { foreach($settings as $setting) {
//Don't display Plugin Settings //Don't display Plugin Settings
if (array_search($setting->class, $pluginClasses) !== FALSE) { if (array_search($setting->class, $pluginClasses) !== FALSE) {
continue; continue;

View File

@ -373,7 +373,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
} }
/** /**
* Toogle a Boolean Setting * Toggle a Boolean Setting
* *
* @param Player $player * @param Player $player
* @param $setting * @param $setting

View File

@ -383,7 +383,7 @@ class ManiaControl implements CommandListener, TimerListener {
*/ */
private function connect() { private function connect() {
// Load remote client // Load remote client
$success = $this->server->loadConfig(); $this->server->loadConfig();
$this->log("Connecting to server at {$this->server->config->host}:{$this->server->config->port}..."); $this->log("Connecting to server at {$this->server->config->host}:{$this->server->config->port}...");

View File

@ -24,7 +24,6 @@ use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Maps\MapCommands; use ManiaControl\Maps\MapCommands;
use ManiaControl\Maps\MapManager; use ManiaControl\Maps\MapManager;
use ManiaControl\Maps\MapQueue;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
/** /**

View File

@ -360,7 +360,7 @@ class ManiaExchangeManager{
} }
/** /**
* Gets the Current Environemnt by String * Gets the Current Environment by String
* *
* @param $env * @param $env
* @return int * @return int

View File

@ -10,7 +10,6 @@ use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
use Maniaplanet\DedicatedServer\Xmlrpc\LoginUnknownException; use Maniaplanet\DedicatedServer\Xmlrpc\LoginUnknownException;
use Maniaplanet\DedicatedServer\Xmlrpc\NotInScriptModeException; use Maniaplanet\DedicatedServer\Xmlrpc\NotInScriptModeException;

View File

@ -4,7 +4,6 @@ namespace ManiaControl\Maps;
use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Admin\AuthenticationManager;
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Commands\CommandListener; use ManiaControl\Commands\CommandListener;
use ManiaControl\Formatter; use ManiaControl\Formatter;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;

View File

@ -377,7 +377,7 @@ class PlayerManager implements CallbackListener, TimerListener {
return null; return null;
} }
$player = new Player(false); $player = new Player(null);
$player->index = $playerIndex; $player->index = $playerIndex;
$player->login = $row->login; $player->login = $row->login;
$player->rawNickname = $row->nickname; $player->rawNickname = $row->nickname;
@ -412,7 +412,7 @@ class PlayerManager implements CallbackListener, TimerListener {
return null; return null;
} }
$player = new Player(false); $player = new Player(null);
$player->index = $row->index; $player->index = $row->index;
$player->login = $row->login; $player->login = $row->login;
$player->rawNickname = $row->nickname; $player->rawNickname = $row->nickname;

View File

@ -76,9 +76,7 @@ class PluginManager {
* @return bool * @return bool
*/ */
public function isPluginActive($pluginClass) { public function isPluginActive($pluginClass) {
if (is_object($pluginClass)) { $pluginClass = $this->getPluginClass($pluginClass);
$pluginClass = get_class($pluginClass);
}
return isset($this->activePlugins[$pluginClass]); return isset($this->activePlugins[$pluginClass]);
} }
@ -89,9 +87,7 @@ class PluginManager {
* @return bool * @return bool
*/ */
public function isPluginClass($pluginClass) { public function isPluginClass($pluginClass) {
if (is_object($pluginClass)) { $pluginClass = $this->getPluginClass($pluginClass);
$pluginClass = get_class($pluginClass);
}
if (!in_array(Plugin::PLUGIN_INTERFACE, class_implements($pluginClass))) { if (!in_array(Plugin::PLUGIN_INTERFACE, class_implements($pluginClass))) {
return false; return false;
} }
@ -105,9 +101,7 @@ class PluginManager {
* @return bool * @return bool
*/ */
public function addPluginClass($pluginClass) { public function addPluginClass($pluginClass) {
if (is_object($pluginClass)) { $pluginClass = $this->getPluginClass($pluginClass);
$pluginClass = get_class($pluginClass);
}
if (in_array($pluginClass, $this->pluginClasses)) { if (in_array($pluginClass, $this->pluginClasses)) {
return false; return false;
} }
@ -161,9 +155,7 @@ class PluginManager {
* @return bool * @return bool
*/ */
public function deactivatePlugin($pluginClass) { public function deactivatePlugin($pluginClass) {
if (is_object($pluginClass)) { $pluginClass = $this->getPluginClass($pluginClass);
$pluginClass = get_class($pluginClass);
}
if (!$this->isPluginActive($pluginClass)) { if (!$this->isPluginActive($pluginClass)) {
return false; return false;
} }
@ -171,12 +163,11 @@ class PluginManager {
/** @var Plugin $plugin */ /** @var Plugin $plugin */
unset($this->activePlugins[$pluginClass]); unset($this->activePlugins[$pluginClass]);
$plugin->unload(); $plugin->unload();
$interfaces = class_implements($pluginClass); if ($plugin instanceof CallbackListener) {
if (in_array(CallbackListener::CALLBACKLISTENER_INTERFACE, $interfaces)) {
$this->maniaControl->callbackManager->unregisterCallbackListener($plugin); $this->maniaControl->callbackManager->unregisterCallbackListener($plugin);
$this->maniaControl->callbackManager->unregisterScriptCallbackListener($plugin); $this->maniaControl->callbackManager->unregisterScriptCallbackListener($plugin);
} }
if (in_array(ManialinkPageAnswerListener::MANIALINKPAGEANSWERLISTENER_INTERFACE, $interfaces)) { if ($plugin instanceof ManialinkPageAnswerListener) {
$this->maniaControl->manialinkManager->unregisterManialinkPageAnswerListener($plugin); $this->maniaControl->manialinkManager->unregisterManialinkPageAnswerListener($plugin);
} }
$this->savePluginStatus($pluginClass, false); $this->savePluginStatus($pluginClass, false);
@ -357,4 +348,17 @@ class PluginManager {
call_user_func($function, $data, $error); call_user_func($function, $data, $error);
}); });
} }
/**
* Get the Class of the Plugin
*
* @param mixed $pluginClass
* @return string
*/
private function getPluginClass($pluginClass) {
if (is_object($pluginClass)) {
$pluginClass = get_class($pluginClass);
}
return (string) $pluginClass;
}
} }

View File

@ -3,20 +3,15 @@
namespace ManiaControl\Update; namespace ManiaControl\Update;
use FML\Controls\Control; use FML\Controls\Control;
use FML\Controls\Entry;
use FML\Controls\Frame; use FML\Controls\Frame;
use FML\Controls\Label; use FML\Controls\Label;
use FML\Controls\Labels\Label_Button; use FML\Controls\Labels\Label_Button;
use FML\Controls\Labels\Label_Text; use FML\Controls\Labels\Label_Text;
use FML\Controls\Quads\Quad_Icons128x32_1;
use FML\Controls\Quads\Quad_Icons128x128_1;
use FML\Controls\Quads\Quad_Icons64x64_1; use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\Script\Script; use FML\Script\Script;
use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Admin\AuthenticationManager;
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Configurators\ConfiguratorMenu; use ManiaControl\Configurators\ConfiguratorMenu;
use ManiaControl\Formatter;
use ManiaControl\Files\FileUtil; use ManiaControl\Files\FileUtil;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Manialinks\ManialinkPageAnswerListener;
@ -65,8 +60,6 @@ class PluginInstallMenu implements CallbackListener, ConfiguratorMenu, Manialink
$pagesId = 'PluginInstallPages'; $pagesId = 'PluginInstallPages';
$frame = new Frame(); $frame = new Frame();
$pluginClasses = $this->maniaControl->pluginManager->getPluginClasses();
// Config // Config
$pagerSize = 9.; $pagerSize = 9.;
$entryHeight = 5.; $entryHeight = 5.;

View File

@ -501,18 +501,18 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
if (!$bytes || $bytes <= 0) { if (!$bytes || $bytes <= 0) {
trigger_error("Couldn't save plugin Zip."); trigger_error("Couldn't save plugin Zip.");
if ($player) { if ($player) {
$self->maniaControl->chat->sendError('Update failed: Couldn\'t save plugin zip!', $player->login); $self->maniaControl->chat->sendError("Update failed: Couldn't save plugin zip!", $player->login);
} }
return false; return;
} }
$zip = new \ZipArchive(); $zip = new \ZipArchive();
$result = $zip->open($updateFileName); $result = $zip->open($updateFileName);
if ($result !== true) { if ($result !== true) {
trigger_error("Couldn't open plugin Zip. ({$result})"); trigger_error("Couldn't open plugin Zip. ({$result})");
if ($player) { if ($player) {
$self->maniaControl->chat->sendError('Update failed: Couldn\'t open plugin zip!', $player->login); $self->maniaControl->chat->sendError("Update failed: Couldn't open plugin zip!", $player->login);
} }
return false; return;
} }
$zip->extractTo(ManiaControlDir . '/plugins'); $zip->extractTo(ManiaControlDir . '/plugins');
@ -559,15 +559,15 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
$bytes = file_put_contents($installFileName, $installFileContent); $bytes = file_put_contents($installFileName, $installFileContent);
if (!$bytes || $bytes <= 0) { if (!$bytes || $bytes <= 0) {
trigger_error("Couldn't save plugin Zip."); trigger_error("Couldn't save plugin Zip.");
$self->maniaControl->chat->sendError('Install failed: Couldn\'t save plugin zip!', $player->login); $self->maniaControl->chat->sendError("Install failed: Couldn't save plugin zip!", $player->login);
return false; return;
} }
$zip = new \ZipArchive(); $zip = new \ZipArchive();
$result = $zip->open($installFileName); $result = $zip->open($installFileName);
if ($result !== true) { if ($result !== true) {
trigger_error("Couldn't open plugin Zip. ({$result})"); trigger_error("Couldn't open plugin Zip. ({$result})");
$self->maniaControl->chat->sendError('Install failed: Couldn\'t open plugin zip!', $player->login); $self->maniaControl->chat->sendError("Install failed: Couldn't open plugin zip!", $player->login);
return false; return;
} }
$zip->extractTo(ManiaControlDir . '/plugins'); $zip->extractTo(ManiaControlDir . '/plugins');
@ -782,7 +782,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
if (!$bytes || $bytes <= 0) { if (!$bytes || $bytes <= 0) {
trigger_error("Couldn't save Update Zip."); trigger_error("Couldn't save Update Zip.");
if ($player) { if ($player) {
$self->maniaControl->chat->sendError('Update failed: Couldn\'t save Update zip!', $player->login); $self->maniaControl->chat->sendError("Update failed: Couldn't save Update zip!", $player->login);
} }
return false; return false;
} }
@ -791,7 +791,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener
if ($result !== true) { if ($result !== true) {
trigger_error("Couldn't open Update Zip. ({$result})"); trigger_error("Couldn't open Update Zip. ({$result})");
if ($player) { if ($player) {
$self->maniaControl->chat->sendError('Update failed: Couldn\'t open Update zip!', $player->login); $self->maniaControl->chat->sendError("Update failed: Couldn't open Update zip!", $player->login);
} }
return false; return false;
} }

View File

@ -967,6 +967,7 @@ class Dedimania implements CallbackListener, CommandListener, TimerListener, Plu
} else if ($scriptName == 'TimeAttack' || $scriptName == 'Laps' || $scriptName == 'TeamAttack' || $scriptName == 'TimeAttackPlus') { } else if ($scriptName == 'TimeAttack' || $scriptName == 'Laps' || $scriptName == 'TeamAttack' || $scriptName == 'TimeAttackPlus') {
return 'TA'; return 'TA';
} }
break;
} }
case 1: case 1:
case 3: case 3:

View File

@ -218,7 +218,6 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
$karmaGauge->setColor($karmaColor . '7'); $karmaGauge->setColor($karmaColor . '7');
$karmaLabel->setText(' ' . round($karma * 100.) . '% (' . $voteCount . ')'); $karmaLabel->setText(' ' . round($karma * 100.) . '% (' . $voteCount . ')');
} else { } else {
$karma = 0.;
$karmaGauge->setRatio(0.); $karmaGauge->setRatio(0.);
$karmaGauge->setColor('00fb'); $karmaGauge->setColor('00fb');
$karmaLabel->setText('-'); $karmaLabel->setText('-');
@ -227,7 +226,8 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
// Loop players // Loop players
foreach($players as $login => $player) { foreach($players as $login => $player) {
// Get player vote // Get player vote
//$vote = $this->getPlayerVote($player, $map); //TODO what is this for, vote nowhere used? // TODO: show the player his own vote in some way
//$vote = $this->getPlayerVote($player, $map);
// Adjust manialink for player's vote // Adjust manialink for player's vote
$votesFrame = $this->manialink->votesFrame; $votesFrame = $this->manialink->votesFrame;

View File

@ -359,9 +359,8 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList
} }
$mysqli = $this->maniaControl->database->mysqli; $mysqli = $this->maniaControl->database->mysqli;
$removeRecord = $records[$recordId-1];
$query = "DELETE FROM `" . self::TABLE_RECORDS . "` WHERE `mapIndex` = ".$currentMap->index." AND `playerIndex` = ".$player->index.""; $query = "DELETE FROM `" . self::TABLE_RECORDS . "` WHERE `mapIndex` = ".$currentMap->index." AND `playerIndex` = ".$player->index."";
$result = $mysqli->query($query); $mysqli->query($query);
if ($mysqli->error) { if ($mysqli->error) {
trigger_error($mysqli->error); trigger_error($mysqli->error);
return null; return null;

View File

@ -366,7 +366,7 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
* @return bool * @return bool
*/ */
private function addPlayerToQueue(Player $player) { private function addPlayerToQueue(Player $player) {
if($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSetting($this, self::QUEUE_ACTIVE_ON_PASS) == false) return; if($this->maniaControl->client->getServerPassword() != false && $this->maniaControl->settingManager->getSetting($this, self::QUEUE_ACTIVE_ON_PASS) == false) return false;
foreach($this->queue as $queuedPlayer) { foreach($this->queue as $queuedPlayer) {
if($queuedPlayer->login == $player->login) { if($queuedPlayer->login == $player->login) {
@ -379,6 +379,8 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
$this->queue[count($this->queue)] = $player; $this->queue[count($this->queue)] = $player;
$this->sendChatMessage('$<$fff' . $player->nickname . '$> just joined the queue!'); $this->sendChatMessage('$<$fff' . $player->nickname . '$> just joined the queue!');
} }
return true;
} }
/** /**

View File

@ -319,7 +319,6 @@ class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPag
$frame->add($users[$userid]); $frame->add($users[$userid]);
$y = 17.5 + ($i * 2.5); $y = 17.5 + ($i * 2.5);
$users[$userid]->setY($height / 2 - $y); $users[$userid]->setY($height / 2 - $y);
$x = $startx;
if ($channel['pid'] != 0) { if ($channel['pid'] != 0) {
$x = $startx + 7; $x = $startx + 7;
} else { } else {