- updates for new server properties

- refactored various imports
This commit is contained in:
Steffen Schröder 2014-01-06 16:14:49 +01:00
parent c3a2cd6122
commit c7d325c216
13 changed files with 251 additions and 268 deletions

View File

@ -395,8 +395,6 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
return false; return false;
} }
$serverIndex = $this->maniaControl->server->getIndex();
// Notifications // Notifications
$settingsCount = count($newSettings); $settingsCount = count($newSettings);
$settingIndex = 0; $settingIndex = 0;
@ -411,7 +409,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
} }
// Add To Database // Add To Database
$statement->bind_param('iss', $serverIndex, $setting, $value); $statement->bind_param('iss', $this->maniaControl->server->index, $setting, $value);
$statement->execute(); $statement->execute();
if($statement->error) { if($statement->error) {
trigger_error($statement->error); trigger_error($statement->error);

View File

@ -351,8 +351,6 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
return false; return false;
} }
$serverIndex = $this->maniaControl->server->getIndex();
// Notifications // Notifications
$settingsCount = count($newSettings); $settingsCount = count($newSettings);
$settingIndex = 0; $settingIndex = 0;
@ -360,7 +358,7 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
// $chatMessage = '$ff0' . $title . ' $<' . $player->nickname . '$> set ScriptSetting' . ($settingsCount > 1 ? 's' : '') . ' '; // $chatMessage = '$ff0' . $title . ' $<' . $player->nickname . '$> set ScriptSetting' . ($settingsCount > 1 ? 's' : '') . ' ';
foreach($newSettings as $setting => $value) { foreach($newSettings as $setting => $value) {
$statement->bind_param('iss', $serverIndex, $setting, $value); $statement->bind_param('iss', $this->maniaControl->server->index, $setting, $value);
$statement->execute(); $statement->execute();
if($statement->error) { if($statement->error) {
trigger_error($statement->error); trigger_error($statement->error);

View File

@ -34,14 +34,9 @@ require_once __DIR__ . '/ManiaExchange/mxinfofetcher.inc.php';
require_once __DIR__ . '/ManiaExchange/mxinfosearcher.inc.php'; require_once __DIR__ . '/ManiaExchange/mxinfosearcher.inc.php';
require_once __DIR__ . '/Manialinks/ManialinkManager.php'; require_once __DIR__ . '/Manialinks/ManialinkManager.php';
require_once __DIR__ . '/Statistics/StatisticManager.php'; require_once __DIR__ . '/Statistics/StatisticManager.php';
require_once __DIR__ . '/Maps/Map.php';
require_once __DIR__ . '/Maps/MapManager.php'; require_once __DIR__ . '/Maps/MapManager.php';
require_once __DIR__ . '/Maps/MapList.php';
require_once __DIR__ . '/Maps/MapQueue.php';
require_once __DIR__ . '/Players/PlayerManager.php'; require_once __DIR__ . '/Players/PlayerManager.php';
require_once __DIR__ . '/Players/PlayerActions.php';
require_once __DIR__ . '/Plugins/PluginManager.php'; require_once __DIR__ . '/Plugins/PluginManager.php';
require_once __DIR__ . '/Players/PlayerList.php';
require_once __DIR__ . '/Server/Server.php'; require_once __DIR__ . '/Server/Server.php';
require_once __DIR__ . '/Settings/SettingManager.php'; require_once __DIR__ . '/Settings/SettingManager.php';
require_once __DIR__ . '/UpdateManager.php'; require_once __DIR__ . '/UpdateManager.php';

View File

@ -2,9 +2,6 @@
namespace ManiaControl\Maps; namespace ManiaControl\Maps;
require_once __DIR__ . '/Map.php';
require_once __DIR__ . '/MapCommands.php';
use ManiaControl\FileUtil; use ManiaControl\FileUtil;
use ManiaControl\Formatter; use ManiaControl\Formatter;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
@ -12,6 +9,11 @@ use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\CallbackManager;
use MXInfoFetcher; use MXInfoFetcher;
require_once __DIR__ . '/Map.php';
require_once __DIR__ . '/MapCommands.php';
require_once __DIR__ . '/MapList.php';
require_once __DIR__ . '/MapQueue.php';
/** /**
* Manager for Maps * Manager for Maps
* *

View File

@ -54,38 +54,37 @@ class PlayerActions {
// TODO: get used by playercommands // TODO: get used by playercommands
$admin = $this->maniaControl->playerManager->getPlayer($adminLogin); $admin = $this->maniaControl->playerManager->getPlayer($adminLogin);
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
if(!$admin || !$target) { if (!$admin || !$target) {
return; return;
} }
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
if($target->isSpectator) { if ($target->isSpectator) {
$success = $this->maniaControl->client->query('ForceSpectator', $target->login, self::SPECTATOR_PLAYER); $success = $this->maniaControl->client->query('ForceSpectator', $target->login, self::SPECTATOR_PLAYER);
if(!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
} }
$success = $this->maniaControl->client->query('ForcePlayerTeam', $target->login, $teamId); $success = $this->maniaControl->client->query('ForcePlayerTeam', $target->login, $teamId);
if(!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
$chatMessage = false; $chatMessage = false;
if($teamId == self::BLUE_TEAM) { if ($teamId == self::BLUE_TEAM) {
$chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Blue-Team!'; $chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Blue-Team!';
} else if($teamId == self::RED_TEAM) { }
else if ($teamId == self::RED_TEAM) {
$chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Red-Team!'; $chatMessage = $title . ' $<' . $admin->nickname . '$> forced $<' . $target->nickname . '$> into the Red-Team!';
} }
if(!$chatMessage) if (!$chatMessage) return;
return;
$this->maniaControl->chat->sendInformation($chatMessage); $this->maniaControl->chat->sendInformation($chatMessage);
$this->maniaControl->log(Formatter::stripCodes($chatMessage)); $this->maniaControl->log(Formatter::stripCodes($chatMessage));
} }
/** /**
* Force a Player to Spectator * Force a Player to Spectator
* *
@ -100,7 +99,7 @@ class PlayerActions {
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
$success = $this->maniaControl->client->query('ForceSpectator', $targetLogin, $spectatorState); $success = $this->maniaControl->client->query('ForceSpectator', $targetLogin, $spectatorState);
if(!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
@ -110,11 +109,9 @@ class PlayerActions {
$this->maniaControl->log(Formatter::stripCodes($chatMessage)); $this->maniaControl->log(Formatter::stripCodes($chatMessage));
// free player slot // free player slot
if($releaseSlot) if ($releaseSlot) $this->maniaControl->client->query('SpectatorReleasePlayerSlot', $target->login);
$this->maniaControl->client->query('SpectatorReleasePlayerSlot', $target->login);
} }
/** /**
* UnMutes a Player * UnMutes a Player
* *
@ -133,7 +130,7 @@ class PlayerActions {
var_dump($success); var_dump($success);
var_dump($this->maniaControl->client->getResponse()); var_dump($this->maniaControl->client->getResponse());
if(!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
@ -157,7 +154,7 @@ class PlayerActions {
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
$success = $this->maniaControl->client->query('Ignore', $targetLogin); $success = $this->maniaControl->client->query('Ignore', $targetLogin);
if(!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
@ -167,7 +164,6 @@ class PlayerActions {
$this->maniaControl->log(Formatter::stripCodes($chatMessage)); $this->maniaControl->log(Formatter::stripCodes($chatMessage));
} }
/** /**
* Warn a Player * Warn a Player
* *
@ -225,7 +221,7 @@ class PlayerActions {
$label->setTextColor('F00'); $label->setTextColor('F00');
$y = $height / 2 - 15; $y = $height / 2 - 15;
foreach($message as &$line) { foreach ($message as &$line) {
// Warn Labels // Warn Labels
$label = new Label_Text(); $label = new Label_Text();
$frame->add($label); $frame->add($label);
@ -260,13 +256,14 @@ class PlayerActions {
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
if($target->isFakePlayer()) { if ($target->isFakePlayer()) {
$success = $this->maniaControl->client->query('DisconnectFakePlayer', $target->login); $success = $this->maniaControl->client->query('DisconnectFakePlayer', $target->login);
} else { }
else {
$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 occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
@ -290,7 +287,7 @@ class PlayerActions {
$success = $this->maniaControl->client->query('Ban', $target->login, $message); $success = $this->maniaControl->client->query('Ban', $target->login, $message);
if(!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
@ -312,21 +309,23 @@ class PlayerActions {
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
if($this->maniaControl->authenticationManager->checkRight($target, $authLevel)) { if ($this->maniaControl->authenticationManager->checkRight($target, $authLevel)) {
$this->maniaControl->chat->sendError('This Player is already ' . $this->maniaControl->authenticationManager->getAuthLevelName($target->authLevel), $admin->login); $this->maniaControl->chat->sendError(
'This Player is already ' . $this->maniaControl->authenticationManager->getAuthLevelName($target->authLevel), $admin->login);
return; return;
} }
$authLevelName = $this->maniaControl->authenticationManager->getAuthLevelName($authLevel); $authLevelName = $this->maniaControl->authenticationManager->getAuthLevelName($authLevel);
if($this->maniaControl->authenticationManager->checkRight($admin, $authLevel) <= $this->maniaControl->authenticationManager->checkRight($target, $authLevel)) { if ($this->maniaControl->authenticationManager->checkRight($admin, $authLevel) <=
$this->maniaControl->authenticationManager->checkRight($target, $authLevel)) {
$this->maniaControl->chat->sendError('You don\'t have the permission to add a ' . $authLevelName . '!', $admin->login); $this->maniaControl->chat->sendError('You don\'t have the permission to add a ' . $authLevelName . '!', $admin->login);
return; return;
} }
$success = $this->maniaControl->authenticationManager->grantAuthLevel($target, $authLevel); $success = $this->maniaControl->authenticationManager->grantAuthLevel($target, $authLevel);
if(!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
@ -347,14 +346,14 @@ class PlayerActions {
$target = $this->maniaControl->playerManager->getPlayer($targetLogin); $target = $this->maniaControl->playerManager->getPlayer($targetLogin);
$title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel); $title = $this->maniaControl->authenticationManager->getAuthLevelName($admin->authLevel);
if($this->maniaControl->authenticationManager->checkRight($target, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)) { if ($this->maniaControl->authenticationManager->checkRight($target, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)) {
$this->maniaControl->chat->sendError('MasterAdmins can\'t be removed ', $admin->login); $this->maniaControl->chat->sendError('MasterAdmins can\'t be removed ', $admin->login);
return; return;
} }
$success = $this->maniaControl->authenticationManager->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_PLAYER); $success = $this->maniaControl->authenticationManager->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_PLAYER);
if(!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $admin->login);
return; return;
} }
@ -372,9 +371,8 @@ class PlayerActions {
*/ */
public function isPlayerMuted($login) { public function isPlayerMuted($login) {
$this->maniaControl->client->query('GetIgnoreList', 100, 0); $this->maniaControl->client->query('GetIgnoreList', 100, 0);
foreach($this->maniaControl->client->getResponse() as $ignoredPlayers) { foreach ($this->maniaControl->client->getResponse() as $ignoredPlayers) {
if($ignoredPlayers["Login"] == $login) if ($ignoredPlayers["Login"] == $login) return true;
return true;
} }
return false; return false;
} }

View File

@ -12,7 +12,7 @@ use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Manialinks\ManialinkPageAnswerListener;
/** /**
* Class offering various admin commands related to players * Class offering various Admin Commands related to Players
* *
* @author steeffeen & kremsy * @author steeffeen & kremsy
*/ */
@ -25,13 +25,12 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
const ACTION_CANCEL_VOTE = 'PlayerCommands.CancelVote'; const ACTION_CANCEL_VOTE = 'PlayerCommands.CancelVote';
/** /**
* Private properties * Private Properties
*/ */
private $maniaControl = null; private $maniaControl = null;
public $playerList = null;
/** /**
* Create a new server commands instance * Create a new Player Commands Instance
* *
* @param ManiaControl $maniaControl * @param ManiaControl $maniaControl
*/ */
@ -51,29 +50,28 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
$this->maniaControl->commandManager->registerCommandListener('removebot', $this, 'command_RemoveFakePlayers', true); $this->maniaControl->commandManager->registerCommandListener('removebot', $this, 'command_RemoveFakePlayers', true);
$this->maniaControl->commandManager->registerCommandListener('addbots', $this, 'command_AddFakePlayers', true); $this->maniaControl->commandManager->registerCommandListener('addbots', $this, 'command_AddFakePlayers', true);
$this->maniaControl->commandManager->registerCommandListener('removebots', $this, 'command_RemoveFakePlayers', true); $this->maniaControl->commandManager->registerCommandListener('removebots', $this, 'command_RemoveFakePlayers', true);
$this->maniaControl->commandManager->registerCommandListener('cancel', $this, 'command_CancelVote', true); //TODO remove in other class? // TODO: Move into another class
$this->maniaControl->commandManager->registerCommandListener('cancel', $this, 'command_CancelVote', true);
// Register for player chat commands // Register for player chat commands
$this->maniaControl->commandManager->registerCommandListener('player', $this, 'command_playerList'); $this->maniaControl->commandManager->registerCommandListener('player', $this, 'command_playerList');
$this->maniaControl->commandManager->registerCommandListener('players', $this, 'command_playerList'); $this->maniaControl->commandManager->registerCommandListener('players', $this, 'command_playerList');
$this->playerList = new PlayerList($this->maniaControl); // Action Balance Teams
//Action Balance Teams
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_BALANCE_TEAMS, $this, 'command_TeamBalance'); $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_BALANCE_TEAMS, $this, 'command_TeamBalance');
$itemQuad = new Quad_Icons128x32_1(); $itemQuad = new Quad_Icons128x32_1();
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_RT_Team); $itemQuad->setSubStyle($itemQuad::SUBSTYLE_RT_Team);
$itemQuad->setAction(self::ACTION_BALANCE_TEAMS); $itemQuad->setAction(self::ACTION_BALANCE_TEAMS);
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 9, 'Balance Teams'); $this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 9, 'Balance Teams');
//Action cancel Vote // Action cancel Vote
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CANCEL_VOTE, $this, 'command_cancelVote'); $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CANCEL_VOTE, $this, 'command_cancelVote');
$itemQuad = new Quad_Icons64x64_1(); $itemQuad = new Quad_Icons64x64_1();
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ArrowRed); $itemQuad->setSubStyle($itemQuad::SUBSTYLE_ArrowRed);
$itemQuad->setAction(self::ACTION_CANCEL_VOTE); $itemQuad->setAction(self::ACTION_CANCEL_VOTE);
$this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 6, 'Cancel Vote'); $this->maniaControl->actionsMenu->addMenuItem($itemQuad, false, 6, 'Cancel Vote');
//Action Open Playerlist // Action Open Playerlist
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_PLAYERLIST, $this, 'command_playerList'); $this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_PLAYERLIST, $this, 'command_playerList');
$itemQuad = new Quad_UIConstruction_Buttons(); $itemQuad = new Quad_UIConstruction_Buttons();
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_Author); $itemQuad->setSubStyle($itemQuad::SUBSTYLE_Author);
@ -88,12 +86,12 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
* @param Player $player * @param Player $player
*/ */
public function command_CancelVote(array $chatCallback, Player $player) { public function command_CancelVote(array $chatCallback, Player $player) {
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) { if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
} }
$success = $this->maniaControl->client->query('CancelVote'); $success = $this->maniaControl->client->query('CancelVote');
if(!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
@ -107,12 +105,12 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
* @param Player $player * @param Player $player
*/ */
public function command_TeamBalance(array $chatCallback, Player $player) { public function command_TeamBalance(array $chatCallback, Player $player) {
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) { if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
} }
$success = $this->maniaControl->client->query('AutoTeamBalance'); $success = $this->maniaControl->client->query('AutoTeamBalance');
if(!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
@ -126,23 +124,23 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
* @param Player $player * @param Player $player
*/ */
public function command_Kick(array $chat, Player $player) { public function command_Kick(array $chat, Player $player) {
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) { if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
} }
$params = explode(' ', $chat[1][2], 3); $params = explode(' ', $chat[1][2], 3);
if(!isset($params[1])) { if (!isset($params[1])) {
$this->maniaControl->chat->sendUsageInfo('Usage example: //kick login', $player->login); $this->maniaControl->chat->sendUsageInfo('Usage example: //kick login', $player->login);
return; return;
} }
$target = $params[1]; $target = $params[1];
$target = $this->maniaControl->playerManager->getPlayer($target); $target = $this->maniaControl->playerManager->getPlayer($target);
if(!$target) { if (!$target) {
$this->maniaControl->chat->sendError("Invalid player login.", $player->login); $this->maniaControl->chat->sendError("Invalid player login.", $player->login);
return; return;
} }
$message = ''; $message = '';
if(isset($params[2])) { if (isset($params[2])) {
$message = $params[2]; $message = $params[2];
} }
@ -156,31 +154,31 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
* @param Player $player * @param Player $player
*/ */
public function command_ForceSpectator(array $chat, Player $player) { public function command_ForceSpectator(array $chat, Player $player) {
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) { if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
} }
$params = explode(' ', $chat[1][2]); $params = explode(' ', $chat[1][2]);
if(!isset($params[1])) { if (!isset($params[1])) {
$this->maniaControl->chat->sendUsageInfo('Usage example: //forcespec login', $player->login); $this->maniaControl->chat->sendUsageInfo('Usage example: //forcespec login', $player->login);
return; return;
} }
$target = $params[1]; $target = $params[1];
$target = $this->maniaControl->playerManager->getPlayer($target); $target = $this->maniaControl->playerManager->getPlayer($target);
if(!$target) { if (!$target) {
$this->maniaControl->chat->sendError("Invalid player login.", $player->login); $this->maniaControl->chat->sendError("Invalid player login.", $player->login);
return; return;
} }
$type = 3; $type = 3;
if(isset($params[2]) && is_numeric($params[2])) { if (isset($params[2]) && is_numeric($params[2])) {
$type = intval($params[2]); $type = intval($params[2]);
} }
$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 occurred: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
if($type != 1) { if ($type != 1) {
$this->maniaControl->client->query('ForceSpectator', $target->login, 0); $this->maniaControl->client->query('ForceSpectator', $target->login, 0);
} }
$this->maniaControl->chat->sendInformation('$<' . $player->nickname . '$> forced $<' . $target->nickname . '$> to spectator!'); $this->maniaControl->chat->sendInformation('$<' . $player->nickname . '$> forced $<' . $target->nickname . '$> to spectator!');
@ -193,31 +191,31 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
* @param Player $player * @param Player $player
*/ */
public function command_ForcePlayer(array $chat, Player $player) { public function command_ForcePlayer(array $chat, Player $player) {
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) { if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
} }
$params = explode(' ', $chat[1][2]); $params = explode(' ', $chat[1][2]);
if(!isset($params[1])) { if (!isset($params[1])) {
$this->maniaControl->chat->sendUsageInfo('Usage example: //forceplay login', $player->login); $this->maniaControl->chat->sendUsageInfo('Usage example: //forceplay login', $player->login);
return; return;
} }
$target = $params[1]; $target = $params[1];
$target = $this->maniaControl->playerManager->getPlayer($target); $target = $this->maniaControl->playerManager->getPlayer($target);
if(!$target) { if (!$target) {
$this->maniaControl->chat->sendError("Invalid player login.", $player->login); $this->maniaControl->chat->sendError("Invalid player login.", $player->login);
return; return;
} }
$type = 2; $type = 2;
if(isset($params[2]) && is_numeric($params[2])) { if (isset($params[2]) && is_numeric($params[2])) {
$type = intval($params[2]); $type = intval($params[2]);
} }
$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 occurred: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
if($type != 1) { if ($type != 1) {
$this->maniaControl->client->query('ForceSpectator', $target->login, 0); $this->maniaControl->client->query('ForceSpectator', $target->login, 0);
} }
$this->maniaControl->chat->sendInformation('$<' . $player->nickname . '$> forced $<' . $target->nickname . '$> to player!'); $this->maniaControl->chat->sendInformation('$<' . $player->nickname . '$> forced $<' . $target->nickname . '$> to player!');
@ -230,22 +228,22 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
* @param Player $player * @param Player $player
*/ */
public function command_AddFakePlayers(array $chatCallback, Player $player) { public function command_AddFakePlayers(array $chatCallback, Player $player) {
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) { if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
} }
$amount = 1; $amount = 1;
$messageParts = explode(' ', $chatCallback[1][2]); $messageParts = explode(' ', $chatCallback[1][2]);
if(isset($messageParts[1]) && is_numeric($messageParts[1])) { if (isset($messageParts[1]) && is_numeric($messageParts[1])) {
$amount = intval($messageParts[1]); $amount = intval($messageParts[1]);
} }
$success = true; $success = true;
for($i = 0; $i < $amount; $i++) { for ($i = 0; $i < $amount; $i++) {
if(!$this->maniaControl->client->query('ConnectFakePlayer')) { if (!$this->maniaControl->client->query('ConnectFakePlayer')) {
$success = false; $success = false;
} }
} }
if(!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
@ -259,12 +257,12 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
* @param Player $player * @param Player $player
*/ */
public function command_RemoveFakePlayers(array $chatCallback, Player $player) { public function command_RemoveFakePlayers(array $chatCallback, Player $player) {
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) { if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
$this->maniaControl->authenticationManager->sendNotAllowed($player); $this->maniaControl->authenticationManager->sendNotAllowed($player);
return; return;
} }
$success = $this->maniaControl->client->query('DisconnectFakePlayer', '*'); $success = $this->maniaControl->client->query('DisconnectFakePlayer', '*');
if(!$success) { if (!$success) {
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login); $this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
return; return;
} }
@ -278,7 +276,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener {
* @param Player $player * @param Player $player
*/ */
public function command_playerList(array $chatCallback, Player $player) { public function command_playerList(array $chatCallback, Player $player) {
$this->playerList->addPlayerToShownList($player, PlayerList::SHOWN_MAIN_WINDOW); $this->maniaControl->playerManager->playerList->addPlayerToShownList($player, PlayerList::SHOWN_MAIN_WINDOW);
$this->playerList->showPlayerList($player); $this->maniaControl->playerManager->playerList->showPlayerList($player);
} }
} }

View File

@ -2,18 +2,20 @@
namespace ManiaControl\Players; namespace ManiaControl\Players;
require_once __DIR__ . '/Player.php';
require_once __DIR__ . '/PlayerCommands.php';
require_once __DIR__ . '/PlayerDetailed.php';
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Formatter; use ManiaControl\Formatter;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Statistics\StatisticManager; use ManiaControl\Statistics\StatisticManager;
require_once __DIR__ . '/Player.php';
require_once __DIR__ . '/PlayerActions.php';
require_once __DIR__ . '/PlayerCommands.php';
require_once __DIR__ . '/PlayerDetailed.php';
require_once __DIR__ . '/PlayerList.php';
/** /**
* Class managing players * Class managing Players
* *
* @author kremsy & steeffeen * @author kremsy & steeffeen
*/ */
@ -36,7 +38,8 @@ class PlayerManager implements CallbackListener {
public $playerActions = null; public $playerActions = null;
public $playerCommands = null; public $playerCommands = null;
public $playerDetailed = null; public $playerDetailed = null;
public $playerList = array(); public $playerList = null;
public $players = array();
/** /**
* Private Properties * Private Properties
@ -55,6 +58,7 @@ class PlayerManager implements CallbackListener {
$this->playerCommands = new PlayerCommands($maniaControl); $this->playerCommands = new PlayerCommands($maniaControl);
$this->playerActions = new PlayerActions($maniaControl); $this->playerActions = new PlayerActions($maniaControl);
$this->playerDetailed = new PlayerDetailed($maniaControl); $this->playerDetailed = new PlayerDetailed($maniaControl);
$this->playerList = new PlayerList($this->maniaControl);
// Init settings // Init settings
$this->maniaControl->settingManager->initSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES, true); $this->maniaControl->settingManager->initSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES, true);
@ -88,12 +92,12 @@ class PlayerManager implements CallbackListener {
UNIQUE KEY `login` (`login`) UNIQUE KEY `login` (`login`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Player Data' AUTO_INCREMENT=1;"; ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Player Data' AUTO_INCREMENT=1;";
$playerTableStatement = $mysqli->prepare($playerTableQuery); $playerTableStatement = $mysqli->prepare($playerTableQuery);
if($mysqli->error) { if ($mysqli->error) {
trigger_error($mysqli->error, E_USER_ERROR); trigger_error($mysqli->error, E_USER_ERROR);
return false; return false;
} }
$playerTableStatement->execute(); $playerTableStatement->execute();
if($playerTableStatement->error) { if ($playerTableStatement->error) {
trigger_error($playerTableStatement->error, E_USER_ERROR); trigger_error($playerTableStatement->error, E_USER_ERROR);
return false; return false;
} }
@ -109,9 +113,9 @@ class PlayerManager implements CallbackListener {
public function onInit(array $callback) { public function onInit(array $callback) {
// Add all players // Add all players
$this->maniaControl->client->query('GetPlayerList', 300, 0, 2); $this->maniaControl->client->query('GetPlayerList', 300, 0, 2);
$playerList = $this->maniaControl->client->getResponse(); $players = $this->maniaControl->client->getResponse();
foreach($playerList as $playerItem) { foreach ($players as $playerItem) {
if($playerItem['PlayerId'] <= 0) { if ($playerItem['PlayerId'] <= 0) {
continue; continue;
} }
$this->maniaControl->client->query('GetDetailedPlayerInfo', $playerItem['Login']); $this->maniaControl->client->query('GetDetailedPlayerInfo', $playerItem['Login']);
@ -137,14 +141,16 @@ class PlayerManager implements CallbackListener {
$this->addPlayer($player); $this->addPlayer($player);
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) { if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) {
$string = array(0 => '$0f0Player', 1 => '$0f0Moderator', 2 => '$0f0Admin', 3 => '$0f0MasterAdmin', 4 => '$0f0MasterAdmin'); $string = array(0 => '$0f0Player', 1 => '$0f0Moderator', 2 => '$0f0Admin', 3 => '$0f0MasterAdmin', 4 => '$0f0MasterAdmin');
$chatMessage = '$s$0f0' . $string[$player->authLevel] . ' $fff' . $player->nickname . '$z$s$0f0 Nation:$fff ' . $player->getCountry() . ' $z$s$0f0joined!'; $chatMessage = '$s$0f0' . $string[$player->authLevel] . ' $fff' . $player->nickname . '$z$s$0f0 Nation:$fff ' . $player->getCountry() .
' $z$s$0f0joined!';
$this->maniaControl->chat->sendChat($chatMessage); $this->maniaControl->chat->sendChat($chatMessage);
$this->maniaControl->chat->sendInformation('This server uses ManiaControl v' . ManiaControl::VERSION . '!', $player->login); $this->maniaControl->chat->sendInformation('This server uses ManiaControl v' . ManiaControl::VERSION . '!', $player->login);
} }
$logMessage = "Player joined: {$player->login} / " . Formatter::stripCodes($player->nickname) . " Nation: " . $player->getCountry() . " IP: {$player->ipAddress}"; $logMessage = "Player joined: {$player->login} / " . Formatter::stripCodes($player->nickname) . " Nation: " . $player->getCountry() .
" IP: {$player->ipAddress}";
$this->maniaControl->log($logMessage); $this->maniaControl->log($logMessage);
// Trigger own PlayerJoined callback // Trigger own PlayerJoined callback
@ -163,7 +169,7 @@ class PlayerManager implements CallbackListener {
// Trigger own callback // Trigger own callback
$this->maniaControl->callbackManager->triggerCallback(self::CB_PLAYERDISCONNECTED, array(self::CB_PLAYERDISCONNECTED, $player)); $this->maniaControl->callbackManager->triggerCallback(self::CB_PLAYERDISCONNECTED, array(self::CB_PLAYERDISCONNECTED, $player));
if($player == null || $player->isFakePlayer()) { if ($player == null || $player->isFakePlayer()) {
return; return;
} }
@ -171,7 +177,7 @@ class PlayerManager implements CallbackListener {
$logMessage = "Player left: {$player->login} / {$player->nickname} Playtime: {$played}"; $logMessage = "Player left: {$player->login} / {$player->nickname} Playtime: {$played}";
$this->maniaControl->log(Formatter::stripCodes($logMessage)); $this->maniaControl->log(Formatter::stripCodes($logMessage));
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES)) { if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES)) {
$this->maniaControl->chat->sendChat('$<' . $player->nickname . '$> $s$0f0has left the game'); $this->maniaControl->chat->sendChat('$<' . $player->nickname . '$> $s$0f0has left the game');
} }
} }
@ -183,7 +189,7 @@ class PlayerManager implements CallbackListener {
*/ */
public function playerInfoChanged(array $callback) { public function playerInfoChanged(array $callback) {
$player = $this->getPlayer($callback[1][0]['Login']); $player = $this->getPlayer($callback[1][0]['Login']);
if($player == null) { if ($player == null) {
return; return;
} }
@ -196,66 +202,60 @@ class PlayerManager implements CallbackListener {
} }
/** /**
* Get the complete PlayerList * Get all Players
* *
* @return array * @return array
*/ */
public function getPlayers() { public function getPlayers() {
return $this->playerList; return $this->players;
} }
/** /**
* Get a Player from the PlayerList * Get a Player by Login
* *
* @param string $login * @param string $login
* @return Player * @return Player
*/ */
public function getPlayer($login) { public function getPlayer($login) {
if(!isset($this->playerList[$login])) { if (!isset($this->players[$login])) {
return null; return null;
} }
return $this->playerList[$login]; return $this->players[$login];
} }
/** /**
* Add a player to the PlayerList * Add a player
* *
* @param Player $player * @param Player $player
* @return bool * @return bool
*/ */
private function addPlayer(Player $player) { private function addPlayer(Player $player) {
if(!$player) {
return false;
}
$this->savePlayer($player); $this->savePlayer($player);
$this->playerList[$player->login] = $player; $this->players[$player->login] = $player;
return true; return true;
} }
/** /**
* Remove a Player from the PlayerList * Remove a Player
* *
* @param string $login * @param string $login
* @param bool $savePlayedTime * @param bool $savePlayedTime
* @return Player $player * @return Player $player
*/ */
private function removePlayer($login, $savePlayedTime = true) { private function removePlayer($login, $savePlayedTime = true) {
if(!isset($this->playerList[$login])) { if (!isset($this->players[$login])) return null;
return null; $player = $this->players[$login];
} unset($this->players[$login]);
$player = $this->playerList[$login]; if ($savePlayedTime) {
unset($this->playerList[$login]);
if($savePlayedTime) {
$this->updatePlayedTime($player); $this->updatePlayedTime($player);
} }
return $player; return $player;
} }
/** /**
* Save player in database and fill up object properties * Save player in Database and fill up Object Properties
* *
* @param Player $player * @param Player $player
* @internal param int $joinCount
* @return bool * @return bool
*/ */
private function savePlayer(Player &$player) { private function savePlayer(Player &$player) {
@ -273,13 +273,13 @@ class PlayerManager implements CallbackListener {
`nickname` = VALUES(`nickname`), `nickname` = VALUES(`nickname`),
`path` = VALUES(`path`);"; `path` = VALUES(`path`);";
$playerStatement = $mysqli->prepare($playerQuery); $playerStatement = $mysqli->prepare($playerQuery);
if($mysqli->error) { if ($mysqli->error) {
trigger_error($mysqli->error); trigger_error($mysqli->error);
return false; return false;
} }
$playerStatement->bind_param('sss', $player->login, $player->nickname, $player->path); $playerStatement->bind_param('sss', $player->login, $player->nickname, $player->path);
$playerStatement->execute(); $playerStatement->execute();
if($playerStatement->error) { if ($playerStatement->error) {
trigger_error($playerStatement->error); trigger_error($playerStatement->error);
$playerStatement->close(); $playerStatement->close();
return false; return false;
@ -290,13 +290,13 @@ class PlayerManager implements CallbackListener {
// Get Player Auth Level from DB // Get Player Auth Level from DB
$playerQuery = "SELECT `authLevel` FROM `" . self::TABLE_PLAYERS . "` WHERE `index` = ?;"; $playerQuery = "SELECT `authLevel` FROM `" . self::TABLE_PLAYERS . "` WHERE `index` = ?;";
$playerStatement = $mysqli->prepare($playerQuery); $playerStatement = $mysqli->prepare($playerQuery);
if($mysqli->error) { if ($mysqli->error) {
trigger_error($mysqli->error); trigger_error($mysqli->error);
return false; return false;
} }
$playerStatement->bind_param('i', $player->index); $playerStatement->bind_param('i', $player->index);
$playerStatement->execute(); $playerStatement->execute();
if($playerStatement->error) { if ($playerStatement->error) {
trigger_error($playerStatement->error); trigger_error($playerStatement->error);
$playerStatement->close(); $playerStatement->close();
return false; return false;
@ -320,12 +320,11 @@ class PlayerManager implements CallbackListener {
* @return bool * @return bool
*/ */
private function updatePlayedTime(Player $player) { private function updatePlayedTime(Player $player) {
if(!$player) { if (!$player) {
return false; return false;
} }
$playedTime = time() - $player->joinTime; $playedTime = time() - $player->joinTime;
$serverIndex = $this->maniaControl->server->getIndex(); return $this->maniaControl->statisticManager->insertStat(self::STAT_SERVERTIME, $player, $this->maniaControl->server->index, $playedTime);
return $this->maniaControl->statisticManager->insertStat(self::STAT_SERVERTIME, $player, $serverIndex, $playedTime);
} }
} }

View File

@ -58,7 +58,7 @@ class ServerCommands implements CallbackListener, CommandListener {
public function each5Seconds(array $callback) { public function each5Seconds(array $callback) {
// Empty shutdown // Empty shutdown
if ($this->serverShutdownEmpty) { if ($this->serverShutdownEmpty) {
$players = $this->maniaControl->server->getPlayers(); $players = $this->maniaControl->playerManager->getPlayers();
if (count($players) <= 0) { if (count($players) <= 0) {
$this->shutdownServer('empty'); $this->shutdownServer('empty');
} }

View File

@ -90,9 +90,8 @@ class StatisticCollector implements CallbackListener {
//Write Shoot Data into database //Write Shoot Data into database
if($this->onShootArray[$login] > $this->maniaControl->settingManager->getSetting($this, self::SETTING_ON_SHOOT_PRESTORE)) { if($this->onShootArray[$login] > $this->maniaControl->settingManager->getSetting($this, self::SETTING_ON_SHOOT_PRESTORE)) {
$serverIndex = $this->maniaControl->server->getIndex();
$player = $this->maniaControl->playerManager->getPlayer($login); $player = $this->maniaControl->playerManager->getPlayer($login);
$this->maniaControl->statisticManager->insertStat(self::STAT_ON_SHOOT, $player, $serverIndex, $this->onShootArray[$login]); $this->maniaControl->statisticManager->insertStat(self::STAT_ON_SHOOT, $player, $this->maniaControl->server->index, $this->onShootArray[$login]);
$this->onShootArray[$login] = 0; $this->onShootArray[$login] = 0;
} }
} }
@ -114,8 +113,7 @@ class StatisticCollector implements CallbackListener {
//Insert Data into Database, and destroy player //Insert Data into Database, and destroy player
if(isset($this->onShootArray[$player->login])) { if(isset($this->onShootArray[$player->login])) {
if($this->onShootArray[$player->login] > 0) { if($this->onShootArray[$player->login] > 0) {
$serverIndex = $this->maniaControl->server->getIndex(); $this->maniaControl->statisticManager->insertStat(self::STAT_ON_SHOOT, $player, $this->maniaControl->server->index, $this->onShootArray[$player->login]);
$this->maniaControl->statisticManager->insertStat(self::STAT_ON_SHOOT, $player, $serverIndex, $this->onShootArray[$player->login]);
} }
unset($this->onShootArray[$player->login]); unset($this->onShootArray[$player->login]);
} }

View File

@ -154,7 +154,7 @@ class StatisticManager {
if (!$statId) return false; if (!$statId) return false;
if ($serverIndex == -1) { if ($serverIndex == -1) {
$serverIndex = $this->maniaControl->server->getIndex(); $serverIndex = $this->maniaControl->server->index;
} }
$mysqli = $this->maniaControl->database->mysqli; $mysqli = $this->maniaControl->database->mysqli;

View File

@ -423,8 +423,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
$message = 'Donation successful! Thanks.'; $message = 'Donation successful! Thanks.';
} }
$this->maniaControl->chat->sendSuccess($message, $login); $this->maniaControl->chat->sendSuccess($message, $login);
$serverIndex = $this->maniaControl->server->getIndex(); $this->maniaControl->statisticManager->insertStat(self::STAT_PLAYER_DONATIONS, $player, $this->maniaControl->server->index, $amount);
$this->maniaControl->statisticManager->insertStat(self::STAT_PLAYER_DONATIONS, $player, $serverIndex, $amount);
} }
} }
else { else {

View File

@ -272,8 +272,7 @@ class KarmaPlugin implements CallbackListener, Plugin {
$voted = $this->getPlayerVote($player, $map); $voted = $this->getPlayerVote($player, $map);
var_dump($voted); var_dump($voted);
if(!$voted){ if(!$voted){
$serverIndex = $this->maniaControl->server->getIndex(); $this->maniaControl->statisticManager->incrementStat(self::STAT_PLAYER_MAPVOTES, $player, $this->maniaControl->server->index);
$this->maniaControl->statisticManager->incrementStat(self::STAT_PLAYER_MAPVOTES, $player, $serverIndex);
} }
$success = $this->savePlayerVote($player, $map, $vote); $success = $this->savePlayerVote($player, $map, $vote);

View File

@ -358,8 +358,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
$quad->setPosition($width / 2 - 4, -1.5, -0.5); $quad->setPosition($width / 2 - 4, -1.5, -0.5);
$quad->setSize(4, 4); $quad->setSize(4, 4);
$quad->setHAlign(Control::CENTER); $quad->setHAlign(Control::CENTER);
$serverLogin = $this->maniaControl->server->getLogin(); $quad->setManialink('mcontrol?favorite&' . $this->maniaControl->server->login);
$quad->setManialink('mcontrol?favorite&' . $serverLogin);
// Send manialink // Send manialink
$manialinkText = $maniaLink->render()->saveXML(); $manialinkText = $maniaLink->render()->saveXML();