Merge pull request #2 from ManiaControl/master

sync fork
This commit is contained in:
jonthekiller 2020-07-31 19:03:04 +02:00 committed by GitHub
commit 9c256643fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
206 changed files with 5026 additions and 2186 deletions

14
.gitignore vendored
View File

@ -1,8 +1,12 @@
.idea .*
*.iml !/.git
/configs/server.xml !/.gitignore
!/.idea
/configs/*
!/configs/server.default.xml
/logs/ /logs/
/ManiaControl.log /ManiaControl.log
/ManiaControl.pid /ManiaControl.pid
!/.idea/encodings.xml !/plugins/
!/.idea/codeStyleSettings.xml /plugins/*
!/plugins/MCTeam/

View File

@ -3,7 +3,7 @@
* ManiaControl Server Controller for ManiaPlanet Server * ManiaControl Server Controller for ManiaPlanet Server
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */

0
ManiaControl.sh Normal file → Executable file
View File

View File

@ -1,9 +1,144 @@
##v0.16x### ###v0.255###
# Additions #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 - updated mx links to https
# Changes
#Changes
- CommunicationMethod SET_SERVER_OPTIONS sets the changed values also in database on call - 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### ###v0.163###
#Additions #Additions
@ -12,7 +147,7 @@
- added Scriptcallbacks SCORESREADY / SCORES - added Scriptcallbacks SCORESREADY / SCORES
- added SSL support as well as http Redirections of the FileReader - added SSL support as well as http Redirections of the FileReader
# Bug fixes #Bug Fixes
- Banning of not connected Players now possible - Banning of not connected Players now possible
###v0.162### ###v0.162###

View File

@ -27,7 +27,7 @@ use ManiaControl\Settings\SettingManager;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class ActionsMenu implements SidebarMenuEntryListener, CallbackListener, ManialinkPageAnswerListener, UsageInformationAble { class ActionsMenu implements SidebarMenuEntryListener, CallbackListener, ManialinkPageAnswerListener, UsageInformationAble {

View File

@ -26,7 +26,7 @@ use ManiaControl\Players\Player;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class AdminLists implements ManialinkPageAnswerListener, CallbackListener, UsageInformationAble { class AdminLists implements ManialinkPageAnswerListener, CallbackListener, UsageInformationAble {

View File

@ -12,7 +12,7 @@ use ManiaControl\Players\Player;
* Class offering Commands to grant Authorizations to Players * Class offering Commands to grant Authorizations to Players
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class AuthCommands implements CommandListener, UsageInformationAble { 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.'); $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 * Handle //addsuperadmin command
* *
@ -48,39 +99,7 @@ class AuthCommands implements CommandListener, UsageInformationAble {
* @param Player $player * @param Player $player
*/ */
public function command_AddSuperAdmin(array $chatCallback, Player $player) { public function command_AddSuperAdmin(array $chatCallback, Player $player) {
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)) { $this->command_Add($chatCallback, $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->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);
} }
/** /**
@ -91,39 +110,7 @@ class AuthCommands implements CommandListener, UsageInformationAble {
* @param Player $player * @param Player $player
*/ */
public function command_AddAdmin(array $chatCallback, Player $player) { public function command_AddAdmin(array $chatCallback, Player $player) {
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) { $this->command_Add($chatCallback, $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->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);
} }
/** /**
@ -134,42 +121,9 @@ class AuthCommands implements CommandListener, UsageInformationAble {
* @param Player $player * @param Player $player
*/ */
public function command_AddModerator(array $chatCallback, Player $player) { public function command_AddModerator(array $chatCallback, Player $player) {
if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) { $this->command_Add($chatCallback, $player, AuthenticationManager::AUTH_LEVEL_MODERATOR);
$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);
} }
/**
* 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 * Handle //removerights command
* *
@ -178,44 +132,55 @@ class AuthCommands implements CommandListener, UsageInformationAble {
* @param Player $player * @param Player $player
*/ */
public function command_RemoveRights(array $chatCallback, 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]; $text = $chatCallback[1][2];
$commandParts = explode(' ', $text); $commandParts = explode(' ', $text);
if (!array_key_exists(1, $commandParts)) { 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; return;
} }
$target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]); $target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]);
if (!$target) { 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; return;
} }
if ($target->authLevel == AuthenticationManager::AUTH_LEVEL_MASTERADMIN) { if ($target->authLevel >= AuthenticationManager::AUTH_LEVEL_MASTERADMIN) {
$this->maniaControl->getChat()->sendError("You can't remove an MasterAdmin from the Adminlists", $player); $this->maniaControl->getChat()->sendError('You cannot remove rights of a MasterAdmin!', $player);
return; 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); $success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_PLAYER);
if (!$success) { if (!$success) {
$this->maniaControl->getChat()->sendError('Error occurred.', $player); $this->maniaControl->getChat()->sendError('Error occurred!', $player);
return; 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); $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);
}
} }

View File

