commit
9c256643fa
14
.gitignore
vendored
14
.gitignore
vendored
@ -1,8 +1,12 @@
|
||||
.idea
|
||||
*.iml
|
||||
/configs/server.xml
|
||||
.*
|
||||
!/.git
|
||||
!/.gitignore
|
||||
!/.idea
|
||||
/configs/*
|
||||
!/configs/server.default.xml
|
||||
/logs/
|
||||
/ManiaControl.log
|
||||
/ManiaControl.pid
|
||||
!/.idea/encodings.xml
|
||||
!/.idea/codeStyleSettings.xml
|
||||
!/plugins/
|
||||
/plugins/*
|
||||
!/plugins/MCTeam/
|
||||
|
@ -3,7 +3,7 @@
|
||||
* ManiaControl Server Controller for ManiaPlanet Server
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
|
||||
|
0
ManiaControl.sh
Normal file → Executable file
0
ManiaControl.sh
Normal file → Executable file
145
changelog.txt
145
changelog.txt
@ -1,9 +1,144 @@
|
||||
##v0.16x###
|
||||
# Additions
|
||||
###v0.255###
|
||||
#Additions
|
||||
- added optional descriptions to Settings (but no MC-settings have descriptions yet)
|
||||
- add Setting to allow Karma-Votes only if player has local
|
||||
- add Setting to change Dedimania-Message formatting
|
||||
- add Setting to display author nickname instead of author login
|
||||
- add Setting to hide Plugins to install for incompatible version of ManiaControl
|
||||
- add Setting to hide Script-Settings which have the description "<hidden>"
|
||||
- add Setting to sort GameMode-Settings
|
||||
- CSV-Export of Locals (//exportrecs <filename> [map-id])
|
||||
- new Adhoc-Callbacks, which get executed after the Callback that added them
|
||||
- new GameModePresetPlugin to save and load GameMode-Settings (//loadmode <name> & //savemode <name>)
|
||||
|
||||
#Bug Fixes
|
||||
- deactivate Plugins if they cause uncaught exceptions
|
||||
- finish callbacks got triggered before corresponding checkpoint callback
|
||||
-- some CPs of your local records might be messed up
|
||||
-- you can fix them by either deleting the record "//delrec <rank>", or simply drive a better time
|
||||
- fixed typo in actions panel of players list
|
||||
- fixed crashing GameMode-Settings table on other languages than english
|
||||
|
||||
###v0.254###
|
||||
#Additions
|
||||
- added small scale support for Legacy-Modes
|
||||
|
||||
#Bug Fixes
|
||||
- fixed crashes of MX-List with deactivated Karma-Plugin
|
||||
- solved Finish-/Lap-Callback not getting triggered when Waypoint-Callback is not registered
|
||||
- //unban without login crashed
|
||||
|
||||
#Changes
|
||||
- additional Waypoint-Callback on Finish-/Lap-Callback
|
||||
- moved constant DEFAULT_KARMA_PLUGIN
|
||||
- renamed all occurrences of Script-Settings to GameMode-Settings
|
||||
- includes a renamed database
|
||||
- unified Creations of round Text-Buttons
|
||||
|
||||
###v0.253###
|
||||
#Changes
|
||||
- //restart got replaced by //reboot
|
||||
- unified Creations of a Karma-Gauge in new Manialinks\ElementBuilder
|
||||
|
||||
###v0.252###
|
||||
#Additions
|
||||
- Ingame-Changelog
|
||||
- new customizations for Join&Leave-Messages
|
||||
- symbolic Link resolving in ServerManager
|
||||
- Times in Map Widget
|
||||
|
||||
#Bug Fixes
|
||||
- GReplay for Dedimania-Records are now being sent
|
||||
- solved non-numeric value warning on self-triggered debug notice
|
||||
|
||||
###v0.250###
|
||||
#Additions
|
||||
- AuthenticationManager allows permissions to be stored inside Plugins
|
||||
- CallQueue to balance performance-heavy functions
|
||||
- Commands can be disabled by Plugins
|
||||
- /delrec can delete your personal local record (Permission-Setting)
|
||||
- simple DB-Installation-Script (Unix-only)
|
||||
|
||||
#Bug Fixes
|
||||
- //delrec can delete every local record (Permission-Setting)
|
||||
- replaced deprecated code
|
||||
|
||||
#Changes
|
||||
- format milliseconds with dot instead of double colon (1:02:375 -> 1:02.375)
|
||||
- Notification-System of Local Records
|
||||
|
||||
###v0.226###
|
||||
#Bug Fixes
|
||||
- Dedimania Plugin, everything should work now
|
||||
- moved overlapping widgets in TM
|
||||
|
||||
#Changes
|
||||
- improved Async Webrequest Handling
|
||||
- improved Error Handler
|
||||
- improved Page Chunking
|
||||
- updated FML
|
||||
|
||||
###v0.220###
|
||||
#Additions
|
||||
- Local Records Plugin can capture Lap Records
|
||||
- Plugins for Rounds and Cup (commands for setting point distribution, endround etc.)
|
||||
|
||||
#Bug Fixes
|
||||
- performance improvements (200+ player servers run fine now)
|
||||
- MX list filters by environment of server
|
||||
|
||||
#Changes
|
||||
- reworked Dedimania Plugin
|
||||
- newly designed Local Record Widget
|
||||
|
||||
###v0.205###
|
||||
#Bug Fixes
|
||||
- stability improvements
|
||||
- fixed wrong namespace
|
||||
|
||||
#Changes
|
||||
- reorder admin menu items
|
||||
|
||||
###v0.203###
|
||||
#Additions
|
||||
- admin and player helpall icon
|
||||
- map search feature in maplist
|
||||
- new Script Callbacks and Methods (including Trackmania)
|
||||
|
||||
#Bug Fixes
|
||||
- z-Value fixes in UI
|
||||
|
||||
#Changes
|
||||
- removed MP3 Callbacks
|
||||
- updated Pause/WarmUp-System
|
||||
|
||||
###v0.201###
|
||||
#Additions
|
||||
- full support for new LibXmlRpc Callbacks
|
||||
- min & max plugin-version on maniacontrol.com
|
||||
- new ModeScriptEventManager class
|
||||
- new version of LabelLine
|
||||
- UsageInformationAble interface, plugin authors can use ->getUsageInformation() on nearly every class to be provided with infos about the class
|
||||
|
||||
#Bug Fixes
|
||||
- small design fixes
|
||||
- stability improvements
|
||||
- wrong link on installing a plugin
|
||||
|
||||
#Changes
|
||||
- deprecated old Callbacks
|
||||
- minimum dedicated server version updated to MP4 version
|
||||
- removed deprecates in ManiaControl class
|
||||
- updated Manialink to version 3 (including FML)
|
||||
- updated internal HTTP requests to new AsyncHttpRequest
|
||||
|
||||
###v0.16x###
|
||||
#Additions
|
||||
- updated mx links to https
|
||||
# Changes
|
||||
|
||||
#Changes
|
||||
- CommunicationMethod SET_SERVER_OPTIONS sets the changed values also in database on call
|
||||
- Changed Copyright label to 2014-2016
|
||||
- changed Copyright label to 2014-2016
|
||||
|
||||
###v0.163###
|
||||
#Additions
|
||||
@ -12,7 +147,7 @@
|
||||
- added Scriptcallbacks SCORESREADY / SCORES
|
||||
- added SSL support as well as http Redirections of the FileReader
|
||||
|
||||
# Bug fixes
|
||||
#Bug Fixes
|
||||
- Banning of not connected Players now possible
|
||||
|
||||
###v0.162###
|
||||
|
@ -27,7 +27,7 @@ use ManiaControl\Settings\SettingManager;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class ActionsMenu implements SidebarMenuEntryListener, CallbackListener, ManialinkPageAnswerListener, UsageInformationAble {
|
||||
|
@ -26,7 +26,7 @@ use ManiaControl\Players\Player;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class AdminLists implements ManialinkPageAnswerListener, CallbackListener, UsageInformationAble {
|
||||
|
@ -12,7 +12,7 @@ use ManiaControl\Players\Player;
|
||||
* Class offering Commands to grant Authorizations to Players
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class AuthCommands implements CommandListener, UsageInformationAble {
|
||||
@ -40,6 +40,57 @@ class AuthCommands implements CommandListener, UsageInformationAble {
|
||||
$this->maniaControl->getCommandManager()->registerCommandListener('removerights', $this, 'command_RemoveRights', true, 'Remove Player from the AdminList.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle all //add commands
|
||||
* @internal
|
||||
* @param array $chatCallback
|
||||
* @param Player $player
|
||||
* @param string $targetAuthLevel
|
||||
*/
|
||||
private function command_Add(array $chatCallback, Player $player, $targetAuthLevel) {
|
||||
// $player needs to be at least one AuthLevel higher as the one to be granted
|
||||
if (!AuthenticationManager::checkRight($player, $targetAuthLevel+1)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
|
||||
$text = $chatCallback[1][2];
|
||||
$commandParts = explode(' ', $text);
|
||||
if (!array_key_exists(1, $commandParts)) {
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
'Usage Example: %s %s',
|
||||
$commandParts[0],
|
||||
'login'
|
||||
);
|
||||
$this->maniaControl->getChat()->sendUsageInfo($message, $player);
|
||||
return;
|
||||
}
|
||||
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]);
|
||||
if (!$target) {
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
'Player %s not found!',
|
||||
$commandParts[1]
|
||||
);
|
||||
$this->maniaControl->getChat()->sendError($message, $player);
|
||||
return;
|
||||
}
|
||||
|
||||
$success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, $targetAuthLevel);
|
||||
if (!$success) {
|
||||
$this->maniaControl->getChat()->sendError('Error occurred!', $player);
|
||||
return;
|
||||
}
|
||||
|
||||
$authName = AuthenticationManager::getAuthLevelName($targetAuthLevel);
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
"%s added %s as {$authName}.",
|
||||
$player,
|
||||
$target
|
||||
);
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle //addsuperadmin command
|
||||
*
|
||||
@ -48,39 +99,7 @@ class AuthCommands implements CommandListener, UsageInformationAble {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_AddSuperAdmin(array $chatCallback, Player $player) {
|
||||
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$text = $chatCallback[1][2];
|
||||
$commandParts = explode(' ', $text);
|
||||
if (!array_key_exists(1, $commandParts)) {
|
||||
$this->sendAddSuperAdminUsageInfo($player);
|
||||
return;
|
||||
}
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]);
|
||||
if (!$target) {
|
||||
$this->maniaControl->getChat()->sendError("Player '{$commandParts[1]}' not found!", $player);
|
||||
return;
|
||||
}
|
||||
$success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
if (!$success) {
|
||||
$this->maniaControl->getChat()->sendError('Error occurred.', $player);
|
||||
return;
|
||||
}
|
||||
$message = $player->getEscapedNickname() . ' added ' . $target->getEscapedNickname() . ' as SuperAdmin!';
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send usage example for //addsuperadmin command
|
||||
*
|
||||
* @param Player $player
|
||||
* @return bool
|
||||
*/
|
||||
private function sendAddSuperAdminUsageInfo(Player $player) {
|
||||
$message = "Usage Example: '//addsuperadmin login'";
|
||||
return $this->maniaControl->getChat()->sendUsageInfo($message, $player);
|
||||
$this->command_Add($chatCallback, $player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,39 +110,7 @@ class AuthCommands implements CommandListener, UsageInformationAble {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_AddAdmin(array $chatCallback, Player $player) {
|
||||
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$text = $chatCallback[1][2];
|
||||
$commandParts = explode(' ', $text);
|
||||
if (!array_key_exists(1, $commandParts)) {
|
||||
$this->sendAddAdminUsageInfo($player);
|
||||
return;
|
||||
}
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]);
|
||||
if (!$target) {
|
||||
$this->maniaControl->getChat()->sendError("Player '{$commandParts[1]}' not found!", $player);
|
||||
return;
|
||||
}
|
||||
$success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
if (!$success) {
|
||||
$this->maniaControl->getChat()->sendError('Error occurred.', $player);
|
||||
return;
|
||||
}
|
||||
$message = $player->getEscapedNickname() . ' added ' . $target->getEscapedNickname() . ' as Admin!';
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send usage example for //addadmin command
|
||||
*
|
||||
* @param Player $player
|
||||
* @return bool
|
||||
*/
|
||||
private function sendAddAdminUsageInfo(Player $player) {
|
||||
$message = "Usage Example: '//addadmin login'";
|
||||
return $this->maniaControl->getChat()->sendUsageInfo($message, $player);
|
||||
$this->command_Add($chatCallback, $player, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -134,42 +121,9 @@ class AuthCommands implements CommandListener, UsageInformationAble {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_AddModerator(array $chatCallback, Player $player) {
|
||||
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$text = $chatCallback[1][2];
|
||||
$commandParts = explode(' ', $text);
|
||||
if (!array_key_exists(1, $commandParts)) {
|
||||
$this->sendAddModeratorUsageInfo($player);
|
||||
return;
|
||||
}
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]);
|
||||
if (!$target) {
|
||||
$this->maniaControl->getChat()->sendError("Player '{$commandParts[1]}' not found!", $player);
|
||||
return;
|
||||
}
|
||||
$success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
if (!$success) {
|
||||
$this->maniaControl->getChat()->sendError('Error occurred.', $player);
|
||||
return;
|
||||
}
|
||||
$message = $player->getEscapedNickname() . ' added ' . $target->getEscapedNickname() . ' as Moderator!';
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
$this->command_Add($chatCallback, $player, AuthenticationManager::AUTH_LEVEL_MODERATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send usage example for //addmod command
|
||||
*
|
||||
* @param Player $player
|
||||
* @return bool
|
||||
*/
|
||||
private function sendAddModeratorUsageInfo(Player $player) {
|
||||
$message = "Usage Example: '//addmod login'";
|
||||
return $this->maniaControl->getChat()->sendUsageInfo($message, $player);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle //removerights command
|
||||
*
|
||||
@ -178,44 +132,55 @@ class AuthCommands implements CommandListener, UsageInformationAble {
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_RemoveRights(array $chatCallback, Player $player) {
|
||||
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||
$this->maniaControl->getAuthenticationManager()->sendNotAllowed($player);
|
||||
return;
|
||||
}
|
||||
$text = $chatCallback[1][2];
|
||||
$commandParts = explode(' ', $text);
|
||||
if (!array_key_exists(1, $commandParts)) {
|
||||
$this->sendRemoveRightsUsageInfo($player);
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
'Usage Example: %s %s',
|
||||
$commandParts[0],
|
||||
'login'
|
||||
);
|
||||
$this->maniaControl->getChat()->sendUsageInfo($message, $player);
|
||||
return;
|
||||
}
|
||||
|
||||
$target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]);
|
||||
if (!$target) {
|
||||
$this->maniaControl->getChat()->sendError("Player '{$commandParts[1]}' not found!", $player);
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
'Player %s not found!',
|
||||
$commandParts[1]
|
||||
);
|
||||
$this->maniaControl->getChat()->sendError($message, $player);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($target->authLevel == AuthenticationManager::AUTH_LEVEL_MASTERADMIN) {
|
||||
$this->maniaControl->getChat()->sendError("You can't remove an MasterAdmin from the Adminlists", $player);
|
||||
if ($target->authLevel >= AuthenticationManager::AUTH_LEVEL_MASTERADMIN) {
|
||||
$this->maniaControl->getChat()->sendError('You cannot remove rights of a MasterAdmin!', $player);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($target->authLevel <= AuthenticationManager::AUTH_LEVEL_PLAYER) {
|
||||
$this->maniaControl->getChat()->sendError('Cannot remove rights of a player!', $player);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($player->authLevel <= $target->authLevel) {
|
||||
$this->maniaControl->getChat()->sendError('You cannot remove rights of a higher privileged player!', $player);
|
||||
return;
|
||||
}
|
||||
|
||||
$targetAuthName = $target->getAuthLevelName();
|
||||
$success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_PLAYER);
|
||||
if (!$success) {
|
||||
$this->maniaControl->getChat()->sendError('Error occurred.', $player);
|
||||
$this->maniaControl->getChat()->sendError('Error occurred!', $player);
|
||||
return;
|
||||
}
|
||||
$message = $player->getEscapedNickname() . ' removed ' . $target->getEscapedNickname() . ' from the Adminlists!';
|
||||
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
"%s removed %s from {$targetAuthName}s.",
|
||||
$player,
|
||||
$target
|
||||
);
|
||||
$this->maniaControl->getChat()->sendSuccess($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send usage example for //removerights command
|
||||
*
|
||||
* @param Player $player
|
||||
* @return bool
|
||||
*/
|
||||
private function sendRemoveRightsUsageInfo(Player $player) {
|
||||
$message = "Usage Example: '//addadmin login'";
|
||||
return $this->maniaControl->getChat()->sendUsageInfo($message, $player);
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ use ManiaControl\Logger;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Players\PlayerManager;
|
||||
use ManiaControl\Plugins\Plugin;
|
||||
use ManiaControl\Settings\Setting;
|
||||
|
||||
/**
|
||||
@ -21,7 +22,7 @@ use ManiaControl\Settings\Setting;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class AuthenticationManager implements CallbackListener, EchoListener, CommunicationListener, UsageInformationAble {
|
||||
@ -133,8 +134,10 @@ class AuthenticationManager implements CallbackListener, EchoListener, Communica
|
||||
return self::AUTH_NAME_ADMIN;
|
||||
case self::AUTH_LEVEL_MODERATOR:
|
||||
return self::AUTH_NAME_MODERATOR;
|
||||
case self::AUTH_LEVEL_PLAYER:
|
||||
return self::AUTH_NAME_PLAYER;
|
||||
}
|
||||
return self::AUTH_NAME_PLAYER;
|
||||
return '-';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -172,8 +175,10 @@ class AuthenticationManager implements CallbackListener, EchoListener, Communica
|
||||
return self::AUTH_LEVEL_ADMIN;
|
||||
case self::AUTH_NAME_MODERATOR:
|
||||
return self::AUTH_LEVEL_MODERATOR;
|
||||
case self::AUTH_NAME_PLAYER:
|
||||
return self::AUTH_LEVEL_PLAYER;
|
||||
}
|
||||
return self::AUTH_LEVEL_PLAYER;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -420,7 +425,21 @@ class AuthenticationManager implements CallbackListener, EchoListener, Communica
|
||||
*/
|
||||
public function checkPermission(Player $player, $rightName) {
|
||||
$right = $this->maniaControl->getSettingManager()->getSettingValue($this, $rightName);
|
||||
return $this->checkRight($player, $this->getAuthLevel($right));
|
||||
return self::checkRight($player, self::getAuthLevel($right));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the permission by a right name
|
||||
*
|
||||
* @api
|
||||
* @param Plugin $plugin
|
||||
* @param Player $player
|
||||
* @param $rightName
|
||||
* @return bool
|
||||
*/
|
||||
public function checkPluginPermission(Plugin $plugin, Player $player, $rightName) {
|
||||
$right = $this->maniaControl->getSettingManager()->getSettingValue($plugin, $rightName);
|
||||
return self::checkRight($player, self::getAuthLevel($right));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -429,9 +448,23 @@ class AuthenticationManager implements CallbackListener, EchoListener, Communica
|
||||
* @api
|
||||
* @param string $rightName
|
||||
* @param int $authLevelNeeded
|
||||
* @param string $authLevelsAllowed
|
||||
*/
|
||||
public function definePermissionLevel($rightName, $authLevelNeeded) {
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, $rightName, self::getPermissionLevelNameArray($authLevelNeeded));
|
||||
public function definePermissionLevel($rightName, $authLevelNeeded, $authLevelsAllowed = self::AUTH_LEVEL_MODERATOR) {
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, $rightName, self::getPermissionLevelNameArray($authLevelNeeded, $authLevelsAllowed));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define a Minimum Right Level needed for an Action
|
||||
*
|
||||
* @api
|
||||
* @param Plugin $plugin
|
||||
* @param string $rightName
|
||||
* @param int $authLevelNeeded
|
||||
* @param string $authLevelsAllowed
|
||||
*/
|
||||
public function definePluginPermissionLevel(Plugin $plugin, $rightName, $authLevelNeeded, $authLevelsAllowed = self::AUTH_LEVEL_MODERATOR) {
|
||||
$this->maniaControl->getSettingManager()->initSetting($plugin, $rightName, self::getPermissionLevelNameArray($authLevelNeeded, $authLevelsAllowed));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -439,19 +472,70 @@ class AuthenticationManager implements CallbackListener, EchoListener, Communica
|
||||
*
|
||||
* @api
|
||||
* @param $authLevelNeeded
|
||||
* @param $authLevelsAllowed
|
||||
* @return array[]
|
||||
*/
|
||||
public static function getPermissionLevelNameArray($authLevelNeeded) {
|
||||
switch ($authLevelNeeded) {
|
||||
public static function getPermissionLevelNameArray($authLevelNeeded, $authLevelsAllowed = self::AUTH_LEVEL_MODERATOR) {
|
||||
assert($authLevelNeeded >= $authLevelsAllowed);
|
||||
|
||||
switch ($authLevelsAllowed) {
|
||||
case self::AUTH_LEVEL_PLAYER:
|
||||
switch ($authLevelNeeded) {
|
||||
case self::AUTH_LEVEL_PLAYER:
|
||||
return array(self::AUTH_NAME_PLAYER, self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN);
|
||||
case self::AUTH_LEVEL_MODERATOR:
|
||||
return array(self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_PLAYER);
|
||||
case self::AUTH_LEVEL_ADMIN:
|
||||
return array(self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_PLAYER, self::AUTH_NAME_MODERATOR);
|
||||
case self::AUTH_LEVEL_SUPERADMIN:
|
||||
return array(self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_PLAYER, self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN);
|
||||
case self::AUTH_LEVEL_MASTERADMIN:
|
||||
return array(self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_PLAYER, self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN);
|
||||
}
|
||||
break;
|
||||
|
||||
case self::AUTH_LEVEL_MODERATOR:
|
||||
return array(self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN);
|
||||
switch ($authLevelNeeded) {
|
||||
case self::AUTH_LEVEL_MODERATOR:
|
||||
return array(self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN);
|
||||
case self::AUTH_LEVEL_ADMIN:
|
||||
return array(self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_MODERATOR);
|
||||
case self::AUTH_LEVEL_SUPERADMIN:
|
||||
return array(self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN);
|
||||
case self::AUTH_LEVEL_MASTERADMIN:
|
||||
return array(self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN);
|
||||
}
|
||||
break;
|
||||
|
||||
case self::AUTH_LEVEL_ADMIN:
|
||||
return array(self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_MODERATOR);
|
||||
switch ($authLevelNeeded) {
|
||||
case self::AUTH_LEVEL_ADMIN:
|
||||
return array(self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN);
|
||||
case self::AUTH_LEVEL_SUPERADMIN:
|
||||
return array(self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_ADMIN);
|
||||
case self::AUTH_LEVEL_MASTERADMIN:
|
||||
return array(self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN);
|
||||
}
|
||||
break;
|
||||
|
||||
case self::AUTH_LEVEL_SUPERADMIN:
|
||||
return array(self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN);
|
||||
switch ($authLevelNeeded) {
|
||||
case self::AUTH_LEVEL_SUPERADMIN:
|
||||
return array(self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN);
|
||||
case self::AUTH_LEVEL_MASTERADMIN:
|
||||
return array(self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_SUPERADMIN);
|
||||
}
|
||||
break;
|
||||
|
||||
// just for completeness, should not be used this way
|
||||
case self::AUTH_LEVEL_MASTERADMIN:
|
||||
return array(self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN);
|
||||
switch ($authLevelNeeded) {
|
||||
case self::AUTH_LEVEL_MASTERADMIN:
|
||||
return array(self::AUTH_NAME_MASTERADMIN);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return array("-");
|
||||
}
|
||||
}
|
||||
|
99
core/Admin/ColorManager.php
Normal file
99
core/Admin/ColorManager.php
Normal file
@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Admin;
|
||||
|
||||
use ManiaControl\Admin\AuthenticationManager;
|
||||
use ManiaControl\General\UsageInformationAble;
|
||||
use ManiaControl\General\UsageInformationTrait;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\Player;
|
||||
|
||||
/**
|
||||
* Color Manager Class to give roles different colors
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class ColorManager implements UsageInformationAble {
|
||||
use UsageInformationTrait;
|
||||
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
const SETTING_COLOR_PLAYER = 'Color of Player';
|
||||
const SETTING_COLOR_MODERATOR = 'Color of Moderator';
|
||||
const SETTING_COLOR_ADMIN = 'Color of Admin';
|
||||
const SETTING_COLOR_SUPERADMIN = 'Color of SuperAdmin';
|
||||
const SETTING_COLOR_MASTERADMIN = 'Color of MasterAdmin';
|
||||
|
||||
/*
|
||||
* Private properties
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
|
||||
public function __construct(ManiaControl $maniaControl) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_COLOR_PLAYER, '$ff0');
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_COLOR_MODERATOR, '$0f9');
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_COLOR_ADMIN, '$39f');
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_COLOR_SUPERADMIN, '$f93');
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_COLOR_MASTERADMIN, '$f00');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the admins color by the authentication level
|
||||
*
|
||||
* @param int $authLevel
|
||||
* @return string
|
||||
*/
|
||||
public function getColorByLevel($authLevel) {
|
||||
switch ($authLevel) {
|
||||
case AuthenticationManager::AUTH_LEVEL_PLAYER:
|
||||
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLOR_PLAYER);
|
||||
case AuthenticationManager::AUTH_LEVEL_MODERATOR:
|
||||
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLOR_MODERATOR);
|
||||
case AuthenticationManager::AUTH_LEVEL_ADMIN:
|
||||
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLOR_ADMIN);
|
||||
case AuthenticationManager::AUTH_LEVEL_SUPERADMIN:
|
||||
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLOR_SUPERADMIN);
|
||||
case AuthenticationManager::AUTH_LEVEL_MASTERADMIN:
|
||||
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLOR_MASTERADMIN);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the admins color by the authentication name
|
||||
*
|
||||
* @param string $authName
|
||||
* @return string
|
||||
*/
|
||||
public function getColorByName($authName) {
|
||||
switch ($authName) {
|
||||
case AuthenticationManager::AUTH_NAME_PLAYER:
|
||||
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLOR_PLAYER);
|
||||
case AuthenticationManager::AUTH_NAME_MODERATOR:
|
||||
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLOR_MODERATOR);
|
||||
case AuthenticationManager::AUTH_NAME_ADMIN:
|
||||
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLOR_ADMIN);
|
||||
case AuthenticationManager::AUTH_NAME_SUPERADMIN:
|
||||
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLOR_SUPERADMIN);
|
||||
case AuthenticationManager::AUTH_NAME_MASTERADMIN:
|
||||
return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLOR_MASTERADMIN);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the admins color by the players authentication level
|
||||
*
|
||||
* @param Player $player
|
||||
* @return string
|
||||
*/
|
||||
public function getColorByPlayer(Player $player) {
|
||||
return $this->getColorByLevel($player->authLevel);
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ namespace ManiaControl;
|
||||
* ManiaControl AutoLoader
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
abstract class AutoLoader {
|
||||
|
@ -16,7 +16,7 @@ use Maniaplanet\DedicatedServer\Structures\Bill;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class BillManager implements CallbackListener, UsageInformationAble {
|
||||
|
13
core/Callbacks/CallQueueListener.php
Executable file
13
core/Callbacks/CallQueueListener.php
Executable file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Callbacks;
|
||||
|
||||
/**
|
||||
* Interface for CallQueueListener
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
interface CallQueueListener {
|
||||
}
|
69
core/Callbacks/CallQueueListening.php
Executable file
69
core/Callbacks/CallQueueListening.php
Executable file
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Callbacks;
|
||||
|
||||
use ManiaControl\General\UsageInformationAble;
|
||||
use ManiaControl\General\UsageInformationTrait;
|
||||
|
||||
/**
|
||||
* Model Class for a Call Queue Listening
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CallQueueListening extends Listening implements UsageInformationAble {
|
||||
use UsageInformationTrait;
|
||||
|
||||
private $errorMethod = null;
|
||||
|
||||
/**
|
||||
* Construct a new Call Queue Listening
|
||||
*
|
||||
* @param CallQueueListener $listener
|
||||
* @param mixed $method
|
||||
* @param mixed $errorMethod
|
||||
*/
|
||||
public function __construct(CallQueueListener $listener, $method, $errorMethod) {
|
||||
parent::__construct($listener, $method);
|
||||
if ($errorMethod != null) {
|
||||
$this->errorMethod = array($listener, $errorMethod);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the Listener's Method
|
||||
* @return bool
|
||||
*/
|
||||
public function triggerCallback() {
|
||||
$params = func_get_args();
|
||||
if ($this->triggerCallbackWithParams($params, false) === false) {
|
||||
if ($this->errorMethod != null) {
|
||||
call_user_func($this->errorMethod, $this->method);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the Listener's Method with the given Array of Params
|
||||
*
|
||||
* @param array $params
|
||||
* @return mixed
|
||||
*/
|
||||
public function triggerCallbackWithParams(array $params, $callErrorMethod = true) {
|
||||
$result = call_user_func_array($this->getUserFunction(), $params);
|
||||
if ($callErrorMethod && $result === false) {
|
||||
if ($this->errorMethod != null) {
|
||||
call_user_func($this->errorMethod, $this->getUserFunction());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
117
core/Callbacks/CallQueueManager.php
Executable file
117
core/Callbacks/CallQueueManager.php
Executable file
@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Callbacks;
|
||||
|
||||
use ManiaControl\General\UsageInformationAble;
|
||||
use ManiaControl\General\UsageInformationTrait;
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
/**
|
||||
* Class for managing queued calls.
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CallQueueManager implements UsageInformationAble {
|
||||
use UsageInformationTrait;
|
||||
|
||||
/*
|
||||
* Private properties
|
||||
*/
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
/** @var CallQueueListening[] $queueListenings */
|
||||
private $queueListenings = array();
|
||||
|
||||
/**
|
||||
* Construct a new Call Queue Manager
|
||||
*
|
||||
* @param ManiaControl $maniaControl
|
||||
*/
|
||||
public function __construct(ManiaControl $maniaControl) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a Call Queue Listening
|
||||
*
|
||||
* @param CallQueueListener $listener
|
||||
* @param mixed $methods
|
||||
* @param mixed $errorMethod
|
||||
* @return bool
|
||||
*/
|
||||
public function registerListening(CallQueueListener $listener, $methods, $errorMethod = null, $important = false) {
|
||||
if ($errorMethod != null && !CallQueueListening::checkValidCallback($listener, $errorMethod)) {
|
||||
trigger_error("Given Listener (" . get_class($listener) . ") can't handle Queue Call Callback (No Error Method '{$errorMethod}')!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!is_array($methods)) {
|
||||
$methods = array($methods);
|
||||
}
|
||||
|
||||
foreach ($methods as $method) {
|
||||
if (!CallQueueListening::checkValidCallback($listener, $method)) {
|
||||
trigger_error("Given Listener (" . get_class($listener) . ") can't handle Queue Call Callback (No Method '{$method}')!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($methods as $method) {
|
||||
// Build Call Queue Listening
|
||||
$listening = new CallQueueListening($listener, $method, $errorMethod);
|
||||
if ($important) {
|
||||
$this->addImportantListening($listening);
|
||||
} else {
|
||||
$this->addListening($listening);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an important Listening to the current list of managed queue calls at the front
|
||||
*
|
||||
* @param CallQueueListening $queueListening
|
||||
*/
|
||||
public function addImportantListening(CallQueueListening $queueListening) {
|
||||
array_unshift($this->queueListenings, $queueListening);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a Listening to the current list of managed queue calls at the end
|
||||
*
|
||||
* @param CallQueueListening $queueListening
|
||||
*/
|
||||
public function addListening(CallQueueListening $queueListening) {
|
||||
array_push($this->queueListenings, $queueListening);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks, if one specific listening already has been queued for a call.
|
||||
* Can only check for named functions.
|
||||
* @param CallQueueListener $listener
|
||||
* @param string $method
|
||||
* @return bool
|
||||
*/
|
||||
public function hasListening(CallQueueListener $listener, $method) {
|
||||
foreach ($this->queueListenings as $listening) {
|
||||
if ($listening->listener === $listener && $listening->method === $method) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage one of the queued calls
|
||||
*/
|
||||
public function manageCallQueue() {
|
||||
if (!empty($this->queueListenings)) {
|
||||
$listening = array_shift($this->queueListenings);
|
||||
$listening->triggerCallback();
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ namespace ManiaControl\Callbacks;
|
||||
* Interface for Callback Listener
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
interface CallbackListener {
|
||||
|
@ -15,7 +15,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException;
|
||||
* Class for managing Server and ManiaControl Callbacks
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CallbackManager implements UsageInformationAble {
|
||||
@ -31,6 +31,8 @@ class CallbackManager implements UsageInformationAble {
|
||||
const CB_MP_ENDMATCH = 'ManiaPlanet.EndMatch';
|
||||
const CB_MP_BEGINMAP = 'ManiaPlanet.BeginMap';
|
||||
const CB_MP_ENDMAP = 'ManiaPlanet.EndMap';
|
||||
const CB_MP_BEGINROUND = 'ManiaPlanet.BeginRound';
|
||||
const CB_MP_ENDROUND = 'ManiaPlanet.EndRound';
|
||||
const CB_MP_MAPLISTMODIFIED = 'ManiaPlanet.MapListModified';
|
||||
const CB_MP_ECHO = 'ManiaPlanet.Echo';
|
||||
const CB_MP_BILLUPDATED = 'ManiaPlanet.BillUpdated';
|
||||
@ -61,6 +63,8 @@ class CallbackManager implements UsageInformationAble {
|
||||
|
||||
/** @var ManiaControl $maniaControl */
|
||||
private $maniaControl = null;
|
||||
/** @var Listening[] $adhocCallbacks */
|
||||
private $adhocCallbacks = array();
|
||||
/** @var Listening[][] $callbackListenings */
|
||||
private $callbackListenings = array();
|
||||
/** @var Listening[][] $scriptCallbackListenings */
|
||||
@ -219,6 +223,42 @@ class CallbackManager implements UsageInformationAble {
|
||||
return $this->removeCallbackListener($this->scriptCallbackListenings, $listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* Adds an adhoc Callback to be executed immediately after other callbacks.
|
||||
* Should be used for more specialized Callbacks, which need to be executed soon after a more general callback.
|
||||
*
|
||||
* @param mixed $callbackName
|
||||
*/
|
||||
public function addAdhocCallback($callbackName) {
|
||||
if (!$this->callbackListeningExists($callbackName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$params = func_get_args();
|
||||
$params = array_slice($params, 1, null, true);
|
||||
array_push($this->adhocCallbacks, array($callbackName, $params));
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* Trigger internal adhoc Callbacks between manageCallbacks()
|
||||
*/
|
||||
private function manageAdhocCallbacks() {
|
||||
// TODO add some timing method to determine long loop issues
|
||||
// currently it adds to the non-specialized callback which added the adhoc callback
|
||||
|
||||
foreach ($this->adhocCallbacks as $callback) {
|
||||
list($callbackName, $params) = $callback;
|
||||
foreach ($this->callbackListenings[$callbackName] as $listening) {
|
||||
/** @var Listening $listening */
|
||||
$listening->triggerCallbackWithParams($params);
|
||||
}
|
||||
}
|
||||
|
||||
$this->adhocCallbacks = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger internal Callbacks and manage Server Callbacks
|
||||
*/
|
||||
@ -251,6 +291,8 @@ class CallbackManager implements UsageInformationAble {
|
||||
foreach ($callbacks as $key => $callback) {
|
||||
$time1 = microtime(true);
|
||||
$this->handleCallback($callback);
|
||||
// manage any callbacks added by the previous callback
|
||||
$this->manageAdhocCallbacks();
|
||||
$timings[$key] = array($callback[0], microtime(true) - $time1);
|
||||
}
|
||||
|
||||
@ -312,7 +354,6 @@ class CallbackManager implements UsageInformationAble {
|
||||
* @param mixed $callbackName
|
||||
*/
|
||||
public function triggerCallback($callbackName) {
|
||||
|
||||
if (!$this->callbackListeningExists($callbackName)) {
|
||||
return;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ namespace ManiaControl\Callbacks;
|
||||
* Callbacks Interface
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
interface Callbacks {
|
||||
@ -16,7 +16,9 @@ interface Callbacks {
|
||||
const ONINIT = 'Callbacks.OnInit';
|
||||
const AFTERINIT = 'Callbacks.AfterInit';
|
||||
const ONSHUTDOWN = 'Callbacks.OnShutdown';
|
||||
/** @deprecated */
|
||||
const ONRESTART = 'Callbacks.OnRestart';
|
||||
const ONREBOOT = 'Callbacks.OnReboot';
|
||||
const PRELOOP = 'Callbacks.PreLoop';
|
||||
const AFTERLOOP = 'Callbacks.AfterLoop';
|
||||
|
||||
|
@ -5,7 +5,7 @@ namespace ManiaControl\Callbacks;
|
||||
* Interface for EchoListener
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
interface EchoListener {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
* Class for managing Echo Callbacks
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class EchoManager implements CallbackListener, EchoListener, UsageInformationAble {
|
||||
@ -143,8 +143,9 @@ class EchoManager implements CallbackListener, EchoListener, UsageInformationAbl
|
||||
}
|
||||
|
||||
switch ($name) {
|
||||
case 'ManiaControl.Restart':
|
||||
$this->maniaControl->restart($message);
|
||||
case Callbacks::ONRESTART:
|
||||
case Callbacks::ONREBOOT:
|
||||
$this->maniaControl->reboot($message);
|
||||
break;
|
||||
default:
|
||||
$this->triggerEchoCallback($name, $message);
|
||||
|
@ -25,7 +25,7 @@ use ManiaControl\ManiaControl;
|
||||
* Class converting LibXmlRpc Callbacks
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class LibXmlRpcCallbacks implements CallbackListener {
|
||||
|
@ -9,7 +9,7 @@ use ManiaControl\General\UsageInformationTrait;
|
||||
* Model Class for a Basic Listening
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class Listening implements UsageInformationAble {
|
||||
|
@ -36,7 +36,7 @@ use ManiaControl\ManiaControl;
|
||||
* Class handling and parsing ShootMania Callbacks
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class ShootManiaCallbacks implements CallbackListener {
|
||||
|
@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class BasePlayerTimeStructure extends BaseTimeStructure {
|
||||
|
@ -9,7 +9,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class BaseResponseStructure extends BaseStructure {
|
||||
|
@ -14,7 +14,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
abstract class BaseStructure implements UsageInformationAble, JsonSerializable {
|
||||
|
@ -9,7 +9,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class BaseTimeStructure extends BaseStructure {
|
||||
|
@ -3,8 +3,6 @@
|
||||
namespace ManiaControl\Callbacks\Structures\Common;
|
||||
|
||||
|
||||
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
|
||||
use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure;
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
/**
|
||||
@ -12,7 +10,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CommonCommandStructure extends BaseTimeStructure {
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace ManiaControl\Callbacks\Structures\ShootMania;
|
||||
|
||||
|
||||
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
|
||||
use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure;
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
@ -12,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CommonDefaultEventStructure extends BaseTimeStructure {
|
||||
|
@ -5,8 +5,6 @@ namespace ManiaControl\Callbacks\Structures\Common;
|
||||
|
||||
use ManiaControl\Callbacks\Structures\Common\Models\CommonPlayerScore;
|
||||
use ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore;
|
||||
use ManiaControl\General\JsonSerializable;
|
||||
use ManiaControl\General\JsonSerializeTrait;
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
/**
|
||||
@ -14,7 +12,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CommonScoresStructure extends BaseResponseStructure {
|
||||
|
@ -14,7 +14,7 @@ use ManiaControl\Players\Player;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CommonPlayerScore implements UsageInformationAble, JsonSerializable {
|
||||
|
@ -12,7 +12,7 @@ use ManiaControl\General\UsageInformationTrait;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CommonTeamScore implements UsageInformationAble, JsonSerializable {
|
||||
|
@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class StatusCallbackStructure extends BaseResponseStructure {
|
||||
|
@ -9,7 +9,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class UIPropertiesBaseStructure extends BaseResponseStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class LoadingUnloadingMapStructure extends BaseTimeStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class ModeUseTeamsStructure extends BaseResponseStructure {
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace ManiaControl\Callbacks\Structures\ManiaPlanet;
|
||||
|
||||
|
||||
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
|
||||
|
||||
use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure;
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
@ -12,7 +12,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class StartEndStructure extends BaseTimeStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class StartServerStructure extends BaseStructure {
|
||||
|
@ -17,7 +17,7 @@ use ManiaControl\General\UsageInformationTrait;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class JoustScore implements UsageInformationAble {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\General\UsageInformationTrait;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class Landmark implements UsageInformationAble {
|
||||
|
@ -10,7 +10,7 @@ use ManiaControl\Callbacks\Structures\Common\Models\CommonPlayerScore;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class PlayerScore extends CommonPlayerScore {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\General\UsageInformationTrait;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class Position implements UsageInformationAble {
|
||||
|
@ -7,7 +7,7 @@ namespace ManiaControl\Callbacks\Structures\ShootMania\Models;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
interface RoyalPointTypes {
|
||||
|
@ -9,7 +9,7 @@ use ManiaControl\Callbacks\Structures\Common\Models\CommonTeamScore;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class TeamScore extends CommonTeamScore {
|
||||
|
@ -7,7 +7,7 @@ namespace ManiaControl\Callbacks\Structures\ShootMania\Models;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
interface VictoryTypes {
|
||||
|
@ -7,7 +7,7 @@ namespace ManiaControl\Callbacks\Structures\ShootMania\Models;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
interface Weapons {
|
||||
|
@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnAFKPropertiesStructure extends BaseResponseStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnActionCustomEventStructure extends BaseStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnActionEvent extends BaseStructure {
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
namespace ManiaControl\Callbacks\Structures\ShootMania;
|
||||
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
|
||||
/**
|
||||
* Structure Class for the OnArmorEmpty Structure Callback
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnArmorEmptyStructure extends OnHitNearMissArmorEmptyBaseStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnBasePlayerObjectTimeStructure extends BasePlayerTimeStructure {
|
||||
|
@ -4,8 +4,8 @@ namespace ManiaControl\Callbacks\Structures\ShootMania;
|
||||
|
||||
|
||||
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
|
||||
use ManiaControl\Callbacks\Structures\ShootMania\Models\Landmark;
|
||||
use ManiaControl\Callbacks\Structures\ShootMania\Models\Position;
|
||||
|
||||
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\Player;
|
||||
|
||||
@ -14,7 +14,7 @@ use ManiaControl\Players\Player;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnCaptureStructure extends BaseStructure {
|
||||
|
@ -10,7 +10,7 @@ use ManiaControl\Callbacks\Structures\Common\CommonCommandStructure;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnCommandStructure extends CommonCommandStructure {
|
||||
|
@ -3,15 +3,15 @@
|
||||
namespace ManiaControl\Callbacks\Structures\ShootMania;
|
||||
|
||||
|
||||
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Structure Class for the Default Event Structure Callback
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnDefaultEventStructure extends CommonDefaultEventStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnEliteEndTurnStructure extends BaseStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnEliteStartTurnStructure extends BaseStructure {
|
||||
|
@ -12,7 +12,7 @@ use ManiaControl\Players\Player;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnFallDamageStructure extends BaseStructure {
|
||||
|
@ -14,7 +14,7 @@ use ManiaControl\Players\Player;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnHitNearMissArmorEmptyBaseStructure extends BaseStructure {
|
||||
|
@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnHitStructure extends OnHitNearMissArmorEmptyBaseStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnJoustReloadStructure extends BaseStructure {
|
||||
|
@ -13,7 +13,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnJoustRoundResultsStructure extends BaseStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnJoustSelectedPlayersStructure extends BaseStructure {
|
||||
|
@ -3,14 +3,14 @@
|
||||
namespace ManiaControl\Callbacks\Structures\ShootMania;
|
||||
|
||||
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
|
||||
/**
|
||||
* Structure Class for the OnNearMiss Structure Callback
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnNearMissStructure extends OnHitNearMissArmorEmptyBaseStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnPlayerRequestActionChange extends BasePlayerTimeStructure {
|
||||
|
@ -4,16 +4,14 @@ namespace ManiaControl\Callbacks\Structures\ShootMania;
|
||||
|
||||
|
||||
use ManiaControl\Callbacks\Structures\Common\BasePlayerTimeStructure;
|
||||
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\Player;
|
||||
|
||||
|
||||
/**
|
||||
* Structure Class for the OnPlayerRequestRespawnStructure Structure Callback
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnPlayerRequestRespawnStructure extends BasePlayerTimeStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnPlayerTriggersSectorStructure extends BasePlayerTimeStructure {
|
||||
|
@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnPlayersAFKStructure extends BaseStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnRoyalPlayerSpawnStructure extends BaseStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnRoyalPointsStructure extends BaseStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnRoyalRoundWinnerStructure extends BaseStructure {
|
||||
|
@ -5,7 +5,7 @@ namespace ManiaControl\Callbacks\Structures\ShootMania;
|
||||
|
||||
use ManiaControl\Callbacks\Structures\Common\CommonScoresStructure;
|
||||
use ManiaControl\Callbacks\Structures\ShootMania\Models\PlayerScore;
|
||||
use ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore;
|
||||
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ use ManiaControl\ManiaControl;
|
||||
* Structure Class for the Shootmania OnScores Structure Callback
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnScoresStructure extends CommonScoresStructure {
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace ManiaControl\Callbacks\Structures\ShootMania;
|
||||
|
||||
|
||||
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
|
||||
|
||||
use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Players\Player;
|
||||
@ -13,7 +13,7 @@ use ManiaControl\Players\Player;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnShootStructure extends BaseTimeStructure {
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace ManiaControl\Callbacks\Structures\ShootMania;
|
||||
|
||||
|
||||
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
|
||||
|
||||
use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure;
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
@ -13,7 +13,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnShotDenyStructure extends BaseTimeStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\Callbacks\Structures\Common\Models\CommonPlayerScore;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class PlayerScore extends CommonPlayerScore {
|
||||
|
@ -9,7 +9,7 @@ use ManiaControl\Callbacks\Structures\Common\Models\CommonTeamScore;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class TeamScore extends CommonTeamScore {
|
||||
|
@ -10,7 +10,7 @@ use ManiaControl\Callbacks\Structures\Common\CommonCommandStructure;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnCommandStructure extends CommonCommandStructure {
|
||||
|
@ -3,17 +3,17 @@
|
||||
namespace ManiaControl\Callbacks\Structures\TrackMania;
|
||||
|
||||
|
||||
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
|
||||
use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure;
|
||||
|
||||
|
||||
use ManiaControl\Callbacks\Structures\ShootMania\CommonDefaultEventStructure;
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
|
||||
/**
|
||||
* Structure Class for the Default Event Structure Callback
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnDefaultEventStructure extends CommonDefaultEventStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnPointsRepartitionStructure extends BaseResponseStructure {
|
||||
|
@ -6,14 +6,14 @@ namespace ManiaControl\Callbacks\Structures\TrackMania;
|
||||
use ManiaControl\Callbacks\Models\RecordCallback;
|
||||
use ManiaControl\Callbacks\Structures\Common\BasePlayerTimeStructure;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Utils\Formatter;
|
||||
|
||||
|
||||
/**
|
||||
* Structure Class for the On Respawn Structure Callback
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnRespawnStructure extends BasePlayerTimeStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnScoresStructure extends CommonScoresStructure {
|
||||
@ -38,10 +38,18 @@ class OnScoresStructure extends CommonScoresStructure {
|
||||
$playerScore->setBestRaceTime($jsonPlayer->bestracetime);
|
||||
$playerScore->setBestLapTime($jsonPlayer->bestlaptime);
|
||||
$playerScore->setStuntScore($jsonPlayer->stuntsscore);
|
||||
$playerScore->setBestRaceRespawns($jsonPlayer->bestracerespawns);
|
||||
$playerScore->setBestRaceCheckpoints($jsonPlayer->bestracecheckpoints);
|
||||
$playerScore->setBestLapRespawns($jsonPlayer->bestlaprespawns);
|
||||
$playerScore->setBestLapCheckpoints($jsonPlayer->bestlapcheckpoints);
|
||||
|
||||
// removed in TM2020
|
||||
if (property_exists($jsonPlayer, 'bestracerespawns')) {
|
||||
$playerScore->setBestRaceRespawns($jsonPlayer->bestracerespawns);
|
||||
}
|
||||
// removed in TM2020
|
||||
if (property_exists($jsonPlayer, 'bestlaprespawns')) {
|
||||
$playerScore->setBestLapRespawns($jsonPlayer->bestlaprespawns);
|
||||
}
|
||||
|
||||
//New attributes in 2.5.0
|
||||
if (property_exists($jsonPlayer, 'prevracetime')) {
|
||||
$playerScore->setPrevRaceTime($jsonPlayer->prevracetime);
|
||||
|
@ -10,7 +10,7 @@ use ManiaControl\Callbacks\Structures\Common\BasePlayerTimeStructure;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnStartLineEventStructure extends BasePlayerTimeStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnStuntEventStructure extends BasePlayerTimeStructure {
|
||||
|
@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnWarmupStartEndRoundStructure extends BaseStructure {
|
||||
|
@ -12,7 +12,7 @@ use ManiaControl\Utils\Formatter;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class OnWayPointEventStructure extends BasePlayerTimeStructure {
|
||||
@ -39,14 +39,14 @@ class OnWayPointEventStructure extends BasePlayerTimeStructure {
|
||||
|
||||
$this->raceTime = (int) $this->getPlainJsonObject()->racetime;
|
||||
$this->lapTime = (int) $this->getPlainJsonObject()->laptime;
|
||||
$this->stuntsScore = $this->getPlainJsonObject()->stuntsscore;
|
||||
$this->stuntsScore = isset($this->getPlainJsonObject()->stuntsscore) ? $this->getPlainJsonObject()->stuntsscore : null;
|
||||
$this->checkPointInRace = (int) $this->getPlainJsonObject()->checkpointinrace;
|
||||
$this->checkPointInLap = (int) $this->getPlainJsonObject()->checkpointinlap;
|
||||
$this->isEndRace = Formatter::parseBoolean($this->getPlainJsonObject()->isendrace);
|
||||
$this->isEndLap = Formatter::parseBoolean($this->getPlainJsonObject()->isendlap);
|
||||
$this->blockId = $this->getPlainJsonObject()->blockid;
|
||||
$this->speed = $this->getPlainJsonObject()->speed;
|
||||
$this->distance = $this->getPlainJsonObject()->distance;
|
||||
$this->distance = isset($this->getPlainJsonObject()->distance) ? $this->getPlainJsonObject()->distance : null;
|
||||
|
||||
if ($this->checkPointInRace > 0) {
|
||||
$currentMap = $this->maniaControl->getMapManager()->getCurrentMap();
|
||||
|
@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class AllApiVersionsStructure extends BaseResponseStructure {
|
||||
|
@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class ApiVersionStructure extends BaseResponseStructure {
|
||||
|
@ -9,7 +9,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CallbackHelpStructure extends DocumentationStructure {
|
||||
|
@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CallbackListStructure extends BaseResponseStructure {
|
||||
|
@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class DocumentationStructure extends BaseResponseStructure {
|
||||
|
@ -9,7 +9,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class MethodHelpStructure extends DocumentationStructure {
|
||||
|
@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
|
||||
*
|
||||
* @api
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class MethodListStructure extends BaseResponseStructure {
|
||||
|
@ -6,7 +6,7 @@ namespace ManiaControl\Callbacks;
|
||||
* Interface for TimerListener
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
interface TimerListener {
|
||||
|
@ -9,7 +9,7 @@ use ManiaControl\General\UsageInformationTrait;
|
||||
* Model Class for a Timer Listening
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class TimerListening extends Listening implements UsageInformationAble {
|
||||
@ -57,6 +57,16 @@ class TimerListening extends Listening implements UsageInformationAble {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the deltaTime
|
||||
*
|
||||
* @param float $milliSeconds
|
||||
*/
|
||||
public function setDeltaTime($milliSeconds) {
|
||||
$this->deltaTime = $milliSeconds / 1000.;
|
||||
$this->lastTrigger = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the desired Time is reached
|
||||
*
|
||||
|
@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
|
||||
* Class for managing Timed Callbacks
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class TimerManager implements UsageInformationAble {
|
||||
@ -75,6 +75,24 @@ class TimerManager implements UsageInformationAble {
|
||||
array_push($this->timerListenings, $timerListening);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the deltaTime of a Timer Listening
|
||||
*
|
||||
* @param TimerListener $listener
|
||||
* @param string|callable $method
|
||||
* @param float $milliSeconds
|
||||
*/
|
||||
public function updateTimerListening(TimerListener $listener, $method, $milliSeconds) {
|
||||
$updated = false;
|
||||
foreach ($this->timerListenings as $key => &$listening) {
|
||||
if ($listening->listener === $listener && $listening->method === $method) {
|
||||
$listening->setDeltaTime($milliSeconds);
|
||||
$updated = true;
|
||||
}
|
||||
}
|
||||
return $updated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a Timer Listening
|
||||
*
|
||||
|
@ -19,7 +19,7 @@ use ManiaControl\ManiaControl;
|
||||
* Class handling and parsing TrackMania Callbacks
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class TrackManiaCallbacks implements CallbackListener {
|
||||
@ -41,6 +41,7 @@ class TrackManiaCallbacks implements CallbackListener {
|
||||
|
||||
// Register for script callbacks
|
||||
$callbackManager->registerCallbackListener(Callbacks::SCRIPTCALLBACK, $this, 'handleScriptCallbacks');
|
||||
$callbackManager->registerCallbackListener(Callbacks::TM_ONWAYPOINT, $this, 'handleWayPointCallback');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -73,9 +74,7 @@ class TrackManiaCallbacks implements CallbackListener {
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback($name, new BasePlayerTimeStructure($this->maniaControl, $data));
|
||||
break;
|
||||
case Callbacks::TM_ONWAYPOINT:
|
||||
$this->handleWayPointCallback(new OnWayPointEventStructure($this->maniaControl, $data));
|
||||
|
||||
//$this->maniaControl->getCallbackManager()->triggerCallback($name, $wayPointStructure);
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback($name, new OnWayPointEventStructure($this->maniaControl, $data));
|
||||
break;
|
||||
case Callbacks::TM_ONRESPAWN:
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback($name, new OnRespawnStructure($this->maniaControl, $data));
|
||||
@ -105,13 +104,11 @@ class TrackManiaCallbacks implements CallbackListener {
|
||||
*
|
||||
* @param \ManiaControl\Callbacks\Structures\TrackMania\OnWayPointEventStructure $structure
|
||||
*/
|
||||
private function handleWayPointCallback(OnWayPointEventStructure $structure) {
|
||||
public function handleWayPointCallback(OnWayPointEventStructure $structure) {
|
||||
if ($structure->getIsEndRace()) {
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONFINISHLINE, $structure);
|
||||
$this->maniaControl->getCallbackManager()->addAdhocCallback(Callbacks::TM_ONFINISHLINE, $structure);
|
||||
} else if ($structure->getIsEndLap()) {
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONLAPFINISH, $structure);
|
||||
} else {
|
||||
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONWAYPOINT, $structure);
|
||||
$this->maniaControl->getCallbackManager()->addAdhocCallback(Callbacks::TM_ONLAPFINISH, $structure);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
399
core/Chat.php
399
core/Chat.php
@ -10,14 +10,16 @@ use ManiaControl\Communication\CommunicationListener;
|
||||
use ManiaControl\Communication\CommunicationMethods;
|
||||
use ManiaControl\General\UsageInformationAble;
|
||||
use ManiaControl\General\UsageInformationTrait;
|
||||
use ManiaControl\Maps\Map;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Utils\Formatter;
|
||||
use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException;
|
||||
|
||||
/**
|
||||
* Chat Utility Class
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class Chat implements CallbackListener, CommunicationListener, UsageInformationAble {
|
||||
@ -26,13 +28,18 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const SETTING_PUBLIC_PREFIX = 'Public Messages Prefix';
|
||||
const SETTING_PRIVATE_PREFIX = 'Privat Messages Prefix';
|
||||
const SETTING_FORMAT_INFORMATION = 'Information Format';
|
||||
const SETTING_FORMAT_SUCCESS = 'Success Format';
|
||||
const SETTING_FORMAT_ERROR = 'Error Format';
|
||||
const SETTING_FORMAT_USAGEINFO = 'UsageInfo Format';
|
||||
const CHAT_BUFFER_SIZE = 200;
|
||||
const SETTING_FORMAT_ERROR = 'Error Format';
|
||||
const SETTING_FORMAT_INFORMATION = 'Information Format';
|
||||
const SETTING_FORMAT_SUCCESS = 'Success Format';
|
||||
const SETTING_FORMAT_USAGEINFO = 'UsageInfo Format';
|
||||
const SETTING_FORMAT_MESSAGE_INPUT_COLOR = 'Format Message Input Color';
|
||||
const SETTING_FORMAT_MESSAGE_MAP_AUTHOR_LOGIN = 'Format Message Add Map Author Login';
|
||||
const SETTING_FORMAT_MESSAGE_MAP_AUTHOR_NICKNAME = 'Format Message Add Map Author Nickname';
|
||||
const SETTING_FORMAT_MESSAGE_PLAYER_LOGIN = 'Format Message Add Player Login';
|
||||
const SETTING_PUBLIC_PREFIX = 'Public Messages Prefix';
|
||||
const SETTING_PRIVATE_PREFIX = 'Private Messages Prefix';
|
||||
const CHAT_BUFFER_SIZE = 200;
|
||||
|
||||
/*
|
||||
* Private properties
|
||||
*/
|
||||
@ -49,12 +56,16 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
// Settings
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PUBLIC_PREFIX, '» ');
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PRIVATE_PREFIX, '»» ');
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_ERROR, '$f30');
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_INFORMATION, '$fff');
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_SUCCESS, '$0f0');
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_ERROR, '$f30');
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_USAGEINFO, '$f80');
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_MESSAGE_INPUT_COLOR, '$fff');
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_MESSAGE_MAP_AUTHOR_LOGIN, false);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_MESSAGE_MAP_AUTHOR_NICKNAME, true);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_MESSAGE_PLAYER_LOGIN, false);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PUBLIC_PREFIX, '» ');
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PRIVATE_PREFIX, '»» ');
|
||||
|
||||
//Callbacks
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'onPlayerChat');
|
||||
@ -66,51 +77,6 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an information message to the given login
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $login
|
||||
* @param string|bool $prefix
|
||||
* @param bool $multiCall
|
||||
* @return bool
|
||||
*/
|
||||
public function sendInformation($message, $login = null, $prefix = true, $multiCall = true) {
|
||||
$format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_INFORMATION);
|
||||
return $this->sendChat($format . $message, $login, $prefix, $multiCall);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a chat message to the given login
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $login
|
||||
* @param string|bool $prefix
|
||||
* @param bool $multiCall
|
||||
* @return bool
|
||||
*/
|
||||
public function sendChat($message, $login = null, $prefix = true, $multiCall = true) {
|
||||
if (!$this->maniaControl->getClient()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$prefix = $this->buildPrefix($prefix, $login);
|
||||
$chatMessage = '$<$z$ff0' . $prefix . $message . '$>';
|
||||
|
||||
if ($login) {
|
||||
if (!is_array($login)) {
|
||||
$login = Player::parseLogin($login);
|
||||
}
|
||||
try {
|
||||
return $this->maniaControl->getClient()->chatSendServerMessage($chatMessage, $login, $multiCall);
|
||||
} catch (UnknownPlayerException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->maniaControl->getClient()->chatSendServerMessage($chatMessage, null, $multiCall);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the chat message prefix
|
||||
*
|
||||
@ -133,123 +99,6 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an Error Message to all Connected Admins
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $minLevel
|
||||
* @param bool $prefix
|
||||
*/
|
||||
public function sendErrorToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) {
|
||||
$format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_ERROR);
|
||||
$this->sendMessageToAdmins($format . $message, $minLevel, $prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a Message to all connected Admins
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $minLevel
|
||||
* @param bool|string $prefix
|
||||
* @return bool
|
||||
*/
|
||||
public function sendMessageToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) {
|
||||
$admins = $this->maniaControl->getAuthenticationManager()->getConnectedAdmins($minLevel);
|
||||
return $this->sendChat($message, $admins, $prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a success message to the given login
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $login
|
||||
* @param bool|string $prefix
|
||||
* @return bool
|
||||
*/
|
||||
public function sendSuccess($message, $login = null, $prefix = true) {
|
||||
$format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_SUCCESS);
|
||||
return $this->sendChat($format . $message, $login, $prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a Information Message to all connected Admins
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $minLevel
|
||||
* @param bool|string $prefix
|
||||
* @return bool
|
||||
*/
|
||||
public function sendInformationToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) {
|
||||
$format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_INFORMATION);
|
||||
return $this->sendMessageToAdmins($format . $message, $minLevel, $prefix);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sends a Success Message to all connected Admins
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $minLevel
|
||||
* @param bool|string $prefix
|
||||
* @return bool
|
||||
*/
|
||||
public function sendSuccessToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) {
|
||||
$format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_SUCCESS);
|
||||
return $this->sendMessageToAdmins($format . $message, $minLevel, $prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the Exception Information to the Chat
|
||||
*
|
||||
* @param \Exception $exception
|
||||
* @param string $login
|
||||
* @return bool
|
||||
*/
|
||||
public function sendException(\Exception $exception, $login = null) {
|
||||
$message = "Exception occurred: '{$exception->getMessage()}' ({$exception->getCode()})";
|
||||
return $this->sendError($message, $login);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an Error Message to the Chat
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $login
|
||||
* @param string|bool $prefix
|
||||
* @return bool
|
||||
*/
|
||||
public function sendError($message, $login = null, $prefix = true) {
|
||||
$format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_ERROR);
|
||||
return $this->sendChat($format . $message, $login, $prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a Exception Message to all Connected Admins
|
||||
*
|
||||
* @param \Exception $exception
|
||||
* @param int $minLevel
|
||||
* @param bool|string $prefix
|
||||
*/
|
||||
public function sendExceptionToAdmins(\Exception $exception, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) {
|
||||
$format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_ERROR);
|
||||
$message = $format . "Exception: '{$exception->getMessage()}' ({$exception->getCode()})";
|
||||
$this->sendMessageToAdmins($message, $minLevel, $prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an usage info message to the given login
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $login
|
||||
* @param string|bool $prefix
|
||||
* @return bool
|
||||
*/
|
||||
public function sendUsageInfo($message, $login = null, $prefix = false) {
|
||||
$format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_USAGEINFO);
|
||||
return $this->sendChat($format . $message, $login, $prefix);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handles SendChat Communication Request
|
||||
*
|
||||
@ -317,6 +166,49 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA
|
||||
return new CommunicationAnswer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the given message with the given inputs and colors the inputs.
|
||||
* @param string $message
|
||||
* @param mixed ...$inputs
|
||||
* @return string
|
||||
*/
|
||||
public function formatMessage($message, ...$inputs) {
|
||||
$addMapAuthorLogin = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_MESSAGE_MAP_AUTHOR_LOGIN);
|
||||
$addMapAuthorNickname = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_MESSAGE_MAP_AUTHOR_NICKNAME);
|
||||
$addPlayerLogin = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_MESSAGE_PLAYER_LOGIN);
|
||||
$formatInputColor = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_MESSAGE_INPUT_COLOR);
|
||||
|
||||
$formattedInputs = array($message);
|
||||
foreach ($inputs as $input) {
|
||||
$strInput = null;
|
||||
|
||||
if (is_bool($input)) {
|
||||
$strInput = $input ? 'true' : 'false';
|
||||
} elseif ($input instanceof Map) {
|
||||
$strInput = $input->getEscapedName();
|
||||
if ($addMapAuthorNickname && $input->authorNick) {
|
||||
$strInput .= " (by {$input->authorNick}";
|
||||
if ($addMapAuthorLogin && $input->authorLogin) {
|
||||
$strInput .= " ({$input->authorLogin})";
|
||||
}
|
||||
$strInput .= ")";
|
||||
} elseif ($addMapAuthorLogin && $input->authorLogin) {
|
||||
$strInput .= " (by {$input->authorLogin})";
|
||||
}
|
||||
} elseif ($input instanceof Player) {
|
||||
$strInput = $input->getEscapedNickname();
|
||||
if ($addPlayerLogin && $input->login) {
|
||||
$strInput .= " ({$input->login})";
|
||||
}
|
||||
} else {
|
||||
$strInput = strval($input);
|
||||
}
|
||||
|
||||
array_push($formattedInputs, Formatter::escapeText($formatInputColor . $strInput));
|
||||
}
|
||||
|
||||
return call_user_func_array('sprintf', $formattedInputs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the ChatMessage in the Buffer
|
||||
@ -336,4 +228,165 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA
|
||||
array_shift($this->chatBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a chat message to the given login
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $login
|
||||
* @param string|bool $prefix
|
||||
* @param bool $multiCall
|
||||
* @return bool
|
||||
*/
|
||||
public function sendChat($message, $login = null, $prefix = true, $multiCall = true) {
|
||||
if (!$this->maniaControl->getClient()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$prefix = $this->buildPrefix($prefix, $login);
|
||||
$chatMessage = '$<$z$ff0' . $prefix . $message . '$>';
|
||||
|
||||
if ($login) {
|
||||
if (!is_array($login)) {
|
||||
$login = Player::parseLogin($login);
|
||||
}
|
||||
try {
|
||||
return $this->maniaControl->getClient()->chatSendServerMessage($chatMessage, $login, $multiCall);
|
||||
} catch (UnknownPlayerException $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->maniaControl->getClient()->chatSendServerMessage($chatMessage, null, $multiCall);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an Error Message to all Connected Admins
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $minLevel
|
||||
* @param bool $prefix
|
||||
*/
|
||||
public function sendErrorToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) {
|
||||
$format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_ERROR);
|
||||
$this->sendMessageToAdmins($format . $message, $minLevel, $prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an Error Message to the Chat
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $login
|
||||
* @param string|bool $prefix
|
||||
* @return bool
|
||||
*/
|
||||
public function sendError($message, $login = null, $prefix = true) {
|
||||
$format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_ERROR);
|
||||
return $this->sendChat($format . $message, $login, $prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the Exception Information to the Chat
|
||||
*
|
||||
* @param \Exception $exception
|
||||
* @param string $login
|
||||
* @return bool
|
||||
*/
|
||||
public function sendException(\Exception $exception, $login = null) {
|
||||
$message = "Exception occurred: '{$exception->getMessage()}' ({$exception->getCode()})";
|
||||
return $this->sendError($message, $login);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a Exception Message to all Connected Admins
|
||||
*
|
||||
* @param \Exception $exception
|
||||
* @param int $minLevel
|
||||
* @param bool|string $prefix
|
||||
*/
|
||||
public function sendExceptionToAdmins(\Exception $exception, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) {
|
||||
$format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_ERROR);
|
||||
$message = $format . "Exception: '{$exception->getMessage()}' ({$exception->getCode()})";
|
||||
$this->sendMessageToAdmins($message, $minLevel, $prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an information message to the given login
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $login
|
||||
* @param string|bool $prefix
|
||||
* @param bool $multiCall
|
||||
* @return bool
|
||||
*/
|
||||
public function sendInformation($message, $login = null, $prefix = true, $multiCall = true) {
|
||||
$format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_INFORMATION);
|
||||
return $this->sendChat($format . $message, $login, $prefix, $multiCall);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a Information Message to all connected Admins
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $minLevel
|
||||
* @param bool|string $prefix
|
||||
* @return bool
|
||||
*/
|
||||
public function sendInformationToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) {
|
||||
$format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_INFORMATION);
|
||||
return $this->sendMessageToAdmins($format . $message, $minLevel, $prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a Message to all connected Admins
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $minLevel
|
||||
* @param bool|string $prefix
|
||||
* @return bool
|
||||
*/
|
||||
public function sendMessageToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) {
|
||||
$admins = $this->maniaControl->getAuthenticationManager()->getConnectedAdmins($minLevel);
|
||||
return $this->sendChat($message, $admins, $prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a success message to the given login
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $login
|
||||
* @param bool|string $prefix
|
||||
* @return bool
|
||||
*/
|
||||
public function sendSuccess($message, $login = null, $prefix = true) {
|
||||
$format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_SUCCESS);
|
||||
return $this->sendChat($format . $message, $login, $prefix);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sends a Success Message to all connected Admins
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $minLevel
|
||||
* @param bool|string $prefix
|
||||
* @return bool
|
||||
*/
|
||||
public function sendSuccessToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) {
|
||||
$format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_SUCCESS);
|
||||
return $this->sendMessageToAdmins($format . $message, $minLevel, $prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an usage info message to the given login
|
||||
*
|
||||
* @param string $message
|
||||
* @param string $login
|
||||
* @param string|bool $prefix
|
||||
* @return bool
|
||||
*/
|
||||
public function sendUsageInfo($message, $login = null, $prefix = false) {
|
||||
$format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_USAGEINFO);
|
||||
return $this->sendChat($format . $message, $login, $prefix);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ namespace ManiaControl\Commands;
|
||||
* Interface for Command Listeners
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
interface CommandListener {
|
||||
|
@ -13,7 +13,7 @@ use ManiaControl\ManiaControl;
|
||||
* Class for handling Chat Commands
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CommandManager implements CallbackListener, UsageInformationAble {
|
||||
@ -28,8 +28,12 @@ class CommandManager implements CallbackListener, UsageInformationAble {
|
||||
private $helpManager = array();
|
||||
/** @var Listening[][] $commandListenings */
|
||||
private $commandListenings = array();
|
||||
/** @var CommandListener[][] $disabledCommands */
|
||||
private $disabledCommands = array();
|
||||
/** @var Listening[][] $adminCommandListenings */
|
||||
private $adminCommandListenings = array();
|
||||
/** @var CommandListener[][] $disabledAdminCommands */
|
||||
private $disabledAdminCommands = array();
|
||||
|
||||
/**
|
||||
* Construct a new Commands Manager
|
||||
@ -116,6 +120,138 @@ class CommandManager implements CallbackListener, UsageInformationAble {
|
||||
array_push($listeningsArray[$command], $listening);
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the command(s) by the given listener.
|
||||
* The specific listener has to also manually reenable the commands, before the command can be used again.
|
||||
* @param mixed $commandName
|
||||
* @param bool $adminCommand
|
||||
* @param CommandListener $listener
|
||||
*/
|
||||
public function disableCommand($commandName, $adminCommand, CommandListener $listener) {
|
||||
if (is_array($commandName)) {
|
||||
foreach ($commandName as $command) {
|
||||
$this->disableCommand($command, $adminCommand, $listener);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$command = strtolower(trim($commandName));
|
||||
// first, check if the command actually exists
|
||||
if (!array_key_exists($command, $this->commandListenings) && !array_key_exists($command, $this->adminCommandListenings)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$disabledCommands = null;
|
||||
if ($adminCommand) {
|
||||
$disabledCommands = &$this->disabledAdminCommands;
|
||||
} else {
|
||||
$disabledCommands = &$this->disabledCommands;
|
||||
}
|
||||
|
||||
if (!array_key_exists($command, $disabledCommands)) {
|
||||
$disabledCommands[$command] = array();
|
||||
}
|
||||
|
||||
if (!in_array($listener, $disabledCommands[$command])) {
|
||||
array_push($disabledCommands[$command], $listener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the command(s) by the given listener.
|
||||
* @param mixed $commandName
|
||||
* @param bool $adminCommand
|
||||
* @param CommandListener $listener
|
||||
*/
|
||||
public function enableCommand($commandName, $adminCommand, CommandListener $listener) {
|
||||
if (is_array($commandName)) {
|
||||
foreach ($commandName as $command) {
|
||||
$this->enableCommand($command, $adminCommand, $listener);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$command = strtolower(trim($commandName));
|
||||
|
||||
$disabledCommands = null;
|
||||
if ($adminCommand) {
|
||||
$disabledCommands = &$this->disabledAdminCommands;
|
||||
} else {
|
||||
$disabledCommands = &$this->disabledCommands;
|
||||
}
|
||||
|
||||
if (!array_key_exists($command, $disabledCommands)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (($key = array_search($listener, $disabledCommands[$command])) !== false) {
|
||||
unset($disabledCommands[$command][$key]);
|
||||
if (empty($disabledCommands[$command])) {
|
||||
unset($disabledCommands[$command]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a command is enabled.
|
||||
* @param mixed $commandName
|
||||
* @param bool $adminCommand
|
||||
* @return bool|array
|
||||
*/
|
||||
public function isCommandEnabled($commandName, $adminCommand) {
|
||||
if (is_array($commandName)) {
|
||||
$results = array();
|
||||
foreach ($commandName as $command) {
|
||||
array_push($results, $this->isCommandEnabled($command, $adminCommand));
|
||||
}
|
||||
$resultsUnique = array_unique($results);
|
||||
if (count($resultsUnique) === 1) {
|
||||
return $resultsUnique[0];
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
$command = strtolower(trim($commandName));
|
||||
|
||||
$disabledCommands = null;
|
||||
if ($adminCommand) {
|
||||
$disabledCommands = &$this->disabledAdminCommands;
|
||||
} else {
|
||||
$disabledCommands = &$this->disabledCommands;
|
||||
}
|
||||
|
||||
if (!array_key_exists($command, $disabledCommands)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// if the command is disabled, there should be at least one listener in the array
|
||||
assert(!empty($disabledCommands[$command]));
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the given CommandListener blocking commands.
|
||||
*
|
||||
* @param array &$disabledCommands
|
||||
* @param CommandListener $listener
|
||||
* @return bool
|
||||
*/
|
||||
private function removeDisabledCommandListener(array &$disabledCommands, CommandListener $listener) {
|
||||
$removed = false;
|
||||
foreach ($disabledCommands as $command => $disableListeners) {
|
||||
if (($key = array_search($listener, $disableListeners)) !== false) {
|
||||
unset($disabledCommands[$command][$key]);
|
||||
$removed = true;
|
||||
|
||||
if (empty($disabledCommands[$command])) {
|
||||
unset($disabledCommands[$command]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $removed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a Command Listener
|
||||
*
|
||||
@ -130,6 +266,12 @@ class CommandManager implements CallbackListener, UsageInformationAble {
|
||||
if ($this->removeCommandListener($this->adminCommandListenings, $listener)) {
|
||||
$removed = true;
|
||||
}
|
||||
if ($this->removeDisabledCommandListener($this->disabledCommands, $listener)) {
|
||||
$removed = true;
|
||||
}
|
||||
if ($this->removeDisabledCommandListener($this->disabledAdminCommands, $listener)) {
|
||||
$removed = true;
|
||||
}
|
||||
return $removed;
|
||||
}
|
||||
|
||||
@ -178,9 +320,11 @@ class CommandManager implements CallbackListener, UsageInformationAble {
|
||||
if (!$command) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$isAdminCommand = null;
|
||||
if (substr($message, 0, 2) === '//' || $command === 'admin') {
|
||||
// Admin command
|
||||
$isAdminCommand = true;
|
||||
$commandListenings = $this->adminCommandListenings;
|
||||
|
||||
if ($command === 'admin') {
|
||||
@ -197,6 +341,7 @@ class CommandManager implements CallbackListener, UsageInformationAble {
|
||||
$callback[1][2] = $message;
|
||||
} else {
|
||||
// User command
|
||||
$isAdminCommand = false;
|
||||
$commandListenings = $this->commandListenings;
|
||||
}
|
||||
|
||||
@ -205,6 +350,17 @@ class CommandManager implements CallbackListener, UsageInformationAble {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->isCommandEnabled($command, $isAdminCommand)) {
|
||||
$prefix = $isAdminCommand ? '//' : '/';
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
'The command %s%s is currently disabled!',
|
||||
$prefix,
|
||||
$command
|
||||
);
|
||||
$this->maniaControl->getChat()->sendError($message, $player);
|
||||
return;
|
||||
}
|
||||
|
||||
// Inform command listeners
|
||||
foreach ($commandListenings[$command] as $listening) {
|
||||
/** @var Listening $listening */
|
||||
|
@ -19,7 +19,7 @@ use ManiaControl\Players\Player;
|
||||
* ManiaControl Help Manager Class
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class HelpManager implements CommandListener, CallbackListener, ManialinkPageAnswerListener {
|
||||
@ -53,7 +53,7 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns
|
||||
$this->maniaControl->getActionsMenu()->addMenuItem($itemQuad, true, 0, 'Available commands');
|
||||
$itemQuad = clone $itemQuad;
|
||||
$itemQuad->setAction(self::ACTION_OPEN_ADMIN_HELP_ALL);
|
||||
$this->maniaControl->getActionsMenu()->addAdminMenuItem($itemQuad,0,'Available admin commands');
|
||||
$this->maniaControl->getActionsMenu()->addAdminMenuItem($itemQuad, 0, 'Available admin commands');
|
||||
|
||||
// Callbacks
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
|
||||
@ -79,9 +79,13 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns
|
||||
// Parse list from array
|
||||
$message = $this->parseHelpList($this->adminCommands);
|
||||
|
||||
// Show message when it's not empty
|
||||
if ($message != null) {
|
||||
$message = 'Supported Admin Commands: ' . $message;
|
||||
if ($message === null) {
|
||||
$this->maniaControl->getChat()->sendError('No Admin Commands supported!', $player);
|
||||
} else {
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
'Supported Admin Commands: %s',
|
||||
$message
|
||||
);
|
||||
$this->maniaControl->getChat()->sendChat($message, $player);
|
||||
}
|
||||
}
|
||||
@ -96,13 +100,27 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns
|
||||
// Parse list from array
|
||||
$message = $this->parseHelpList($this->playerCommands);
|
||||
|
||||
// Show message when it's not empty
|
||||
if ($message != null) {
|
||||
$message = 'Supported Player Commands: ' . $message;
|
||||
if ($message === null) {
|
||||
$this->maniaControl->getChat()->sendError('No Player Commands supported!', $player);
|
||||
} else {
|
||||
$message = $this->maniaControl->getChat()->formatMessage(
|
||||
'Supported Player Commands: %s',
|
||||
$message
|
||||
);
|
||||
$this->maniaControl->getChat()->sendChat($message, $player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a ManiaLink list of Admin Commands
|
||||
*
|
||||
* @param array $chatCallback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_adminHelpAll(array $chatCallback, Player $player) {
|
||||
$this->parseHelpList($this->adminCommands, true, $player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a ManiaLink list of Player Commands
|
||||
*
|
||||
@ -120,8 +138,8 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns
|
||||
* @param \ManiaControl\Players\Player $player
|
||||
* @internal
|
||||
*/
|
||||
public function maniaLink_helpAll(array $callback, Player $player) {
|
||||
$this->parseHelpList($this->playerCommands, true, $player);
|
||||
public function maniaLink_adminHelpAll(array $callback, Player $player){
|
||||
$this->parseHelpList($this->adminCommands,true, $player);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -131,8 +149,8 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns
|
||||
* @param \ManiaControl\Players\Player $player
|
||||
* @internal
|
||||
*/
|
||||
public function maniaLink_adminHelpAll(array $callback, Player $player){
|
||||
$this->parseHelpList($this->adminCommands,true, $player);
|
||||
public function maniaLink_helpAll(array $callback, Player $player) {
|
||||
$this->parseHelpList($this->playerCommands, true, $player);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -185,7 +203,7 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns
|
||||
* @param array $commands
|
||||
* @param mixed $player
|
||||
*/
|
||||
public function showHelpAllList(array $commands, $player) {
|
||||
public function showHelpAllList(array $commands, $player) {
|
||||
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
||||
|
||||
@ -254,16 +272,6 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns
|
||||
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'HelpAllList');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a ManiaLink list of Admin Commands
|
||||
*
|
||||
* @param array $chatCallback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function command_adminHelpAll(array $chatCallback, Player $player) {
|
||||
$this->parseHelpList($this->adminCommands, true, $player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new Command
|
||||
*
|
||||
@ -273,6 +281,7 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns
|
||||
* @param string $method
|
||||
*/
|
||||
public function registerCommand($name, $adminCommand = false, $description = '', $method) {
|
||||
// TODO replace with new class Command
|
||||
if ($adminCommand) {
|
||||
array_push($this->adminCommands, array("Name" => $name, "Description" => $description, "Method" => $method));
|
||||
} else {
|
||||
|
@ -7,7 +7,7 @@ namespace ManiaControl\Communication;
|
||||
* to call @see \ManiaControl\Communication\CommunicationManager::createCommunication()
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class Communication {
|
||||
|
@ -6,7 +6,7 @@ namespace ManiaControl\Communication;
|
||||
* Class for Answer of Communication Request
|
||||
*
|
||||
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||
* @copyright 2014-2019 ManiaControl Team
|
||||
* @copyright 2014-2020 ManiaControl Team
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
class CommunicationAnswer {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user