revert match settings manager (nevermind)
This commit is contained in:
parent
0834d2c587
commit
f9df0fc325
@ -16,6 +16,7 @@ class CallbackManager {
|
||||
* Constants
|
||||
*/
|
||||
// ManiaControl callbacks
|
||||
// TODO: move into Callbacks interface
|
||||
const CB_ONINIT = 'ManiaControl.OnInit';
|
||||
const CB_AFTERINIT = 'ManiaControl.AfterInit';
|
||||
const CB_ONSHUTDOWN = 'ManiaControl.OnShutdown';
|
||||
|
@ -39,7 +39,7 @@ class Map {
|
||||
public $titleUid = '';
|
||||
public $startTime = -1;
|
||||
public $lastUpdate = 0;
|
||||
|
||||
public $karma = null;
|
||||
|
||||
/**
|
||||
* Create a new Map Object from Rpc Data
|
||||
|
@ -9,7 +9,7 @@ use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\Commands\CommandListener;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use ManiaControl\Server\MatchSettingsManager;
|
||||
use ManiaControl\Server\Server;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||
|
||||
/**
|
||||
@ -62,7 +62,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca
|
||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_TEAM_BALANCE, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
|
||||
//CallbackManager
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(MatchSettingsManager::CB_TEAM_MODE_CHANGED, $this, 'teamStatusChanged');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(Server::CB_TEAM_MODE_CHANGED, $this, 'teamStatusChanged');
|
||||
|
||||
// Action Open Playerlist
|
||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_OPEN_PLAYERLIST, $this, 'command_playerList');
|
||||
|
@ -326,7 +326,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
|
||||
$playerQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
}
|
||||
|
||||
if ($this->maniaControl->server->matchSettingsManager->isTeamMode()) {
|
||||
if ($this->maniaControl->server->isTeamMode()) {
|
||||
if ($this->maniaControl->authenticationManager->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)) {
|
||||
// Force to Red-Team Quad
|
||||
$redQuad = new Quad_Emblems();
|
||||
|
@ -122,7 +122,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
|
||||
//Check if the Player is in a Team, to notify if its a TeamMode or not
|
||||
if ($playerItem->teamId != -1) {
|
||||
$this->maniaControl->server->matchSettingsManager->setTeamMode(true);
|
||||
$this->maniaControl->server->setTeamMode(true);
|
||||
}
|
||||
|
||||
$player = new Player($this->maniaControl, true);
|
||||
@ -321,7 +321,7 @@ class PlayerManager implements CallbackListener, TimerListener {
|
||||
|
||||
//Check if the Player is in a Team, to notify if its a TeamMode or not
|
||||
if ($player->teamId != -1) {
|
||||
$this->maniaControl->server->matchSettingsManager->setTeamMode(true);
|
||||
$this->maniaControl->server->setTeamMode(true);
|
||||
}
|
||||
|
||||
$prevJoinState = $player->hasJoinedGame;
|
||||
|
@ -1,96 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Server;
|
||||
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
/**
|
||||
* Class managing the current Match Settings of the Server
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class MatchSettingsManager implements CallbackListener {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const CB_TEAM_MODE_CHANGED = 'MatchSettings.TeamModeChanged';
|
||||
|
||||
/*
|
||||
* Private Properties
|
||||
*/
|
||||
private $maniaControl = null;
|
||||
private $teamMode = null;
|
||||
|
||||
/**
|
||||
* Construct a new Match Settings Manager
|
||||
*
|
||||
* @param ManiaControl $maniaControl
|
||||
*/
|
||||
public function __construct(ManiaControl $maniaControl) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether the Server Runs a Team-Based Mode or not
|
||||
*
|
||||
* @param bool $teamMode
|
||||
*/
|
||||
public function setTeamMode($teamMode = true) {
|
||||
$oldStatus = $this->teamMode;
|
||||
$this->teamMode = (bool)$teamMode;
|
||||
|
||||
// Trigger callback
|
||||
if ($oldStatus !== $this->teamMode | $oldStatus === null) {
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_TEAM_MODE_CHANGED, $teamMode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Server Runs a Team-Based Mode
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isTeamMode() {
|
||||
return $this->teamMode;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch the current Game Mode
|
||||
*
|
||||
* @param bool $stringValue
|
||||
* @param int $parseValue
|
||||
* @return int | string
|
||||
*/
|
||||
public function getGameMode($stringValue = false, $parseValue = null) {
|
||||
if (is_int($parseValue)) {
|
||||
$gameMode = $parseValue;
|
||||
} else {
|
||||
$gameMode = $this->maniaControl->client->getGameMode();
|
||||
}
|
||||
if ($stringValue) {
|
||||
switch ($gameMode) {
|
||||
case 0:
|
||||
return 'Script';
|
||||
case 1:
|
||||
return 'Rounds';
|
||||
case 2:
|
||||
return 'TimeAttack';
|
||||
case 3:
|
||||
return 'Team';
|
||||
case 4:
|
||||
return 'Laps';
|
||||
case 5:
|
||||
return 'Cup';
|
||||
case 6:
|
||||
return 'Stunts';
|
||||
default:
|
||||
return 'Unknown';
|
||||
}
|
||||
}
|
||||
return $gameMode;
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ class Server implements CallbackListener {
|
||||
* Constants
|
||||
*/
|
||||
const TABLE_SERVERS = 'mc_servers';
|
||||
const CB_TEAM_MODE_CHANGED = 'Server.TeamModeChanged';
|
||||
|
||||
/*
|
||||
* Public Properties
|
||||
@ -37,12 +38,12 @@ class Server implements CallbackListener {
|
||||
public $usageReporter = null;
|
||||
public $rankingManager = null;
|
||||
public $scriptManager = null;
|
||||
public $matchSettingsManager = null;
|
||||
|
||||
/*
|
||||
* Private Properties
|
||||
*/
|
||||
private $maniaControl = null;
|
||||
private $teamMode = null;
|
||||
|
||||
/**
|
||||
* Construct a new Server
|
||||
@ -57,7 +58,6 @@ class Server implements CallbackListener {
|
||||
$this->usageReporter = new UsageReporter($maniaControl);
|
||||
$this->rankingManager = new RankingManager($maniaControl);
|
||||
$this->scriptManager = new ScriptManager($maniaControl);
|
||||
$this->matchSettingsManager = new MatchSettingsManager($maniaControl);
|
||||
|
||||
// Register for callbacks
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_ONINIT, $this, 'onInit');
|
||||
@ -290,7 +290,7 @@ class Server implements CallbackListener {
|
||||
|
||||
// Build file name
|
||||
$map = $this->maniaControl->mapManager->getCurrentMap();
|
||||
$gameMode = $this->matchSettingsManager->getGameMode();
|
||||
$gameMode = $this->getGameMode();
|
||||
$time = time();
|
||||
$fileName = "GhostReplays/Ghost.{$login}.{$gameMode}.{$time}.{$map->uid}.Replay.Gbx";
|
||||
|
||||
@ -327,6 +327,42 @@ class Server implements CallbackListener {
|
||||
return (is_dir($directory) && is_writable($directory));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the current Game Mode
|
||||
*
|
||||
* @param bool $stringValue
|
||||
* @param int $parseValue
|
||||
* @return int | string
|
||||
*/
|
||||
public function getGameMode($stringValue = false, $parseValue = null) {
|
||||
if (is_int($parseValue)) {
|
||||
$gameMode = $parseValue;
|
||||
} else {
|
||||
$gameMode = $this->maniaControl->client->getGameMode();
|
||||
}
|
||||
if ($stringValue) {
|
||||
switch ($gameMode) {
|
||||
case 0:
|
||||
return 'Script';
|
||||
case 1:
|
||||
return 'Rounds';
|
||||
case 2:
|
||||
return 'TimeAttack';
|
||||
case 3:
|
||||
return 'Team';
|
||||
case 4:
|
||||
return 'Laps';
|
||||
case 5:
|
||||
return 'Cup';
|
||||
case 6:
|
||||
return 'Stunts';
|
||||
default:
|
||||
return 'Unknown';
|
||||
}
|
||||
}
|
||||
return $gameMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wait for the Server to have the given Status
|
||||
*
|
||||
@ -361,37 +397,27 @@ class Server implements CallbackListener {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set whether the Server Runs a Team-Based Mode or not
|
||||
*
|
||||
* @deprecated Use MatchSettingsManager instead
|
||||
* @param bool $teamMode
|
||||
*/
|
||||
public function setTeamMode($teamMode = true) {
|
||||
$this->matchSettingsManager->setTeamMode($teamMode);
|
||||
$oldStatus = $this->teamMode;
|
||||
$this->teamMode = (bool)$teamMode;
|
||||
|
||||
// Trigger callback
|
||||
if ($oldStatus !== $this->teamMode | $oldStatus === null) {
|
||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_TEAM_MODE_CHANGED, $teamMode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Server Runs a Team-Based Mode
|
||||
*
|
||||
* @deprecated Use MatchSettingsManager instead
|
||||
* @return bool
|
||||
*/
|
||||
public function isTeamMode() {
|
||||
$this->matchSettingsManager->isTeamMode();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch the current Game Mode
|
||||
*
|
||||
* @deprecated Use MatchSettingsManager instead
|
||||
* @param bool $stringValue
|
||||
* @param int $parseValue
|
||||
* @return int | string
|
||||
*/
|
||||
public function getGameMode($stringValue = false, $parseValue = null) {
|
||||
$this->matchSettingsManager->getGameMode($stringValue, $parseValue);
|
||||
return $this->teamMode;
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Players\PlayerManager;
|
||||
use ManiaControl\Plugins\Plugin;
|
||||
use ManiaControl\Server\MatchSettingsManager;
|
||||
use ManiaControl\Server\Server;
|
||||
use ManiaControl\Server\ServerCommands;
|
||||
use Maniaplanet\DedicatedServer\Structures\VoteRatio;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\NotInScriptModeException;
|
||||
@ -139,7 +139,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(self::CB_CUSTOM_VOTE_FINISHED, $this, 'handleVoteFinished');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(MatchSettingsManager::CB_TEAM_MODE_CHANGED, $this, 'constructMenu');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(Server::CB_TEAM_MODE_CHANGED, $this, 'constructMenu');
|
||||
|
||||
//Settings
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_VOTE_ICON_POSX, 156.);
|
||||
@ -243,7 +243,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
$itemQuad->setAction(self::ACTION_START_VOTE . 'skipmap');
|
||||
$this->addVoteMenuItem($itemQuad, 15, 'Vote for a Mapskip');
|
||||
|
||||
if ($this->maniaControl->server->matchSettingsManager->isTeamMode()) {
|
||||
if ($this->maniaControl->server->isTeamMode()) {
|
||||
//Menu TeamBalance
|
||||
$itemQuad = new Quad_Icons128x32_1();
|
||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_RT_Team);
|
||||
|
@ -358,7 +358,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene
|
||||
* @return String
|
||||
*/
|
||||
private function getGameModeString() {
|
||||
$gameMode = $this->maniaControl->server->matchSettingsManager->getGameMode();
|
||||
$gameMode = $this->maniaControl->server->getGameMode();
|
||||
$scriptNameResponse = $this->maniaControl->client->getScriptName();
|
||||
$scriptName = str_replace('.Script.txt', '', $scriptNameResponse["CurrentValue"]);
|
||||
if ($gameMode === null) {
|
||||
|
@ -335,7 +335,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
|
||||
$properties = array();
|
||||
|
||||
$gameMode = $this->maniaControl->server->matchSettingsManager->getGameMode(true);
|
||||
$gameMode = $this->maniaControl->server->getGameMode(true);
|
||||
if ($gameMode == 'Script') {
|
||||
$scriptName = $this->maniaControl->client->getScriptName();
|
||||
$properties['gamemode'] = $scriptName["CurrentValue"];
|
||||
@ -444,7 +444,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||
return;
|
||||
}
|
||||
|
||||
$gameMode = $this->maniaControl->server->matchSettingsManager->getGameMode(true);
|
||||
$gameMode = $this->maniaControl->server->getGameMode(true);
|
||||
|
||||
if (count($votes) == 0) {
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user