@ -14,6 +14,7 @@ use ManiaControl\Logger;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
use ManiaControl\Players\PlayerManager; use ManiaControl\Players\PlayerManager;
use ManiaControl\Plugins\Plugin;
use ManiaControl\Settings\Setting; use ManiaControl\Settings\Setting;
/** /**
@ -21,7 +22,7 @@ use ManiaControl\Settings\Setting;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class AuthenticationManager implements CallbackListener, EchoListener, CommunicationListener, UsageInformationAble { class AuthenticationManager implements CallbackListener, EchoListener, CommunicationListener, UsageInformationAble {
@ -133,8 +134,10 @@ class AuthenticationManager implements CallbackListener, EchoListener, Communica
return self::AUTH_NAME_ADMIN; return self::AUTH_NAME_ADMIN;
case self::AUTH_LEVEL_MODERATOR: case self::AUTH_LEVEL_MODERATOR:
return self::AUTH_NAME_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; return self::AUTH_LEVEL_ADMIN;
case self::AUTH_NAME_MODERATOR: case self::AUTH_NAME_MODERATOR:
return self::AUTH_LEVEL_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) { public function checkPermission(Player $player, $rightName) {
$right = $this->maniaControl->getSettingManager()->getSettingValue($this, $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 * @api
* @param string $rightName * @param string $rightName
* @param int $authLevelNeeded * @param int $authLevelNeeded
* @param string $authLevelsAllowed
*/ */
public function definePermissionLevel($rightName, $authLevelNeeded) { public function definePermissionLevel($rightName, $authLevelNeeded, $authLevelsAllowed = self::AUTH_LEVEL_MODERATOR) {
$this->maniaControl->getSettingManager()->initSetting($this, $rightName, self::getPermissionLevelNameArray($authLevelNeeded)); $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 * @api
* @param $authLevelNeeded * @param $authLevelNeeded
* @param $authLevelsAllowed
* @return array[] * @return array[]
*/ */
public static function getPermissionLevelNameArray($authLevelNeeded) { public static function getPermissionLevelNameArray($authLevelNeeded, $authLevelsAllowed = self::AUTH_LEVEL_MODERATOR) {
switch ($authLevelNeeded) { 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: 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: 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: 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: 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("-"); return array("-");
} }
} }

View 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);
}
}

View File

@ -6,7 +6,7 @@ namespace ManiaControl;
* ManiaControl AutoLoader * ManiaControl AutoLoader
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
abstract class AutoLoader { abstract class AutoLoader {

View File

@ -16,7 +16,7 @@ use Maniaplanet\DedicatedServer\Structures\Bill;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class BillManager implements CallbackListener, UsageInformationAble { class BillManager implements CallbackListener, UsageInformationAble {

View 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 {
}

View 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;
}
}

View 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();
}
}
}

View File

