removed old timed callbacks
This commit is contained in:
parent
620807c419
commit
1c0dd7e83d
@ -15,9 +15,6 @@ class CallbackManager {
|
|||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
// ManiaControl callbacks
|
// ManiaControl callbacks
|
||||||
const CB_MC_1_SECOND = 'ManiaControl.1Second';
|
|
||||||
const CB_MC_5_SECOND = 'ManiaControl.5Second';
|
|
||||||
const CB_MC_1_MINUTE = 'ManiaControl.1Minute';
|
|
||||||
const CB_MC_ONINIT = 'ManiaControl.OnInit';
|
const CB_MC_ONINIT = 'ManiaControl.OnInit';
|
||||||
const CB_MC_ONSHUTDOWN = 'ManiaControl.OnShutdown';
|
const CB_MC_ONSHUTDOWN = 'ManiaControl.OnShutdown';
|
||||||
const CB_MC_CLIENTUPDATED = 'ManiaControl.ClientUpdated';
|
const CB_MC_CLIENTUPDATED = 'ManiaControl.ClientUpdated';
|
||||||
@ -186,9 +183,8 @@ class CallbackManager {
|
|||||||
* Trigger internal Callbacks and manage Server Callbacks
|
* Trigger internal Callbacks and manage Server Callbacks
|
||||||
*/
|
*/
|
||||||
public function manageCallbacks() {
|
public function manageCallbacks() {
|
||||||
// Timed callbacks
|
// Manage Timings
|
||||||
$this->maniaControl->timerManager->manageTimings();
|
$this->maniaControl->timerManager->manageTimings();
|
||||||
$this->manageTimedCallbacks();
|
|
||||||
|
|
||||||
// Server Callbacks
|
// Server Callbacks
|
||||||
if (!$this->maniaControl->client) {
|
if (!$this->maniaControl->client) {
|
||||||
@ -267,30 +263,4 @@ class CallbackManager {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Manage recurring timed Callbacks
|
|
||||||
*/
|
|
||||||
private function manageTimedCallbacks() {
|
|
||||||
// 1 second
|
|
||||||
if ($this->last1Second > time() - 1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$this->last1Second = time();
|
|
||||||
$this->triggerCallback(self::CB_MC_1_SECOND, array(self::CB_MC_1_SECOND));
|
|
||||||
|
|
||||||
// 5 second
|
|
||||||
if ($this->last5Second > time() - 5) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$this->last5Second = time();
|
|
||||||
$this->triggerCallback(self::CB_MC_5_SECOND, array(self::CB_MC_5_SECOND));
|
|
||||||
|
|
||||||
// 1 minute
|
|
||||||
if ($this->last1Minute > time() - 60) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$this->last1Minute = time();
|
|
||||||
$this->triggerCallback(self::CB_MC_1_MINUTE, array(self::CB_MC_1_MINUTE));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ namespace ManiaControl\Manialinks;
|
|||||||
|
|
||||||
use FML\CustomUI;
|
use FML\CustomUI;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
use ManiaControl\Players\PlayerManager;
|
use ManiaControl\Players\PlayerManager;
|
||||||
@ -14,7 +14,7 @@ use ManiaControl\Players\PlayerManager;
|
|||||||
*
|
*
|
||||||
* @author steeffeen & kremsy
|
* @author steeffeen & kremsy
|
||||||
*/
|
*/
|
||||||
class CustomUIManager implements CallbackListener {
|
class CustomUIManager implements CallbackListener, TimerListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
@ -38,7 +38,7 @@ class CustomUIManager implements CallbackListener {
|
|||||||
$this->prepareManialink();
|
$this->prepareManialink();
|
||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_SECOND, $this, 'handle1Second');
|
$this->maniaControl->timerManager->registerTimerListening($this, 'handle1Second', 1000);
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerJoined');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerJoined');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,11 +64,11 @@ class CustomUIManager implements CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle 1Second Callback
|
* Handle 1Second
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param $time
|
||||||
*/
|
*/
|
||||||
public function handle1Second(array $callback) {
|
public function handle1Second($time) {
|
||||||
if (!$this->updateManialink) {
|
if (!$this->updateManialink) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ use FML\Controls\Quads\Quad_Icons64x64_1;
|
|||||||
use ManiaControl\Admin\AuthenticationManager;
|
use ManiaControl\Admin\AuthenticationManager;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||||
@ -18,7 +19,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
|||||||
*
|
*
|
||||||
* @author steeffeen & kremsy
|
* @author steeffeen & kremsy
|
||||||
*/
|
*/
|
||||||
class ServerCommands implements CallbackListener, CommandListener, ManialinkPageAnswerListener {
|
class ServerCommands implements CallbackListener, CommandListener, ManialinkPageAnswerListener, TimerListener {
|
||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
@ -42,7 +43,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_5_SECOND, $this, 'each5Seconds');
|
$this->maniaControl->timerManager->registerTimerListening($this, 'each5Seconds', 5000);
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit');
|
||||||
|
|
||||||
// Register for commands
|
// Register for commands
|
||||||
@ -69,14 +70,14 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
|
|
||||||
$pauseExists = false;
|
$pauseExists = false;
|
||||||
foreach($scriptInfos->commandDescs as $param) {
|
foreach($scriptInfos->commandDescs as $param) {
|
||||||
if($param->name == "Command_ForceWarmUp") {
|
if ($param->name == "Command_ForceWarmUp") {
|
||||||
$pauseExists = true;
|
$pauseExists = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set Pause
|
// Set Pause
|
||||||
if($pauseExists) {
|
if ($pauseExists) {
|
||||||
$itemQuad = new Quad_Icons128x32_1();
|
$itemQuad = new Quad_Icons128x32_1();
|
||||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ManiaLinkSwitch);
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ManiaLinkSwitch);
|
||||||
$itemQuad->setAction(self::ACTION_SET_PAUSE);
|
$itemQuad->setAction(self::ACTION_SET_PAUSE);
|
||||||
@ -98,7 +99,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
* @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;
|
||||||
}
|
}
|
||||||
@ -117,7 +118,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
*/
|
*/
|
||||||
public function setPause(array $callback) {
|
public function setPause(array $callback) {
|
||||||
$success = $this->maniaControl->client->sendModeScriptCommands(array('Command_ForceWarmUp' => True));
|
$success = $this->maniaControl->client->sendModeScriptCommands(array('Command_ForceWarmUp' => True));
|
||||||
if(!$success) {
|
if (!$success) {
|
||||||
$this->maniaControl->chat->sendError("Error while setting the pause");
|
$this->maniaControl->chat->sendError("Error while setting the pause");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,21 +126,21 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
/**
|
/**
|
||||||
* Check stuff each 5 seconds
|
* Check stuff each 5 seconds
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param $timer
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function each5Seconds(array $callback) {
|
public function each5Seconds($timer) {
|
||||||
// Empty shutdown
|
// Empty shutdown
|
||||||
if($this->serverShutdownEmpty) {
|
if ($this->serverShutdownEmpty) {
|
||||||
$players = $this->maniaControl->playerManager->getPlayers();
|
$players = $this->maniaControl->playerManager->getPlayers();
|
||||||
if(count($players) <= 0) {
|
if (count($players) <= 0) {
|
||||||
$this->shutdownServer('empty');
|
$this->shutdownServer('empty');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delayed shutdown
|
// Delayed shutdown
|
||||||
if($this->serverShutdownTime > 0) {
|
if ($this->serverShutdownTime > 0) {
|
||||||
if(time() >= $this->serverShutdownTime) {
|
if (time() >= $this->serverShutdownTime) {
|
||||||
$this->shutdownServer('delayed');
|
$this->shutdownServer('delayed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,7 +153,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_SystemInfo(array $chat, Player $player) {
|
public function command_SystemInfo(array $chat, Player $player) {
|
||||||
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
||||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -168,17 +169,17 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_ShutdownServer(array $chat, Player $player) {
|
public function command_ShutdownServer(array $chat, Player $player) {
|
||||||
if(!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
if (!$this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
||||||
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
$this->maniaControl->authenticationManager->sendNotAllowed($player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Check for delayed shutdown
|
// Check for delayed shutdown
|
||||||
$params = explode(' ', $chat[1][2]);
|
$params = explode(' ', $chat[1][2]);
|
||||||
if(count($params) >= 2) {
|
if (count($params) >= 2) {
|
||||||
$param = $params[1];
|
$param = $params[1];
|
||||||
if($param == 'empty') {
|
if ($param == 'empty') {
|
||||||
$this->serverShutdownEmpty = !$this->serverShutdownEmpty;
|
$this->serverShutdownEmpty = !$this->serverShutdownEmpty;
|
||||||
if($this->serverShutdownEmpty) {
|
if ($this->serverShutdownEmpty) {
|
||||||
$this->maniaControl->chat->sendInformation("The server will shutdown as soon as it's empty!", $player->login);
|
$this->maniaControl->chat->sendInformation("The server will shutdown as soon as it's empty!", $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -186,7 +187,7 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$delay = (int)$param;
|
$delay = (int)$param;
|
||||||
if($delay <= 0) {
|
if ($delay <= 0) {
|
||||||
// Cancel shutdown
|
// Cancel shutdown
|
||||||
$this->serverShutdownTime = -1;
|
$this->serverShutdownTime = -1;
|
||||||
$this->maniaControl->chat->sendInformation("Delayed shutdown cancelled!", $player->login);
|
$this->maniaControl->chat->sendInformation("Delayed shutdown cancelled!", $player->login);
|
||||||
@ -207,12 +208,12 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_SetServerName(array $chat, Player $player) {
|
public function command_SetServerName(array $chat, 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;
|
||||||
}
|
}
|
||||||
$params = explode(' ', $chat[1][2], 2);
|
$params = explode(' ', $chat[1][2], 2);
|
||||||
if(count($params) < 2) {
|
if (count($params) < 2) {
|
||||||
$this->maniaControl->chat->sendUsageInfo('Usage example: //setservername ManiaPlanet Server', $player->login);
|
$this->maniaControl->chat->sendUsageInfo('Usage example: //setservername ManiaPlanet Server', $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -233,14 +234,14 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_SetPwd(array $chatCallback, Player $player) {
|
public function command_SetPwd(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;
|
||||||
}
|
}
|
||||||
$messageParts = explode(' ', $chatCallback[1][2], 2);
|
$messageParts = explode(' ', $chatCallback[1][2], 2);
|
||||||
$password = '';
|
$password = '';
|
||||||
$successMessage = 'Password removed!';
|
$successMessage = 'Password removed!';
|
||||||
if(isset($messageParts[1])) {
|
if (isset($messageParts[1])) {
|
||||||
$password = $messageParts[1];
|
$password = $messageParts[1];
|
||||||
$successMessage = "Password changed to: '{$password}'!";
|
$successMessage = "Password changed to: '{$password}'!";
|
||||||
}
|
}
|
||||||
@ -260,14 +261,14 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_SetSpecPwd(array $chatCallback, Player $player) {
|
public function command_SetSpecPwd(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;
|
||||||
}
|
}
|
||||||
$messageParts = explode(' ', $chatCallback[1][2], 2);
|
$messageParts = explode(' ', $chatCallback[1][2], 2);
|
||||||
$password = '';
|
$password = '';
|
||||||
$successMessage = 'Spectator password removed!';
|
$successMessage = 'Spectator password removed!';
|
||||||
if(isset($messageParts[1])) {
|
if (isset($messageParts[1])) {
|
||||||
$password = $messageParts[1];
|
$password = $messageParts[1];
|
||||||
$successMessage = "Spectator password changed to: '{$password}'!";
|
$successMessage = "Spectator password changed to: '{$password}'!";
|
||||||
}
|
}
|
||||||
@ -287,22 +288,22 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_SetMaxPlayers(array $chatCallback, Player $player) {
|
public function command_SetMaxPlayers(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;
|
||||||
}
|
}
|
||||||
$messageParts = explode(' ', $chatCallback[1][2], 2);
|
$messageParts = explode(' ', $chatCallback[1][2], 2);
|
||||||
if(!isset($messageParts[1])) {
|
if (!isset($messageParts[1])) {
|
||||||
$this->maniaControl->chat->sendUsageInfo('Usage example: //setmaxplayers 16', $player->login);
|
$this->maniaControl->chat->sendUsageInfo('Usage example: //setmaxplayers 16', $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$amount = $messageParts[1];
|
$amount = $messageParts[1];
|
||||||
if(!is_numeric($amount)) {
|
if (!is_numeric($amount)) {
|
||||||
$this->maniaControl->chat->sendUsageInfo('Usage example: //setmaxplayers 16', $player->login);
|
$this->maniaControl->chat->sendUsageInfo('Usage example: //setmaxplayers 16', $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$amount = (int)$amount;
|
$amount = (int)$amount;
|
||||||
if($amount < 0) {
|
if ($amount < 0) {
|
||||||
$amount = 0;
|
$amount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,22 +324,22 @@ class ServerCommands implements CallbackListener, CommandListener, ManialinkPage
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function command_SetMaxSpectators(array $chatCallback, Player $player) {
|
public function command_SetMaxSpectators(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;
|
||||||
}
|
}
|
||||||
$messageParts = explode(' ', $chatCallback[1][2], 2);
|
$messageParts = explode(' ', $chatCallback[1][2], 2);
|
||||||
if(!isset($messageParts[1])) {
|
if (!isset($messageParts[1])) {
|
||||||
$this->maniaControl->chat->sendUsageInfo('Usage example: //setmaxspectators 16', $player->login);
|
$this->maniaControl->chat->sendUsageInfo('Usage example: //setmaxspectators 16', $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$amount = $messageParts[1];
|
$amount = $messageParts[1];
|
||||||
if(!is_numeric($amount)) {
|
if (!is_numeric($amount)) {
|
||||||
$this->maniaControl->chat->sendUsageInfo('Usage example: //setmaxspectators 16', $player->login);
|
$this->maniaControl->chat->sendUsageInfo('Usage example: //setmaxspectators 16', $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$amount = (int)$amount;
|
$amount = (int)$amount;
|
||||||
if($amount < 0) {
|
if ($amount < 0) {
|
||||||
$amount = 0;
|
$amount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
namespace ManiaControl\Server;
|
namespace ManiaControl\Server;
|
||||||
|
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,7 +10,7 @@ use ManiaControl\ManiaControl;
|
|||||||
*
|
*
|
||||||
* @author steeffeen & kremsy
|
* @author steeffeen & kremsy
|
||||||
*/
|
*/
|
||||||
class UsageReporter implements CallbackListener {
|
class UsageReporter implements TimerListener {
|
||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
@ -21,7 +20,6 @@ class UsageReporter implements CallbackListener {
|
|||||||
* Private Properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
private $minuteCount = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new Server Settings Instance
|
* Create a new Server Settings Instance
|
||||||
@ -31,34 +29,35 @@ class UsageReporter implements CallbackListener {
|
|||||||
public function __construct(ManiaControl $maniaControl) {
|
public function __construct(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
//TODO setting
|
//TODO setting
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_MINUTE, $this, 'handleEveryMinute');
|
|
||||||
|
$this->maniaControl->timerManager->registerTimerListening($this, 'reportUsage', 1000 * 60 * self::UPDATE_MINUTE_COUNT);
|
||||||
|
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_DISABLE_USAGE_REPORTING, false);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_DISABLE_USAGE_REPORTING, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function handleEveryMinute(array $callback) {
|
/**
|
||||||
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_DISABLE_USAGE_REPORTING)) {
|
* Reports Usage every xx Minutes
|
||||||
|
*
|
||||||
|
* @param $time
|
||||||
|
*/
|
||||||
|
public function reportUsage($time) {
|
||||||
|
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_DISABLE_USAGE_REPORTING)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->minuteCount++;
|
$properties = array();
|
||||||
|
$properties['MC_Version'] = ManiaControl::VERSION;
|
||||||
|
$properties['OperatingSystem'] = php_uname();
|
||||||
|
$properties['PHPVersion'] = phpversion();
|
||||||
|
$properties['ServerLogin'] = $this->maniaControl->server->login;
|
||||||
|
$properties['TitleId'] = $this->maniaControl->server->titleId;
|
||||||
|
$properties['ServerName'] = $this->maniaControl->server->getName();
|
||||||
|
$properties['PlayerCount'] = count($this->maniaControl->playerManager->getPlayers());
|
||||||
|
$properties['MaxPlayers'] = $this->maniaControl->client->getMaxPlayers();
|
||||||
|
|
||||||
if($this->minuteCount >= self::UPDATE_MINUTE_COUNT) {
|
$json = json_encode($properties);
|
||||||
$properties = array();
|
$info = base64_encode($json);
|
||||||
$properties['MC_Version'] = ManiaControl::VERSION;
|
|
||||||
$properties['OperatingSystem'] = php_uname();
|
|
||||||
$properties['PHPVersion'] = phpversion();
|
|
||||||
$properties['ServerLogin'] = $this->maniaControl->server->login;
|
|
||||||
$properties['TitleId'] = $this->maniaControl->server->titleId;
|
|
||||||
$properties['ServerName'] = $this->maniaControl->server->getName();
|
|
||||||
$properties['PlayerCount'] = count($this->maniaControl->playerManager->getPlayers());
|
|
||||||
$properties['MaxPlayers'] = $this->maniaControl->client->getMaxPlayers();
|
|
||||||
|
|
||||||
$json = json_encode($properties);
|
//TODO send Info
|
||||||
$info = base64_encode($json);
|
|
||||||
|
|
||||||
//TODO send Info
|
|
||||||
$this->minuteCount = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,7 +4,7 @@ namespace ManiaControl;
|
|||||||
|
|
||||||
use ManiaControl\Admin\AuthenticationManager;
|
use ManiaControl\Admin\AuthenticationManager;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
use ManiaControl\Players\PlayerManager;
|
use ManiaControl\Players\PlayerManager;
|
||||||
@ -15,7 +15,7 @@ use ManiaControl\Plugins\Plugin;
|
|||||||
*
|
*
|
||||||
* @author steeffeen & kremsy
|
* @author steeffeen & kremsy
|
||||||
*/
|
*/
|
||||||
class UpdateManager implements CallbackListener, CommandListener {
|
class UpdateManager implements CallbackListener, CommandListener, TimerListener {
|
||||||
/*
|
/*
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
@ -54,7 +54,7 @@ class UpdateManager implements CallbackListener, CommandListener {
|
|||||||
|
|
||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_MINUTE, $this, 'handle1Minute');
|
$this->maniaControl->timerManager->registerTimerListening($this, 'handle1Minute', 1000 * 60);
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerJoined');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerJoined');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'handlePlayerDisconnected');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'handlePlayerDisconnected');
|
||||||
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_UPDATE, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
$this->maniaControl->authenticationManager->definePermissionLevel(self::SETTING_PERMISSION_UPDATE, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||||
@ -68,9 +68,9 @@ class UpdateManager implements CallbackListener, CommandListener {
|
|||||||
/**
|
/**
|
||||||
* Handle ManiaControl 1Minute callback
|
* Handle ManiaControl 1Minute callback
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param $time
|
||||||
*/
|
*/
|
||||||
public function handle1Minute(array $callback) {
|
public function handle1Minute($time) {
|
||||||
$updateCheckEnabled = $this->maniaControl->settingManager->getSetting($this, self::SETTING_ENABLEUPDATECHECK);
|
$updateCheckEnabled = $this->maniaControl->settingManager->getSetting($this, self::SETTING_ENABLEUPDATECHECK);
|
||||||
if (!$updateCheckEnabled) {
|
if (!$updateCheckEnabled) {
|
||||||
// Automatic update check disabled
|
// Automatic update check disabled
|
||||||
|
@ -15,6 +15,7 @@ use FML\ManiaLink;
|
|||||||
use FML\Script\Script;
|
use FML\Script\Script;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
use ManiaControl\ColorUtil;
|
use ManiaControl\ColorUtil;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
@ -31,7 +32,7 @@ use Maniaplanet\DedicatedServer\Structures\VoteRatio;
|
|||||||
*
|
*
|
||||||
* @author kremsy and steeffeen
|
* @author kremsy and steeffeen
|
||||||
*/
|
*/
|
||||||
class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkPageAnswerListener, Plugin {
|
class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkPageAnswerListener, TimerListener, Plugin {
|
||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
@ -104,7 +105,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
$this->maniaControl->commandManager->registerCommandListener('vote', $this, 'chat_vote');
|
$this->maniaControl->commandManager->registerCommandListener('vote', $this, 'chat_vote');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_SECOND, $this, 'handle1Second');
|
$this->maniaControl->timerManager->registerTimerListening($this, 'handle1Second', 1000);
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(ServerCommands::CB_VOTE_CANCELED, $this, 'handleVoteCanceled');
|
$this->maniaControl->callbackManager->registerCallbackListener(ServerCommands::CB_VOTE_CANCELED, $this, 'handleVoteCanceled');
|
||||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_POSITIVE_VOTE, $this, 'handlePositiveVote');
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_POSITIVE_VOTE, $this, 'handlePositiveVote');
|
||||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_NEGATIVE_VOTE, $this, 'handleNegativeVote');
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_NEGATIVE_VOTE, $this, 'handleNegativeVote');
|
||||||
@ -211,7 +212,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
* @param string $description
|
* @param string $description
|
||||||
*/
|
*/
|
||||||
public function addVoteMenuItem(Control $control, $order = 0, $description = null) {
|
public function addVoteMenuItem(Control $control, $order = 0, $description = null) {
|
||||||
if(!isset($this->voteMenuItems[$order])) {
|
if (!isset($this->voteMenuItems[$order])) {
|
||||||
$this->voteMenuItems[$order] = array();
|
$this->voteMenuItems[$order] = array();
|
||||||
}
|
}
|
||||||
array_push($this->voteMenuItems[$order], array($control, $description));
|
array_push($this->voteMenuItems[$order], array($control, $description));
|
||||||
@ -226,8 +227,8 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
*/
|
*/
|
||||||
public function chat_vote(array $chat, Player $player) {
|
public function chat_vote(array $chat, Player $player) {
|
||||||
$command = explode(" ", $chat[1][2]);
|
$command = explode(" ", $chat[1][2]);
|
||||||
if(isset($command[1])) {
|
if (isset($command[1])) {
|
||||||
if(isset($this->voteCommands[$command[1]])) {
|
if (isset($this->voteCommands[$command[1]])) {
|
||||||
$this->startVote($player, strtolower($command[1]));
|
$this->startVote($player, strtolower($command[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -250,14 +251,14 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
|
|
||||||
$pauseExists = false;
|
$pauseExists = false;
|
||||||
foreach($scriptInfos->commandDescs as $param) {
|
foreach($scriptInfos->commandDescs as $param) {
|
||||||
if($param->name == "Command_ForceWarmUp") {
|
if ($param->name == "Command_ForceWarmUp") {
|
||||||
$pauseExists = true;
|
$pauseExists = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Menu Pause
|
// Menu Pause
|
||||||
if($pauseExists) {
|
if ($pauseExists) {
|
||||||
$itemQuad = new Quad_Icons128x32_1();
|
$itemQuad = new Quad_Icons128x32_1();
|
||||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ManiaLinkSwitch);
|
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_ManiaLinkSwitch);
|
||||||
$itemQuad->setAction(self::ACTION_START_VOTE . 'pausegame');
|
$itemQuad->setAction(self::ACTION_START_VOTE . 'pausegame');
|
||||||
@ -299,7 +300,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
$voteName = $callback[1];
|
$voteName = $callback[1];
|
||||||
$voteResult = $callback[2];
|
$voteResult = $callback[2];
|
||||||
|
|
||||||
if($voteResult >= $this->currentNeededRatio) {
|
if ($voteResult >= $this->currentNeededRatio) {
|
||||||
switch($voteName) {
|
switch($voteName) {
|
||||||
case 'teambalance':
|
case 'teambalance':
|
||||||
$this->maniaControl->client->autoTeamBalance();
|
$this->maniaControl->client->autoTeamBalance();
|
||||||
@ -332,12 +333,12 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
public function handleManialinkPageAnswer(array $callback) {
|
public function handleManialinkPageAnswer(array $callback) {
|
||||||
$actionId = $callback[1][2];
|
$actionId = $callback[1][2];
|
||||||
$actionArray = explode('.', $actionId);
|
$actionArray = explode('.', $actionId);
|
||||||
if(count($actionArray) <= 2) {
|
if (count($actionArray) <= 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$voteIndex = $actionArray[2];
|
$voteIndex = $actionArray[2];
|
||||||
if(isset($this->voteCommands[$voteIndex])) {
|
if (isset($this->voteCommands[$voteIndex])) {
|
||||||
$login = $callback[1][1];
|
$login = $callback[1][1];
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
$this->startVote($player, $voteIndex);
|
$this->startVote($player, $voteIndex);
|
||||||
@ -350,7 +351,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
* @param $voteName
|
* @param $voteName
|
||||||
*/
|
*/
|
||||||
public function defineVote($voteIndex, $voteName, $neededRatio = -1) {
|
public function defineVote($voteIndex, $voteName, $neededRatio = -1) {
|
||||||
if($neededRatio == -1) {
|
if ($neededRatio == -1) {
|
||||||
$neededRatio = $this->maniaControl->settingManager->getSetting($this, self::SETTING_DEFAULT_RATIO);
|
$neededRatio = $this->maniaControl->settingManager->getSetting($this, self::SETTING_DEFAULT_RATIO);
|
||||||
}
|
}
|
||||||
$this->voteCommands[$voteIndex] = array("Index" => $voteIndex, "Name" => $voteName, "Ratio" => $neededRatio);
|
$this->voteCommands[$voteIndex] = array("Index" => $voteIndex, "Name" => $voteName, "Ratio" => $neededRatio);
|
||||||
@ -364,25 +365,25 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
*/
|
*/
|
||||||
public function startVote(Player $player, $voteIndex) {
|
public function startVote(Player $player, $voteIndex) {
|
||||||
//Player is muted
|
//Player is muted
|
||||||
if($this->maniaControl->playerManager->playerActions->isPlayerMuted($player)) {
|
if ($this->maniaControl->playerManager->playerActions->isPlayerMuted($player)) {
|
||||||
$this->maniaControl->chat->sendError('Muted Players are not allowed to start a vote.', $player->login);
|
$this->maniaControl->chat->sendError('Muted Players are not allowed to start a vote.', $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Specators are not allowed to start a vote
|
//Specators are not allowed to start a vote
|
||||||
if($player->isSpectator && !$this->maniaControl->settingManager->getSetting($this, self::SETTING_SPECTATOR_ALLOW_START_VOTE)) {
|
if ($player->isSpectator && !$this->maniaControl->settingManager->getSetting($this, self::SETTING_SPECTATOR_ALLOW_START_VOTE)) {
|
||||||
$this->maniaControl->chat->sendError('Spectators are not allowed to start a vote.', $player->login);
|
$this->maniaControl->chat->sendError('Spectators are not allowed to start a vote.', $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Vote does not exist
|
//Vote does not exist
|
||||||
if(!isset($this->voteCommands[$voteIndex])) {
|
if (!isset($this->voteCommands[$voteIndex])) {
|
||||||
$this->maniaControl->chat->sendError('Undefined vote.', $player->login);
|
$this->maniaControl->chat->sendError('Undefined vote.', $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//A vote is currently running
|
//A vote is currently running
|
||||||
if($this->currentVote != null) {
|
if ($this->currentVote != null) {
|
||||||
$this->maniaControl->chat->sendError('There is currently another vote running.', $player->login);
|
$this->maniaControl->chat->sendError('There is currently another vote running.', $player->login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -410,12 +411,12 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function handlePositiveVote(array $callback, Player $player) {
|
public function handlePositiveVote(array $callback, Player $player) {
|
||||||
if($player->isSpectator && !$this->maniaControl->settingManager->getSetting($this, self::SETTING_SPECTATOR_ALLOW_VOTE)) {
|
if ($player->isSpectator && !$this->maniaControl->settingManager->getSetting($this, self::SETTING_SPECTATOR_ALLOW_VOTE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($this->playersVoted[$player->login])) {
|
if (isset($this->playersVoted[$player->login])) {
|
||||||
if($this->playersVoted[$player->login] == self::VOTE_AGAINST_ACTION) {
|
if ($this->playersVoted[$player->login] == self::VOTE_AGAINST_ACTION) {
|
||||||
$this->playersVoted[$player->login] = self::VOTE_FOR_ACTION;
|
$this->playersVoted[$player->login] = self::VOTE_FOR_ACTION;
|
||||||
$this->playersVotedPositiv++;
|
$this->playersVotedPositiv++;
|
||||||
}
|
}
|
||||||
@ -432,12 +433,12 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function handleNegativeVote(array $callback, Player $player) {
|
public function handleNegativeVote(array $callback, Player $player) {
|
||||||
if($player->isSpectator && !$this->maniaControl->settingManager->getSetting($this, self::SETTING_SPECTATOR_ALLOW_VOTE)) {
|
if ($player->isSpectator && !$this->maniaControl->settingManager->getSetting($this, self::SETTING_SPECTATOR_ALLOW_VOTE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($this->playersVoted[$player->login])) {
|
if (isset($this->playersVoted[$player->login])) {
|
||||||
if($this->playersVoted[$player->login] == self::VOTE_FOR_ACTION) {
|
if ($this->playersVoted[$player->login] == self::VOTE_FOR_ACTION) {
|
||||||
$this->playersVoted[$player->login] = self::VOTE_AGAINST_ACTION;
|
$this->playersVoted[$player->login] = self::VOTE_AGAINST_ACTION;
|
||||||
$this->playersVotedPositiv--;
|
$this->playersVotedPositiv--;
|
||||||
}
|
}
|
||||||
@ -449,10 +450,10 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
/**
|
/**
|
||||||
* Handle ManiaControl 1 Second callback
|
* Handle ManiaControl 1 Second callback
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param $time
|
||||||
*/
|
*/
|
||||||
public function handle1Second(array $callback) {
|
public function handle1Second($time) {
|
||||||
if($this->currentVote == null) {
|
if ($this->currentVote == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -465,7 +466,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
$playersVoteRatio = (100 / $playerCount * count($this->playersVoted)) / 100;
|
$playersVoteRatio = (100 / $playerCount * count($this->playersVoted)) / 100;
|
||||||
|
|
||||||
//Check if vote is over
|
//Check if vote is over
|
||||||
if($timeUntilExpire <= 0 || (($playersVoteRatio >= $this->currentNeededPlayerRatio) && (($votePercentage >= $this->currentNeededRatio) || ($votePercentage <= 1 - $this->currentNeededRatio)))) {
|
if ($timeUntilExpire <= 0 || (($playersVoteRatio >= $this->currentNeededPlayerRatio) && (($votePercentage >= $this->currentNeededRatio) || ($votePercentage <= 1 - $this->currentNeededRatio)))) {
|
||||||
// Trigger callback
|
// Trigger callback
|
||||||
$this->maniaControl->callbackManager->triggerCallback(self::CB_CUSTOM_VOTE_FINISHED, array(self::CB_CUSTOM_VOTE_FINISHED, $this->currentVote["Index"], $votePercentage));
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_CUSTOM_VOTE_FINISHED, array(self::CB_CUSTOM_VOTE_FINISHED, $this->currentVote["Index"], $votePercentage));
|
||||||
|
|
||||||
@ -643,7 +644,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
$titlePrefix = strtoupper(substr($titleId, 0, 2));
|
$titlePrefix = strtoupper(substr($titleId, 0, 2));
|
||||||
|
|
||||||
//If game is shootmania lower the icons position by 20
|
//If game is shootmania lower the icons position by 20
|
||||||
if($titlePrefix == 'SM') {
|
if ($titlePrefix == 'SM') {
|
||||||
$posY -= $shootManiaOffset;
|
$posY -= $shootManiaOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -706,7 +707,6 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
foreach($menuItems as $menuItem) {
|
foreach($menuItems as $menuItem) {
|
||||||
$menuQuad = $menuItem[0];
|
$menuQuad = $menuItem[0];
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var Quad $menuQuad
|
* @var Quad $menuQuad
|
||||||
*/
|
*/
|
||||||
$popoutFrame->add($menuQuad);
|
$popoutFrame->add($menuQuad);
|
||||||
@ -715,7 +715,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
|||||||
$menuQuad->setHAlign(Control::RIGHT);
|
$menuQuad->setHAlign(Control::RIGHT);
|
||||||
$x -= $itemSize * 1.05;
|
$x -= $itemSize * 1.05;
|
||||||
|
|
||||||
if($menuItem[1]) {
|
if ($menuItem[1]) {
|
||||||
$description = '$s' . $menuItem[1];
|
$description = '$s' . $menuItem[1];
|
||||||
$script->addTooltip($menuQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => $description));
|
$script->addTooltip($menuQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => $description));
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ use FML\Controls\Quad;
|
|||||||
use FML\ManiaLink;
|
use FML\ManiaLink;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
use ManiaControl\ColorUtil;
|
use ManiaControl\ColorUtil;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Maps\Map;
|
use ManiaControl\Maps\Map;
|
||||||
@ -17,7 +18,7 @@ use ManiaControl\Plugins\Plugin;
|
|||||||
*
|
*
|
||||||
* @author steeffeen
|
* @author steeffeen
|
||||||
*/
|
*/
|
||||||
class KarmaPlugin implements CallbackListener, Plugin {
|
class KarmaPlugin implements CallbackListener, TimerListener, Plugin {
|
||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
@ -74,8 +75,8 @@ class KarmaPlugin implements CallbackListener, Plugin {
|
|||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_HEIGHT, 12.);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_WIDGET_HEIGHT, 12.);
|
||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
|
$this->maniaControl->timerManager->registerTimerListening($this, 'handle1Second', 1000);
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'handleBeginMap');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'handleBeginMap');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_SECOND, $this, 'handle1Second');
|
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCONNECT, $this, 'handlePlayerConnect');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'handlePlayerChat');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'handlePlayerChat');
|
||||||
|
|
||||||
@ -144,9 +145,9 @@ class KarmaPlugin implements CallbackListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Handle ManiaControl 1 Second callback
|
* Handle ManiaControl 1 Second callback
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param $time
|
||||||
*/
|
*/
|
||||||
public function handle1Second(array $callback) {
|
public function handle1Second($time) {
|
||||||
if(!$this->updateManialink) {
|
if(!$this->updateManialink) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
use ManiaControl\Formatter;
|
use ManiaControl\Formatter;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
@ -18,7 +19,7 @@ use FML\Controls\Quad;
|
|||||||
*
|
*
|
||||||
* @author steeffeen
|
* @author steeffeen
|
||||||
*/
|
*/
|
||||||
class LocalRecordsPlugin implements CallbackListener, Plugin {
|
class LocalRecordsPlugin implements CallbackListener, TimerListener, Plugin {
|
||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
@ -74,8 +75,8 @@ class LocalRecordsPlugin implements CallbackListener, Plugin {
|
|||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_NOTIFY_BEST_RECORDS, -1);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_NOTIFY_BEST_RECORDS, -1);
|
||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
|
$this->maniaControl->timerManager->registerTimerListening($this, 'handle1Second', 1000);
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_SECOND, $this, 'handle1Second');
|
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'handleMapBegin');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'handleMapBegin');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_CLIENTUPDATED, $this,
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_CLIENTUPDATED, $this,
|
||||||
'handleClientUpdated');
|
'handleClientUpdated');
|
||||||
@ -166,9 +167,9 @@ class LocalRecordsPlugin implements CallbackListener, Plugin {
|
|||||||
/**
|
/**
|
||||||
* Handle 1Second callback
|
* Handle 1Second callback
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param $time
|
||||||
*/
|
*/
|
||||||
public function handle1Second(array $callback) {
|
public function handle1Second($time) {
|
||||||
if (!$this->updateManialink) return;
|
if (!$this->updateManialink) return;
|
||||||
$this->updateManialink = false;
|
$this->updateManialink = false;
|
||||||
$manialink = $this->buildManialink();
|
$manialink = $this->buildManialink();
|
||||||
|
@ -7,6 +7,7 @@ use FML\Controls\Quads\Quad_Icons64x64_1;
|
|||||||
use FML\ManiaLink;
|
use FML\ManiaLink;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||||
@ -23,7 +24,7 @@ use ManiaControl\Plugins\Plugin;
|
|||||||
// TODO: worst kick function
|
// TODO: worst kick function
|
||||||
// TODO: idlekick function (?)
|
// TODO: idlekick function (?)
|
||||||
|
|
||||||
class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAnswerListener, Plugin {
|
class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAnswerListener, TimerListener , Plugin {
|
||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
@ -63,10 +64,10 @@ class QueuePlugin implements CallbackListener, CommandListener, ManialinkPageAns
|
|||||||
public function load(ManiaControl $maniaControl) {
|
public function load(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
|
$this->maniaControl->timerManager->registerTimerListening($this, 'handleEverySecond', 1000);
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'handlePlayerDisconnect');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'handlePlayerDisconnect');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERINFOCHANGED, $this, 'handlePlayerInfoChanged');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERINFOCHANGED, $this, 'handlePlayerInfoChanged');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_SECOND, $this, 'handleEverySecond');
|
|
||||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ML_ADDTOQUEUE, $this, 'handleManiaLinkAnswerAdd');
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ML_ADDTOQUEUE, $this, 'handleManiaLinkAnswerAdd');
|
||||||
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ML_REMOVEFROMQUEUE, $this, 'handleManiaLinkAnswerRemove');
|
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ML_REMOVEFROMQUEUE, $this, 'handleManiaLinkAnswerRemove');
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ use FML\ManiaLink;
|
|||||||
use ManiaControl\Admin\ActionsMenu;
|
use ManiaControl\Admin\ActionsMenu;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||||
use ManiaControl\Players\Player;
|
use ManiaControl\Players\Player;
|
||||||
@ -16,7 +17,7 @@ use ManiaControl\Players\PlayerManager;
|
|||||||
use ManiaControl\Plugins\Plugin;
|
use ManiaControl\Plugins\Plugin;
|
||||||
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
||||||
|
|
||||||
class SlotMachinePlugin implements Plugin, CallbackListener, ManialinkPageAnswerListener {
|
class SlotMachinePlugin implements Plugin, CallbackListener, ManialinkPageAnswerListener, TimerListener {
|
||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
@ -92,9 +93,10 @@ class SlotMachinePlugin implements Plugin, CallbackListener, ManialinkPageAnswer
|
|||||||
public function load(ManiaControl $maniaControl) {
|
public function load(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
|
$this->maniaControl->timerManager->registerTimerListening($this, 'onEverySecond', 1000);
|
||||||
|
$this->maniaControl->timerManager->registerTimerListening($this, 'updateDatabaseEveryMinute', 1000 * 60);
|
||||||
|
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_BILLUPDATED, $this, 'handleBillUpdated');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_BILLUPDATED, $this, 'handleBillUpdated');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_SECOND, $this, 'onEverySecond');
|
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_MINUTE, $this, 'updateDatabaseEveryMinute');
|
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'handlePlayerDisconnect');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'handlePlayerDisconnect');
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ use FML\Controls\Quads\Quad_Icons64x64_1;
|
|||||||
use FML\ManiaLink;
|
use FML\ManiaLink;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Manialinks\ManialinkManager;
|
use ManiaControl\Manialinks\ManialinkManager;
|
||||||
@ -21,7 +22,7 @@ use ManiaControl\Plugins\Plugin;
|
|||||||
*
|
*
|
||||||
* @author TheM
|
* @author TheM
|
||||||
*/
|
*/
|
||||||
class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPageAnswerListener, Plugin {
|
class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPageAnswerListener, TimerListener, Plugin {
|
||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
@ -76,7 +77,7 @@ class TeamSpeakPlugin implements CallbackListener, CommandListener, ManialinkPag
|
|||||||
$this->maniaControl->manialinkManager->iconManager->addIcon(self::TS_ICON);
|
$this->maniaControl->manialinkManager->iconManager->addIcon(self::TS_ICON);
|
||||||
$this->maniaControl->manialinkManager->iconManager->addIcon(self::TS_ICON_MOVER);
|
$this->maniaControl->manialinkManager->iconManager->addIcon(self::TS_ICON_MOVER);
|
||||||
|
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_SECOND, $this, 'ts3_queryServer');
|
$this->maniaControl->timerManager->registerTimerListening($this, 'ts3_queryServer', 1000);
|
||||||
|
|
||||||
$this->addToMenu();
|
$this->addToMenu();
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ use FML\ManiaLink;
|
|||||||
use FML\Script\Script;
|
use FML\Script\Script;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
use ManiaControl\Formatter;
|
use ManiaControl\Formatter;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Manialinks\IconManager;
|
use ManiaControl\Manialinks\IconManager;
|
||||||
@ -21,7 +22,7 @@ use ManiaControl\Plugins\Plugin;
|
|||||||
*
|
*
|
||||||
* @author kremsy
|
* @author kremsy
|
||||||
*/
|
*/
|
||||||
class WidgetPlugin implements CallbackListener, Plugin {
|
class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
@ -67,7 +68,6 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
* Private Properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var maniaControl $maniaControl
|
* @var maniaControl $maniaControl
|
||||||
*/
|
*/
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
@ -99,7 +99,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ENDMAP, $this, 'handleOnEndMap');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ENDMAP, $this, 'handleOnEndMap');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'handlePlayerDisconnect');
|
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECTED, $this, 'handlePlayerDisconnect');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_MINUTE, $this, 'handleEveryMinute');
|
|
||||||
|
$this->maniaControl->timerManager->registerTimerListening($this, 'handleEveryMinute', 1000 * 60);
|
||||||
|
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED, true);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED, true);
|
||||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_POSX, 160 - 20);
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_POSX, 160 - 20);
|
||||||
@ -148,13 +149,13 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
*/
|
*/
|
||||||
private function displayWidgets() {
|
private function displayWidgets() {
|
||||||
// Display Map Widget
|
// Display Map Widget
|
||||||
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
|
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
|
||||||
$this->displayMapWidget();
|
$this->displayMapWidget();
|
||||||
}
|
}
|
||||||
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
|
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
|
||||||
$this->displayClockWidget();
|
$this->displayClockWidget();
|
||||||
}
|
}
|
||||||
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
|
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
|
||||||
$this->displayServerInfoWidget();
|
$this->displayServerInfoWidget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -213,7 +214,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
$label->setText($map->authorLogin);
|
$label->setText($map->authorLogin);
|
||||||
$label->setTextColor("FFF");
|
$label->setTextColor("FFF");
|
||||||
|
|
||||||
if(isset($map->mx->pageurl)) {
|
if (isset($map->mx->pageurl)) {
|
||||||
$quad = new Quad();
|
$quad = new Quad();
|
||||||
$frame->add($quad);
|
$frame->add($quad);
|
||||||
$quad->setImageFocus($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_MOVER));
|
$quad->setImageFocus($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_MOVER));
|
||||||
@ -310,11 +311,10 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
$playerCount = 0;
|
$playerCount = 0;
|
||||||
$spectatorCount = 0;
|
$spectatorCount = 0;
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var Player $player
|
* @var Player $player
|
||||||
*/
|
*/
|
||||||
foreach($players as $player) {
|
foreach($players as $player) {
|
||||||
if($player->isSpectator) {
|
if ($player->isSpectator) {
|
||||||
$spectatorCount++;
|
$spectatorCount++;
|
||||||
} else {
|
} else {
|
||||||
$playerCount++;
|
$playerCount++;
|
||||||
@ -385,7 +385,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
*/
|
*/
|
||||||
public function handleOnBeginMap(array $callback) {
|
public function handleOnBeginMap(array $callback) {
|
||||||
// Display Map Widget
|
// Display Map Widget
|
||||||
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
|
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
|
||||||
$this->displayMapWidget();
|
$this->displayMapWidget();
|
||||||
}
|
}
|
||||||
$this->closeWidget(self::MLID_NEXTMAPWIDGET);
|
$this->closeWidget(self::MLID_NEXTMAPWIDGET);
|
||||||
@ -409,7 +409,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
*/
|
*/
|
||||||
public function handleOnEndMap(array $callback) {
|
public function handleOnEndMap(array $callback) {
|
||||||
// Display Map Widget
|
// Display Map Widget
|
||||||
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED)) {
|
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED)) {
|
||||||
$this->displayNextMapWidget();
|
$this->displayNextMapWidget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -446,12 +446,11 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
$queuedMap = $this->maniaControl->mapManager->mapQueue->getNextMap();
|
$queuedMap = $this->maniaControl->mapManager->mapQueue->getNextMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @var Player $requester
|
* @var Player $requester
|
||||||
*/
|
*/
|
||||||
$requester = null;
|
$requester = null;
|
||||||
// if the nextmap is not a queued map, get it from map info
|
// if the nextmap is not a queued map, get it from map info
|
||||||
if($queuedMap == null) {
|
if ($queuedMap == null) {
|
||||||
$map = $this->maniaControl->client->getNextMapInfo();
|
$map = $this->maniaControl->client->getNextMapInfo();
|
||||||
$name = Formatter::stripDirtyCodes($map->name);
|
$name = Formatter::stripDirtyCodes($map->name);
|
||||||
$author = $map->author;
|
$author = $map->author;
|
||||||
@ -495,7 +494,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
$label->setText($author);
|
$label->setText($author);
|
||||||
$label->setTextColor("FFF");
|
$label->setTextColor("FFF");
|
||||||
|
|
||||||
if($requester != null) {
|
if ($requester != null) {
|
||||||
$label = new Label_Text();
|
$label = new Label_Text();
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setX(0);
|
$label->setX(0);
|
||||||
@ -522,13 +521,13 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
public function handlePlayerConnect(array $callback) {
|
public function handlePlayerConnect(array $callback) {
|
||||||
$player = $callback[1];
|
$player = $callback[1];
|
||||||
// Display Map Widget
|
// Display Map Widget
|
||||||
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
|
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
|
||||||
$this->displayMapWidget($player->login);
|
$this->displayMapWidget($player->login);
|
||||||
}
|
}
|
||||||
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
|
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
|
||||||
$this->displayClockWidget($player->login);
|
$this->displayClockWidget($player->login);
|
||||||
}
|
}
|
||||||
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
|
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
|
||||||
$this->displayServerInfoWidget();
|
$this->displayServerInfoWidget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -539,18 +538,18 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
* @param array $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function handlePlayerDisconnect(array $callback) {
|
public function handlePlayerDisconnect(array $callback) {
|
||||||
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
|
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
|
||||||
$this->displayServerInfoWidget();
|
$this->displayServerInfoWidget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Aktualize the clock widget every minute
|
* Actualize the clock widget every minute
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param $time
|
||||||
*/
|
*/
|
||||||
public function handleEveryMinute(array $callback) {
|
public function handleEveryMinute($time) {
|
||||||
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
|
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
|
||||||
$this->displayClockWidget();
|
$this->displayClockWidget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user