@ -6,7 +6,7 @@ namespace ManiaControl\Callbacks;
* Interface for Callback Listener * Interface for Callback Listener
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
interface CallbackListener { interface CallbackListener {

View File

@ -15,7 +15,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException;
* Class for managing Server and ManiaControl Callbacks * Class for managing Server and ManiaControl Callbacks
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class CallbackManager implements UsageInformationAble { class CallbackManager implements UsageInformationAble {
@ -31,6 +31,8 @@ class CallbackManager implements UsageInformationAble {
const CB_MP_ENDMATCH = 'ManiaPlanet.EndMatch'; const CB_MP_ENDMATCH = 'ManiaPlanet.EndMatch';
const CB_MP_BEGINMAP = 'ManiaPlanet.BeginMap'; const CB_MP_BEGINMAP = 'ManiaPlanet.BeginMap';
const CB_MP_ENDMAP = 'ManiaPlanet.EndMap'; 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_MAPLISTMODIFIED = 'ManiaPlanet.MapListModified';
const CB_MP_ECHO = 'ManiaPlanet.Echo'; const CB_MP_ECHO = 'ManiaPlanet.Echo';
const CB_MP_BILLUPDATED = 'ManiaPlanet.BillUpdated'; const CB_MP_BILLUPDATED = 'ManiaPlanet.BillUpdated';
@ -61,6 +63,8 @@ class CallbackManager implements UsageInformationAble {
/** @var ManiaControl $maniaControl */ /** @var ManiaControl $maniaControl */
private $maniaControl = null; private $maniaControl = null;
/** @var Listening[] $adhocCallbacks */
private $adhocCallbacks = array();
/** @var Listening[][] $callbackListenings */ /** @var Listening[][] $callbackListenings */
private $callbackListenings = array(); private $callbackListenings = array();
/** @var Listening[][] $scriptCallbackListenings */ /** @var Listening[][] $scriptCallbackListenings */
@ -219,6 +223,42 @@ class CallbackManager implements UsageInformationAble {
return $this->removeCallbackListener($this->scriptCallbackListenings, $listener); 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 * Trigger internal Callbacks and manage Server Callbacks
*/ */
@ -251,6 +291,8 @@ class CallbackManager implements UsageInformationAble {
foreach ($callbacks as $key => $callback) { foreach ($callbacks as $key => $callback) {
$time1 = microtime(true); $time1 = microtime(true);
$this->handleCallback($callback); $this->handleCallback($callback);
// manage any callbacks added by the previous callback
$this->manageAdhocCallbacks();
$timings[$key] = array($callback[0], microtime(true) - $time1); $timings[$key] = array($callback[0], microtime(true) - $time1);
} }
@ -312,7 +354,6 @@ class CallbackManager implements UsageInformationAble {
* @param mixed $callbackName * @param mixed $callbackName
*/ */
public function triggerCallback($callbackName) { public function triggerCallback($callbackName) {
if (!$this->callbackListeningExists($callbackName)) { if (!$this->callbackListeningExists($callbackName)) {
return; return;
} }

View File

@ -6,7 +6,7 @@ namespace ManiaControl\Callbacks;
* Callbacks Interface * Callbacks Interface
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
interface Callbacks { interface Callbacks {
@ -16,7 +16,9 @@ interface Callbacks {
const ONINIT = 'Callbacks.OnInit'; const ONINIT = 'Callbacks.OnInit';
const AFTERINIT = 'Callbacks.AfterInit'; const AFTERINIT = 'Callbacks.AfterInit';
const ONSHUTDOWN = 'Callbacks.OnShutdown'; const ONSHUTDOWN = 'Callbacks.OnShutdown';
/** @deprecated */
const ONRESTART = 'Callbacks.OnRestart'; const ONRESTART = 'Callbacks.OnRestart';
const ONREBOOT = 'Callbacks.OnReboot';
const PRELOOP = 'Callbacks.PreLoop'; const PRELOOP = 'Callbacks.PreLoop';
const AFTERLOOP = 'Callbacks.AfterLoop'; const AFTERLOOP = 'Callbacks.AfterLoop';

View File

@ -5,7 +5,7 @@ namespace ManiaControl\Callbacks;
* Interface for EchoListener * Interface for EchoListener
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
interface EchoListener { interface EchoListener {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* Class for managing Echo Callbacks * Class for managing Echo Callbacks
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class EchoManager implements CallbackListener, EchoListener, UsageInformationAble { class EchoManager implements CallbackListener, EchoListener, UsageInformationAble {
@ -143,8 +143,9 @@ class EchoManager implements CallbackListener, EchoListener, UsageInformationAbl
} }
switch ($name) { switch ($name) {
case 'ManiaControl.Restart': case Callbacks::ONRESTART:
$this->maniaControl->restart($message); case Callbacks::ONREBOOT:
$this->maniaControl->reboot($message);
break; break;
default: default:
$this->triggerEchoCallback($name, $message); $this->triggerEchoCallback($name, $message);

View File

@ -25,7 +25,7 @@ use ManiaControl\ManiaControl;
* Class converting LibXmlRpc Callbacks * Class converting LibXmlRpc Callbacks
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class LibXmlRpcCallbacks implements CallbackListener { class LibXmlRpcCallbacks implements CallbackListener {

View File

@ -9,7 +9,7 @@ use ManiaControl\General\UsageInformationTrait;
* Model Class for a Basic Listening * Model Class for a Basic Listening
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class Listening implements UsageInformationAble { class Listening implements UsageInformationAble {

View File

@ -36,7 +36,7 @@ use ManiaControl\ManiaControl;
* Class handling and parsing ShootMania Callbacks * Class handling and parsing ShootMania Callbacks
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class ShootManiaCallbacks implements CallbackListener { class ShootManiaCallbacks implements CallbackListener {

View File

@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class BasePlayerTimeStructure extends BaseTimeStructure { class BasePlayerTimeStructure extends BaseTimeStructure {

View File

@ -9,7 +9,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class BaseResponseStructure extends BaseStructure { class BaseResponseStructure extends BaseStructure {

View File

@ -14,7 +14,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
abstract class BaseStructure implements UsageInformationAble, JsonSerializable { abstract class BaseStructure implements UsageInformationAble, JsonSerializable {

View File

@ -9,7 +9,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class BaseTimeStructure extends BaseStructure { class BaseTimeStructure extends BaseStructure {

View File

@ -3,8 +3,6 @@
namespace ManiaControl\Callbacks\Structures\Common; namespace ManiaControl\Callbacks\Structures\Common;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
/** /**
@ -12,7 +10,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class CommonCommandStructure extends BaseTimeStructure { class CommonCommandStructure extends BaseTimeStructure {

View File

@ -3,7 +3,6 @@
namespace ManiaControl\Callbacks\Structures\ShootMania; namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure; use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
@ -12,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class CommonDefaultEventStructure extends BaseTimeStructure { class CommonDefaultEventStructure extends BaseTimeStructure {

View File

@ -5,8 +5,6 @@ namespace ManiaControl\Callbacks\Structures\Common;
use ManiaControl\Callbacks\Structures\Common\Models\CommonPlayerScore; use ManiaControl\Callbacks\Structures\Common\Models\CommonPlayerScore;
use ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore; use ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore;
use ManiaControl\General\JsonSerializable;
use ManiaControl\General\JsonSerializeTrait;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
/** /**
@ -14,7 +12,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class CommonScoresStructure extends BaseResponseStructure { class CommonScoresStructure extends BaseResponseStructure {

View File

@ -14,7 +14,7 @@ use ManiaControl\Players\Player;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class CommonPlayerScore implements UsageInformationAble, JsonSerializable { class CommonPlayerScore implements UsageInformationAble, JsonSerializable {

View File

@ -12,7 +12,7 @@ use ManiaControl\General\UsageInformationTrait;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class CommonTeamScore implements UsageInformationAble, JsonSerializable { class CommonTeamScore implements UsageInformationAble, JsonSerializable {

View File

@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class StatusCallbackStructure extends BaseResponseStructure { class StatusCallbackStructure extends BaseResponseStructure {

View File

@ -9,7 +9,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class UIPropertiesBaseStructure extends BaseResponseStructure { class UIPropertiesBaseStructure extends BaseResponseStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class LoadingUnloadingMapStructure extends BaseTimeStructure { class LoadingUnloadingMapStructure extends BaseTimeStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class ModeUseTeamsStructure extends BaseResponseStructure { class ModeUseTeamsStructure extends BaseResponseStructure {

View File

@ -3,7 +3,7 @@
namespace ManiaControl\Callbacks\Structures\ManiaPlanet; namespace ManiaControl\Callbacks\Structures\ManiaPlanet;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure; use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
@ -12,7 +12,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class StartEndStructure extends BaseTimeStructure { class StartEndStructure extends BaseTimeStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class StartServerStructure extends BaseStructure { class StartServerStructure extends BaseStructure {

View File

@ -17,7 +17,7 @@ use ManiaControl\General\UsageInformationTrait;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class JoustScore implements UsageInformationAble { class JoustScore implements UsageInformationAble {

View File

@ -11,7 +11,7 @@ use ManiaControl\General\UsageInformationTrait;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class Landmark implements UsageInformationAble { class Landmark implements UsageInformationAble {

View File

@ -10,7 +10,7 @@ use ManiaControl\Callbacks\Structures\Common\Models\CommonPlayerScore;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class PlayerScore extends CommonPlayerScore { class PlayerScore extends CommonPlayerScore {

View File

@ -11,7 +11,7 @@ use ManiaControl\General\UsageInformationTrait;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class Position implements UsageInformationAble { class Position implements UsageInformationAble {

View File

@ -7,7 +7,7 @@ namespace ManiaControl\Callbacks\Structures\ShootMania\Models;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
interface RoyalPointTypes { interface RoyalPointTypes {

View File

@ -9,7 +9,7 @@ use ManiaControl\Callbacks\Structures\Common\Models\CommonTeamScore;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class TeamScore extends CommonTeamScore { class TeamScore extends CommonTeamScore {

View File

@ -7,7 +7,7 @@ namespace ManiaControl\Callbacks\Structures\ShootMania\Models;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
interface VictoryTypes { interface VictoryTypes {

View File

@ -7,7 +7,7 @@ namespace ManiaControl\Callbacks\Structures\ShootMania\Models;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
interface Weapons { interface Weapons {

View File

@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnAFKPropertiesStructure extends BaseResponseStructure { class OnAFKPropertiesStructure extends BaseResponseStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnActionCustomEventStructure extends BaseStructure { class OnActionCustomEventStructure extends BaseStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnActionEvent extends BaseStructure { class OnActionEvent extends BaseStructure {

View File

@ -2,14 +2,14 @@
namespace ManiaControl\Callbacks\Structures\ShootMania; namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\ManiaControl;
/** /**
* Structure Class for the OnArmorEmpty Structure Callback * Structure Class for the OnArmorEmpty Structure Callback
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnArmorEmptyStructure extends OnHitNearMissArmorEmptyBaseStructure { class OnArmorEmptyStructure extends OnHitNearMissArmorEmptyBaseStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnBasePlayerObjectTimeStructure extends BasePlayerTimeStructure { class OnBasePlayerObjectTimeStructure extends BasePlayerTimeStructure {

View File

@ -4,8 +4,8 @@ namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure; 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\ManiaControl;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
@ -14,7 +14,7 @@ use ManiaControl\Players\Player;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnCaptureStructure extends BaseStructure { class OnCaptureStructure extends BaseStructure {

View File

@ -10,7 +10,7 @@ use ManiaControl\Callbacks\Structures\Common\CommonCommandStructure;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnCommandStructure extends CommonCommandStructure { class OnCommandStructure extends CommonCommandStructure {

View File

@ -3,15 +3,15 @@
namespace ManiaControl\Callbacks\Structures\ShootMania; namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\ManiaControl;
/** /**
* Structure Class for the Default Event Structure Callback * Structure Class for the Default Event Structure Callback
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnDefaultEventStructure extends CommonDefaultEventStructure { class OnDefaultEventStructure extends CommonDefaultEventStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnEliteEndTurnStructure extends BaseStructure { class OnEliteEndTurnStructure extends BaseStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnEliteStartTurnStructure extends BaseStructure { class OnEliteStartTurnStructure extends BaseStructure {

View File

@ -12,7 +12,7 @@ use ManiaControl\Players\Player;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnFallDamageStructure extends BaseStructure { class OnFallDamageStructure extends BaseStructure {

View File

@ -14,7 +14,7 @@ use ManiaControl\Players\Player;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnHitNearMissArmorEmptyBaseStructure extends BaseStructure { class OnHitNearMissArmorEmptyBaseStructure extends BaseStructure {

View File

@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnHitStructure extends OnHitNearMissArmorEmptyBaseStructure { class OnHitStructure extends OnHitNearMissArmorEmptyBaseStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnJoustReloadStructure extends BaseStructure { class OnJoustReloadStructure extends BaseStructure {

View File

@ -13,7 +13,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnJoustRoundResultsStructure extends BaseStructure { class OnJoustRoundResultsStructure extends BaseStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnJoustSelectedPlayersStructure extends BaseStructure { class OnJoustSelectedPlayersStructure extends BaseStructure {

View File

@ -3,14 +3,14 @@
namespace ManiaControl\Callbacks\Structures\ShootMania; namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\ManiaControl;
/** /**
* Structure Class for the OnNearMiss Structure Callback * Structure Class for the OnNearMiss Structure Callback
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnNearMissStructure extends OnHitNearMissArmorEmptyBaseStructure { class OnNearMissStructure extends OnHitNearMissArmorEmptyBaseStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnPlayerRequestActionChange extends BasePlayerTimeStructure { class OnPlayerRequestActionChange extends BasePlayerTimeStructure {

View File

@ -4,16 +4,14 @@ namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BasePlayerTimeStructure; 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 * Structure Class for the OnPlayerRequestRespawnStructure Structure Callback
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnPlayerRequestRespawnStructure extends BasePlayerTimeStructure { class OnPlayerRequestRespawnStructure extends BasePlayerTimeStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnPlayerTriggersSectorStructure extends BasePlayerTimeStructure { class OnPlayerTriggersSectorStructure extends BasePlayerTimeStructure {

View File

@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnPlayersAFKStructure extends BaseStructure { class OnPlayersAFKStructure extends BaseStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnRoyalPlayerSpawnStructure extends BaseStructure { class OnRoyalPlayerSpawnStructure extends BaseStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnRoyalPointsStructure extends BaseStructure { class OnRoyalPointsStructure extends BaseStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnRoyalRoundWinnerStructure extends BaseStructure { class OnRoyalRoundWinnerStructure extends BaseStructure {

View File

@ -5,7 +5,7 @@ namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\CommonScoresStructure; use ManiaControl\Callbacks\Structures\Common\CommonScoresStructure;
use ManiaControl\Callbacks\Structures\ShootMania\Models\PlayerScore; use ManiaControl\Callbacks\Structures\ShootMania\Models\PlayerScore;
use ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
@ -13,7 +13,7 @@ use ManiaControl\ManiaControl;
* Structure Class for the Shootmania OnScores Structure Callback * Structure Class for the Shootmania OnScores Structure Callback
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnScoresStructure extends CommonScoresStructure { class OnScoresStructure extends CommonScoresStructure {

View File

@ -3,7 +3,7 @@
namespace ManiaControl\Callbacks\Structures\ShootMania; namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure; use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
@ -13,7 +13,7 @@ use ManiaControl\Players\Player;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnShootStructure extends BaseTimeStructure { class OnShootStructure extends BaseTimeStructure {

View File

@ -3,7 +3,7 @@
namespace ManiaControl\Callbacks\Structures\ShootMania; namespace ManiaControl\Callbacks\Structures\ShootMania;
use ManiaControl\Callbacks\Structures\Common\BaseStructure;
use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure; use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
@ -13,7 +13,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnShotDenyStructure extends BaseTimeStructure { class OnShotDenyStructure extends BaseTimeStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\Callbacks\Structures\Common\Models\CommonPlayerScore;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class PlayerScore extends CommonPlayerScore { class PlayerScore extends CommonPlayerScore {

View File

@ -9,7 +9,7 @@ use ManiaControl\Callbacks\Structures\Common\Models\CommonTeamScore;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class TeamScore extends CommonTeamScore { class TeamScore extends CommonTeamScore {

View File

@ -10,7 +10,7 @@ use ManiaControl\Callbacks\Structures\Common\CommonCommandStructure;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnCommandStructure extends CommonCommandStructure { class OnCommandStructure extends CommonCommandStructure {

View File

@ -3,17 +3,17 @@
namespace ManiaControl\Callbacks\Structures\TrackMania; 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\Callbacks\Structures\ShootMania\CommonDefaultEventStructure;
use ManiaControl\ManiaControl;
/** /**
* Structure Class for the Default Event Structure Callback * Structure Class for the Default Event Structure Callback
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnDefaultEventStructure extends CommonDefaultEventStructure { class OnDefaultEventStructure extends CommonDefaultEventStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnPointsRepartitionStructure extends BaseResponseStructure { class OnPointsRepartitionStructure extends BaseResponseStructure {

View File

@ -6,14 +6,14 @@ namespace ManiaControl\Callbacks\Structures\TrackMania;
use ManiaControl\Callbacks\Models\RecordCallback; use ManiaControl\Callbacks\Models\RecordCallback;
use ManiaControl\Callbacks\Structures\Common\BasePlayerTimeStructure; use ManiaControl\Callbacks\Structures\Common\BasePlayerTimeStructure;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Utils\Formatter;
/** /**
* Structure Class for the On Respawn Structure Callback * Structure Class for the On Respawn Structure Callback
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnRespawnStructure extends BasePlayerTimeStructure { class OnRespawnStructure extends BasePlayerTimeStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnScoresStructure extends CommonScoresStructure { class OnScoresStructure extends CommonScoresStructure {
@ -38,10 +38,18 @@ class OnScoresStructure extends CommonScoresStructure {
$playerScore->setBestRaceTime($jsonPlayer->bestracetime); $playerScore->setBestRaceTime($jsonPlayer->bestracetime);
$playerScore->setBestLapTime($jsonPlayer->bestlaptime); $playerScore->setBestLapTime($jsonPlayer->bestlaptime);
$playerScore->setStuntScore($jsonPlayer->stuntsscore); $playerScore->setStuntScore($jsonPlayer->stuntsscore);
$playerScore->setBestRaceRespawns($jsonPlayer->bestracerespawns);
$playerScore->setBestRaceCheckpoints($jsonPlayer->bestracecheckpoints); $playerScore->setBestRaceCheckpoints($jsonPlayer->bestracecheckpoints);
$playerScore->setBestLapRespawns($jsonPlayer->bestlaprespawns);
$playerScore->setBestLapCheckpoints($jsonPlayer->bestlapcheckpoints); $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 //New attributes in 2.5.0
if (property_exists($jsonPlayer, 'prevracetime')) { if (property_exists($jsonPlayer, 'prevracetime')) {
$playerScore->setPrevRaceTime($jsonPlayer->prevracetime); $playerScore->setPrevRaceTime($jsonPlayer->prevracetime);

View File

@ -10,7 +10,7 @@ use ManiaControl\Callbacks\Structures\Common\BasePlayerTimeStructure;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnStartLineEventStructure extends BasePlayerTimeStructure { class OnStartLineEventStructure extends BasePlayerTimeStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnStuntEventStructure extends BasePlayerTimeStructure { class OnStuntEventStructure extends BasePlayerTimeStructure {

View File

@ -11,7 +11,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnWarmupStartEndRoundStructure extends BaseStructure { class OnWarmupStartEndRoundStructure extends BaseStructure {

View File

@ -12,7 +12,7 @@ use ManiaControl\Utils\Formatter;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class OnWayPointEventStructure extends BasePlayerTimeStructure { class OnWayPointEventStructure extends BasePlayerTimeStructure {
@ -39,14 +39,14 @@ class OnWayPointEventStructure extends BasePlayerTimeStructure {
$this->raceTime = (int) $this->getPlainJsonObject()->racetime; $this->raceTime = (int) $this->getPlainJsonObject()->racetime;
$this->lapTime = (int) $this->getPlainJsonObject()->laptime; $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->checkPointInRace = (int) $this->getPlainJsonObject()->checkpointinrace;
$this->checkPointInLap = (int) $this->getPlainJsonObject()->checkpointinlap; $this->checkPointInLap = (int) $this->getPlainJsonObject()->checkpointinlap;
$this->isEndRace = Formatter::parseBoolean($this->getPlainJsonObject()->isendrace); $this->isEndRace = Formatter::parseBoolean($this->getPlainJsonObject()->isendrace);
$this->isEndLap = Formatter::parseBoolean($this->getPlainJsonObject()->isendlap); $this->isEndLap = Formatter::parseBoolean($this->getPlainJsonObject()->isendlap);
$this->blockId = $this->getPlainJsonObject()->blockid; $this->blockId = $this->getPlainJsonObject()->blockid;
$this->speed = $this->getPlainJsonObject()->speed; $this->speed = $this->getPlainJsonObject()->speed;
$this->distance = $this->getPlainJsonObject()->distance; $this->distance = isset($this->getPlainJsonObject()->distance) ? $this->getPlainJsonObject()->distance : null;
if ($this->checkPointInRace > 0) { if ($this->checkPointInRace > 0) {
$currentMap = $this->maniaControl->getMapManager()->getCurrentMap(); $currentMap = $this->maniaControl->getMapManager()->getCurrentMap();

View File

@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class AllApiVersionsStructure extends BaseResponseStructure { class AllApiVersionsStructure extends BaseResponseStructure {

View File

@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class ApiVersionStructure extends BaseResponseStructure { class ApiVersionStructure extends BaseResponseStructure {

View File

@ -9,7 +9,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class CallbackHelpStructure extends DocumentationStructure { class CallbackHelpStructure extends DocumentationStructure {

View File

@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class CallbackListStructure extends BaseResponseStructure { class CallbackListStructure extends BaseResponseStructure {

View File

@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class DocumentationStructure extends BaseResponseStructure { class DocumentationStructure extends BaseResponseStructure {

View File

@ -9,7 +9,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class MethodHelpStructure extends DocumentationStructure { class MethodHelpStructure extends DocumentationStructure {

View File

@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
* *
* @api * @api
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class MethodListStructure extends BaseResponseStructure { class MethodListStructure extends BaseResponseStructure {

View File

@ -6,7 +6,7 @@ namespace ManiaControl\Callbacks;
* Interface for TimerListener * Interface for TimerListener
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
interface TimerListener { interface TimerListener {

View File

@ -9,7 +9,7 @@ use ManiaControl\General\UsageInformationTrait;
* Model Class for a Timer Listening * Model Class for a Timer Listening
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class TimerListening extends Listening implements UsageInformationAble { 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 * Check if the desired Time is reached
* *

View File

@ -10,7 +10,7 @@ use ManiaControl\ManiaControl;
* Class for managing Timed Callbacks * Class for managing Timed Callbacks
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class TimerManager implements UsageInformationAble { class TimerManager implements UsageInformationAble {
@ -75,6 +75,24 @@ class TimerManager implements UsageInformationAble {
array_push($this->timerListenings, $timerListening); 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 * Unregister a Timer Listening
* *

View File

@ -19,7 +19,7 @@ use ManiaControl\ManiaControl;
* Class handling and parsing TrackMania Callbacks * Class handling and parsing TrackMania Callbacks
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class TrackManiaCallbacks implements CallbackListener { class TrackManiaCallbacks implements CallbackListener {
@ -41,6 +41,7 @@ class TrackManiaCallbacks implements CallbackListener {
// Register for script callbacks // Register for script callbacks
$callbackManager->registerCallbackListener(Callbacks::SCRIPTCALLBACK, $this, 'handleScriptCallbacks'); $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)); $this->maniaControl->getCallbackManager()->triggerCallback($name, new BasePlayerTimeStructure($this->maniaControl, $data));
break; break;
case Callbacks::TM_ONWAYPOINT: case Callbacks::TM_ONWAYPOINT:
$this->handleWayPointCallback(new OnWayPointEventStructure($this->maniaControl, $data)); $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnWayPointEventStructure($this->maniaControl, $data));
//$this->maniaControl->getCallbackManager()->triggerCallback($name, $wayPointStructure);
break; break;
case Callbacks::TM_ONRESPAWN: case Callbacks::TM_ONRESPAWN:
$this->maniaControl->getCallbackManager()->triggerCallback($name, new OnRespawnStructure($this->maniaControl, $data)); $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 * @param \ManiaControl\Callbacks\Structures\TrackMania\OnWayPointEventStructure $structure
*/ */
private function handleWayPointCallback(OnWayPointEventStructure $structure) { public function handleWayPointCallback(OnWayPointEventStructure $structure) {
if ($structure->getIsEndRace()) { if ($structure->getIsEndRace()) {
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONFINISHLINE, $structure); $this->maniaControl->getCallbackManager()->addAdhocCallback(Callbacks::TM_ONFINISHLINE, $structure);
} else if ($structure->getIsEndLap()) { } else if ($structure->getIsEndLap()) {
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONLAPFINISH, $structure); $this->maniaControl->getCallbackManager()->addAdhocCallback(Callbacks::TM_ONLAPFINISH, $structure);
} else {
$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONWAYPOINT, $structure);
} }
} }
} }

View File

@ -10,14 +10,16 @@ use ManiaControl\Communication\CommunicationListener;
use ManiaControl\Communication\CommunicationMethods; use ManiaControl\Communication\CommunicationMethods;
use ManiaControl\General\UsageInformationAble; use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait; use ManiaControl\General\UsageInformationTrait;
use ManiaControl\Maps\Map;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
use ManiaControl\Utils\Formatter;
use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException; use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException;
/** /**
* Chat Utility Class * Chat Utility Class
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class Chat implements CallbackListener, CommunicationListener, UsageInformationAble { class Chat implements CallbackListener, CommunicationListener, UsageInformationAble {
@ -26,13 +28,18 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA
/* /*
* Constants * Constants
*/ */
const SETTING_PUBLIC_PREFIX = 'Public Messages Prefix'; const SETTING_FORMAT_ERROR = 'Error Format';
const SETTING_PRIVATE_PREFIX = 'Privat Messages Prefix'; const SETTING_FORMAT_INFORMATION = 'Information Format';
const SETTING_FORMAT_INFORMATION = 'Information Format'; const SETTING_FORMAT_SUCCESS = 'Success Format';
const SETTING_FORMAT_SUCCESS = 'Success Format'; const SETTING_FORMAT_USAGEINFO = 'UsageInfo Format';
const SETTING_FORMAT_ERROR = 'Error Format'; const SETTING_FORMAT_MESSAGE_INPUT_COLOR = 'Format Message Input Color';
const SETTING_FORMAT_USAGEINFO = 'UsageInfo Format'; const SETTING_FORMAT_MESSAGE_MAP_AUTHOR_LOGIN = 'Format Message Add Map Author Login';
const CHAT_BUFFER_SIZE = 200; 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 * Private properties
*/ */
@ -49,12 +56,16 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA
$this->maniaControl = $maniaControl; $this->maniaControl = $maniaControl;
// Settings // Settings
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PUBLIC_PREFIX, '» '); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_ERROR, '$f30');
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PRIVATE_PREFIX, '»» ');
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_INFORMATION, '$fff'); $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_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_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 //Callbacks
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'onPlayerChat'); $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 * Build the chat message prefix
* *
@ -133,123 +99,6 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA
return ''; 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 * Handles SendChat Communication Request
* *
@ -317,6 +166,49 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA
return new CommunicationAnswer(); 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 * Stores the ChatMessage in the Buffer
@ -336,4 +228,165 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA
array_shift($this->chatBuffer); 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);
}
} }

View File

@ -6,7 +6,7 @@ namespace ManiaControl\Commands;
* Interface for Command Listeners * Interface for Command Listeners
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
interface CommandListener { interface CommandListener {

View File

@ -13,7 +13,7 @@ use ManiaControl\ManiaControl;
* Class for handling Chat Commands * Class for handling Chat Commands
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class CommandManager implements CallbackListener, UsageInformationAble { class CommandManager implements CallbackListener, UsageInformationAble {
@ -28,8 +28,12 @@ class CommandManager implements CallbackListener, UsageInformationAble {
private $helpManager = array(); private $helpManager = array();
/** @var Listening[][] $commandListenings */ /** @var Listening[][] $commandListenings */
private $commandListenings = array(); private $commandListenings = array();
/** @var CommandListener[][] $disabledCommands */
private $disabledCommands = array();
/** @var Listening[][] $adminCommandListenings */ /** @var Listening[][] $adminCommandListenings */
private $adminCommandListenings = array(); private $adminCommandListenings = array();
/** @var CommandListener[][] $disabledAdminCommands */
private $disabledAdminCommands = array();
/** /**
* Construct a new Commands Manager * Construct a new Commands Manager
@ -116,6 +120,138 @@ class CommandManager implements CallbackListener, UsageInformationAble {
array_push($listeningsArray[$command], $listening); 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 * Unregister a Command Listener
* *
@ -130,6 +266,12 @@ class CommandManager implements CallbackListener, UsageInformationAble {
if ($this->removeCommandListener($this->adminCommandListenings, $listener)) { if ($this->removeCommandListener($this->adminCommandListenings, $listener)) {
$removed = true; $removed = true;
} }
if ($this->removeDisabledCommandListener($this->disabledCommands, $listener)) {
$removed = true;
}
if ($this->removeDisabledCommandListener($this->disabledAdminCommands, $listener)) {
$removed = true;
}
return $removed; return $removed;
} }
@ -178,9 +320,11 @@ class CommandManager implements CallbackListener, UsageInformationAble {
if (!$command) { if (!$command) {
return; return;
} }
$isAdminCommand = null;
if (substr($message, 0, 2) === '//' || $command === 'admin') { if (substr($message, 0, 2) === '//' || $command === 'admin') {
// Admin command // Admin command
$isAdminCommand = true;
$commandListenings = $this->adminCommandListenings; $commandListenings = $this->adminCommandListenings;
if ($command === 'admin') { if ($command === 'admin') {
@ -197,6 +341,7 @@ class CommandManager implements CallbackListener, UsageInformationAble {
$callback[1][2] = $message; $callback[1][2] = $message;
} else { } else {
// User command // User command
$isAdminCommand = false;
$commandListenings = $this->commandListenings; $commandListenings = $this->commandListenings;
} }
@ -205,6 +350,17 @@ class CommandManager implements CallbackListener, UsageInformationAble {
return; 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 // Inform command listeners
foreach ($commandListenings[$command] as $listening) { foreach ($commandListenings[$command] as $listening) {
/** @var Listening $listening */ /** @var Listening $listening */

View File

@ -19,7 +19,7 @@ use ManiaControl\Players\Player;
* ManiaControl Help Manager Class * ManiaControl Help Manager Class
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class HelpManager implements CommandListener, CallbackListener, ManialinkPageAnswerListener { 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'); $this->maniaControl->getActionsMenu()->addMenuItem($itemQuad, true, 0, 'Available commands');
$itemQuad = clone $itemQuad; $itemQuad = clone $itemQuad;
$itemQuad->setAction(self::ACTION_OPEN_ADMIN_HELP_ALL); $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 // Callbacks
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit'); $this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit');
@ -79,9 +79,13 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns
// Parse list from array // Parse list from array
$message = $this->parseHelpList($this->adminCommands); $message = $this->parseHelpList($this->adminCommands);
// Show message when it's not empty if ($message === null) {
if ($message != null) { $this->maniaControl->getChat()->sendError('No Admin Commands supported!', $player);
$message = 'Supported Admin Commands: ' . $message; } else {
$message = $this->maniaControl->getChat()->formatMessage(
'Supported Admin Commands: %s',
$message
);
$this->maniaControl->getChat()->sendChat($message, $player); $this->maniaControl->getChat()->sendChat($message, $player);
} }
} }
@ -96,13 +100,27 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns
// Parse list from array // Parse list from array
$message = $this->parseHelpList($this->playerCommands); $message = $this->parseHelpList($this->playerCommands);
// Show message when it's not empty if ($message === null) {
if ($message != null) { $this->maniaControl->getChat()->sendError('No Player Commands supported!', $player);
$message = 'Supported Player Commands: ' . $message; } else {
$message = $this->maniaControl->getChat()->formatMessage(
'Supported Player Commands: %s',
$message
);
$this->maniaControl->getChat()->sendChat($message, $player); $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 * Show a ManiaLink list of Player Commands
* *
@ -120,8 +138,8 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns
* @param \ManiaControl\Players\Player $player * @param \ManiaControl\Players\Player $player
* @internal * @internal
*/ */
public function maniaLink_helpAll(array $callback, Player $player) { public function maniaLink_adminHelpAll(array $callback, Player $player){
$this->parseHelpList($this->playerCommands, true, $player); $this->parseHelpList($this->adminCommands,true, $player);
} }
/** /**
@ -131,8 +149,8 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns
* @param \ManiaControl\Players\Player $player * @param \ManiaControl\Players\Player $player
* @internal * @internal
*/ */
public function maniaLink_adminHelpAll(array $callback, Player $player){ public function maniaLink_helpAll(array $callback, Player $player) {
$this->parseHelpList($this->adminCommands,true, $player); $this->parseHelpList($this->playerCommands, true, $player);
} }
/** /**
@ -185,7 +203,7 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns
* @param array $commands * @param array $commands
* @param mixed $player * @param mixed $player
*/ */
public function showHelpAllList(array $commands, $player) { public function showHelpAllList(array $commands, $player) {
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth(); $width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight(); $height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
@ -254,16 +272,6 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'HelpAllList'); $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 * Register a new Command
* *
@ -273,6 +281,7 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns
* @param string $method * @param string $method
*/ */
public function registerCommand($name, $adminCommand = false, $description = '', $method) { public function registerCommand($name, $adminCommand = false, $description = '', $method) {
// TODO replace with new class Command
if ($adminCommand) { if ($adminCommand) {
array_push($this->adminCommands, array("Name" => $name, "Description" => $description, "Method" => $method)); array_push($this->adminCommands, array("Name" => $name, "Description" => $description, "Method" => $method));
} else { } else {

View File

@ -7,7 +7,7 @@ namespace ManiaControl\Communication;
* to call @see \ManiaControl\Communication\CommunicationManager::createCommunication() * to call @see \ManiaControl\Communication\CommunicationManager::createCommunication()
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class Communication { class Communication {

View File

@ -6,7 +6,7 @@ namespace ManiaControl\Communication;
* Class for Answer of Communication Request * Class for Answer of Communication Request
* *
* @author ManiaControl Team <mail@maniacontrol.com> * @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 * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/ */
class CommunicationAnswer { class CommunicationAnswer {

Some files were not shown because too many files have changed in this diff Show More