From 9d0677364e1787b0ae9653c687c0645c750d4e89 Mon Sep 17 00:00:00 2001 From: jonthekiller Date: Mon, 15 Jul 2019 21:25:49 +0200 Subject: [PATCH 01/98] Add //endwu to be able to stop a WarmUp Adding //endwu command to be able to stop the WarmUp in progress. --- plugins/MCTeam/TrackmaniaRoundsPlugin.php | 24 +++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/plugins/MCTeam/TrackmaniaRoundsPlugin.php b/plugins/MCTeam/TrackmaniaRoundsPlugin.php index c5ee48e2..cd60b9b0 100644 --- a/plugins/MCTeam/TrackmaniaRoundsPlugin.php +++ b/plugins/MCTeam/TrackmaniaRoundsPlugin.php @@ -13,7 +13,7 @@ use ManiaControl\Plugins\Plugin; * ManiaControl Trackmania Rounds Plugin * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2018 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class TrackmaniaRoundsPlugin implements Plugin, CommandListener { @@ -21,7 +21,7 @@ class TrackmaniaRoundsPlugin implements Plugin, CommandListener { * Constants */ const PLUGIN_ID = 6; - const PLUGIN_VERSION = 0.11; + const PLUGIN_VERSION = 0.12; const PLUGIN_NAME = 'Trackmania Rounds Plugin'; const PLUGIN_AUTHOR = 'MCTeam'; @@ -71,6 +71,7 @@ class TrackmaniaRoundsPlugin implements Plugin, CommandListener { $this->maniaControl->getCommandManager()->registerCommandListener(array('getrpoints', 'getpointsdistribution'), $this, 'commandGetPointsRepartition', true, 'Gets the Rounds Point Repartition.'); $this->maniaControl->getCommandManager()->registerCommandListener(array('endround', 'end'), $this, 'commandTrackManiaEndRound', true, 'Ends the Current Round.'); + $this->maniaControl->getCommandManager()->registerCommandListener('endwu', $this, 'commandTrackManiaEndWarmUp', true, 'Ends the Current WarmUp.'); } @@ -149,6 +150,25 @@ class TrackmaniaRoundsPlugin implements Plugin, CommandListener { $this->maniaControl->getChat()->sendSuccess($player->getEscapedNickname() . ' forced end of the Round!'); } + /** + * Handle //endwu command + * + * @param array $chatCallback + * @param \ManiaControl\Players\Player $player + */ + public function commandTrackManiaEndWarmUp(array $chatCallback, Player $player) { + $permission = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_PERMISSION_END_ROUND); + if (!AuthenticationManager::checkRight($player, AuthenticationManager::getAuthLevel($permission))) { + $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); + return; + } + + try { + $this->maniaControl->getModeScriptEventManager()->triggerModeScriptEvent("Trackmania.WarmUp.ForceStop"); + } catch (\Throwable $e) { + } + $this->maniaControl->getChat()->sendSuccess($player->getEscapedNickname() . ' forced end of the WarmUp!'); + } /** * @see \ManiaControl\Plugins\Plugin::getId() */ From e3dd2599eebc31fa9017433df237c38cd7748d04 Mon Sep 17 00:00:00 2001 From: jonthekiller Date: Mon, 15 Jul 2019 21:26:47 +0200 Subject: [PATCH 02/98] Fix Copyright date --- plugins/MCTeam/TrackmaniaRoundsPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/MCTeam/TrackmaniaRoundsPlugin.php b/plugins/MCTeam/TrackmaniaRoundsPlugin.php index cd60b9b0..84d97040 100644 --- a/plugins/MCTeam/TrackmaniaRoundsPlugin.php +++ b/plugins/MCTeam/TrackmaniaRoundsPlugin.php @@ -13,7 +13,7 @@ use ManiaControl\Plugins\Plugin; * ManiaControl Trackmania Rounds Plugin * * @author ManiaControl Team - * @copyright 2014-2018 ManiaControl Team + * @copyright 2014-2019 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class TrackmaniaRoundsPlugin implements Plugin, CommandListener { From d817363076c274ce3e2fde281aff36d40c93e421 Mon Sep 17 00:00:00 2001 From: jonthekiller Date: Wed, 22 Jan 2020 10:28:20 +0100 Subject: [PATCH 03/98] Fix display for rank > 9999 (#227) --- plugins/MCTeam/Common/RecordWidget.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/MCTeam/Common/RecordWidget.php b/plugins/MCTeam/Common/RecordWidget.php index 202152ee..b331360d 100644 --- a/plugins/MCTeam/Common/RecordWidget.php +++ b/plugins/MCTeam/Common/RecordWidget.php @@ -14,7 +14,7 @@ use ManiaControl\Utils\Formatter; * ManiaControl Local Records Plugin * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2018 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class RecordWidget { @@ -49,7 +49,12 @@ class RecordWidget { if ($record->rank > 999) { $largeNumberDiff = 0.03; } - + if ($record->rank > 9999) { + $largeNumberDiff = 0.06; + } + if ($record->rank > 99999) { + $largeNumberDiff = 0.09; + } $rankLabel = new Label(); $recordFrame->addChild($rankLabel); $rankLabel->setHorizontalAlign($rankLabel::LEFT); From 1038abdbeddf3eaa62ad05b7a5397be5bd79a591 Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 22 Jan 2020 10:39:35 +0100 Subject: [PATCH 04/98] updated copyright label --- ManiaControl.php | 2 +- core/Admin/ActionsMenu.php | 2 +- core/Admin/AdminLists.php | 2 +- core/Admin/AuthCommands.php | 2 +- core/Admin/AuthenticationManager.php | 2 +- core/AutoLoader.php | 2 +- core/Bills/BillManager.php | 2 +- core/Callbacks/CallbackListener.php | 2 +- core/Callbacks/CallbackManager.php | 2 +- core/Callbacks/Callbacks.php | 2 +- core/Callbacks/EchoListener.php | 2 +- core/Callbacks/EchoManager.php | 2 +- core/Callbacks/LibXmlRpcCallbacks.php | 2 +- core/Callbacks/Listening.php | 2 +- core/Callbacks/ShootManiaCallbacks.php | 2 +- core/Callbacks/Structures/Common/BasePlayerTimeStructure.php | 2 +- core/Callbacks/Structures/Common/BaseResponseStructure.php | 2 +- core/Callbacks/Structures/Common/BaseStructure.php | 2 +- core/Callbacks/Structures/Common/BaseTimeStructure.php | 2 +- core/Callbacks/Structures/Common/CommonCommandStructure.php | 2 +- .../Callbacks/Structures/Common/CommonDefaultEventStructure.php | 2 +- core/Callbacks/Structures/Common/CommonScoresStructure.php | 2 +- core/Callbacks/Structures/Common/Models/CommonPlayerScore.php | 2 +- core/Callbacks/Structures/Common/Models/CommonTeamScore.php | 2 +- core/Callbacks/Structures/Common/StatusCallbackStructure.php | 2 +- core/Callbacks/Structures/Common/UIPropertiesBaseStructure.php | 2 +- .../Structures/ManiaPlanet/LoadingUnloadingMapStructure.php | 2 +- core/Callbacks/Structures/ManiaPlanet/ModeUseTeamsStructure.php | 2 +- core/Callbacks/Structures/ManiaPlanet/StartEndStructure.php | 2 +- core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php | 2 +- core/Callbacks/Structures/ShootMania/Models/JoustScore.php | 2 +- core/Callbacks/Structures/ShootMania/Models/Landmark.php | 2 +- core/Callbacks/Structures/ShootMania/Models/PlayerScore.php | 2 +- core/Callbacks/Structures/ShootMania/Models/Position.php | 2 +- core/Callbacks/Structures/ShootMania/Models/RoyalPointTypes.php | 2 +- core/Callbacks/Structures/ShootMania/Models/TeamScore.php | 2 +- core/Callbacks/Structures/ShootMania/Models/VictoryTypes.php | 2 +- core/Callbacks/Structures/ShootMania/Models/Weapons.php | 2 +- .../Structures/ShootMania/OnAFKPropertiesStructure.php | 2 +- .../Structures/ShootMania/OnActionCustomEventStructure.php | 2 +- core/Callbacks/Structures/ShootMania/OnActionEvent.php | 2 +- core/Callbacks/Structures/ShootMania/OnArmorEmptyStructure.php | 2 +- .../Structures/ShootMania/OnBasePlayerObjectTimeStructure.php | 2 +- core/Callbacks/Structures/ShootMania/OnCaptureStructure.php | 2 +- core/Callbacks/Structures/ShootMania/OnCommandStructure.php | 2 +- .../Callbacks/Structures/ShootMania/OnDefaultEventStructure.php | 2 +- .../Callbacks/Structures/ShootMania/OnEliteEndTurnStructure.php | 2 +- .../Structures/ShootMania/OnEliteStartTurnStructure.php | 2 +- core/Callbacks/Structures/ShootMania/OnFallDamageStructure.php | 2 +- .../ShootMania/OnHitNearMissArmorEmptyBaseStructure.php | 2 +- core/Callbacks/Structures/ShootMania/OnHitStructure.php | 2 +- core/Callbacks/Structures/ShootMania/OnJoustReloadStructure.php | 2 +- .../Structures/ShootMania/OnJoustRoundResultsStructure.php | 2 +- .../Structures/ShootMania/OnJoustSelectedPlayersStructure.php | 2 +- core/Callbacks/Structures/ShootMania/OnNearMissStructure.php | 2 +- .../Structures/ShootMania/OnPlayerRequestActionChange.php | 2 +- .../Structures/ShootMania/OnPlayerRequestRespawnStructure.php | 2 +- .../Structures/ShootMania/OnPlayerTriggersSectorStructure.php | 2 +- core/Callbacks/Structures/ShootMania/OnPlayersAFKStructure.php | 2 +- .../Structures/ShootMania/OnRoyalPlayerSpawnStructure.php | 2 +- core/Callbacks/Structures/ShootMania/OnRoyalPointsStructure.php | 2 +- .../Structures/ShootMania/OnRoyalRoundWinnerStructure.php | 2 +- core/Callbacks/Structures/ShootMania/OnScoresStructure.php | 2 +- core/Callbacks/Structures/ShootMania/OnShootStructure.php | 2 +- core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php | 2 +- core/Callbacks/Structures/TrackMania/Models/PlayerScore.php | 2 +- core/Callbacks/Structures/TrackMania/Models/TeamScore.php | 2 +- core/Callbacks/Structures/TrackMania/OnCommandStructure.php | 2 +- .../Callbacks/Structures/TrackMania/OnDefaultEventStructure.php | 2 +- .../Structures/TrackMania/OnPointsRepartitionStructure.php | 2 +- core/Callbacks/Structures/TrackMania/OnRespawnStructure.php | 2 +- core/Callbacks/Structures/TrackMania/OnScoresStructure.php | 2 +- .../Structures/TrackMania/OnStartLineEventStructure.php | 2 +- core/Callbacks/Structures/TrackMania/OnStuntEventStructure.php | 2 +- .../Structures/TrackMania/OnWarmupStartEndRoundStructure.php | 2 +- .../Structures/TrackMania/OnWayPointEventStructure.php | 2 +- core/Callbacks/Structures/XmlRpc/AllApiVersionsStructure.php | 2 +- core/Callbacks/Structures/XmlRpc/ApiVersionStructure.php | 2 +- core/Callbacks/Structures/XmlRpc/CallbackHelpStructure.php | 2 +- core/Callbacks/Structures/XmlRpc/CallbackListStructure.php | 2 +- core/Callbacks/Structures/XmlRpc/DocumentationStructure.php | 2 +- core/Callbacks/Structures/XmlRpc/MethodHelpStructure.php | 2 +- core/Callbacks/Structures/XmlRpc/MethodListStructure.php | 2 +- core/Callbacks/TimerListener.php | 2 +- core/Callbacks/TimerListening.php | 2 +- core/Callbacks/TimerManager.php | 2 +- core/Callbacks/TrackManiaCallbacks.php | 2 +- core/Chat.php | 2 +- core/Commands/CommandListener.php | 2 +- core/Commands/CommandManager.php | 2 +- core/Commands/HelpManager.php | 2 +- core/Communication/Communication.php | 2 +- core/Communication/CommunicationAnswer.php | 2 +- core/Communication/CommunicationListener.php | 2 +- core/Communication/CommunicationManager.php | 2 +- core/Communication/CommunicationMethods.php | 2 +- core/Configurator/Configurator.php | 2 +- core/Configurator/ConfiguratorMenu.php | 2 +- core/Configurator/ManiaControlSettings.php | 2 +- core/Configurator/ScriptSettings.php | 2 +- core/Database/Config.php | 2 +- core/Database/Database.php | 2 +- core/Database/MigrationHelper.php | 2 +- core/ErrorHandler.php | 2 +- core/Files/AsyncHttpRequest.php | 2 +- core/Files/AsynchronousFileReader.php | 2 +- core/Files/BackupUtil.php | 2 +- core/Files/FileUtil.php | 2 +- core/Logger.php | 2 +- core/ManiaControl.php | 2 +- core/ManiaExchange/MXMapInfo.php | 2 +- core/ManiaExchange/ManiaExchangeList.php | 2 +- core/ManiaExchange/ManiaExchangeManager.php | 2 +- core/ManiaExchange/ManiaExchangeMapSearch.php | 2 +- core/Manialinks/CustomUIManager.php | 2 +- core/Manialinks/IconManager.php | 2 +- core/Manialinks/LabelLine.php | 2 +- core/Manialinks/ManialinkManager.php | 2 +- core/Manialinks/ManialinkPageAnswerListener.php | 2 +- core/Manialinks/SidebarMenuEntryListener.php | 2 +- core/Manialinks/SidebarMenuManager.php | 2 +- core/Manialinks/StyleManager.php | 2 +- core/Maps/DirectoryBrowser.php | 2 +- core/Maps/Map.php | 2 +- core/Maps/MapActions.php | 2 +- core/Maps/MapCommands.php | 2 +- core/Maps/MapList.php | 2 +- core/Maps/MapManager.php | 2 +- core/Maps/MapQueue.php | 2 +- core/Players/Player.php | 2 +- core/Players/PlayerActions.php | 2 +- core/Players/PlayerCommands.php | 2 +- core/Players/PlayerDataManager.php | 2 +- core/Players/PlayerDetailed.php | 2 +- core/Players/PlayerList.php | 2 +- core/Players/PlayerManager.php | 2 +- core/Plugins/InstallMenu.php | 2 +- core/Plugins/Plugin.php | 2 +- core/Plugins/PluginManager.php | 2 +- core/Plugins/PluginMenu.php | 2 +- core/Script/InvokeScriptCallback.php | 2 +- core/Script/ModeScriptEventManager.php | 2 +- core/Script/ScriptManager.php | 2 +- core/Server/Commands.php | 2 +- core/Server/Config.php | 2 +- core/Server/Directory.php | 2 +- core/Server/RankingManager.php | 2 +- core/Server/Server.php | 2 +- core/Server/ServerOptionsMenu.php | 2 +- core/Server/UsageReporter.php | 2 +- core/Server/VoteRatiosMenu.php | 2 +- core/Settings/Setting.php | 2 +- core/Settings/SettingManager.php | 2 +- core/Statistics/SimpleStatsList.php | 2 +- core/Statistics/StatisticCollector.php | 2 +- core/Statistics/StatisticManager.php | 2 +- core/Update/PluginUpdateData.php | 2 +- core/Update/PluginUpdateManager.php | 2 +- core/Update/UpdateData.php | 2 +- core/Update/UpdateManager.php | 2 +- core/Utils/ClassUtil.php | 2 +- core/Utils/ColorUtil.php | 2 +- core/Utils/CommandLineHelper.php | 2 +- core/Utils/Formatter.php | 2 +- core/Utils/SystemUtil.php | 2 +- core/Utils/WebReader.php | 2 +- phpunittests/core/LoggerTest.php | 2 +- phpunittests/core/ManiaControlTest.php | 2 +- phpunittests/core/Manialinks/CustomUIManagerTest.php | 2 +- phpunittests/core/Manialinks/LabelLineTest.php | 2 +- phpunittests/core/Script/ModeScriptEventManagerTest.php | 2 +- phpunittests/core/Update/PluginUpdateManagerTest.php | 2 +- phpunittests/core/Update/UpdateManagerTest.php | 2 +- plugins/MCTeam/ChatMessagePlugin.php | 2 +- plugins/MCTeam/Common/RecordWidget.php | 2 +- plugins/MCTeam/CustomVotesPlugin.php | 2 +- plugins/MCTeam/Dedimania/DedimaniaData.php | 2 +- plugins/MCTeam/Dedimania/DedimaniaPlayer.php | 2 +- plugins/MCTeam/Dedimania/DedimaniaPlugin.php | 2 +- plugins/MCTeam/Dedimania/DedimaniaWebHandler.php | 2 +- plugins/MCTeam/Dedimania/RecordData.php | 2 +- plugins/MCTeam/DonationPlugin.php | 2 +- plugins/MCTeam/DynamicPointLimitPlugin.php | 2 +- plugins/MCTeam/KarmaPlugin.php | 2 +- plugins/MCTeam/ServerRankingPlugin.php | 2 +- plugins/MCTeam/TrackmaniaRoundsPlugin.php | 2 +- plugins/MCTeam/WidgetPlugin.php | 2 +- 187 files changed, 187 insertions(+), 187 deletions(-) diff --git a/ManiaControl.php b/ManiaControl.php index 84038644..3ba6598b 100644 --- a/ManiaControl.php +++ b/ManiaControl.php @@ -3,7 +3,7 @@ * ManiaControl Server Controller for ManiaPlanet Server * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ diff --git a/core/Admin/ActionsMenu.php b/core/Admin/ActionsMenu.php index 5c5dd51b..5e984f4e 100644 --- a/core/Admin/ActionsMenu.php +++ b/core/Admin/ActionsMenu.php @@ -27,7 +27,7 @@ use ManiaControl\Settings\SettingManager; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class ActionsMenu implements SidebarMenuEntryListener, CallbackListener, ManialinkPageAnswerListener, UsageInformationAble { diff --git a/core/Admin/AdminLists.php b/core/Admin/AdminLists.php index 40701d95..9cf58f37 100644 --- a/core/Admin/AdminLists.php +++ b/core/Admin/AdminLists.php @@ -26,7 +26,7 @@ use ManiaControl\Players\Player; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class AdminLists implements ManialinkPageAnswerListener, CallbackListener, UsageInformationAble { diff --git a/core/Admin/AuthCommands.php b/core/Admin/AuthCommands.php index 8ec6615d..1352f700 100644 --- a/core/Admin/AuthCommands.php +++ b/core/Admin/AuthCommands.php @@ -12,7 +12,7 @@ use ManiaControl\Players\Player; * Class offering Commands to grant Authorizations to Players * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class AuthCommands implements CommandListener, UsageInformationAble { diff --git a/core/Admin/AuthenticationManager.php b/core/Admin/AuthenticationManager.php index 503ba54f..a69b35de 100644 --- a/core/Admin/AuthenticationManager.php +++ b/core/Admin/AuthenticationManager.php @@ -21,7 +21,7 @@ use ManiaControl\Settings\Setting; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class AuthenticationManager implements CallbackListener, EchoListener, CommunicationListener, UsageInformationAble { diff --git a/core/AutoLoader.php b/core/AutoLoader.php index 67f44f0a..bd52ce99 100644 --- a/core/AutoLoader.php +++ b/core/AutoLoader.php @@ -6,7 +6,7 @@ namespace ManiaControl; * ManiaControl AutoLoader * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ abstract class AutoLoader { diff --git a/core/Bills/BillManager.php b/core/Bills/BillManager.php index ddc9210c..04f157a6 100644 --- a/core/Bills/BillManager.php +++ b/core/Bills/BillManager.php @@ -16,7 +16,7 @@ use Maniaplanet\DedicatedServer\Structures\Bill; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class BillManager implements CallbackListener, UsageInformationAble { diff --git a/core/Callbacks/CallbackListener.php b/core/Callbacks/CallbackListener.php index 2b902963..f0090f1f 100644 --- a/core/Callbacks/CallbackListener.php +++ b/core/Callbacks/CallbackListener.php @@ -6,7 +6,7 @@ namespace ManiaControl\Callbacks; * Interface for Callback Listener * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ interface CallbackListener { diff --git a/core/Callbacks/CallbackManager.php b/core/Callbacks/CallbackManager.php index db617009..0c8e2a4c 100644 --- a/core/Callbacks/CallbackManager.php +++ b/core/Callbacks/CallbackManager.php @@ -15,7 +15,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException; * Class for managing Server and ManiaControl Callbacks * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class CallbackManager implements UsageInformationAble { diff --git a/core/Callbacks/Callbacks.php b/core/Callbacks/Callbacks.php index 0008f71f..34c74067 100644 --- a/core/Callbacks/Callbacks.php +++ b/core/Callbacks/Callbacks.php @@ -6,7 +6,7 @@ namespace ManiaControl\Callbacks; * Callbacks Interface * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ interface Callbacks { diff --git a/core/Callbacks/EchoListener.php b/core/Callbacks/EchoListener.php index cd491609..d9ecb74f 100644 --- a/core/Callbacks/EchoListener.php +++ b/core/Callbacks/EchoListener.php @@ -5,7 +5,7 @@ namespace ManiaControl\Callbacks; * Interface for EchoListener * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ interface EchoListener { diff --git a/core/Callbacks/EchoManager.php b/core/Callbacks/EchoManager.php index ae53b77c..5bad9475 100644 --- a/core/Callbacks/EchoManager.php +++ b/core/Callbacks/EchoManager.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * Class for managing Echo Callbacks * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class EchoManager implements CallbackListener, EchoListener, UsageInformationAble { diff --git a/core/Callbacks/LibXmlRpcCallbacks.php b/core/Callbacks/LibXmlRpcCallbacks.php index aa10afc5..25cac830 100644 --- a/core/Callbacks/LibXmlRpcCallbacks.php +++ b/core/Callbacks/LibXmlRpcCallbacks.php @@ -25,7 +25,7 @@ use ManiaControl\ManiaControl; * Class converting LibXmlRpc Callbacks * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class LibXmlRpcCallbacks implements CallbackListener { diff --git a/core/Callbacks/Listening.php b/core/Callbacks/Listening.php index 1bf48b4a..5c9577f3 100644 --- a/core/Callbacks/Listening.php +++ b/core/Callbacks/Listening.php @@ -9,7 +9,7 @@ use ManiaControl\General\UsageInformationTrait; * Model Class for a Basic Listening * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class Listening implements UsageInformationAble { diff --git a/core/Callbacks/ShootManiaCallbacks.php b/core/Callbacks/ShootManiaCallbacks.php index dddb739e..20868cf8 100644 --- a/core/Callbacks/ShootManiaCallbacks.php +++ b/core/Callbacks/ShootManiaCallbacks.php @@ -36,7 +36,7 @@ use ManiaControl\ManiaControl; * Class handling and parsing ShootMania Callbacks * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class ShootManiaCallbacks implements CallbackListener { diff --git a/core/Callbacks/Structures/Common/BasePlayerTimeStructure.php b/core/Callbacks/Structures/Common/BasePlayerTimeStructure.php index ec7abc9c..7424b23d 100644 --- a/core/Callbacks/Structures/Common/BasePlayerTimeStructure.php +++ b/core/Callbacks/Structures/Common/BasePlayerTimeStructure.php @@ -10,7 +10,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class BasePlayerTimeStructure extends BaseTimeStructure { diff --git a/core/Callbacks/Structures/Common/BaseResponseStructure.php b/core/Callbacks/Structures/Common/BaseResponseStructure.php index 847cdc6c..b705d25b 100644 --- a/core/Callbacks/Structures/Common/BaseResponseStructure.php +++ b/core/Callbacks/Structures/Common/BaseResponseStructure.php @@ -9,7 +9,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class BaseResponseStructure extends BaseStructure { diff --git a/core/Callbacks/Structures/Common/BaseStructure.php b/core/Callbacks/Structures/Common/BaseStructure.php index a4a70367..73c26190 100644 --- a/core/Callbacks/Structures/Common/BaseStructure.php +++ b/core/Callbacks/Structures/Common/BaseStructure.php @@ -14,7 +14,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ abstract class BaseStructure implements UsageInformationAble, JsonSerializable { diff --git a/core/Callbacks/Structures/Common/BaseTimeStructure.php b/core/Callbacks/Structures/Common/BaseTimeStructure.php index 5ed30e22..23b98e53 100644 --- a/core/Callbacks/Structures/Common/BaseTimeStructure.php +++ b/core/Callbacks/Structures/Common/BaseTimeStructure.php @@ -9,7 +9,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class BaseTimeStructure extends BaseStructure { diff --git a/core/Callbacks/Structures/Common/CommonCommandStructure.php b/core/Callbacks/Structures/Common/CommonCommandStructure.php index eac94a33..96146e02 100644 --- a/core/Callbacks/Structures/Common/CommonCommandStructure.php +++ b/core/Callbacks/Structures/Common/CommonCommandStructure.php @@ -12,7 +12,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class CommonCommandStructure extends BaseTimeStructure { diff --git a/core/Callbacks/Structures/Common/CommonDefaultEventStructure.php b/core/Callbacks/Structures/Common/CommonDefaultEventStructure.php index 85fbed11..6a0e1c79 100644 --- a/core/Callbacks/Structures/Common/CommonDefaultEventStructure.php +++ b/core/Callbacks/Structures/Common/CommonDefaultEventStructure.php @@ -12,7 +12,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class CommonDefaultEventStructure extends BaseTimeStructure { diff --git a/core/Callbacks/Structures/Common/CommonScoresStructure.php b/core/Callbacks/Structures/Common/CommonScoresStructure.php index 2ce480d9..a988ab25 100644 --- a/core/Callbacks/Structures/Common/CommonScoresStructure.php +++ b/core/Callbacks/Structures/Common/CommonScoresStructure.php @@ -14,7 +14,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class CommonScoresStructure extends BaseResponseStructure { diff --git a/core/Callbacks/Structures/Common/Models/CommonPlayerScore.php b/core/Callbacks/Structures/Common/Models/CommonPlayerScore.php index 19dbfa38..8e7a7dc7 100644 --- a/core/Callbacks/Structures/Common/Models/CommonPlayerScore.php +++ b/core/Callbacks/Structures/Common/Models/CommonPlayerScore.php @@ -14,7 +14,7 @@ use ManiaControl\Players\Player; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class CommonPlayerScore implements UsageInformationAble, JsonSerializable { diff --git a/core/Callbacks/Structures/Common/Models/CommonTeamScore.php b/core/Callbacks/Structures/Common/Models/CommonTeamScore.php index 31d938fb..43af696a 100644 --- a/core/Callbacks/Structures/Common/Models/CommonTeamScore.php +++ b/core/Callbacks/Structures/Common/Models/CommonTeamScore.php @@ -12,7 +12,7 @@ use ManiaControl\General\UsageInformationTrait; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class CommonTeamScore implements UsageInformationAble, JsonSerializable { diff --git a/core/Callbacks/Structures/Common/StatusCallbackStructure.php b/core/Callbacks/Structures/Common/StatusCallbackStructure.php index 5f597271..ccb7b417 100644 --- a/core/Callbacks/Structures/Common/StatusCallbackStructure.php +++ b/core/Callbacks/Structures/Common/StatusCallbackStructure.php @@ -10,7 +10,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class StatusCallbackStructure extends BaseResponseStructure { diff --git a/core/Callbacks/Structures/Common/UIPropertiesBaseStructure.php b/core/Callbacks/Structures/Common/UIPropertiesBaseStructure.php index 22469fd7..fddd64bb 100644 --- a/core/Callbacks/Structures/Common/UIPropertiesBaseStructure.php +++ b/core/Callbacks/Structures/Common/UIPropertiesBaseStructure.php @@ -9,7 +9,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class UIPropertiesBaseStructure extends BaseResponseStructure { diff --git a/core/Callbacks/Structures/ManiaPlanet/LoadingUnloadingMapStructure.php b/core/Callbacks/Structures/ManiaPlanet/LoadingUnloadingMapStructure.php index 37c2758d..17a2b493 100644 --- a/core/Callbacks/Structures/ManiaPlanet/LoadingUnloadingMapStructure.php +++ b/core/Callbacks/Structures/ManiaPlanet/LoadingUnloadingMapStructure.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class LoadingUnloadingMapStructure extends BaseTimeStructure { diff --git a/core/Callbacks/Structures/ManiaPlanet/ModeUseTeamsStructure.php b/core/Callbacks/Structures/ManiaPlanet/ModeUseTeamsStructure.php index 4a7b6797..caa059aa 100644 --- a/core/Callbacks/Structures/ManiaPlanet/ModeUseTeamsStructure.php +++ b/core/Callbacks/Structures/ManiaPlanet/ModeUseTeamsStructure.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class ModeUseTeamsStructure extends BaseResponseStructure { diff --git a/core/Callbacks/Structures/ManiaPlanet/StartEndStructure.php b/core/Callbacks/Structures/ManiaPlanet/StartEndStructure.php index 1f0ee7e1..ddf37ab3 100644 --- a/core/Callbacks/Structures/ManiaPlanet/StartEndStructure.php +++ b/core/Callbacks/Structures/ManiaPlanet/StartEndStructure.php @@ -12,7 +12,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class StartEndStructure extends BaseTimeStructure { diff --git a/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php b/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php index bfe1218a..04e44516 100644 --- a/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php +++ b/core/Callbacks/Structures/ManiaPlanet/StartServerStructure.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class StartServerStructure extends BaseStructure { diff --git a/core/Callbacks/Structures/ShootMania/Models/JoustScore.php b/core/Callbacks/Structures/ShootMania/Models/JoustScore.php index 369dc445..ed3ca406 100644 --- a/core/Callbacks/Structures/ShootMania/Models/JoustScore.php +++ b/core/Callbacks/Structures/ShootMania/Models/JoustScore.php @@ -17,7 +17,7 @@ use ManiaControl\General\UsageInformationTrait; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class JoustScore implements UsageInformationAble { diff --git a/core/Callbacks/Structures/ShootMania/Models/Landmark.php b/core/Callbacks/Structures/ShootMania/Models/Landmark.php index cd165da2..10eb0c4b 100644 --- a/core/Callbacks/Structures/ShootMania/Models/Landmark.php +++ b/core/Callbacks/Structures/ShootMania/Models/Landmark.php @@ -11,7 +11,7 @@ use ManiaControl\General\UsageInformationTrait; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class Landmark implements UsageInformationAble { diff --git a/core/Callbacks/Structures/ShootMania/Models/PlayerScore.php b/core/Callbacks/Structures/ShootMania/Models/PlayerScore.php index 2956ef95..b9ea73ae 100644 --- a/core/Callbacks/Structures/ShootMania/Models/PlayerScore.php +++ b/core/Callbacks/Structures/ShootMania/Models/PlayerScore.php @@ -10,7 +10,7 @@ use ManiaControl\Callbacks\Structures\Common\Models\CommonPlayerScore; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class PlayerScore extends CommonPlayerScore { diff --git a/core/Callbacks/Structures/ShootMania/Models/Position.php b/core/Callbacks/Structures/ShootMania/Models/Position.php index 2a584917..b9300082 100644 --- a/core/Callbacks/Structures/ShootMania/Models/Position.php +++ b/core/Callbacks/Structures/ShootMania/Models/Position.php @@ -11,7 +11,7 @@ use ManiaControl\General\UsageInformationTrait; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class Position implements UsageInformationAble { diff --git a/core/Callbacks/Structures/ShootMania/Models/RoyalPointTypes.php b/core/Callbacks/Structures/ShootMania/Models/RoyalPointTypes.php index f5a17391..063b00dd 100644 --- a/core/Callbacks/Structures/ShootMania/Models/RoyalPointTypes.php +++ b/core/Callbacks/Structures/ShootMania/Models/RoyalPointTypes.php @@ -7,7 +7,7 @@ namespace ManiaControl\Callbacks\Structures\ShootMania\Models; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ interface RoyalPointTypes { diff --git a/core/Callbacks/Structures/ShootMania/Models/TeamScore.php b/core/Callbacks/Structures/ShootMania/Models/TeamScore.php index 0f247d51..45bdd047 100644 --- a/core/Callbacks/Structures/ShootMania/Models/TeamScore.php +++ b/core/Callbacks/Structures/ShootMania/Models/TeamScore.php @@ -9,7 +9,7 @@ use ManiaControl\Callbacks\Structures\Common\Models\CommonTeamScore; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class TeamScore extends CommonTeamScore { diff --git a/core/Callbacks/Structures/ShootMania/Models/VictoryTypes.php b/core/Callbacks/Structures/ShootMania/Models/VictoryTypes.php index c2815bc5..55a52f4a 100644 --- a/core/Callbacks/Structures/ShootMania/Models/VictoryTypes.php +++ b/core/Callbacks/Structures/ShootMania/Models/VictoryTypes.php @@ -7,7 +7,7 @@ namespace ManiaControl\Callbacks\Structures\ShootMania\Models; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ interface VictoryTypes { diff --git a/core/Callbacks/Structures/ShootMania/Models/Weapons.php b/core/Callbacks/Structures/ShootMania/Models/Weapons.php index d58d9a13..d792e95a 100644 --- a/core/Callbacks/Structures/ShootMania/Models/Weapons.php +++ b/core/Callbacks/Structures/ShootMania/Models/Weapons.php @@ -7,7 +7,7 @@ namespace ManiaControl\Callbacks\Structures\ShootMania\Models; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ interface Weapons { diff --git a/core/Callbacks/Structures/ShootMania/OnAFKPropertiesStructure.php b/core/Callbacks/Structures/ShootMania/OnAFKPropertiesStructure.php index e7fb1cdd..1f0e9054 100644 --- a/core/Callbacks/Structures/ShootMania/OnAFKPropertiesStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnAFKPropertiesStructure.php @@ -10,7 +10,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnAFKPropertiesStructure extends BaseResponseStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnActionCustomEventStructure.php b/core/Callbacks/Structures/ShootMania/OnActionCustomEventStructure.php index 2f0c1ddd..5eca603f 100644 --- a/core/Callbacks/Structures/ShootMania/OnActionCustomEventStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnActionCustomEventStructure.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnActionCustomEventStructure extends BaseStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnActionEvent.php b/core/Callbacks/Structures/ShootMania/OnActionEvent.php index 2e891359..90d42fb7 100644 --- a/core/Callbacks/Structures/ShootMania/OnActionEvent.php +++ b/core/Callbacks/Structures/ShootMania/OnActionEvent.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnActionEvent extends BaseStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnArmorEmptyStructure.php b/core/Callbacks/Structures/ShootMania/OnArmorEmptyStructure.php index 5767169c..d6f5b0e1 100644 --- a/core/Callbacks/Structures/ShootMania/OnArmorEmptyStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnArmorEmptyStructure.php @@ -9,7 +9,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnArmorEmptyStructure extends OnHitNearMissArmorEmptyBaseStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnBasePlayerObjectTimeStructure.php b/core/Callbacks/Structures/ShootMania/OnBasePlayerObjectTimeStructure.php index 5b9d0bf2..25889988 100644 --- a/core/Callbacks/Structures/ShootMania/OnBasePlayerObjectTimeStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnBasePlayerObjectTimeStructure.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnBasePlayerObjectTimeStructure extends BasePlayerTimeStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php b/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php index eaa413cd..c98e1812 100644 --- a/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php @@ -14,7 +14,7 @@ use ManiaControl\Players\Player; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnCaptureStructure extends BaseStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnCommandStructure.php b/core/Callbacks/Structures/ShootMania/OnCommandStructure.php index b587ead3..76656160 100644 --- a/core/Callbacks/Structures/ShootMania/OnCommandStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnCommandStructure.php @@ -10,7 +10,7 @@ use ManiaControl\Callbacks\Structures\Common\CommonCommandStructure; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnCommandStructure extends CommonCommandStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnDefaultEventStructure.php b/core/Callbacks/Structures/ShootMania/OnDefaultEventStructure.php index 2b1b8046..46d5be7e 100644 --- a/core/Callbacks/Structures/ShootMania/OnDefaultEventStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnDefaultEventStructure.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnDefaultEventStructure extends CommonDefaultEventStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnEliteEndTurnStructure.php b/core/Callbacks/Structures/ShootMania/OnEliteEndTurnStructure.php index e51f0e00..5edf4228 100644 --- a/core/Callbacks/Structures/ShootMania/OnEliteEndTurnStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnEliteEndTurnStructure.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnEliteEndTurnStructure extends BaseStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnEliteStartTurnStructure.php b/core/Callbacks/Structures/ShootMania/OnEliteStartTurnStructure.php index ce8bcbe3..3bded828 100644 --- a/core/Callbacks/Structures/ShootMania/OnEliteStartTurnStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnEliteStartTurnStructure.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnEliteStartTurnStructure extends BaseStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnFallDamageStructure.php b/core/Callbacks/Structures/ShootMania/OnFallDamageStructure.php index ff0a3581..42175a30 100644 --- a/core/Callbacks/Structures/ShootMania/OnFallDamageStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnFallDamageStructure.php @@ -12,7 +12,7 @@ use ManiaControl\Players\Player; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnFallDamageStructure extends BaseStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyBaseStructure.php b/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyBaseStructure.php index 2718cd36..f8b70c6b 100644 --- a/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyBaseStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnHitNearMissArmorEmptyBaseStructure.php @@ -14,7 +14,7 @@ use ManiaControl\Players\Player; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnHitNearMissArmorEmptyBaseStructure extends BaseStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnHitStructure.php b/core/Callbacks/Structures/ShootMania/OnHitStructure.php index f4a7fc93..5be3a788 100644 --- a/core/Callbacks/Structures/ShootMania/OnHitStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnHitStructure.php @@ -10,7 +10,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnHitStructure extends OnHitNearMissArmorEmptyBaseStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnJoustReloadStructure.php b/core/Callbacks/Structures/ShootMania/OnJoustReloadStructure.php index 0b88e124..e5896891 100644 --- a/core/Callbacks/Structures/ShootMania/OnJoustReloadStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnJoustReloadStructure.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnJoustReloadStructure extends BaseStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnJoustRoundResultsStructure.php b/core/Callbacks/Structures/ShootMania/OnJoustRoundResultsStructure.php index ea3fc2b6..938df249 100644 --- a/core/Callbacks/Structures/ShootMania/OnJoustRoundResultsStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnJoustRoundResultsStructure.php @@ -13,7 +13,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnJoustRoundResultsStructure extends BaseStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnJoustSelectedPlayersStructure.php b/core/Callbacks/Structures/ShootMania/OnJoustSelectedPlayersStructure.php index 0f305c10..92251f51 100644 --- a/core/Callbacks/Structures/ShootMania/OnJoustSelectedPlayersStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnJoustSelectedPlayersStructure.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnJoustSelectedPlayersStructure extends BaseStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnNearMissStructure.php b/core/Callbacks/Structures/ShootMania/OnNearMissStructure.php index a72d02ef..e0f2147f 100644 --- a/core/Callbacks/Structures/ShootMania/OnNearMissStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnNearMissStructure.php @@ -10,7 +10,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnNearMissStructure extends OnHitNearMissArmorEmptyBaseStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnPlayerRequestActionChange.php b/core/Callbacks/Structures/ShootMania/OnPlayerRequestActionChange.php index 49694278..c5721a8f 100644 --- a/core/Callbacks/Structures/ShootMania/OnPlayerRequestActionChange.php +++ b/core/Callbacks/Structures/ShootMania/OnPlayerRequestActionChange.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnPlayerRequestActionChange extends BasePlayerTimeStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php b/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php index d5bae166..a94cc2f0 100644 --- a/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php @@ -13,7 +13,7 @@ use ManiaControl\Players\Player; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnPlayerRequestRespawnStructure extends BasePlayerTimeStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnPlayerTriggersSectorStructure.php b/core/Callbacks/Structures/ShootMania/OnPlayerTriggersSectorStructure.php index 534176db..c5e089e4 100644 --- a/core/Callbacks/Structures/ShootMania/OnPlayerTriggersSectorStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnPlayerTriggersSectorStructure.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnPlayerTriggersSectorStructure extends BasePlayerTimeStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnPlayersAFKStructure.php b/core/Callbacks/Structures/ShootMania/OnPlayersAFKStructure.php index 255c8b7d..13fc0805 100644 --- a/core/Callbacks/Structures/ShootMania/OnPlayersAFKStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnPlayersAFKStructure.php @@ -10,7 +10,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnPlayersAFKStructure extends BaseStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnRoyalPlayerSpawnStructure.php b/core/Callbacks/Structures/ShootMania/OnRoyalPlayerSpawnStructure.php index aaad3e31..a29cf13c 100644 --- a/core/Callbacks/Structures/ShootMania/OnRoyalPlayerSpawnStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnRoyalPlayerSpawnStructure.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnRoyalPlayerSpawnStructure extends BaseStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnRoyalPointsStructure.php b/core/Callbacks/Structures/ShootMania/OnRoyalPointsStructure.php index 1f5f6181..0d515726 100644 --- a/core/Callbacks/Structures/ShootMania/OnRoyalPointsStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnRoyalPointsStructure.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnRoyalPointsStructure extends BaseStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnRoyalRoundWinnerStructure.php b/core/Callbacks/Structures/ShootMania/OnRoyalRoundWinnerStructure.php index 3531bf06..fa01d236 100644 --- a/core/Callbacks/Structures/ShootMania/OnRoyalRoundWinnerStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnRoyalRoundWinnerStructure.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnRoyalRoundWinnerStructure extends BaseStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnScoresStructure.php b/core/Callbacks/Structures/ShootMania/OnScoresStructure.php index 5ab53427..c1aaaa24 100644 --- a/core/Callbacks/Structures/ShootMania/OnScoresStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnScoresStructure.php @@ -13,7 +13,7 @@ use ManiaControl\ManiaControl; * Structure Class for the Shootmania OnScores Structure Callback * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnScoresStructure extends CommonScoresStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnShootStructure.php b/core/Callbacks/Structures/ShootMania/OnShootStructure.php index a8417074..ec4d8a1c 100644 --- a/core/Callbacks/Structures/ShootMania/OnShootStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnShootStructure.php @@ -13,7 +13,7 @@ use ManiaControl\Players\Player; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnShootStructure extends BaseTimeStructure { diff --git a/core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php b/core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php index b18f9955..04f20b0a 100644 --- a/core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php @@ -13,7 +13,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnShotDenyStructure extends BaseTimeStructure { diff --git a/core/Callbacks/Structures/TrackMania/Models/PlayerScore.php b/core/Callbacks/Structures/TrackMania/Models/PlayerScore.php index 87e084b8..f0a633fa 100644 --- a/core/Callbacks/Structures/TrackMania/Models/PlayerScore.php +++ b/core/Callbacks/Structures/TrackMania/Models/PlayerScore.php @@ -11,7 +11,7 @@ use ManiaControl\Callbacks\Structures\Common\Models\CommonPlayerScore; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class PlayerScore extends CommonPlayerScore { diff --git a/core/Callbacks/Structures/TrackMania/Models/TeamScore.php b/core/Callbacks/Structures/TrackMania/Models/TeamScore.php index 20f47fdf..67ea3ca9 100644 --- a/core/Callbacks/Structures/TrackMania/Models/TeamScore.php +++ b/core/Callbacks/Structures/TrackMania/Models/TeamScore.php @@ -9,7 +9,7 @@ use ManiaControl\Callbacks\Structures\Common\Models\CommonTeamScore; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class TeamScore extends CommonTeamScore { diff --git a/core/Callbacks/Structures/TrackMania/OnCommandStructure.php b/core/Callbacks/Structures/TrackMania/OnCommandStructure.php index 38081424..b9250efb 100644 --- a/core/Callbacks/Structures/TrackMania/OnCommandStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnCommandStructure.php @@ -10,7 +10,7 @@ use ManiaControl\Callbacks\Structures\Common\CommonCommandStructure; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnCommandStructure extends CommonCommandStructure { diff --git a/core/Callbacks/Structures/TrackMania/OnDefaultEventStructure.php b/core/Callbacks/Structures/TrackMania/OnDefaultEventStructure.php index e47fb31c..76b71db8 100644 --- a/core/Callbacks/Structures/TrackMania/OnDefaultEventStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnDefaultEventStructure.php @@ -13,7 +13,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnDefaultEventStructure extends CommonDefaultEventStructure { diff --git a/core/Callbacks/Structures/TrackMania/OnPointsRepartitionStructure.php b/core/Callbacks/Structures/TrackMania/OnPointsRepartitionStructure.php index 3e15362c..66e27aa8 100644 --- a/core/Callbacks/Structures/TrackMania/OnPointsRepartitionStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnPointsRepartitionStructure.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnPointsRepartitionStructure extends BaseResponseStructure { diff --git a/core/Callbacks/Structures/TrackMania/OnRespawnStructure.php b/core/Callbacks/Structures/TrackMania/OnRespawnStructure.php index fe2ba1be..7d76b129 100644 --- a/core/Callbacks/Structures/TrackMania/OnRespawnStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnRespawnStructure.php @@ -13,7 +13,7 @@ use ManiaControl\Utils\Formatter; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnRespawnStructure extends BasePlayerTimeStructure { diff --git a/core/Callbacks/Structures/TrackMania/OnScoresStructure.php b/core/Callbacks/Structures/TrackMania/OnScoresStructure.php index 5d96aa64..a15fd7ed 100644 --- a/core/Callbacks/Structures/TrackMania/OnScoresStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnScoresStructure.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnScoresStructure extends CommonScoresStructure { diff --git a/core/Callbacks/Structures/TrackMania/OnStartLineEventStructure.php b/core/Callbacks/Structures/TrackMania/OnStartLineEventStructure.php index df1f246c..6a819182 100644 --- a/core/Callbacks/Structures/TrackMania/OnStartLineEventStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnStartLineEventStructure.php @@ -10,7 +10,7 @@ use ManiaControl\Callbacks\Structures\Common\BasePlayerTimeStructure; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnStartLineEventStructure extends BasePlayerTimeStructure { diff --git a/core/Callbacks/Structures/TrackMania/OnStuntEventStructure.php b/core/Callbacks/Structures/TrackMania/OnStuntEventStructure.php index 09ca3bd6..79e8d0d1 100644 --- a/core/Callbacks/Structures/TrackMania/OnStuntEventStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnStuntEventStructure.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnStuntEventStructure extends BasePlayerTimeStructure { diff --git a/core/Callbacks/Structures/TrackMania/OnWarmupStartEndRoundStructure.php b/core/Callbacks/Structures/TrackMania/OnWarmupStartEndRoundStructure.php index 235c9feb..f59154e1 100644 --- a/core/Callbacks/Structures/TrackMania/OnWarmupStartEndRoundStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnWarmupStartEndRoundStructure.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnWarmupStartEndRoundStructure extends BaseStructure { diff --git a/core/Callbacks/Structures/TrackMania/OnWayPointEventStructure.php b/core/Callbacks/Structures/TrackMania/OnWayPointEventStructure.php index 882fa21f..a946a8fa 100644 --- a/core/Callbacks/Structures/TrackMania/OnWayPointEventStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnWayPointEventStructure.php @@ -12,7 +12,7 @@ use ManiaControl\Utils\Formatter; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class OnWayPointEventStructure extends BasePlayerTimeStructure { diff --git a/core/Callbacks/Structures/XmlRpc/AllApiVersionsStructure.php b/core/Callbacks/Structures/XmlRpc/AllApiVersionsStructure.php index d371360e..3ee79921 100644 --- a/core/Callbacks/Structures/XmlRpc/AllApiVersionsStructure.php +++ b/core/Callbacks/Structures/XmlRpc/AllApiVersionsStructure.php @@ -10,7 +10,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class AllApiVersionsStructure extends BaseResponseStructure { diff --git a/core/Callbacks/Structures/XmlRpc/ApiVersionStructure.php b/core/Callbacks/Structures/XmlRpc/ApiVersionStructure.php index a367078f..07452171 100644 --- a/core/Callbacks/Structures/XmlRpc/ApiVersionStructure.php +++ b/core/Callbacks/Structures/XmlRpc/ApiVersionStructure.php @@ -10,7 +10,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class ApiVersionStructure extends BaseResponseStructure { diff --git a/core/Callbacks/Structures/XmlRpc/CallbackHelpStructure.php b/core/Callbacks/Structures/XmlRpc/CallbackHelpStructure.php index d44fd3a4..d26cc9a8 100644 --- a/core/Callbacks/Structures/XmlRpc/CallbackHelpStructure.php +++ b/core/Callbacks/Structures/XmlRpc/CallbackHelpStructure.php @@ -9,7 +9,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class CallbackHelpStructure extends DocumentationStructure { diff --git a/core/Callbacks/Structures/XmlRpc/CallbackListStructure.php b/core/Callbacks/Structures/XmlRpc/CallbackListStructure.php index c0e5759d..6481c6e3 100644 --- a/core/Callbacks/Structures/XmlRpc/CallbackListStructure.php +++ b/core/Callbacks/Structures/XmlRpc/CallbackListStructure.php @@ -10,7 +10,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class CallbackListStructure extends BaseResponseStructure { diff --git a/core/Callbacks/Structures/XmlRpc/DocumentationStructure.php b/core/Callbacks/Structures/XmlRpc/DocumentationStructure.php index a0eb2b09..c95ddbf9 100644 --- a/core/Callbacks/Structures/XmlRpc/DocumentationStructure.php +++ b/core/Callbacks/Structures/XmlRpc/DocumentationStructure.php @@ -10,7 +10,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class DocumentationStructure extends BaseResponseStructure { diff --git a/core/Callbacks/Structures/XmlRpc/MethodHelpStructure.php b/core/Callbacks/Structures/XmlRpc/MethodHelpStructure.php index cebc1655..b1e72c23 100644 --- a/core/Callbacks/Structures/XmlRpc/MethodHelpStructure.php +++ b/core/Callbacks/Structures/XmlRpc/MethodHelpStructure.php @@ -9,7 +9,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class MethodHelpStructure extends DocumentationStructure { diff --git a/core/Callbacks/Structures/XmlRpc/MethodListStructure.php b/core/Callbacks/Structures/XmlRpc/MethodListStructure.php index 13ae8018..59ce2864 100644 --- a/core/Callbacks/Structures/XmlRpc/MethodListStructure.php +++ b/core/Callbacks/Structures/XmlRpc/MethodListStructure.php @@ -10,7 +10,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class MethodListStructure extends BaseResponseStructure { diff --git a/core/Callbacks/TimerListener.php b/core/Callbacks/TimerListener.php index a236e63f..5c8e5bb7 100644 --- a/core/Callbacks/TimerListener.php +++ b/core/Callbacks/TimerListener.php @@ -6,7 +6,7 @@ namespace ManiaControl\Callbacks; * Interface for TimerListener * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ interface TimerListener { diff --git a/core/Callbacks/TimerListening.php b/core/Callbacks/TimerListening.php index 7a34647b..a723e14c 100644 --- a/core/Callbacks/TimerListening.php +++ b/core/Callbacks/TimerListening.php @@ -9,7 +9,7 @@ use ManiaControl\General\UsageInformationTrait; * Model Class for a Timer Listening * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class TimerListening extends Listening implements UsageInformationAble { diff --git a/core/Callbacks/TimerManager.php b/core/Callbacks/TimerManager.php index 21efe314..1eefdc9d 100644 --- a/core/Callbacks/TimerManager.php +++ b/core/Callbacks/TimerManager.php @@ -10,7 +10,7 @@ use ManiaControl\ManiaControl; * Class for managing Timed Callbacks * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class TimerManager implements UsageInformationAble { diff --git a/core/Callbacks/TrackManiaCallbacks.php b/core/Callbacks/TrackManiaCallbacks.php index d7297f30..3e81b997 100644 --- a/core/Callbacks/TrackManiaCallbacks.php +++ b/core/Callbacks/TrackManiaCallbacks.php @@ -19,7 +19,7 @@ use ManiaControl\ManiaControl; * Class handling and parsing TrackMania Callbacks * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class TrackManiaCallbacks implements CallbackListener { diff --git a/core/Chat.php b/core/Chat.php index 706191b1..209fb9c3 100644 --- a/core/Chat.php +++ b/core/Chat.php @@ -17,7 +17,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException; * Chat Utility Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class Chat implements CallbackListener, CommunicationListener, UsageInformationAble { diff --git a/core/Commands/CommandListener.php b/core/Commands/CommandListener.php index 8907e874..c8fd5245 100644 --- a/core/Commands/CommandListener.php +++ b/core/Commands/CommandListener.php @@ -6,7 +6,7 @@ namespace ManiaControl\Commands; * Interface for Command Listeners * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ interface CommandListener { diff --git a/core/Commands/CommandManager.php b/core/Commands/CommandManager.php index 5a1c0780..93363ec9 100644 --- a/core/Commands/CommandManager.php +++ b/core/Commands/CommandManager.php @@ -13,7 +13,7 @@ use ManiaControl\ManiaControl; * Class for handling Chat Commands * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class CommandManager implements CallbackListener, UsageInformationAble { diff --git a/core/Commands/HelpManager.php b/core/Commands/HelpManager.php index bc8f01b4..4706f542 100644 --- a/core/Commands/HelpManager.php +++ b/core/Commands/HelpManager.php @@ -19,7 +19,7 @@ use ManiaControl\Players\Player; * ManiaControl Help Manager Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAnswerListener { diff --git a/core/Communication/Communication.php b/core/Communication/Communication.php index ddd8b2e3..aa6620f7 100644 --- a/core/Communication/Communication.php +++ b/core/Communication/Communication.php @@ -7,7 +7,7 @@ namespace ManiaControl\Communication; * to call @see \ManiaControl\Communication\CommunicationManager::createCommunication() * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class Communication { diff --git a/core/Communication/CommunicationAnswer.php b/core/Communication/CommunicationAnswer.php index b5d00136..b39f14b2 100644 --- a/core/Communication/CommunicationAnswer.php +++ b/core/Communication/CommunicationAnswer.php @@ -6,7 +6,7 @@ namespace ManiaControl\Communication; * Class for Answer of Communication Request * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class CommunicationAnswer { diff --git a/core/Communication/CommunicationListener.php b/core/Communication/CommunicationListener.php index 78678e74..dda7852f 100644 --- a/core/Communication/CommunicationListener.php +++ b/core/Communication/CommunicationListener.php @@ -6,7 +6,7 @@ namespace ManiaControl\Communication; * Interface for SocketListener * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ interface CommunicationListener { diff --git a/core/Communication/CommunicationManager.php b/core/Communication/CommunicationManager.php index b319b537..2362d740 100644 --- a/core/Communication/CommunicationManager.php +++ b/core/Communication/CommunicationManager.php @@ -21,7 +21,7 @@ use React\Socket\Server; * Class for managing Socket Callbacks * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class CommunicationManager implements CallbackListener, UsageInformationAble { diff --git a/core/Communication/CommunicationMethods.php b/core/Communication/CommunicationMethods.php index ae8b9f40..8f47de38 100644 --- a/core/Communication/CommunicationMethods.php +++ b/core/Communication/CommunicationMethods.php @@ -6,7 +6,7 @@ namespace ManiaControl\Communication; * Communication Methods Interface * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ interface CommunicationMethods { diff --git a/core/Configurator/Configurator.php b/core/Configurator/Configurator.php index ddb31932..cf437f8a 100644 --- a/core/Configurator/Configurator.php +++ b/core/Configurator/Configurator.php @@ -25,7 +25,7 @@ use ManiaControl\Server\VoteRatiosMenu; * Class managing ingame ManiaControl Configuration * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class Configurator implements CallbackListener, CommandListener, ManialinkPageAnswerListener { diff --git a/core/Configurator/ConfiguratorMenu.php b/core/Configurator/ConfiguratorMenu.php index aef75c8a..19777b15 100644 --- a/core/Configurator/ConfiguratorMenu.php +++ b/core/Configurator/ConfiguratorMenu.php @@ -9,7 +9,7 @@ use ManiaControl\Players\Player; * Interface for Configurator Menus * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ interface ConfiguratorMenu { diff --git a/core/Configurator/ManiaControlSettings.php b/core/Configurator/ManiaControlSettings.php index 55c914af..1ba57175 100644 --- a/core/Configurator/ManiaControlSettings.php +++ b/core/Configurator/ManiaControlSettings.php @@ -23,7 +23,7 @@ use ManiaControl\Settings\Setting; * Class offering a Configurator for ManiaControl Settings * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener { diff --git a/core/Configurator/ScriptSettings.php b/core/Configurator/ScriptSettings.php index 56c41713..45e936ae 100644 --- a/core/Configurator/ScriptSettings.php +++ b/core/Configurator/ScriptSettings.php @@ -27,7 +27,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; * Class offering a Configurator for Script Settings * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class ScriptSettings implements ConfiguratorMenu, CallbackListener, CommunicationListener { diff --git a/core/Database/Config.php b/core/Database/Config.php index 6a76bb52..16a3a895 100644 --- a/core/Database/Config.php +++ b/core/Database/Config.php @@ -6,7 +6,7 @@ namespace ManiaControl\Database; * Model Class holding the Database Config * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class Config { diff --git a/core/Database/Database.php b/core/Database/Database.php index 471594f9..0cebe7cf 100644 --- a/core/Database/Database.php +++ b/core/Database/Database.php @@ -10,7 +10,7 @@ use ManiaControl\ManiaControl; * Database Connection Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class Database implements TimerListener { diff --git a/core/Database/MigrationHelper.php b/core/Database/MigrationHelper.php index 7f08ce4f..92910ea9 100644 --- a/core/Database/MigrationHelper.php +++ b/core/Database/MigrationHelper.php @@ -10,7 +10,7 @@ use ManiaControl\Utils\ClassUtil; * Database Migration Assistant * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class MigrationHelper { diff --git a/core/ErrorHandler.php b/core/ErrorHandler.php index 0f455088..88edd08c 100644 --- a/core/ErrorHandler.php +++ b/core/ErrorHandler.php @@ -13,7 +13,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\TransportException; * Error and Exception Manager Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class ErrorHandler { diff --git a/core/Files/AsyncHttpRequest.php b/core/Files/AsyncHttpRequest.php index fc0f9885..92623040 100644 --- a/core/Files/AsyncHttpRequest.php +++ b/core/Files/AsyncHttpRequest.php @@ -12,7 +12,7 @@ use ManiaControl\ManiaControl; * Asynchronous Http Request Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class AsyncHttpRequest implements UsageInformationAble { diff --git a/core/Files/AsynchronousFileReader.php b/core/Files/AsynchronousFileReader.php index 39f4742a..57a864d9 100644 --- a/core/Files/AsynchronousFileReader.php +++ b/core/Files/AsynchronousFileReader.php @@ -12,7 +12,7 @@ use ManiaControl\ManiaControl; * Asynchronous File Reader * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class AsynchronousFileReader implements UsageInformationAble { diff --git a/core/Files/BackupUtil.php b/core/Files/BackupUtil.php index 08c67986..02c940f1 100644 --- a/core/Files/BackupUtil.php +++ b/core/Files/BackupUtil.php @@ -9,7 +9,7 @@ use ManiaControl\ManiaControl; * Backup Utility Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ abstract class BackupUtil { diff --git a/core/Files/FileUtil.php b/core/Files/FileUtil.php index ca079e11..b4791873 100644 --- a/core/Files/FileUtil.php +++ b/core/Files/FileUtil.php @@ -10,7 +10,7 @@ use ManiaControl\Utils\WebReader; * Files Utility Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ abstract class FileUtil { diff --git a/core/Logger.php b/core/Logger.php index 1743efcc..4f47ef40 100644 --- a/core/Logger.php +++ b/core/Logger.php @@ -11,7 +11,7 @@ use ManiaControl\Utils\Formatter; * ManiaControl Logger Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ abstract class Logger implements UsageInformationAble { diff --git a/core/ManiaControl.php b/core/ManiaControl.php index 50214d87..382f177e 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -43,7 +43,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\TransportException; * ManiaControl Server Controller for ManiaPlanet Server * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class ManiaControl implements CallbackListener, CommandListener, TimerListener, CommunicationListener, UsageInformationAble { diff --git a/core/ManiaExchange/MXMapInfo.php b/core/ManiaExchange/MXMapInfo.php index 61d2c87a..ed9c6a2f 100644 --- a/core/ManiaExchange/MXMapInfo.php +++ b/core/ManiaExchange/MXMapInfo.php @@ -9,7 +9,7 @@ use ManiaControl\Utils\Formatter; * * @author Xymph * @updated kremsy - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class MXMapInfo { diff --git a/core/ManiaExchange/ManiaExchangeList.php b/core/ManiaExchange/ManiaExchangeList.php index f93e2155..d6e0723e 100644 --- a/core/ManiaExchange/ManiaExchangeList.php +++ b/core/ManiaExchange/ManiaExchangeList.php @@ -28,7 +28,7 @@ use ManiaControl\Utils\Formatter; * ManiaExchange List Widget Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener { diff --git a/core/ManiaExchange/ManiaExchangeManager.php b/core/ManiaExchange/ManiaExchangeManager.php index 015b92ec..06988e97 100644 --- a/core/ManiaExchange/ManiaExchangeManager.php +++ b/core/ManiaExchange/ManiaExchangeManager.php @@ -13,7 +13,7 @@ use ManiaControl\Maps\MapManager; * Mania Exchange Manager Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class ManiaExchangeManager implements UsageInformationAble { diff --git a/core/ManiaExchange/ManiaExchangeMapSearch.php b/core/ManiaExchange/ManiaExchangeMapSearch.php index 9ec992a0..5dc61c50 100644 --- a/core/ManiaExchange/ManiaExchangeMapSearch.php +++ b/core/ManiaExchange/ManiaExchangeMapSearch.php @@ -12,7 +12,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; * Mania Exchange Map Searching Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class ManiaExchangeMapSearch implements UsageInformationAble { diff --git a/core/Manialinks/CustomUIManager.php b/core/Manialinks/CustomUIManager.php index a1c8e174..4eff5ccb 100644 --- a/core/Manialinks/CustomUIManager.php +++ b/core/Manialinks/CustomUIManager.php @@ -16,7 +16,7 @@ use ManiaControl\Players\PlayerManager; * Class managing the Custom UI in ManiaPlanet * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class CustomUIManager implements CallbackListener, TimerListener, UsageInformationAble, CommandListener { diff --git a/core/Manialinks/IconManager.php b/core/Manialinks/IconManager.php index cb579416..e2bfb029 100644 --- a/core/Manialinks/IconManager.php +++ b/core/Manialinks/IconManager.php @@ -17,7 +17,7 @@ use ManiaControl\Players\PlayerManager; * Class managing Icons * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class IconManager implements CallbackListener, UsageInformationAble { diff --git a/core/Manialinks/LabelLine.php b/core/Manialinks/LabelLine.php index 3d031f74..d65db25f 100644 --- a/core/Manialinks/LabelLine.php +++ b/core/Manialinks/LabelLine.php @@ -12,7 +12,7 @@ use ManiaControl\General\UsageInformationTrait; * Class providing easy labels in a line * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class LabelLine implements UsageInformationAble { diff --git a/core/Manialinks/ManialinkManager.php b/core/Manialinks/ManialinkManager.php index 772293ea..03b1a5b4 100644 --- a/core/Manialinks/ManialinkManager.php +++ b/core/Manialinks/ManialinkManager.php @@ -21,7 +21,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException; * Manialink Manager Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener, UsageInformationAble { diff --git a/core/Manialinks/ManialinkPageAnswerListener.php b/core/Manialinks/ManialinkPageAnswerListener.php index b27cd808..7039e532 100644 --- a/core/Manialinks/ManialinkPageAnswerListener.php +++ b/core/Manialinks/ManialinkPageAnswerListener.php @@ -6,7 +6,7 @@ namespace ManiaControl\Manialinks; * Interface for Manialink Page Answer Listeners * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ interface ManialinkPageAnswerListener { diff --git a/core/Manialinks/SidebarMenuEntryListener.php b/core/Manialinks/SidebarMenuEntryListener.php index b3609f9c..999451d8 100644 --- a/core/Manialinks/SidebarMenuEntryListener.php +++ b/core/Manialinks/SidebarMenuEntryListener.php @@ -8,7 +8,7 @@ namespace ManiaControl\Manialinks; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ diff --git a/core/Manialinks/SidebarMenuManager.php b/core/Manialinks/SidebarMenuManager.php index b989574d..36b2bf55 100644 --- a/core/Manialinks/SidebarMenuManager.php +++ b/core/Manialinks/SidebarMenuManager.php @@ -13,7 +13,7 @@ use ManiaControl\ManiaControl; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class SidebarMenuManager implements UsageInformationAble, CallbackListener { diff --git a/core/Manialinks/StyleManager.php b/core/Manialinks/StyleManager.php index 4fd4975b..0d98d21b 100644 --- a/core/Manialinks/StyleManager.php +++ b/core/Manialinks/StyleManager.php @@ -23,7 +23,7 @@ use ManiaControl\ManiaControl; * Class managing default Control Styles * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class StyleManager implements UsageInformationAble { diff --git a/core/Maps/DirectoryBrowser.php b/core/Maps/DirectoryBrowser.php index a4d92f01..ac3859ac 100644 --- a/core/Maps/DirectoryBrowser.php +++ b/core/Maps/DirectoryBrowser.php @@ -25,7 +25,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\InvalidMapException; * Maps Directory Browser * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class DirectoryBrowser implements ManialinkPageAnswerListener { diff --git a/core/Maps/Map.php b/core/Maps/Map.php index e0bf20bc..6c0d0ddd 100644 --- a/core/Maps/Map.php +++ b/core/Maps/Map.php @@ -13,7 +13,7 @@ use ManiaControl\Utils\Formatter; * ManiaControl Map Model Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class Map implements Dumpable, UsageInformationAble { diff --git a/core/Maps/MapActions.php b/core/Maps/MapActions.php index 90fcd75b..da96a7b7 100644 --- a/core/Maps/MapActions.php +++ b/core/Maps/MapActions.php @@ -14,7 +14,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\ChangeInProgressException; * ManiaControl Map Actions Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class MapActions implements CommunicationListener, UsageInformationAble { diff --git a/core/Maps/MapCommands.php b/core/Maps/MapCommands.php index 43b0a779..0550c636 100644 --- a/core/Maps/MapCommands.php +++ b/core/Maps/MapCommands.php @@ -21,7 +21,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\FaultException; * Class offering Commands to manage Maps * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class MapCommands implements CommandListener, ManialinkPageAnswerListener, CallbackListener { diff --git a/core/Maps/MapList.php b/core/Maps/MapList.php index 2a888cae..ce1669a2 100644 --- a/core/Maps/MapList.php +++ b/core/Maps/MapList.php @@ -36,7 +36,7 @@ use MCTeam\KarmaPlugin; * MapList Widget Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class MapList implements ManialinkPageAnswerListener, CallbackListener { diff --git a/core/Maps/MapManager.php b/core/Maps/MapManager.php index e24359a8..551f1f75 100644 --- a/core/Maps/MapManager.php +++ b/core/Maps/MapManager.php @@ -34,7 +34,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnavailableFeatureException; * ManiaControl Map Manager Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class MapManager implements CallbackListener, CommunicationListener, UsageInformationAble { diff --git a/core/Maps/MapQueue.php b/core/Maps/MapQueue.php index 49591ae9..d0cdff7d 100644 --- a/core/Maps/MapQueue.php +++ b/core/Maps/MapQueue.php @@ -19,7 +19,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\NotInListException; * ManiaControl Map Queue Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class MapQueue implements CallbackListener, CommandListener, UsageInformationAble { diff --git a/core/Players/Player.php b/core/Players/Player.php index 68e49e5e..3df19746 100644 --- a/core/Players/Player.php +++ b/core/Players/Player.php @@ -16,7 +16,7 @@ use Maniaplanet\DedicatedServer\Structures\LadderStats; * Player Model Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class Player implements Dumpable, UsageInformationAble { diff --git a/core/Players/PlayerActions.php b/core/Players/PlayerActions.php index 47b78b10..f0038036 100644 --- a/core/Players/PlayerActions.php +++ b/core/Players/PlayerActions.php @@ -30,7 +30,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class PlayerActions implements EchoListener, CommunicationListener, UsageInformationAble { diff --git a/core/Players/PlayerCommands.php b/core/Players/PlayerCommands.php index 73d02ace..1e5ec9da 100644 --- a/core/Players/PlayerCommands.php +++ b/core/Players/PlayerCommands.php @@ -17,7 +17,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnavailableFeatureException; * Class offering various Admin Commands related to Players * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, CallbackListener { diff --git a/core/Players/PlayerDataManager.php b/core/Players/PlayerDataManager.php index 5a392c72..32d3e104 100644 --- a/core/Players/PlayerDataManager.php +++ b/core/Players/PlayerDataManager.php @@ -12,7 +12,7 @@ use ManiaControl\Utils\ClassUtil; * Player Data Manager * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class PlayerDataManager implements UsageInformationAble { diff --git a/core/Players/PlayerDetailed.php b/core/Players/PlayerDetailed.php index c96ea346..bf50bd06 100644 --- a/core/Players/PlayerDetailed.php +++ b/core/Players/PlayerDetailed.php @@ -17,7 +17,7 @@ use ManiaControl\Utils\Formatter; * Player Detailed Page * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class PlayerDetailed { diff --git a/core/Players/PlayerList.php b/core/Players/PlayerList.php index 51f79b06..33225cfa 100644 --- a/core/Players/PlayerList.php +++ b/core/Players/PlayerList.php @@ -30,7 +30,7 @@ use MCTeam\CustomVotesPlugin; * PlayerList Widget Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, TimerListener { diff --git a/core/Players/PlayerManager.php b/core/Players/PlayerManager.php index 36f6df1d..476174eb 100644 --- a/core/Players/PlayerManager.php +++ b/core/Players/PlayerManager.php @@ -24,7 +24,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class PlayerManager implements CallbackListener, TimerListener, CommunicationListener, UsageInformationAble { diff --git a/core/Plugins/InstallMenu.php b/core/Plugins/InstallMenu.php index a1a61090..0be42d8e 100644 --- a/core/Plugins/InstallMenu.php +++ b/core/Plugins/InstallMenu.php @@ -21,7 +21,7 @@ use ManiaControl\Utils\WebReader; * Configurator for installing Plugins * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener { diff --git a/core/Plugins/Plugin.php b/core/Plugins/Plugin.php index 6b406575..63ff2686 100644 --- a/core/Plugins/Plugin.php +++ b/core/Plugins/Plugin.php @@ -8,7 +8,7 @@ use ManiaControl\ManiaControl; * Interface for ManiaControl Plugins * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ interface Plugin { diff --git a/core/Plugins/PluginManager.php b/core/Plugins/PluginManager.php index 64781429..10c93f49 100644 --- a/core/Plugins/PluginManager.php +++ b/core/Plugins/PluginManager.php @@ -21,7 +21,7 @@ use ReflectionClass; * Class managing Plugins * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class PluginManager { diff --git a/core/Plugins/PluginMenu.php b/core/Plugins/PluginMenu.php index b33d3414..e4ea5d7f 100644 --- a/core/Plugins/PluginMenu.php +++ b/core/Plugins/PluginMenu.php @@ -29,7 +29,7 @@ use ManiaControl\Settings\Setting; * Configurator for enabling and disabling Plugins * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAnswerListener { diff --git a/core/Script/InvokeScriptCallback.php b/core/Script/InvokeScriptCallback.php index 6ae76ced..5a5f4bd6 100644 --- a/core/Script/InvokeScriptCallback.php +++ b/core/Script/InvokeScriptCallback.php @@ -12,7 +12,7 @@ use ManiaControl\General\UsageInformationTrait; * Class For Invoking Callbacks on Script Methods * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class InvokeScriptCallback implements CallbackListener, UsageInformationAble { diff --git a/core/Script/ModeScriptEventManager.php b/core/Script/ModeScriptEventManager.php index 9ba8c7d4..489fbc88 100644 --- a/core/Script/ModeScriptEventManager.php +++ b/core/Script/ModeScriptEventManager.php @@ -17,7 +17,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; * Manager for Mode Script Events * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class ModeScriptEventManager implements UsageInformationAble { diff --git a/core/Script/ScriptManager.php b/core/Script/ScriptManager.php index 225f59c3..7a246f17 100644 --- a/core/Script/ScriptManager.php +++ b/core/Script/ScriptManager.php @@ -15,7 +15,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class ScriptManager implements UsageInformationAble { diff --git a/core/Server/Commands.php b/core/Server/Commands.php index e3ce5560..6595bef8 100644 --- a/core/Server/Commands.php +++ b/core/Server/Commands.php @@ -22,7 +22,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; * Class offering various Commands related to the Dedicated Server * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswerListener, TimerListener { diff --git a/core/Server/Config.php b/core/Server/Config.php index 4df4e20f..f7ea5d7f 100644 --- a/core/Server/Config.php +++ b/core/Server/Config.php @@ -6,7 +6,7 @@ namespace ManiaControl\Server; * Model Class holding the Server Config * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class Config { diff --git a/core/Server/Directory.php b/core/Server/Directory.php index f451b221..a248a471 100644 --- a/core/Server/Directory.php +++ b/core/Server/Directory.php @@ -13,7 +13,7 @@ use ManiaControl\ManiaControl; * Class offering Operations for the Server Directory * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class Directory implements CallbackListener, UsageInformationAble { diff --git a/core/Server/RankingManager.php b/core/Server/RankingManager.php index 044a9644..33cb440b 100644 --- a/core/Server/RankingManager.php +++ b/core/Server/RankingManager.php @@ -16,7 +16,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; * * @deprecated * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class RankingManager implements CallbackListener, UsageInformationAble { diff --git a/core/Server/Server.php b/core/Server/Server.php index bfa8825d..556521e1 100644 --- a/core/Server/Server.php +++ b/core/Server/Server.php @@ -18,7 +18,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\Exception; * Class providing access to the connected ManiaPlanet Server * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class Server implements CallbackListener, CommandListener, UsageInformationAble { diff --git a/core/Server/ServerOptionsMenu.php b/core/Server/ServerOptionsMenu.php index bbb653f7..e35f6be2 100644 --- a/core/Server/ServerOptionsMenu.php +++ b/core/Server/ServerOptionsMenu.php @@ -28,7 +28,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\ServerOptionsException; * Class offering a Configurator Menu for Server Options * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class ServerOptionsMenu implements CallbackListener, ConfiguratorMenu, TimerListener, CommunicationListener { diff --git a/core/Server/UsageReporter.php b/core/Server/UsageReporter.php index 3d4b890b..f19d4ad8 100644 --- a/core/Server/UsageReporter.php +++ b/core/Server/UsageReporter.php @@ -13,7 +13,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; * Class reporting ManiaControl Usage for the Server * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class UsageReporter implements TimerListener { diff --git a/core/Server/VoteRatiosMenu.php b/core/Server/VoteRatiosMenu.php index 5d64d947..f3587dbb 100644 --- a/core/Server/VoteRatiosMenu.php +++ b/core/Server/VoteRatiosMenu.php @@ -18,7 +18,7 @@ use Maniaplanet\DedicatedServer\Structures\VoteRatio; * Class offering a Configurator Menu for Vote Ratios * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class VoteRatiosMenu implements CallbackListener, ConfiguratorMenu, TimerListener { diff --git a/core/Settings/Setting.php b/core/Settings/Setting.php index 17df7032..29627f5d 100644 --- a/core/Settings/Setting.php +++ b/core/Settings/Setting.php @@ -10,7 +10,7 @@ use ManiaControl\Utils\ClassUtil; * ManiaControl Setting Model Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class Setting implements UsageInformationAble { diff --git a/core/Settings/SettingManager.php b/core/Settings/SettingManager.php index b91a9b9f..bde44b34 100644 --- a/core/Settings/SettingManager.php +++ b/core/Settings/SettingManager.php @@ -14,7 +14,7 @@ use ManiaControl\Utils\ClassUtil; * Class managing ManiaControl Settings and Configurations * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class SettingManager implements CallbackListener, UsageInformationAble { diff --git a/core/Statistics/SimpleStatsList.php b/core/Statistics/SimpleStatsList.php index d226ae28..30166b30 100644 --- a/core/Statistics/SimpleStatsList.php +++ b/core/Statistics/SimpleStatsList.php @@ -28,7 +28,7 @@ use ManiaControl\Utils\Formatter; * Simple Stats List Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, CommandListener { diff --git a/core/Statistics/StatisticCollector.php b/core/Statistics/StatisticCollector.php index 6dfa2c99..f465f7e9 100644 --- a/core/Statistics/StatisticCollector.php +++ b/core/Statistics/StatisticCollector.php @@ -22,7 +22,7 @@ use ManiaControl\Players\PlayerManager; * Statistic Collector Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class StatisticCollector implements CallbackListener { //TODO remove old callbacks later diff --git a/core/Statistics/StatisticManager.php b/core/Statistics/StatisticManager.php index ecb5d616..218fca47 100644 --- a/core/Statistics/StatisticManager.php +++ b/core/Statistics/StatisticManager.php @@ -13,7 +13,7 @@ use ManiaControl\Players\PlayerManager; * * @api * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class StatisticManager implements UsageInformationAble { diff --git a/core/Update/PluginUpdateData.php b/core/Update/PluginUpdateData.php index ea82882c..7b1ef72d 100644 --- a/core/Update/PluginUpdateData.php +++ b/core/Update/PluginUpdateData.php @@ -6,7 +6,7 @@ namespace ManiaControl\Update; * Plugin Update Data Model Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class PluginUpdateData { diff --git a/core/Update/PluginUpdateManager.php b/core/Update/PluginUpdateManager.php index a9ba135b..f9823677 100644 --- a/core/Update/PluginUpdateManager.php +++ b/core/Update/PluginUpdateManager.php @@ -22,7 +22,7 @@ use ManiaControl\Utils\WebReader; * Manager checking for ManiaControl Plugin Updates * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class PluginUpdateManager implements CallbackListener, CommandListener, TimerListener { diff --git a/core/Update/UpdateData.php b/core/Update/UpdateData.php index 14cf9922..f166c0e3 100644 --- a/core/Update/UpdateData.php +++ b/core/Update/UpdateData.php @@ -6,7 +6,7 @@ namespace ManiaControl\Update; * ManiaControl Update Data Model Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class UpdateData { diff --git a/core/Update/UpdateManager.php b/core/Update/UpdateManager.php index 09f1c785..79e5ed6e 100644 --- a/core/Update/UpdateManager.php +++ b/core/Update/UpdateManager.php @@ -21,7 +21,7 @@ use ManiaControl\Players\PlayerManager; * Manager checking for ManiaControl Core Updates * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class UpdateManager implements CallbackListener, CommandListener, TimerListener, CommunicationListener { diff --git a/core/Utils/ClassUtil.php b/core/Utils/ClassUtil.php index d9d4109a..05b8e3b7 100644 --- a/core/Utils/ClassUtil.php +++ b/core/Utils/ClassUtil.php @@ -6,7 +6,7 @@ namespace ManiaControl\Utils; * Utility Class offering Methods related to Classes * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ abstract class ClassUtil { diff --git a/core/Utils/ColorUtil.php b/core/Utils/ColorUtil.php index 35f796d7..25d0bb79 100644 --- a/core/Utils/ColorUtil.php +++ b/core/Utils/ColorUtil.php @@ -9,7 +9,7 @@ use ManiaControl\General\UsageInformationTrait; * Utility Class offering Methods to convert and use ManiaPlanet Colors * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ abstract class ColorUtil implements UsageInformationAble { diff --git a/core/Utils/CommandLineHelper.php b/core/Utils/CommandLineHelper.php index 5e719d36..a04ce15f 100644 --- a/core/Utils/CommandLineHelper.php +++ b/core/Utils/CommandLineHelper.php @@ -9,7 +9,7 @@ use ManiaControl\General\UsageInformationTrait; * Command Line Helper Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class CommandLineHelper implements UsageInformationAble { diff --git a/core/Utils/Formatter.php b/core/Utils/Formatter.php index a097be63..7df8937c 100644 --- a/core/Utils/Formatter.php +++ b/core/Utils/Formatter.php @@ -10,7 +10,7 @@ use ManiaControl\Logger; * Class offering Methods to format Texts and Values * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ abstract class Formatter implements UsageInformationAble { diff --git a/core/Utils/SystemUtil.php b/core/Utils/SystemUtil.php index 8f5949c0..d647eff2 100644 --- a/core/Utils/SystemUtil.php +++ b/core/Utils/SystemUtil.php @@ -8,7 +8,7 @@ use ManiaControl\Logger; * System Utility Class * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class SystemUtil { diff --git a/core/Utils/WebReader.php b/core/Utils/WebReader.php index be2f8306..1b73de2f 100644 --- a/core/Utils/WebReader.php +++ b/core/Utils/WebReader.php @@ -11,7 +11,7 @@ use ManiaControl\ManiaControl; * * @see \ManiaControl\Files\AsyncHttpRequest For Asynchron Requests * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ abstract class WebReader { diff --git a/phpunittests/core/LoggerTest.php b/phpunittests/core/LoggerTest.php index f3643b46..bf325c6f 100644 --- a/phpunittests/core/LoggerTest.php +++ b/phpunittests/core/LoggerTest.php @@ -6,7 +6,7 @@ use ManiaControl\Logger; * PHP Unit Test for Logger Class * * @author ManiaControl Team - * @copyright 2014-2018 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class LoggerTest extends PHPUnit_Framework_TestCase { diff --git a/phpunittests/core/ManiaControlTest.php b/phpunittests/core/ManiaControlTest.php index e9957ec8..e0e57508 100644 --- a/phpunittests/core/ManiaControlTest.php +++ b/phpunittests/core/ManiaControlTest.php @@ -6,7 +6,7 @@ use ManiaControl\ManiaControl; * PHP Unit Test for Mania Control Class * * @author ManiaControl Team - * @copyright 2014-2018 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class ManiaControlTest extends PHPUnit_Framework_TestCase { diff --git a/phpunittests/core/Manialinks/CustomUIManagerTest.php b/phpunittests/core/Manialinks/CustomUIManagerTest.php index 002ef4db..241d28ee 100644 --- a/phpunittests/core/Manialinks/CustomUIManagerTest.php +++ b/phpunittests/core/Manialinks/CustomUIManagerTest.php @@ -6,7 +6,7 @@ use ManiaControl\ManiaControl; * PHP Unit Test for Custom UI Manager * * @author ManiaControl Team - * @copyright 2014-2018 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class CustomUIManagerTest extends PHPUnit_Framework_TestCase { diff --git a/phpunittests/core/Manialinks/LabelLineTest.php b/phpunittests/core/Manialinks/LabelLineTest.php index 6d90b221..992326bc 100644 --- a/phpunittests/core/Manialinks/LabelLineTest.php +++ b/phpunittests/core/Manialinks/LabelLineTest.php @@ -8,7 +8,7 @@ use ManiaControl\Manialinks\LabelLine; * PHP Unit Test for Label Line Class * * @author ManiaControl Team - * @copyright 2014-2018 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class LabelLineTest extends PHPUnit_Framework_TestCase { diff --git a/phpunittests/core/Script/ModeScriptEventManagerTest.php b/phpunittests/core/Script/ModeScriptEventManagerTest.php index 4695196f..f0c90b62 100644 --- a/phpunittests/core/Script/ModeScriptEventManagerTest.php +++ b/phpunittests/core/Script/ModeScriptEventManagerTest.php @@ -17,7 +17,7 @@ use ManiaControl\Script\ModeScriptEventManager; * PHP Unit Test for Mode Script Event Manager Class * * @author ManiaControl Team - * @copyright 2014-2018 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class ModeScriptEventManagerTest extends \PHPUnit_Framework_TestCase { diff --git a/phpunittests/core/Update/PluginUpdateManagerTest.php b/phpunittests/core/Update/PluginUpdateManagerTest.php index 9c465702..8d53becd 100644 --- a/phpunittests/core/Update/PluginUpdateManagerTest.php +++ b/phpunittests/core/Update/PluginUpdateManagerTest.php @@ -9,7 +9,7 @@ use ManiaControl\Utils\WebReader; * PHP Unit Test for Plugin Update Manager Class * * @author ManiaControl Team - * @copyright 2014-2018 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class PluginUpdateManagerTest extends \PHPUnit_Framework_TestCase { diff --git a/phpunittests/core/Update/UpdateManagerTest.php b/phpunittests/core/Update/UpdateManagerTest.php index 864a4794..0f53bbdd 100644 --- a/phpunittests/core/Update/UpdateManagerTest.php +++ b/phpunittests/core/Update/UpdateManagerTest.php @@ -11,7 +11,7 @@ use ManiaControl\Update\UpdateManager; * PHP Unit Test for Update Manager Class * * @author ManiaControl Team - * @copyright 2014-2018 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ final class UpdateManagerTest extends \PHPUnit_Framework_TestCase { diff --git a/plugins/MCTeam/ChatMessagePlugin.php b/plugins/MCTeam/ChatMessagePlugin.php index e490d0a1..70ce2a9c 100644 --- a/plugins/MCTeam/ChatMessagePlugin.php +++ b/plugins/MCTeam/ChatMessagePlugin.php @@ -14,7 +14,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException; * ManiaControl Chat-Message Plugin * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class ChatMessagePlugin implements CommandListener, Plugin { diff --git a/plugins/MCTeam/Common/RecordWidget.php b/plugins/MCTeam/Common/RecordWidget.php index b331360d..2078c754 100644 --- a/plugins/MCTeam/Common/RecordWidget.php +++ b/plugins/MCTeam/Common/RecordWidget.php @@ -14,7 +14,7 @@ use ManiaControl\Utils\Formatter; * ManiaControl Local Records Plugin * * @author ManiaControl Team - * @copyright 2014-2018 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class RecordWidget { diff --git a/plugins/MCTeam/CustomVotesPlugin.php b/plugins/MCTeam/CustomVotesPlugin.php index 76dde281..4ff6f0ee 100644 --- a/plugins/MCTeam/CustomVotesPlugin.php +++ b/plugins/MCTeam/CustomVotesPlugin.php @@ -44,7 +44,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; * ManiaControl Custom-Votes Plugin * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class CustomVotesPlugin implements SidebarMenuEntryListener, CommandListener, CallbackListener, ManialinkPageAnswerListener, TimerListener, Plugin { diff --git a/plugins/MCTeam/Dedimania/DedimaniaData.php b/plugins/MCTeam/Dedimania/DedimaniaData.php index fcdd50c9..62533c9e 100644 --- a/plugins/MCTeam/Dedimania/DedimaniaData.php +++ b/plugins/MCTeam/Dedimania/DedimaniaData.php @@ -10,7 +10,7 @@ use Maniaplanet\DedicatedServer\Structures\Version; * ManiaControl Dedimania Plugin Data Structure * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class DedimaniaData { diff --git a/plugins/MCTeam/Dedimania/DedimaniaPlayer.php b/plugins/MCTeam/Dedimania/DedimaniaPlayer.php index 8bf1736b..52f85931 100644 --- a/plugins/MCTeam/Dedimania/DedimaniaPlayer.php +++ b/plugins/MCTeam/Dedimania/DedimaniaPlayer.php @@ -6,7 +6,7 @@ namespace MCTeam\Dedimania; * ManiaControl Dedimania Plugin Player Data Structure * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class DedimaniaPlayer { diff --git a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php index 2da7bea0..94f84aa7 100644 --- a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php +++ b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php @@ -28,7 +28,7 @@ use MCTeam\Common\RecordWidget; * ManiaControl Dedimania Plugin * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListener, Plugin { diff --git a/plugins/MCTeam/Dedimania/DedimaniaWebHandler.php b/plugins/MCTeam/Dedimania/DedimaniaWebHandler.php index 936dd373..45a1dce7 100644 --- a/plugins/MCTeam/Dedimania/DedimaniaWebHandler.php +++ b/plugins/MCTeam/Dedimania/DedimaniaWebHandler.php @@ -13,7 +13,7 @@ use ManiaControl\Players\Player; * ManiaControl Dedimania Webhandler Class for Dedimania Plugin * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class DedimaniaWebHandler implements TimerListener { diff --git a/plugins/MCTeam/Dedimania/RecordData.php b/plugins/MCTeam/Dedimania/RecordData.php index d0c440a0..7ac3c730 100644 --- a/plugins/MCTeam/Dedimania/RecordData.php +++ b/plugins/MCTeam/Dedimania/RecordData.php @@ -8,7 +8,7 @@ use ManiaControl\Utils\Formatter; * ManiaControl Dedimania Plugin Record Data Structure * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class RecordData { diff --git a/plugins/MCTeam/DonationPlugin.php b/plugins/MCTeam/DonationPlugin.php index 00e0f23d..1587e7af 100644 --- a/plugins/MCTeam/DonationPlugin.php +++ b/plugins/MCTeam/DonationPlugin.php @@ -29,7 +29,7 @@ use ManiaControl\Plugins\Plugin; * ManiaControl Donation Plugin * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class DonationPlugin implements CallbackListener, CommandListener, Plugin, SidebarMenuEntryListener { diff --git a/plugins/MCTeam/DynamicPointLimitPlugin.php b/plugins/MCTeam/DynamicPointLimitPlugin.php index a621a907..a1d8ad67 100644 --- a/plugins/MCTeam/DynamicPointLimitPlugin.php +++ b/plugins/MCTeam/DynamicPointLimitPlugin.php @@ -17,7 +17,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; * Dynamic Point Limit Plugin * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ // TODO: test setpointlimit command diff --git a/plugins/MCTeam/KarmaPlugin.php b/plugins/MCTeam/KarmaPlugin.php index df837a52..c3df7883 100644 --- a/plugins/MCTeam/KarmaPlugin.php +++ b/plugins/MCTeam/KarmaPlugin.php @@ -27,7 +27,7 @@ use ManiaControl\Utils\ColorUtil; * ManiaControl Karma Plugin * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { diff --git a/plugins/MCTeam/ServerRankingPlugin.php b/plugins/MCTeam/ServerRankingPlugin.php index acac85e5..bcdad75a 100644 --- a/plugins/MCTeam/ServerRankingPlugin.php +++ b/plugins/MCTeam/ServerRankingPlugin.php @@ -22,7 +22,7 @@ use Maniaplanet\DedicatedServer\Structures\AbstractStructure; * ManiaControl ServerRanking Plugin * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { diff --git a/plugins/MCTeam/TrackmaniaRoundsPlugin.php b/plugins/MCTeam/TrackmaniaRoundsPlugin.php index 84d97040..1fccf8b6 100644 --- a/plugins/MCTeam/TrackmaniaRoundsPlugin.php +++ b/plugins/MCTeam/TrackmaniaRoundsPlugin.php @@ -13,7 +13,7 @@ use ManiaControl\Plugins\Plugin; * ManiaControl Trackmania Rounds Plugin * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class TrackmaniaRoundsPlugin implements Plugin, CommandListener { diff --git a/plugins/MCTeam/WidgetPlugin.php b/plugins/MCTeam/WidgetPlugin.php index 0d0f7200..bd8f4189 100644 --- a/plugins/MCTeam/WidgetPlugin.php +++ b/plugins/MCTeam/WidgetPlugin.php @@ -27,7 +27,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\FaultException; * ManiaControl Widget Plugin * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { From 9252605be0829ee08e31020c336e3f685472fbdd Mon Sep 17 00:00:00 2001 From: kremsy Date: Wed, 22 Jan 2020 10:44:09 +0100 Subject: [PATCH 05/98] version increase --- core/ManiaControl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ManiaControl.php b/core/ManiaControl.php index 382f177e..f31cce1c 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -52,7 +52,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, /* * Constants */ - const VERSION = '0.232'; + const VERSION = '0.240'; const API_VERSION = '2013-04-16'; const MIN_DEDIVERSION = '2017-05-03_21_00'; const SCRIPT_TIMEOUT = 40; From fa7ea9f4f3f1840dbe93440f420e86ee273c4cc5 Mon Sep 17 00:00:00 2001 From: axelalex2 <39660135+axelalex2@users.noreply.github.com> Date: Mon, 24 Feb 2020 17:20:51 +0100 Subject: [PATCH 06/98] Multiple Features to improve ManiaControl usability (#234) * ServerUIPropertiesMenu for Configurator to edit builtin UIProperties of MP * fixed unregister-functions of CallbackManager * Reducing menuItemHeight in Configurator to avoid overlapping of the menu items * Fully rebuild the admins menu after a player rights changed * Added function to FileUtil to improve realpath, so symbolic links can be resolved * Fixed indentation * Update FileUtil.php Fixed error in case of an absolute path on Unix-like systems. * New CallQueue which runs once inbetween the MC-loops * Added important queued call to be executed earlier * ErrorMethod made optional, as in some cases, there might be nothing to fail * Clean up repository from unnecessary files * Added easy installation script for DB on Unix-like systems * Replaced deprecated is_real by is_float * Add milliseconds with dot instead of double colon * Resolved deprecated curly braces error * gitignore all hidden files (except git and gitignore) * Update MC-update-check-interval, so that a restart is not required * Update gitignore to not ignore changes in MCTeam-Plugins * Update gitignore again * And another try * fixed MasterAdmin //delrec, added personal /delrec-command with permission-setting * Increase version number of local records plugin * Add Permission to delete any record * Reworked notifications of locals, removed private only, added private at rank * Fix formatting * Allow AuthenticationManager to store Plugin Permissions * Method to check, if a named function call is already queued * Added command disable feature * Reset timer if DeltaTime updated, so it does not try to catch up missed timings * Added private notification setting * To reduce load of multiple records (especially in rounds), queue call chat notifications * Added internal function to plugin manager to return plugin menu * restore .idea codestyle files * Update MC-Version number to 0.250 --- .gitignore | 11 +- ManiaControl.sh | 0 core/Admin/AuthenticationManager.php | 106 +++++++++-- core/Callbacks/CallQueueListener.php | 13 ++ core/Callbacks/CallQueueListening.php | 69 +++++++ core/Callbacks/CallQueueManager.php | 117 ++++++++++++ core/Callbacks/TimerListening.php | 10 + core/Callbacks/TimerManager.php | 18 ++ core/Commands/CommandManager.php | 153 ++++++++++++++- core/ManiaControl.php | 20 +- core/Plugins/PluginManager.php | 8 + core/Settings/Setting.php | 2 +- core/Statistics/SimpleStatsList.php | 2 +- core/Update/UpdateManager.php | 12 ++ core/Utils/Formatter.php | 2 +- install_db.sh | 24 +++ plugins/MCTeam/Dedimania/DedimaniaPlugin.php | 39 ++-- plugins/MCTeam/LocalRecordsPlugin.php | 185 +++++++++++++------ 18 files changed, 700 insertions(+), 91 deletions(-) mode change 100644 => 100755 ManiaControl.sh create mode 100755 core/Callbacks/CallQueueListener.php create mode 100755 core/Callbacks/CallQueueListening.php create mode 100755 core/Callbacks/CallQueueManager.php create mode 100755 install_db.sh diff --git a/.gitignore b/.gitignore index 3d3c3abe..12e91612 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,11 @@ -.idea -*.iml +.* +!/.git +!/.gitignore +!/.idea /configs/server.xml /logs/ /ManiaControl.log /ManiaControl.pid -!/.idea/encodings.xml -!/.idea/codeStyleSettings.xml +!/plugins/ +/plugins/* +!/plugins/MCTeam/ diff --git a/ManiaControl.sh b/ManiaControl.sh old mode 100644 new mode 100755 diff --git a/core/Admin/AuthenticationManager.php b/core/Admin/AuthenticationManager.php index a69b35de..dd660b6c 100644 --- a/core/Admin/AuthenticationManager.php +++ b/core/Admin/AuthenticationManager.php @@ -14,6 +14,7 @@ use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; use ManiaControl\Players\PlayerManager; +use ManiaControl\Plugins\Plugin; use ManiaControl\Settings\Setting; /** @@ -133,8 +134,10 @@ class AuthenticationManager implements CallbackListener, EchoListener, Communica return self::AUTH_NAME_ADMIN; case self::AUTH_LEVEL_MODERATOR: return self::AUTH_NAME_MODERATOR; + case self::AUTH_LEVEL_PLAYER: + return self::AUTH_NAME_PLAYER; } - return self::AUTH_NAME_PLAYER; + return '-'; } /** @@ -172,8 +175,10 @@ class AuthenticationManager implements CallbackListener, EchoListener, Communica return self::AUTH_LEVEL_ADMIN; case self::AUTH_NAME_MODERATOR: return self::AUTH_LEVEL_MODERATOR; + case self::AUTH_NAME_PLAYER: + return self::AUTH_LEVEL_PLAYER; } - return self::AUTH_LEVEL_PLAYER; + return -1; } /** @@ -420,7 +425,21 @@ class AuthenticationManager implements CallbackListener, EchoListener, Communica */ public function checkPermission(Player $player, $rightName) { $right = $this->maniaControl->getSettingManager()->getSettingValue($this, $rightName); - return $this->checkRight($player, $this->getAuthLevel($right)); + return self::checkRight($player, self::getAuthLevel($right)); + } + + /** + * Checks the permission by a right name + * + * @api + * @param Plugin $plugin + * @param Player $player + * @param $rightName + * @return bool + */ + public function checkPluginPermission(Plugin $plugin, Player $player, $rightName) { + $right = $this->maniaControl->getSettingManager()->getSettingValue($plugin, $rightName); + return self::checkRight($player, self::getAuthLevel($right)); } /** @@ -429,9 +448,23 @@ class AuthenticationManager implements CallbackListener, EchoListener, Communica * @api * @param string $rightName * @param int $authLevelNeeded + * @param string $authLevelsAllowed */ - public function definePermissionLevel($rightName, $authLevelNeeded) { - $this->maniaControl->getSettingManager()->initSetting($this, $rightName, self::getPermissionLevelNameArray($authLevelNeeded)); + public function definePermissionLevel($rightName, $authLevelNeeded, $authLevelsAllowed = self::AUTH_LEVEL_MODERATOR) { + $this->maniaControl->getSettingManager()->initSetting($this, $rightName, self::getPermissionLevelNameArray($authLevelNeeded, $authLevelsAllowed)); + } + + /** + * Define a Minimum Right Level needed for an Action + * + * @api + * @param Plugin $plugin + * @param string $rightName + * @param int $authLevelNeeded + * @param string $authLevelsAllowed + */ + public function definePluginPermissionLevel(Plugin $plugin, $rightName, $authLevelNeeded, $authLevelsAllowed = self::AUTH_LEVEL_MODERATOR) { + $this->maniaControl->getSettingManager()->initSetting($plugin, $rightName, self::getPermissionLevelNameArray($authLevelNeeded, $authLevelsAllowed)); } /** @@ -439,19 +472,70 @@ class AuthenticationManager implements CallbackListener, EchoListener, Communica * * @api * @param $authLevelNeeded + * @param $authLevelsAllowed * @return array[] */ - public static function getPermissionLevelNameArray($authLevelNeeded) { - switch ($authLevelNeeded) { + public static function getPermissionLevelNameArray($authLevelNeeded, $authLevelsAllowed = self::AUTH_LEVEL_MODERATOR) { + assert($authLevelNeeded >= $authLevelsAllowed); + + switch ($authLevelsAllowed) { + case self::AUTH_LEVEL_PLAYER: + switch ($authLevelNeeded) { + case self::AUTH_LEVEL_PLAYER: + return array(self::AUTH_NAME_PLAYER, self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN); + case self::AUTH_LEVEL_MODERATOR: + return array(self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_PLAYER); + case self::AUTH_LEVEL_ADMIN: + return array(self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_PLAYER, self::AUTH_NAME_MODERATOR); + case self::AUTH_LEVEL_SUPERADMIN: + return array(self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_PLAYER, self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN); + case self::AUTH_LEVEL_MASTERADMIN: + return array(self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_PLAYER, self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN); + } + break; + case self::AUTH_LEVEL_MODERATOR: - return array(self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN); + switch ($authLevelNeeded) { + case self::AUTH_LEVEL_MODERATOR: + return array(self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN); + case self::AUTH_LEVEL_ADMIN: + return array(self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_MODERATOR); + case self::AUTH_LEVEL_SUPERADMIN: + return array(self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN); + case self::AUTH_LEVEL_MASTERADMIN: + return array(self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN); + } + break; + case self::AUTH_LEVEL_ADMIN: - return array(self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_MODERATOR); + switch ($authLevelNeeded) { + case self::AUTH_LEVEL_ADMIN: + return array(self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN); + case self::AUTH_LEVEL_SUPERADMIN: + return array(self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_ADMIN); + case self::AUTH_LEVEL_MASTERADMIN: + return array(self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN); + } + break; + case self::AUTH_LEVEL_SUPERADMIN: - return array(self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN); + switch ($authLevelNeeded) { + case self::AUTH_LEVEL_SUPERADMIN: + return array(self::AUTH_NAME_SUPERADMIN, self::AUTH_NAME_MASTERADMIN); + case self::AUTH_LEVEL_MASTERADMIN: + return array(self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_SUPERADMIN); + } + break; + + // just for completeness, should not be used this way case self::AUTH_LEVEL_MASTERADMIN: - return array(self::AUTH_NAME_MASTERADMIN, self::AUTH_NAME_MODERATOR, self::AUTH_NAME_ADMIN, self::AUTH_NAME_SUPERADMIN); + switch ($authLevelNeeded) { + case self::AUTH_LEVEL_MASTERADMIN: + return array(self::AUTH_NAME_MASTERADMIN); + } + break; } + return array("-"); } } diff --git a/core/Callbacks/CallQueueListener.php b/core/Callbacks/CallQueueListener.php new file mode 100755 index 00000000..05f15cc2 --- /dev/null +++ b/core/Callbacks/CallQueueListener.php @@ -0,0 +1,13 @@ + + * @copyright 2014-2019 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +interface CallQueueListener { +} diff --git a/core/Callbacks/CallQueueListening.php b/core/Callbacks/CallQueueListening.php new file mode 100755 index 00000000..41371a5d --- /dev/null +++ b/core/Callbacks/CallQueueListening.php @@ -0,0 +1,69 @@ + + * @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, bool $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; + } +} diff --git a/core/Callbacks/CallQueueManager.php b/core/Callbacks/CallQueueManager.php new file mode 100755 index 00000000..14f13a7c --- /dev/null +++ b/core/Callbacks/CallQueueManager.php @@ -0,0 +1,117 @@ + + * @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, bool $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, string $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(); + } + } +} diff --git a/core/Callbacks/TimerListening.php b/core/Callbacks/TimerListening.php index a723e14c..4442b1da 100644 --- a/core/Callbacks/TimerListening.php +++ b/core/Callbacks/TimerListening.php @@ -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 * diff --git a/core/Callbacks/TimerManager.php b/core/Callbacks/TimerManager.php index 1eefdc9d..63fd9080 100644 --- a/core/Callbacks/TimerManager.php +++ b/core/Callbacks/TimerManager.php @@ -75,6 +75,24 @@ class TimerManager implements UsageInformationAble { array_push($this->timerListenings, $timerListening); } + /** + * Update the deltaTime of a Timer Listening + * + * @param TimerListener $listener + * @param string|callable $method + * @param float $milliSeconds + */ + public function updateTimerListening(TimerListener $listener, $method, $milliSeconds) { + $updated = false; + foreach ($this->timerListenings as $key => &$listening) { + if ($listening->listener === $listener && $listening->method === $method) { + $listening->setDeltaTime($milliSeconds); + $updated = true; + } + } + return $updated; + } + /** * Unregister a Timer Listening * diff --git a/core/Commands/CommandManager.php b/core/Commands/CommandManager.php index 93363ec9..72389ad2 100644 --- a/core/Commands/CommandManager.php +++ b/core/Commands/CommandManager.php @@ -28,8 +28,12 @@ class CommandManager implements CallbackListener, UsageInformationAble { private $helpManager = array(); /** @var Listening[][] $commandListenings */ private $commandListenings = array(); + /** @var CommandListener[][] $disabledCommands */ + private $disabledCommands = array(); /** @var Listening[][] $adminCommandListenings */ private $adminCommandListenings = array(); + /** @var CommandListener[][] $disabledAdminCommands */ + private $disabledAdminCommands = array(); /** * Construct a new Commands Manager @@ -116,6 +120,138 @@ class CommandManager implements CallbackListener, UsageInformationAble { array_push($listeningsArray[$command], $listening); } + /** + * Disable the command(s) by the given listener. + * The specific listener has to also manually reenable the commands, before the command can be used again. + * @param mixed $commandName + * @param bool $adminCommand + * @param CommandListener $listener + */ + public function disableCommand($commandName, bool $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, bool $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, bool $adminCommand) { + if (is_array($commandName)) { + $results = array(); + foreach ($commandName as $command) { + array_push($results, $this->isCommandEnabled($command, $adminCommand)); + } + $resultsUnique = array_unique($results); + if (count($resultsUnique) === 1) { + return $resultsUnique[0]; + } + + return $results; + } + + $command = strtolower(trim($commandName)); + + $disabledCommands = null; + if ($adminCommand) { + $disabledCommands = &$this->disabledAdminCommands; + } else { + $disabledCommands = &$this->disabledCommands; + } + + if (!array_key_exists($command, $disabledCommands)) { + return true; + } + + // if the command is disabled, there should be at least one listener in the array + assert(!empty($disabledCommands[$command])); + return false; + } + + /** + * Removes the given CommandListener blocking commands. + * + * @param array &$disabledCommands + * @param CommandListener $listener + * @return bool + */ + private function removeDisabledCommandListener(array &$disabledCommands, CommandListener $listener) { + $removed = false; + foreach ($disabledCommands as $command => $disableListeners) { + if (($key = array_search($listener, $disableListeners)) !== false) { + unset($disabledCommands[$command][$key]); + $removed = true; + + if (empty($disabledCommands[$command])) { + unset($disabledCommands[$command]); + } + } + } + return $removed; + } + /** * Unregister a Command Listener * @@ -130,6 +266,12 @@ class CommandManager implements CallbackListener, UsageInformationAble { if ($this->removeCommandListener($this->adminCommandListenings, $listener)) { $removed = true; } + if ($this->removeDisabledCommandListener($this->disabledCommands, $listener)) { + $removed = true; + } + if ($this->removeDisabledCommandListener($this->disabledAdminCommands, $listener)) { + $removed = true; + } return $removed; } @@ -178,9 +320,11 @@ class CommandManager implements CallbackListener, UsageInformationAble { if (!$command) { return; } - + + $isAdminCommand = null; if (substr($message, 0, 2) === '//' || $command === 'admin') { // Admin command + $isAdminCommand = true; $commandListenings = $this->adminCommandListenings; if ($command === 'admin') { @@ -197,6 +341,7 @@ class CommandManager implements CallbackListener, UsageInformationAble { $callback[1][2] = $message; } else { // User command + $isAdminCommand = false; $commandListenings = $this->commandListenings; } @@ -205,6 +350,12 @@ class CommandManager implements CallbackListener, UsageInformationAble { return; } + if (!$this->isCommandEnabled($command, $isAdminCommand)) { + $prefix = $isAdminCommand ? '//' : '/'; + $this->maniaControl->getChat()->sendError('The command $<$fff'.$prefix.$command.'$> is currently disabled!', $player); + return; + } + // Inform command listeners foreach ($commandListenings[$command] as $listening) { /** @var Listening $listening */ diff --git a/core/ManiaControl.php b/core/ManiaControl.php index f31cce1c..12c84743 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -8,6 +8,7 @@ use ManiaControl\Bills\BillManager; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\Callbacks; +use ManiaControl\Callbacks\CallQueueManager; use ManiaControl\Callbacks\EchoManager; use ManiaControl\Callbacks\TimerListener; use ManiaControl\Callbacks\TimerManager; @@ -52,7 +53,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, /* * Constants */ - const VERSION = '0.240'; + const VERSION = '0.250'; const API_VERSION = '2013-04-16'; const MIN_DEDIVERSION = '2017-05-03_21_00'; const SCRIPT_TIMEOUT = 40; @@ -84,6 +85,10 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, * @see getCallbackManager() */ private $callbackManager = null; + /** @var CallQueueManager $callQueueManager + * @see getCallQueueManager() + */ + private $callQueueManager = null; /** @var Chat $chat * @see getChat() */ @@ -180,6 +185,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, // Load ManiaControl Modules $this->callbackManager = new CallbackManager($this); + $this->callQueueManager = new CallQueueManager($this); $this->modeScriptEventManager = new ModeScriptEventManager($this); $this->echoManager = new EchoManager($this); $this->communicationManager = new CommunicationManager($this); @@ -298,6 +304,15 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, return $this->callbackManager; } + /** + * Return the call queue manager + * + * @return CallQueueManager + */ + public function getCallQueueManager() { + return $this->callQueueManager; + } + /** * Return the echo manager * @@ -705,6 +720,9 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, // Manage callbacks $this->getCallbackManager()->manageCallbacks(); + // Manage queued calls + $this->getCallQueueManager()->manageCallQueue(); + // Manage async file reader $this->getFileReader()->appendData(); diff --git a/core/Plugins/PluginManager.php b/core/Plugins/PluginManager.php index 10c93f49..695b9276 100644 --- a/core/Plugins/PluginManager.php +++ b/core/Plugins/PluginManager.php @@ -561,6 +561,14 @@ class PluginManager { $asyncHttpRequest->getData(); } + /** + * @internal + * @return \ManiaControl\Plugins\PluginMenu + */ + public function getPluginMenu() { + return $this->pluginMenu; + } + /** * @internal * @return \ManiaControl\Plugins\InstallMenu diff --git a/core/Settings/Setting.php b/core/Settings/Setting.php index 29627f5d..8e4edb89 100644 --- a/core/Settings/Setting.php +++ b/core/Settings/Setting.php @@ -111,7 +111,7 @@ class Setting implements UsageInformationAble { if (is_int($value)) { return self::TYPE_INT; } - if (is_real($value)) { + if (is_float($value)) { return self::TYPE_REAL; } if (is_bool($value)) { diff --git a/core/Statistics/SimpleStatsList.php b/core/Statistics/SimpleStatsList.php index 30166b30..dfa979d9 100644 --- a/core/Statistics/SimpleStatsList.php +++ b/core/Statistics/SimpleStatsList.php @@ -237,7 +237,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener, } //Slice Array to chunk length - $statRankings[$order] = array_slice($statRankings{$order}, $playerBeginIndex, self::MAX_PAGES_PER_CHUNK * self::MAX_PLAYERS_PER_PAGE, true); + $statRankings[$order] = array_slice($statRankings[$order], $playerBeginIndex, self::MAX_PAGES_PER_CHUNK * self::MAX_PLAYERS_PER_PAGE, true); $pageNumber = 1 + $chunkIndex * self::MAX_PAGES_PER_CHUNK; foreach ($statRankings[$order] as $playerId => $value) { if ($index % self::MAX_PLAYERS_PER_PAGE === 1) { diff --git a/core/Update/UpdateManager.php b/core/Update/UpdateManager.php index 79e5ed6e..ca37d6ce 100644 --- a/core/Update/UpdateManager.php +++ b/core/Update/UpdateManager.php @@ -16,6 +16,8 @@ use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; use ManiaControl\Players\PlayerManager; +use ManiaControl\Settings\Setting; +use ManiaControl\Settings\SettingManager; /** * Manager checking for ManiaControl Core Updates @@ -72,6 +74,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener, $this->maniaControl->getTimerManager()->registerTimerListening($this, 'hourlyUpdateCheck', 1000 * 60 * 60 * $updateInterval); $this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerJoined'); $this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERDISCONNECT, $this, 'handlePlayerDisconnect'); + $this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'handleSettingChanged'); // Permissions $this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_UPDATE, AuthenticationManager::AUTH_LEVEL_ADMIN); @@ -455,6 +458,15 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener, $this->checkAutoUpdate(); } + public function handleSettingChanged(Setting $setting) { + if (!$setting->setting != self::SETTING_UPDATECHECK_INTERVAL) { + return; + } + + $updateInterval = $setting->value; + $this->maniaControl->getTimerManager()->updateTimerListening($this, 'hourlyUpdateCheck', 1000 * 60 * 60, $updateInterval); + } + /** * Handle //checkupdate command * diff --git a/core/Utils/Formatter.php b/core/Utils/Formatter.php index 7df8937c..39900534 100644 --- a/core/Utils/Formatter.php +++ b/core/Utils/Formatter.php @@ -43,7 +43,7 @@ abstract class Formatter implements UsageInformationAble { $seconds -= ($hours * 60 + $minutes) * 60; $format = ($hours > 0 ? $hours . ':' : ''); $format .= ($hours > 0 && $minutes < 10 ? '0' : '') . $minutes . ':'; - $format .= ($seconds < 10 ? '0' : '') . $seconds . ':'; + $format .= ($seconds < 10 ? '0' : '') . $seconds . '.'; $format .= ($milliseconds < 100 ? '0' : '') . ($milliseconds < 10 ? '0' : '') . $milliseconds; return $format; } diff --git a/install_db.sh b/install_db.sh new file mode 100755 index 00000000..75c296bf --- /dev/null +++ b/install_db.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +read -e -p "Enter database name: " -i "maniacontrol_db" DATABASE_NAME +read -e -p "Enter user name: " -i "maniacontrol" USER_NAME +read -s -p "Enter user password: " USER_PASSWORD +echo +echo + +# Preparation +SQL_FILE_NAME="install_db.sql" +rm -f ${SQL_FILE_NAME} + +echo "Creating SQL script ..." +echo "CREATE DATABASE ${DATABASE_NAME} DEFAULT CHARACTER SET 'utf8mb4' DEFAULT COLLATE 'utf8mb4_unicode_ci';" >> ${SQL_FILE_NAME} +echo "CREATE USER '${USER_NAME}'@'localhost' IDENTIFIED BY '${USER_PASSWORD}';" >> ${SQL_FILE_NAME} +echo "GRANT ALL PRIVILEGES ON ${DATABASE_NAME}.* TO '${USER_NAME}'@'localhost';" >> ${SQL_FILE_NAME} + +echo "Executing SQL script as root ..." +sudo mysql -u root -p < ${SQL_FILE_NAME} + +echo "Cleaning up ..." +rm ${SQL_FILE_NAME} + +echo "Done." diff --git a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php index 94f84aa7..48f81c31 100644 --- a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php +++ b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php @@ -36,21 +36,22 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene * Constants */ const ID = 8; - const VERSION = 0.5; + const VERSION = 0.6; const AUTHOR = 'MCTeam'; const NAME = 'Dedimania Plugin'; const MLID_DEDIMANIA = 'Dedimania.ManialinkId'; - const SETTING_WIDGET_ENABLE = 'Enable Dedimania Widget'; - const SETTING_WIDGET_TITLE = 'Widget Title'; - const SETTING_WIDGET_POSX = 'Widget Position: X'; - const SETTING_WIDGET_POSY = 'Widget Position: Y'; - const SETTING_WIDGET_WIDTH = 'Widget Width'; - const SETTING_WIDGET_LINE_COUNT = 'Widget Displayed Lines Count'; - const SETTING_WIDGET_LINE_HEIGHT = 'Widget Line Height'; - const SETTING_DEDIMANIA_CODE = '$l[http://dedimania.net/tm2stats/?do=register]Dedimania Code for '; - const SETTING_NOTIFY_BEST_RECORDS = 'Notify Publicly only for the X Best Records'; - const SETTING_MAX_RECORDS = 'Max Records, only increase if you bought a rank update from Dedimania!'; + const SETTING_WIDGET_ENABLE = 'Enable Dedimania Widget'; + const SETTING_WIDGET_TITLE = 'Widget Title'; + const SETTING_WIDGET_POSX = 'Widget Position: X'; + const SETTING_WIDGET_POSY = 'Widget Position: Y'; + const SETTING_WIDGET_WIDTH = 'Widget Width'; + const SETTING_WIDGET_LINE_COUNT = 'Widget Displayed Lines Count'; + const SETTING_WIDGET_LINE_HEIGHT = 'Widget Line Height'; + const SETTING_DEDIMANIA_CODE = '$l[http://dedimania.net/tm2stats/?do=register]Dedimania Code for '; + const SETTING_NOTIFY_BEST_RECORDS_PUBLIC = 'Notify Publicly only for the X Best Records'; + const SETTING_NOTIFY_BEST_RECORDS_PRIVATE = 'Notify Privately only for the X Best Records'; + const SETTING_MAX_RECORDS = 'Max Records, only increase if you bought a rank update from Dedimania!'; const CB_DEDIMANIA_CHANGED = 'Dedimania.Changed'; const CB_DEDIMANIA_UPDATED = 'Dedimania.Updated'; @@ -103,7 +104,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_WIDTH, 40); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_LINE_HEIGHT, 4); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_LINE_COUNT, 12); - $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NOTIFY_BEST_RECORDS, 30); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NOTIFY_BEST_RECORDS_PRIVATE, 30); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NOTIFY_BEST_RECORDS_PUBLIC, 15); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAX_RECORDS, 30); // Callbacks @@ -361,8 +363,6 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_DEDIMANIA_CHANGED, $newRecord); - $notifyOnlyBestRecords = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NOTIFY_BEST_RECORDS); - // Announce record if ($oldRecord->nullRecord || $newRecord->rank < $oldRecord->rank) { // Gained rank @@ -372,21 +372,22 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene $improvement = 'improved the'; } - if ($newRecord->rank <= $notifyOnlyBestRecords) { + $notifyOnlyBestRecordsPrivate = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NOTIFY_BEST_RECORDS_PRIVATE); + $notifyOnlyBestRecordsPublic = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NOTIFY_BEST_RECORDS_PUBLIC); + if ($newRecord->rank <= $notifyOnlyBestRecordsPublic) { $notifyName = $player->nickname; - } else { + } elseif ($newRecord->rank <= $notifyOnlyBestRecordsPrivate) { $notifyName = 'You'; } - $message = '$390$<$fff' . $notifyName . '$> ' . $improvement . ' $<$ff0' . $newRecord->rank . '.$> Dedimania Record: $<$fff' . Formatter::formatTime($newRecord->best) . '$>'; if (!$oldRecord->nullRecord) { $message .= ' ($<$ff0' . $oldRecord->rank . '.$> $<$fff-' . Formatter::formatTime(($oldRecord->best - $recTime)) . '$>)'; } - if ($newRecord->rank <= $notifyOnlyBestRecords) { + if ($newRecord->rank <= $notifyOnlyBestRecordsPublic) { $this->maniaControl->getChat()->sendInformation($message . '!'); - } else { + } elseif ($newRecord->rank <= $notifyOnlyBestRecordsPrivate) { $this->maniaControl->getChat()->sendInformation($message . '!', $player); } diff --git a/plugins/MCTeam/LocalRecordsPlugin.php b/plugins/MCTeam/LocalRecordsPlugin.php index f5d21367..ce26e97e 100644 --- a/plugins/MCTeam/LocalRecordsPlugin.php +++ b/plugins/MCTeam/LocalRecordsPlugin.php @@ -12,6 +12,7 @@ use FML\Script\Features\Paging; use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\Callbacks; +use ManiaControl\Callbacks\CallQueueListener; use ManiaControl\Callbacks\Structures\TrackMania\OnWayPointEventStructure; use ManiaControl\Callbacks\TimerListener; use ManiaControl\Commands\CommandListener; @@ -36,30 +37,33 @@ use MCTeam\Common\RecordWidget; * @copyright 2014-2019 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListener, CommandListener, TimerListener, Plugin { +class LocalRecordsPlugin implements CallbackListener, CallQueueListener, CommandListener, ManialinkPageAnswerListener, TimerListener, Plugin { /* * Constants */ - const ID = 7; - const VERSION = 0.5; - const NAME = 'Local Records Plugin'; - const AUTHOR = 'MCTeam'; - const MLID_RECORDS = 'ml_local_records'; - const TABLE_RECORDS = 'mc_localrecords'; - const SETTING_MULTILAP_SAVE_SINGLE = 'Save every Lap as Record in Multilap'; - const SETTING_WIDGET_TITLE = 'Widget Title'; - const SETTING_WIDGET_POSX = 'Widget Position: X'; - const SETTING_WIDGET_POSY = 'Widget Position: Y'; - const SETTING_WIDGET_WIDTH = 'Widget Width'; - const SETTING_WIDGET_LINESCOUNT = 'Widget Displayed Lines Count'; - const SETTING_WIDGET_LINEHEIGHT = 'Widget Line Height'; - const SETTING_WIDGET_ENABLE = 'Enable Local Records Widget'; - const SETTING_NOTIFY_ONLY_DRIVER = 'Notify only the Driver on New Records'; - const SETTING_NOTIFY_BEST_RECORDS = 'Notify Publicly only for the X Best Records'; - const SETTING_ADJUST_OUTER_BORDER = 'Adjust outer Border to Number of actual Records'; - const SETTING_RECORDS_BEFORE_AFTER = 'Number of Records displayed before and after a player'; - const CB_LOCALRECORDS_CHANGED = 'LocalRecords.Changed'; - const ACTION_SHOW_RECORDSLIST = 'LocalRecords.ShowRecordsList'; + const ID = 7; + const VERSION = 0.8; + const NAME = 'Local Records Plugin'; + const AUTHOR = 'MCTeam'; + const MLID_RECORDS = 'ml_local_records'; + const TABLE_RECORDS = 'mc_localrecords'; + const PERMISSION_DELETE_ANY_RECORD = 'Permission remove any record'; + const PERMISSION_DELETE_PERSONAL_RECORD = 'Permission remove personal record'; + const SETTING_MULTILAP_SAVE_SINGLE = 'Save every Lap as Record in Multilap'; + const SETTING_WIDGET_TITLE = 'Widget Title'; + const SETTING_WIDGET_POSX = 'Widget Position: X'; + const SETTING_WIDGET_POSY = 'Widget Position: Y'; + const SETTING_WIDGET_WIDTH = 'Widget Width'; + const SETTING_WIDGET_LINESCOUNT = 'Widget Displayed Lines Count'; + const SETTING_WIDGET_LINEHEIGHT = 'Widget Line Height'; + const SETTING_WIDGET_ENABLE = 'Enable Local Records Widget'; + const SETTING_NOTIFICATION_MESSAGE_PREFIX = 'Notification Message Prefix'; + const SETTING_NOTIFY_BEST_RECORDS_PRIVATE = 'Notify privately for the X Best Records'; + const SETTING_NOTIFY_BEST_RECORDS_PUBLIC = 'Notify publicly for the X Best Records'; + const SETTING_ADJUST_OUTER_BORDER = 'Adjust outer Border to Number of actual Records'; + const SETTING_RECORDS_BEFORE_AFTER = 'Number of Records displayed before and after a player'; + const CB_LOCALRECORDS_CHANGED = 'LocalRecords.Changed'; + const ACTION_SHOW_RECORDSLIST = 'LocalRecords.ShowRecordsList'; /* @@ -126,6 +130,19 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene $this->recordWidget = new RecordWidget($this->maniaControl); // Settings + $this->maniaControl->getAuthenticationManager()->definePluginPermissionLevel( + $this, + self::PERMISSION_DELETE_ANY_RECORD, + AuthenticationManager::AUTH_LEVEL_SUPERADMIN, + AuthenticationManager::AUTH_LEVEL_MODERATOR + ); + $this->maniaControl->getAuthenticationManager()->definePluginPermissionLevel( + $this, + self::PERMISSION_DELETE_PERSONAL_RECORD, + AuthenticationManager::AUTH_LEVEL_ADMIN, + AuthenticationManager::AUTH_LEVEL_PLAYER + ); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_TITLE, 'Local Records'); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_POSX, -139.); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_POSY, 75); @@ -133,8 +150,9 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_LINESCOUNT, 15); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_LINEHEIGHT, 4.); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_ENABLE, true); - $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NOTIFY_ONLY_DRIVER, false); - $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NOTIFY_BEST_RECORDS, 10); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NOTIFICATION_MESSAGE_PREFIX, '$3c0'); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NOTIFY_BEST_RECORDS_PRIVATE, 100); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NOTIFY_BEST_RECORDS_PUBLIC, 10); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_ADJUST_OUTER_BORDER, false); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_RECORDS_BEFORE_AFTER, 2); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MULTILAP_SAVE_SINGLE, false); @@ -154,7 +172,8 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene $this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_ONLAPFINISH, $this, 'handleFinishLapCallback'); $this->maniaControl->getCommandManager()->registerCommandListener(array('recs', 'records'), $this, 'showRecordsList', false, 'Shows a list of Local Records on the current map.'); - $this->maniaControl->getCommandManager()->registerCommandListener('delrec', $this, 'deleteRecord', true, 'Removes a record from the database.'); + $this->maniaControl->getCommandManager()->registerCommandListener('delrec', $this, 'deletePersonalRecord', false, 'Removes your record from the database.'); + $this->maniaControl->getCommandManager()->registerCommandListener('delrec', $this, 'deleteAnyRecord', true, 'Removes any record from the database.'); $this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_SHOW_RECORDSLIST, $this, 'handleShowRecordsList'); @@ -493,8 +512,9 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene $checkpointsString = $this->getCheckpoints($player->login); $this->checkpoints[$player->login] = array(); - $notifyOnlyDriver = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NOTIFY_ONLY_DRIVER); - $notifyOnlyBestRecords = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NOTIFY_BEST_RECORDS); + $message = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NOTIFICATION_MESSAGE_PREFIX); + $notifyPrivatelyAt = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NOTIFY_BEST_RECORDS_PRIVATE); + $notifyPubliclyAt = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NOTIFY_BEST_RECORDS_PUBLIC); // Check old record of the player $oldRecord = $this->getLocalRecord($map, $player); @@ -502,23 +522,30 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene if ($oldRecord->time < $time) { // Not improved return; - } - if ($oldRecord->time == $time) { + } else if ($oldRecord->time == $time) { // Same time - $message = '$3c0'; - if ($notifyOnlyDriver) { + if ($notifyPubliclyAt < $oldRecord->rank && $oldRecord->rank <= $notifyPrivatelyAt) { $message .= 'You'; } else { $message .= '$<$fff' . $player->nickname . '$>'; } - $message .= ' equalized the $<$ff0' . $oldRecord->rank . '.$> Local Record:'; $message .= ' $<$fff' . Formatter::formatTime($oldRecord->time) . '$>!'; - if ($notifyOnlyDriver) { - $this->maniaControl->getChat()->sendInformation($message, $player); - } else if (!$notifyOnlyBestRecords || $oldRecord->rank <= $notifyOnlyBestRecords) { - $this->maniaControl->getChat()->sendInformation($message); + if ($oldRecord->rank <= $notifyPubliclyAt) { + $this->maniaControl->getCallQueueManager()->registerListening( + $this, + function () use ($message) { + $this->maniaControl->getChat()->sendInformation($message); + } + ); + } else if ($oldRecord->rank <= $notifyPrivatelyAt) { + $this->maniaControl->getCallQueueManager()->registerListening( + $this, + function () use ($message, $player) { + $this->maniaControl->getChat()->sendInformation($message, $player); + } + ); } return; } @@ -548,16 +575,14 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene // Announce record $newRecord = $this->getLocalRecord($map, $player); - $improvedRank = (!$oldRecord || $newRecord->rank < $oldRecord->rank); + $improvedRank = ($oldRecord && $newRecord->rank >= $oldRecord->rank); - - $message = '$3c0'; - if ($notifyOnlyDriver) { + if ($notifyPubliclyAt < $newRecord->rank && $newRecord->rank <= $notifyPrivatelyAt) { $message .= 'You'; } else { $message .= '$<$fff' . $player->nickname . '$>'; } - $message .= ' ' . ($improvedRank ? 'gained' : 'improved') . ' the'; + $message .= ' ' . ($improvedRank ? 'improved' : 'gained') . ' the'; $message .= ' $<$ff0' . $newRecord->rank . '.$> Local Record:'; $message .= ' $<$fff' . Formatter::formatTime($newRecord->time) . '$>!'; if ($oldRecord) { @@ -569,10 +594,20 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene $message .= '$<$fff-' . Formatter::formatTime($timeDiff) . '$>)'; } - if ($notifyOnlyDriver) { - $this->maniaControl->getChat()->sendInformation($message, $player); - } else if (!$notifyOnlyBestRecords || $newRecord->rank <= $notifyOnlyBestRecords) { - $this->maniaControl->getChat()->sendInformation($message); + if ($newRecord->rank <= $notifyPubliclyAt) { + $this->maniaControl->getCallQueueManager()->registerListening( + $this, + function () use ($message) { + $this->maniaControl->getChat()->sendInformation($message); + } + ); + } else if ($newRecord->rank <= $notifyPrivatelyAt) { + $this->maniaControl->getCallQueueManager()->registerListening( + $this, + function () use ($message, $player) { + $this->maniaControl->getChat()->sendInformation($message, $player); + } + ); } $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_LOCALRECORDS_CHANGED, $newRecord); @@ -753,29 +788,75 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene } /** - * Delete a Player's record + * Delete any record * * @internal * @param array $chat * @param Player $player */ - public function deleteRecord(array $chat, Player $player) { - if (!$this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)) { + public function deleteAnyRecord(array $chat, Player $player) { + if (!$this->maniaControl->getAuthenticationManager()->checkPluginPermission($this, $player, self::PERMISSION_DELETE_ANY_RECORD)) { $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } $commandParts = explode(' ', $chat[1][2]); - if (count($commandParts) < 2) { + if (count($commandParts) < 2 || strlen($commandParts[1]) == 0) { $this->maniaControl->getChat()->sendUsageInfo('Missing Record ID! (Example: //delrec 3)', $player); return; } - $recordId = (int) $commandParts[1]; + $recordRank = (int) $commandParts[1]; $currentMap = $this->maniaControl->getMapManager()->getCurrentMap(); $records = $this->getLocalRecords($currentMap); - if (count($records) < $recordId) { - $this->maniaControl->getChat()->sendError('Cannot remove record $<$fff' . $recordId . '$>!', $player); + if ($recordRank <= 0 || count($records) < $recordRank) { + $this->maniaControl->getChat()->sendError('Cannot remove record $<$fff' . $recordRank . '$>!', $player); + return; + } + + assert($recordRank == $records[$recordRank-1]->rank); + $playerIndex = $records[$recordRank-1]->playerIndex; + $playerNick = $records[$recordRank-1]->nickname; + + $mysqli = $this->maniaControl->getDatabase()->getMysqli(); + $query = "DELETE FROM `" . self::TABLE_RECORDS . "` + WHERE `mapIndex` = {$currentMap->index} + AND `playerIndex` = {$playerIndex};"; + $mysqli->query($query); + if ($mysqli->error) { + trigger_error($mysqli->error); + return; + } + + $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_LOCALRECORDS_CHANGED, null); + $this->maniaControl->getChat()->sendSuccess('Record no. $<$fff' . $recordRank . '$> by $<$fff' . $playerNick . '$> has been removed!'); + } + + /** + * Delete the personal record + * + * @internal + * @param array $chat + * @param Player $player + */ + public function deletePersonalRecord(array $chat, Player $player) { + if (!$this->maniaControl->getAuthenticationManager()->checkPluginPermission($this, $player, self::PERMISSION_DELETE_PERSONAL_RECORD)) { + $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); + return; + } + + $currentMap = $this->maniaControl->getMapManager()->getCurrentMap(); + $records = $this->getLocalRecords($currentMap); + $hasRecord = true; + foreach ($records as $record) { + if ($record->login === $player->login) { + $hasRecord = true; + break; + } + } + + if (!$hasRecord) { + $this->maniaControl->getChat()->sendError('You have no personal record to remove!', $player); return; } @@ -790,7 +871,7 @@ class LocalRecordsPlugin implements ManialinkPageAnswerListener, CallbackListene } $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_LOCALRECORDS_CHANGED, null); - $this->maniaControl->getChat()->sendInformation('Record no. $<$fff' . $recordId . '$> has been removed!'); + $this->maniaControl->getChat()->sendSuccess('$<$fff'.$player->getEscapedNickname().'$> removed his personal record!'); } /** From 29fff4e012de16104c832c6fec5adb5c1b2f29e4 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 25 Feb 2020 17:48:08 +0100 Subject: [PATCH 07/98] Replace deprecated is_real by is_float --- core/Players/PlayerDataManager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Players/PlayerDataManager.php b/core/Players/PlayerDataManager.php index 32d3e104..f69f48ac 100644 --- a/core/Players/PlayerDataManager.php +++ b/core/Players/PlayerDataManager.php @@ -187,7 +187,7 @@ class PlayerDataManager implements UsageInformationAble { if (is_int($param)) { return self::TYPE_INT; } - if (is_real($param)) { + if (is_float($param)) { return self::TYPE_REAL; } if (is_bool($param)) { From e8d2b2e81e087388c84306b4df7fae5230161386 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 25 Feb 2020 17:48:27 +0100 Subject: [PATCH 08/98] Remove scalar typehints to support PHP5 --- core/Callbacks/CallQueueListening.php | 4 ++-- core/Callbacks/CallQueueManager.php | 4 ++-- core/Commands/CommandManager.php | 6 +++--- core/Files/FileUtil.php | 2 +- core/Utils/DataUtil.php | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/Callbacks/CallQueueListening.php b/core/Callbacks/CallQueueListening.php index 41371a5d..70e53c51 100755 --- a/core/Callbacks/CallQueueListening.php +++ b/core/Callbacks/CallQueueListening.php @@ -38,7 +38,7 @@ class CallQueueListening extends Listening implements UsageInformationAble { public function triggerCallback() { $params = func_get_args(); if ($this->triggerCallbackWithParams($params, false) === false) { - if ($this->$errorMethod != null) { + if ($this->errorMethod != null) { call_user_func($this->errorMethod, $this->method); } @@ -54,7 +54,7 @@ class CallQueueListening extends Listening implements UsageInformationAble { * @param array $params * @return mixed */ - public function triggerCallbackWithParams(array $params, bool $callErrorMethod = true) { + public function triggerCallbackWithParams(array $params, $callErrorMethod = true) { $result = call_user_func_array($this->getUserFunction(), $params); if ($callErrorMethod && $result === false) { if ($this->errorMethod != null) { diff --git a/core/Callbacks/CallQueueManager.php b/core/Callbacks/CallQueueManager.php index 14f13a7c..8950f168 100755 --- a/core/Callbacks/CallQueueManager.php +++ b/core/Callbacks/CallQueueManager.php @@ -41,7 +41,7 @@ class CallQueueManager implements UsageInformationAble { * @param mixed $errorMethod * @return bool */ - public function registerListening(CallQueueListener $listener, $methods, $errorMethod = null, bool $important = false) { + 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; @@ -96,7 +96,7 @@ class CallQueueManager implements UsageInformationAble { * @param string $method * @return bool */ - public function hasListening(CallQueueListener $listener, string $method) { + public function hasListening(CallQueueListener $listener, $method) { foreach ($this->queueListenings as $listening) { if ($listening->listener === $listener && $listening->method === $method) { return true; diff --git a/core/Commands/CommandManager.php b/core/Commands/CommandManager.php index 72389ad2..2fc1219e 100644 --- a/core/Commands/CommandManager.php +++ b/core/Commands/CommandManager.php @@ -127,7 +127,7 @@ class CommandManager implements CallbackListener, UsageInformationAble { * @param bool $adminCommand * @param CommandListener $listener */ - public function disableCommand($commandName, bool $adminCommand, CommandListener $listener) { + public function disableCommand($commandName, $adminCommand, CommandListener $listener) { if (is_array($commandName)) { foreach ($commandName as $command) { $this->disableCommand($command, $adminCommand, $listener); @@ -163,7 +163,7 @@ class CommandManager implements CallbackListener, UsageInformationAble { * @param bool $adminCommand * @param CommandListener $listener */ - public function enableCommand($commandName, bool $adminCommand, CommandListener $listener) { + public function enableCommand($commandName, $adminCommand, CommandListener $listener) { if (is_array($commandName)) { foreach ($commandName as $command) { $this->enableCommand($command, $adminCommand, $listener); @@ -198,7 +198,7 @@ class CommandManager implements CallbackListener, UsageInformationAble { * @param bool $adminCommand * @return bool|array */ - public function isCommandEnabled($commandName, bool $adminCommand) { + public function isCommandEnabled($commandName, $adminCommand) { if (is_array($commandName)) { $results = array(); foreach ($commandName as $command) { diff --git a/core/Files/FileUtil.php b/core/Files/FileUtil.php index b4791873..9b7b9377 100644 --- a/core/Files/FileUtil.php +++ b/core/Files/FileUtil.php @@ -244,7 +244,7 @@ abstract class FileUtil { * @param string $path * @return string */ - public static function shortenPath(string $path) { + public static function shortenPath($path) { $root = substr($path, 0, 1) === '/'; $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen'); diff --git a/core/Utils/DataUtil.php b/core/Utils/DataUtil.php index 16803441..0a3d2d70 100644 --- a/core/Utils/DataUtil.php +++ b/core/Utils/DataUtil.php @@ -20,7 +20,7 @@ abstract class DataUtil { * @param string $root * @return string */ - public static function buildXmlStandaloneFromArray(array $a, string $root = '') { + public static function buildXmlStandaloneFromArray(array $a, $root = '') { $domDocument = new \DOMDocument("1.0", "utf-8"); $domDocument->xmlStandalone = true; @@ -70,7 +70,7 @@ abstract class DataUtil { * @param bool $recurse * @return array */ - public static function implodePositions(array $a, bool $recurse = true) { + public static function implodePositions(array $a, $recurse = true) { $result = array(); foreach ($a as $key => $value) { if (is_array($value)) { @@ -95,7 +95,7 @@ abstract class DataUtil { * @param string $prefix (used for recursion) * @return array */ - public static function flattenArray(array $a, string $delimiter = '.', string $prefix = '') { + public static function flattenArray(array $a, $delimiter = '.', $prefix = '') { $result = array(); foreach ($a as $key => $value) { @@ -121,7 +121,7 @@ abstract class DataUtil { * @param string $delimiter * @return array */ - public static function unflattenArray(array $a, string $delimiter = '.') { + public static function unflattenArray(array $a, $delimiter = '.') { $result = array(); foreach ($a as $key => $value) { if (!is_string($key)) { From 6eff76b3cf22377f1dfaee57ab3b7d294e93efc5 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 25 Feb 2020 18:46:29 +0100 Subject: [PATCH 09/98] Increase version number to 0.251 --- core/ManiaControl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ManiaControl.php b/core/ManiaControl.php index 12c84743..d959a716 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -53,7 +53,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, /* * Constants */ - const VERSION = '0.250'; + const VERSION = '0.251'; const API_VERSION = '2013-04-16'; const MIN_DEDIVERSION = '2017-05-03_21_00'; const SCRIPT_TIMEOUT = 40; From ef5fdcc53c5e28bb8140e79b22f7a099fe97fb9f Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 25 Feb 2020 19:37:17 +0100 Subject: [PATCH 10/98] Fixed missing variable notice --- plugins/MCTeam/Dedimania/DedimaniaPlugin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php index 48f81c31..c08cfe2b 100644 --- a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php +++ b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php @@ -372,6 +372,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene $improvement = 'improved the'; } + $notifyName = ''; $notifyOnlyBestRecordsPrivate = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NOTIFY_BEST_RECORDS_PRIVATE); $notifyOnlyBestRecordsPublic = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NOTIFY_BEST_RECORDS_PUBLIC); if ($newRecord->rank <= $notifyOnlyBestRecordsPublic) { From 849e781208fbc1a0b877ba80a511aebfd2aaa82c Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Thu, 27 Feb 2020 00:41:01 +0100 Subject: [PATCH 11/98] Solve non-numeric warning on self-triggered debug notice --- core/ErrorHandler.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/ErrorHandler.php b/core/ErrorHandler.php index 88edd08c..611dd772 100644 --- a/core/ErrorHandler.php +++ b/core/ErrorHandler.php @@ -253,8 +253,8 @@ class ErrorHandler { * @return bool */ private static function isUserErrorNumber($errorNumber) { - return ($errorNumber & E_USER_ERROR || $errorNumber & E_USER_WARNING || $errorNumber & E_USER_NOTICE - || $errorNumber & E_USER_DEPRECATED); + $userError = (E_USER_ERROR | E_USER_WARNING | E_USER_NOTICE | E_USER_DEPRECATED); + return is_int($errorNumber) && ($errorNumber & $userError); } /** @@ -265,7 +265,7 @@ class ErrorHandler { */ public static function isFatalError($errorNumber) { $fatalError = (E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR); - return ($errorNumber & $fatalError); + return is_int($errorNumber) && ($errorNumber & $fatalError); } /** From 264698ce647f383b184c82e9b15c245f0bc97057 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Thu, 27 Feb 2020 10:40:55 +0100 Subject: [PATCH 12/98] Set directoryAccessChecked to null to enable a GReplay being sent --- plugins/MCTeam/Dedimania/DedimaniaData.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/MCTeam/Dedimania/DedimaniaData.php b/plugins/MCTeam/Dedimania/DedimaniaData.php index 62533c9e..8cdfa32c 100644 --- a/plugins/MCTeam/Dedimania/DedimaniaData.php +++ b/plugins/MCTeam/Dedimania/DedimaniaData.php @@ -31,7 +31,7 @@ class DedimaniaData { public $records = array(); /** @var DedimaniaPlayer[] $players */ public $players = array(); - public $directoryAccessChecked = false; + public $directoryAccessChecked = null; public $serverMaxRank = 30; /** From f8da5473266c118feb3b8c2e30cff732f2605b14 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Fri, 28 Feb 2020 16:18:05 +0100 Subject: [PATCH 13/98] Resolve symbolic links with realpath in server directories --- core/Server/Directory.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/Server/Directory.php b/core/Server/Directory.php index a248a471..bf6e272e 100644 --- a/core/Server/Directory.php +++ b/core/Server/Directory.php @@ -43,7 +43,7 @@ class Directory implements CallbackListener, UsageInformationAble { * @return string */ public function getMapsFolder() { - return $this->maniaControl->getClient()->getMapsDirectory(); + return realpath($this->maniaControl->getClient()->getMapsDirectory()) . DIRECTORY_SEPARATOR; } /** @@ -52,7 +52,7 @@ class Directory implements CallbackListener, UsageInformationAble { * @return string */ public function getSkinsFolder() { - return $this->maniaControl->getClient()->getSkinsDirectory(); + return realpath($this->maniaControl->getClient()->getSkinsDirectory()) . DIRECTORY_SEPARATOR; } /** @@ -78,7 +78,7 @@ class Directory implements CallbackListener, UsageInformationAble { * @return string */ public function getLogsFolder() { - return $this->getUserDataFolder() . '..' . DIRECTORY_SEPARATOR . 'Logs' . DIRECTORY_SEPARATOR; + return realpath($this->getUserDataFolder() . '..' . DIRECTORY_SEPARATOR . 'Logs') . DIRECTORY_SEPARATOR; } /** @@ -87,7 +87,7 @@ class Directory implements CallbackListener, UsageInformationAble { * @return string */ public function getGameDataFolder(){ - return $this->getUserDataFolder() . '..' . DIRECTORY_SEPARATOR . 'GameData' . DIRECTORY_SEPARATOR; + return realpath($this->getUserDataFolder() . '..' . DIRECTORY_SEPARATOR . 'GameData') . DIRECTORY_SEPARATOR; } /** @@ -96,7 +96,7 @@ class Directory implements CallbackListener, UsageInformationAble { * @return string */ public function getUserDataFolder() { - return $this->maniaControl->getClient()->gameDataDirectory(); + return realpath($this->maniaControl->getClient()->gameDataDirectory()) . DIRECTORY_SEPARATOR; } /** @@ -105,7 +105,7 @@ class Directory implements CallbackListener, UsageInformationAble { * @return string */ public function getScriptsFolder(){ - return $this->getGameDataFolder() . 'Scripts' . DIRECTORY_SEPARATOR; + return realpath($this->getGameDataFolder() . 'Scripts') . DIRECTORY_SEPARATOR; } /** @@ -121,6 +121,6 @@ class Directory implements CallbackListener, UsageInformationAble { * @return string */ public function getCacheFolder() { - return $this->getUserDataFolder() . '..' . DIRECTORY_SEPARATOR . 'CommonData' . DIRECTORY_SEPARATOR . 'Cache' . DIRECTORY_SEPARATOR; + return realpath($this->getUserDataFolder() . '..' . DIRECTORY_SEPARATOR . 'CommonData' . DIRECTORY_SEPARATOR . 'Cache') . DIRECTORY_SEPARATOR; } } From ae3d1d69dafb7ce5ea81d907c81770c4ddf7d8a3 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Fri, 28 Feb 2020 17:38:05 +0100 Subject: [PATCH 14/98] Added chat colors to roles, only used in Join/Leave messages so far --- core/Chat.php | 77 +++++++++++++++++++++++++++++++--- core/Players/PlayerManager.php | 20 +++++---- 2 files changed, 84 insertions(+), 13 deletions(-) diff --git a/core/Chat.php b/core/Chat.php index 209fb9c3..65c0cce7 100644 --- a/core/Chat.php +++ b/core/Chat.php @@ -26,13 +26,19 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA /* * Constants */ - const SETTING_PUBLIC_PREFIX = 'Public Messages Prefix'; - const SETTING_PRIVATE_PREFIX = 'Privat Messages Prefix'; + 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'; + const SETTING_FORMAT_ERROR = 'Error Format'; const SETTING_FORMAT_INFORMATION = 'Information Format'; const SETTING_FORMAT_SUCCESS = 'Success Format'; - const SETTING_FORMAT_ERROR = 'Error Format'; const SETTING_FORMAT_USAGEINFO = 'UsageInfo Format'; + const SETTING_PUBLIC_PREFIX = 'Public Messages Prefix'; + const SETTING_PRIVATE_PREFIX = 'Privat Messages Prefix'; const CHAT_BUFFER_SIZE = 200; + /* * Private properties */ @@ -49,12 +55,17 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA $this->maniaControl = $maniaControl; // Settings - $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PUBLIC_PREFIX, '» '); - $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PRIVATE_PREFIX, '»» '); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_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'); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_ERROR, '$f30'); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_INFORMATION, '$fff'); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_SUCCESS, '$0f0'); - $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_ERROR, '$f30'); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_USAGEINFO, '$f80'); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PUBLIC_PREFIX, '» '); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_PRIVATE_PREFIX, '»» '); //Callbacks $this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERCHAT, $this, 'onPlayerChat'); @@ -66,6 +77,60 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA }); } + /** + * 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 ($authLevel) { + 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); + } + /** * Send an information message to the given login * diff --git a/core/Players/PlayerManager.php b/core/Players/PlayerManager.php index 476174eb..3823ed98 100644 --- a/core/Players/PlayerManager.php +++ b/core/Players/PlayerManager.php @@ -3,6 +3,7 @@ namespace ManiaControl\Players; use ManiaControl\Admin\AdminLists; +use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\Callbacks; @@ -374,10 +375,13 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis $logMessage = "Player left: {$player->login} / {$player->nickname} Playtime: {$played}"; Logger::logInfo($logMessage, true); - if (!$player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer() + if (!$player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES) || $player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES_SPECTATOR) ) { - $this->maniaControl->getChat()->sendChat('$0f0$<$fff' . $player->nickname . '$> has left the game'); + $color = $this->maniaControl->getChat()->getColorByPlayer($player); + $authname = AuthenticationManager::getAuthLevelName($player->authLevel); + $nickname = $player->getEscapedNickname(); + $this->maniaControl->getChat()->sendChat("{$color}{$authname} {$nickname} has left after \$fff{$played}!"); } //Destroys stored PlayerData, after all Disconnect Callbacks got Handled @@ -484,20 +488,22 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis //Check if Player finished joining the game if ($player->hasJoinedGame && !$prevJoinState) { + $color = $this->maniaControl->getChat()->getColorByPlayer($player); + $authname = AuthenticationManager::getAuthLevelName($player->authLevel); + $nickname = $player->getEscapedNickname(); + $nation = '$<$fff' . $player->getCountry() . '$>'; if (!$player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) { - $string = array(0 => '$0f0Player', 1 => '$0f0Moderator', 2 => '$0f0Admin', 3 => '$0f0SuperAdmin', 4 => '$0f0MasterAdmin'); - $chatMessage = '$0f0' . $string[$player->authLevel] . ' $<$fff' . $player->nickname . '$> Nation: $<$fff' . $player->getCountry() . '$> joined!'; + $chatMessage = "{$color}{$authname} {$nickname} Nation: {$nation} joined!"; $this->maniaControl->getChat()->sendChat($chatMessage); } else if ($player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES_SPECTATOR)) { - $string = array(0 => '$0f0Player', 1 => '$0f0Moderator', 2 => '$0f0Admin', 3 => '$0f0SuperAdmin', 4 => '$0f0MasterAdmin'); - $chatMessage = '$0f0' . $string[$player->authLevel] . ' $<$fff' . $player->nickname . '$> Nation: $<$fff' . $player->getCountry() . '$> joined as Spectator!'; + $chatMessage = "{$color}{$authname} {$nickname} Nation: {$nation} joined as Spectator!"; $this->maniaControl->getChat()->sendChat($chatMessage); } $this->maniaControl->getChat()->sendInformation('This server uses ManiaControl v' . ManiaControl::VERSION . '!', $player->login); - $logMessage = "Player joined: {$player->login} / {$player->nickname} Nation: " . $player->getCountry() . " IP: {$player->ipAddress}"; + $logMessage = "Player joined: {$player->login} / {$player->nickname} Nation: {$nation} IP: {$player->ipAddress}"; Logger::logInfo($logMessage, true); // Increment the Player Join Count From 14f0d9b20cc2beddfe3ad95e08fa6a975cf60bab Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Fri, 28 Feb 2020 19:54:47 +0100 Subject: [PATCH 15/98] Include map times in Map-Structure and update them when necessary --- core/Maps/Map.php | 4 ++++ core/Maps/MapManager.php | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/core/Maps/Map.php b/core/Maps/Map.php index 6c0d0ddd..0e8a8b38 100644 --- a/core/Maps/Map.php +++ b/core/Maps/Map.php @@ -33,6 +33,8 @@ class Map implements Dumpable, UsageInformationAble { public $environment = null; public $authorTime = -1; public $goldTime = -1; + public $silverTime = -1; + public $bronzeTime = -1; public $copperPrice = -1; public $mapType = null; public $mapStyle = null; @@ -69,6 +71,8 @@ class Map implements Dumpable, UsageInformationAble { $this->environment = $mpMap->environnement; $this->authorTime = $mpMap->authorTime; $this->goldTime = $mpMap->goldTime; + $this->silverTime = $mpMap->silverTime; + $this->bronzeTime = $mpMap->bronzeTime; $this->copperPrice = $mpMap->copperPrice; $this->mapType = $mpMap->mapType; $this->mapStyle = $mpMap->mapStyle; diff --git a/core/Maps/MapManager.php b/core/Maps/MapManager.php index 551f1f75..95fe83d6 100644 --- a/core/Maps/MapManager.php +++ b/core/Maps/MapManager.php @@ -681,6 +681,10 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform if (array_key_exists($rpcMap->uId, $this->maps)) { $this->currentMap = $this->maps[$rpcMap->uId]; + $this->currentMap->authorTime = $rpcMap->authorTime; + $this->currentMap->goldTime = $rpcMap->goldTime; + $this->currentMap->silverTime = $rpcMap->silverTime; + $this->currentMap->bronzeTime = $rpcMap->bronzeTime; $this->currentMap->nbCheckpoints = $rpcMap->nbCheckpoints; $this->currentMap->nbLaps = $rpcMap->nbLaps; return $this->currentMap; @@ -835,6 +839,10 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform $this->currentMap = $this->maps[$uid]; if (!$this->currentMap->nbCheckpoints || !$this->currentMap->nbLaps) { $rpcMap = $this->maniaControl->getClient()->getCurrentMapInfo(); + $this->currentMap->authorTime = $rpcMap->authorTime; + $this->currentMap->goldTime = $rpcMap->goldTime; + $this->currentMap->silverTime = $rpcMap->silverTime; + $this->currentMap->bronzeTime = $rpcMap->bronzeTime; $this->currentMap->nbLaps = $rpcMap->nbLaps; $this->currentMap->nbCheckpoints = $rpcMap->nbCheckpoints; } From 981c21a7d4d80e930ff67d74096e336bd262db41 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Fri, 28 Feb 2020 19:55:12 +0100 Subject: [PATCH 16/98] Widget new settings to show map times --- plugins/MCTeam/WidgetPlugin.php | 75 ++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 15 deletions(-) diff --git a/plugins/MCTeam/WidgetPlugin.php b/plugins/MCTeam/WidgetPlugin.php index bd8f4189..20eded0c 100644 --- a/plugins/MCTeam/WidgetPlugin.php +++ b/plugins/MCTeam/WidgetPlugin.php @@ -6,6 +6,7 @@ use FML\Controls\Frame; use FML\Controls\Labels\Label_Text; use FML\Controls\Quad; use FML\Controls\Quads\Quad_Icons128x128_1; +use FML\Controls\Quads\Quad_Icons128x32_1; use FML\Controls\Quads\Quad_Icons64x64_1; use FML\ManiaLink; use FML\Script\Script; @@ -35,17 +36,21 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { * Constants */ const PLUGIN_ID = 1; - const PLUGIN_VERSION = 0.1; + const PLUGIN_VERSION = 0.11; const PLUGIN_NAME = 'WidgetPlugin'; - const PLUGIN_AUTHOR = 'kremsy'; + const PLUGIN_AUTHOR = 'kremsy, axelalex2'; // MapWidget Properties - const MLID_MAP_WIDGET = 'WidgetPlugin.MapWidget'; - const SETTING_MAP_WIDGET_ACTIVATED = 'Map-Widget Activated'; - const SETTING_MAP_WIDGET_POSX = 'Map-Widget-Position: X'; - const SETTING_MAP_WIDGET_POSY = 'Map-Widget-Position: Y'; - const SETTING_MAP_WIDGET_WIDTH = 'Map-Widget-Size: Width'; - const SETTING_MAP_WIDGET_HEIGHT = 'Map-Widget-Size: Height'; + const MLID_MAP_WIDGET = 'WidgetPlugin.MapWidget'; + const SETTING_MAP_WIDGET_ACTIVATED = 'Map-Widget Activated'; + const SETTING_MAP_WIDGET_POSX = 'Map-Widget-Position: X'; + const SETTING_MAP_WIDGET_POSY = 'Map-Widget-Position: Y'; + const SETTING_MAP_WIDGET_HEIGHT = 'Map-Widget-Size: Height'; + const SETTING_MAP_WIDGET_WIDTH = 'Map-Widget-Size: Width'; + const SETTING_MAP_WIDGET_TIME_AUTHOR = 'Map-Widget-Time: Show Author'; + const SETTING_MAP_WIDGET_TIME_GOLD = 'Map-Widget-Time: Show Gold'; + const SETTING_MAP_WIDGET_TIME_SILVER = 'Map-Widget-Time: Show Silver'; + const SETTING_MAP_WIDGET_TIME_BRONZE = 'Map-Widget-Time: Show Bronze'; // ClockWidget Properties const MLID_CLOCK_WIDGET = 'WidgetPlugin.ClockWidget'; @@ -141,9 +146,13 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { // Settings $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED, true); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_POSX, 160 - 20); - $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_POSY, 90 - 4.5); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_POSY, 90 - 6); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_HEIGHT, 12.); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_WIDTH, 40); - $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_HEIGHT, 9.); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_TIME_AUTHOR, false); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_TIME_GOLD, false); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_TIME_SILVER, false); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_TIME_BRONZE, false); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED, true); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SERVERINFO_WIDGET_POSX, -160 + 17.5); @@ -159,7 +168,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED, true); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_POSX, 160 - 5); - $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_POSY, 90 - 11); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_POSY, 90 - 14); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_WIDTH, 10); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_HEIGHT, 5.5); @@ -247,7 +256,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { $label = new Label_Text(); $frame->addChild($label); - $label->setPosition(0, 1.5, 0.2); + $label->setPosition(0, $height/2 - 3, 0.2); $label->setTextSize(1.3); $label->setText(Formatter::stripDirtyCodes($map->name)); $label->setTextColor('fff'); @@ -255,20 +264,56 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { $label = new Label_Text(); $frame->addChild($label); - $label->setPosition(0, -1.4, 0.2); + $label->setPosition(0, $height/2 - 6, 0.2); $label->setTextSize(1); $label->setScale(0.8); $label->setText($map->authorLogin); $label->setTextColor('fff'); $label->setSize($width - 5, $height); + $displayTimeAuthor = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_TIME_AUTHOR); + $displayTimeGold = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_TIME_GOLD ); + $displayTimeSilver = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_TIME_SILVER); + $displayTimeBronze = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_TIME_BRONZE); + if ($displayTimeAuthor || $displayTimeGold || $displayTimeSilver || $displayTimeBronze) { + $times = array(); + if ($displayTimeAuthor && $map->authorTime > 0) { + array_push($times, '$8b4' . Formatter::formatTime($map->authorTime)); + } + if ($displayTimeGold && $map->goldTime > 0) { + array_push($times, '$dc5' . Formatter::formatTime($map->goldTime)); + } + if ($displayTimeSilver && $map->silverTime > 0) { + array_push($times, '$aaa' . Formatter::formatTime($map->silverTime)); + } + if ($displayTimeBronze && $map->bronzeTime > 0) { + array_push($times, '$c95' . Formatter::formatTime($map->bronzeTime)); + } + $times = '$s' . implode('$s$fff // $s', $times); + + $quad = new Quad_Icons128x32_1(); + $frame->addChild($quad); + $quad->setPosition(-$width/2 + 3, -3, -0.5); + $quad->setSize(3.5, 3.5); + $quad->setSubStyle($quad::SUBSTYLE_RT_TimeAttack); + + $label = new Label_Text(); + $frame->addChild($label); + $label->setPosition(0, -3, 0.2); + $label->setScale(0.8); + $label->setSize($width - 5, $height); + $label->setText($times); + $label->setTextColor('fff'); + $label->setTextSize(1); + } + if (isset($map->mx->pageurl)) { $quad = new Quad(); $frame->addChild($quad); $quad->setImageFocusUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_MOVER)); $quad->setImageUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON)); - $quad->setPosition(-$width / 2 + 4, -1.5, -0.5); - $quad->setSize(4, 4); + $quad->setPosition($width/2 - 3, -3, -0.5); + $quad->setSize(3.5, 3.5); $quad->setUrl($map->mx->pageurl); } From bbdb638a9b8189d9c17d5a8c57c3e0b4e84cd7ad Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Sat, 29 Feb 2020 11:12:17 +0100 Subject: [PATCH 17/98] Change defaults so that new settings won't break existing UIs --- plugins/MCTeam/WidgetPlugin.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/MCTeam/WidgetPlugin.php b/plugins/MCTeam/WidgetPlugin.php index 20eded0c..b4e0ebe2 100644 --- a/plugins/MCTeam/WidgetPlugin.php +++ b/plugins/MCTeam/WidgetPlugin.php @@ -146,8 +146,8 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { // Settings $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED, true); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_POSX, 160 - 20); - $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_POSY, 90 - 6); - $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_HEIGHT, 12.); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_POSY, 90 - 4.5); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_HEIGHT, 9.); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_WIDTH, 40); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_TIME_AUTHOR, false); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_TIME_GOLD, false); @@ -168,7 +168,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED, true); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_POSX, 160 - 5); - $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_POSY, 90 - 14); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_POSY, 90 - 11); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_WIDTH, 10); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_HEIGHT, 5.5); From 92e00737b5002654efcaf5c9e1526d1c086d677b Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Sat, 29 Feb 2020 13:43:16 +0100 Subject: [PATCH 18/98] Adjust MX icon to be relative to bottom border --- plugins/MCTeam/WidgetPlugin.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/MCTeam/WidgetPlugin.php b/plugins/MCTeam/WidgetPlugin.php index b4e0ebe2..3647ca65 100644 --- a/plugins/MCTeam/WidgetPlugin.php +++ b/plugins/MCTeam/WidgetPlugin.php @@ -38,7 +38,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { const PLUGIN_ID = 1; const PLUGIN_VERSION = 0.11; const PLUGIN_NAME = 'WidgetPlugin'; - const PLUGIN_AUTHOR = 'kremsy, axelalex2'; + const PLUGIN_AUTHOR = 'MCTeam'; // MapWidget Properties const MLID_MAP_WIDGET = 'WidgetPlugin.MapWidget'; @@ -293,7 +293,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { $quad = new Quad_Icons128x32_1(); $frame->addChild($quad); - $quad->setPosition(-$width/2 + 3, -3, -0.5); + $quad->setPosition(-$width/2 + 3, -$height/2 + 3, -0.5); $quad->setSize(3.5, 3.5); $quad->setSubStyle($quad::SUBSTYLE_RT_TimeAttack); @@ -312,7 +312,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { $frame->addChild($quad); $quad->setImageFocusUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_MOVER)); $quad->setImageUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON)); - $quad->setPosition($width/2 - 3, -3, -0.5); + $quad->setPosition($width/2 - 3, -$height/2 + 3, -0.5); $quad->setSize(3.5, 3.5); $quad->setUrl($map->mx->pageurl); } From 165fec331708fad6625572df48f13b5be19590f0 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Sat, 29 Feb 2020 15:14:48 +0100 Subject: [PATCH 19/98] Move Join-/Leave-Coloring from Chat to Admin/ColorManager, and add setting to disable --- core/Admin/ColorManager.php | 99 ++++++++++++++++++++++++++++++++++ core/Chat.php | 64 ---------------------- core/ManiaControl.php | 15 ++++++ core/Players/PlayerManager.php | 12 ++++- 4 files changed, 124 insertions(+), 66 deletions(-) create mode 100644 core/Admin/ColorManager.php diff --git a/core/Admin/ColorManager.php b/core/Admin/ColorManager.php new file mode 100644 index 00000000..e6f7da07 --- /dev/null +++ b/core/Admin/ColorManager.php @@ -0,0 +1,99 @@ + + * @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 ($authLevel) { + 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); + } +} \ No newline at end of file diff --git a/core/Chat.php b/core/Chat.php index 65c0cce7..ba49aeec 100644 --- a/core/Chat.php +++ b/core/Chat.php @@ -26,11 +26,6 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA /* * 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'; const SETTING_FORMAT_ERROR = 'Error Format'; const SETTING_FORMAT_INFORMATION = 'Information Format'; const SETTING_FORMAT_SUCCESS = 'Success Format'; @@ -55,11 +50,6 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA $this->maniaControl = $maniaControl; // Settings - $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'); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_ERROR, '$f30'); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_INFORMATION, '$fff'); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_SUCCESS, '$0f0'); @@ -77,60 +67,6 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA }); } - /** - * 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 ($authLevel) { - 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); - } - /** * Send an information message to the given login * diff --git a/core/ManiaControl.php b/core/ManiaControl.php index d959a716..5a4f9b7c 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -4,6 +4,7 @@ namespace ManiaControl; use ManiaControl\Admin\ActionsMenu; use ManiaControl\Admin\AuthenticationManager; +use ManiaControl\Admin\ColorManager; use ManiaControl\Bills\BillManager; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; @@ -93,6 +94,10 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, * @see getChat() */ private $chat = null; + /** @var ColorManager $colorManager + * @see getColorManager() + */ + private $colorManager = null; /** @var \SimpleXMLElement $config * @see getConfig() */ @@ -202,6 +207,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, $this->server = new Server($this); $this->authenticationManager = new AuthenticationManager($this); $this->playerManager = new PlayerManager($this); + $this->colorManager = new ColorManager($this); $this->mapManager = new MapManager($this); $this->configurator = new Configurator($this); $this->pluginManager = new PluginManager($this); @@ -451,6 +457,15 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, return $this->playerManager; } + /** + * Return the color manager + * + * @return ColorManager + */ + public function getColorManager() { + return $this->colorManager; + } + /** * Return the setting manager * diff --git a/core/Players/PlayerManager.php b/core/Players/PlayerManager.php index 3823ed98..47adb6a0 100644 --- a/core/Players/PlayerManager.php +++ b/core/Players/PlayerManager.php @@ -41,6 +41,7 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis const CB_PLAYERINFOSCHANGED = 'PlayerManagerCallback.PlayerInfosChanged'; const CB_SERVER_EMPTY = 'PlayerManagerCallback.ServerEmpty'; const TABLE_PLAYERS = 'mc_players'; + const SETTING_JOIN_LEAVE_COLORING = 'Enable Join & Leave Coloring'; const SETTING_JOIN_LEAVE_MESSAGES = 'Enable Join & Leave Messages'; const SETTING_JOIN_LEAVE_MESSAGES_SPECTATOR = 'Enable Join & Leave Messages for Spectators'; const STAT_JOIN_COUNT = 'Joins'; @@ -92,6 +93,7 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis $this->adminLists = new AdminLists($maniaControl); // Settings + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_JOIN_LEAVE_COLORING, false); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES, true); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES_SPECTATOR, true); @@ -378,7 +380,10 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis if (!$player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES) || $player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES_SPECTATOR) ) { - $color = $this->maniaControl->getChat()->getColorByPlayer($player); + $color = '$0f0'; + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_COLORING)) { + $color = $this->maniaControl->getColorManager()->getColorByPlayer($player); + } $authname = AuthenticationManager::getAuthLevelName($player->authLevel); $nickname = $player->getEscapedNickname(); $this->maniaControl->getChat()->sendChat("{$color}{$authname} {$nickname} has left after \$fff{$played}!"); @@ -488,7 +493,10 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis //Check if Player finished joining the game if ($player->hasJoinedGame && !$prevJoinState) { - $color = $this->maniaControl->getChat()->getColorByPlayer($player); + $color = '$0f0'; + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_COLORING)) { + $color = $this->maniaControl->getColorManager()->getColorByPlayer($player); + } $authname = AuthenticationManager::getAuthLevelName($player->authLevel); $nickname = $player->getEscapedNickname(); $nation = '$<$fff' . $player->getCountry() . '$>'; From 96d0a1b5c9f0f79a1cb825c0aafceef368d7e3f4 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Wed, 11 Mar 2020 12:07:26 +0100 Subject: [PATCH 20/98] Extended Join&Leave by Login --- core/Players/PlayerManager.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/core/Players/PlayerManager.php b/core/Players/PlayerManager.php index 47adb6a0..23ae47c7 100644 --- a/core/Players/PlayerManager.php +++ b/core/Players/PlayerManager.php @@ -42,6 +42,7 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis const CB_SERVER_EMPTY = 'PlayerManagerCallback.ServerEmpty'; const TABLE_PLAYERS = 'mc_players'; const SETTING_JOIN_LEAVE_COLORING = 'Enable Join & Leave Coloring'; + const SETTING_JOIN_LEAVE_LOGIN = 'Enable Join & Leave Login'; const SETTING_JOIN_LEAVE_MESSAGES = 'Enable Join & Leave Messages'; const SETTING_JOIN_LEAVE_MESSAGES_SPECTATOR = 'Enable Join & Leave Messages for Spectators'; const STAT_JOIN_COUNT = 'Joins'; @@ -94,6 +95,7 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis // Settings $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_JOIN_LEAVE_COLORING, false); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_JOIN_LEAVE_LOGIN, false); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES, true); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES_SPECTATOR, true); @@ -384,9 +386,14 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_COLORING)) { $color = $this->maniaControl->getColorManager()->getColorByPlayer($player); } + + $nickname = Formatter::escapeText('$fff' . $player->nickname); + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_LOGIN)) { + $nickname .= 'Login: ' . Formatter::escapeText('$fff' . $player->login); + } + $authname = AuthenticationManager::getAuthLevelName($player->authLevel); - $nickname = $player->getEscapedNickname(); - $this->maniaControl->getChat()->sendChat("{$color}{$authname} {$nickname} has left after \$fff{$played}!"); + $this->maniaControl->getChat()->sendChat("{$color}{$authname} {$nickname} has left after \$<\$fff{$played}\$>!"); } //Destroys stored PlayerData, after all Disconnect Callbacks got Handled @@ -497,8 +504,13 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_COLORING)) { $color = $this->maniaControl->getColorManager()->getColorByPlayer($player); } + + $nickname = Formatter::escapeText('$fff' . $player->nickname); + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_LOGIN)) { + $nickname .= 'Login: ' . Formatter::escapeText('$fff' . $player->login); + } + $authname = AuthenticationManager::getAuthLevelName($player->authLevel); - $nickname = $player->getEscapedNickname(); $nation = '$<$fff' . $player->getCountry() . '$>'; if (!$player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) { From 35683d45ba50dcd949e7bc9d5d73642afc7f56b4 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Mon, 16 Mar 2020 00:12:36 +0100 Subject: [PATCH 21/98] Updated changelog with newest versions, added ingame-window to display it. --- changelog.txt | 35 ++++++++- core/ManiaControl.php | 15 ++++ core/Update/ChangeLog.php | 134 ++++++++++++++++++++++++++++++++++ core/Update/UpdateManager.php | 2 +- 4 files changed, 181 insertions(+), 5 deletions(-) create mode 100644 core/Update/ChangeLog.php diff --git a/changelog.txt b/changelog.txt index 08848471..08bea907 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,7 +1,34 @@ -##v0.16x### -# Additions +###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 not being sent +- 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.16x### +#Additions - updated mx links to https -# Changes +#Changes - CommunicationMethod SET_SERVER_OPTIONS sets the changed values also in database on call - Changed Copyright label to 2014-2016 @@ -12,7 +39,7 @@ - added Scriptcallbacks SCORESREADY / SCORES - added SSL support as well as http Redirections of the FileReader -# Bug fixes +#Bug Fixes - Banning of not connected Players now possible ###v0.162### diff --git a/core/ManiaControl.php b/core/ManiaControl.php index 5a4f9b7c..f5a83926 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -34,6 +34,7 @@ use ManiaControl\Script\ModeScriptEventManager; use ManiaControl\Server\Server; use ManiaControl\Settings\SettingManager; use ManiaControl\Statistics\StatisticManager; +use ManiaControl\Update\ChangeLog; use ManiaControl\Update\UpdateManager; use ManiaControl\Utils\CommandLineHelper; use ManiaControl\Utils\SystemUtil; @@ -94,6 +95,10 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, * @see getChat() */ private $chat = null; + /** @var ChangeLog $changeLog + * @see getChangeLog() + */ + private $changeLog = null; /** @var ColorManager $colorManager * @see getColorManager() */ @@ -212,6 +217,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, $this->configurator = new Configurator($this); $this->pluginManager = new PluginManager($this); $this->updateManager = new UpdateManager($this); + $this->changeLog = new ChangeLog($this); $this->getErrorHandler()->init(); @@ -346,6 +352,15 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, return $this->chat; } + /** + * Return the changelog + * + * @return ChangeLog + */ + public function getChangeLog() { + return $this->changeLog; + } + /** * Return the error handler * diff --git a/core/Update/ChangeLog.php b/core/Update/ChangeLog.php new file mode 100644 index 00000000..eea13b15 --- /dev/null +++ b/core/Update/ChangeLog.php @@ -0,0 +1,134 @@ + + * @copyright 2014-2020 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class ChangeLog implements CommandListener { + /* + * Private properties + */ + /** @var ManiaControl $maniaControl */ + private $maniaControl = null; + + /** + * Construct a new update manager instance + * + * @param ManiaControl $maniaControl + */ + public function __construct(ManiaControl $maniaControl) { + $this->maniaControl = $maniaControl; + + // Chat commands + $this->maniaControl->getCommandManager()->registerCommandListener('changelog', $this, 'handle_ChangeLog', true, 'Opens a ChangeLog ingame.'); + } + + /** + * Get the ChangeLog + * @return array + */ + private function getChangeLogArray() { + static $changelog = null; + if ($changelog === null) { + $changelog = $this->readChangeLog(); + } + + return $changelog; + } + + /** + * Displays the ChangeLog Window + * @param array $chatCallback + * @param Player $player + */ + public function handle_ChangeLog(array $chatCallback, Player $player) { + // Build Manialink + $height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight(); + $width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth(); + $quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowStyle(); + $quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowSubStyle(); + + $manialink = new ManiaLink(ManialinkManager::MAIN_MLID); + $script = $manialink->getScript(); + $paging = new Paging(); + $script->addFeature($paging); + + $frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging); + $manialink->addChild($frame); + + // Headline + $label = new Label_Text(); + $frame->addChild($label); + $label->setHorizontalAlign($label::LEFT); + $label->setPosition(-0.45*$width, 0.45*$height); + $label->setSize($width * 0.6, 5); + $label->setStyle($label::STYLE_TextCardSmall); + $label->setText('Changelog of ManiaControl'); + $label->setTextColor('ff0'); + $label->setTextSize(3); + $label->setVerticalAlign($label::TOP); + + $posX = -0.45*$width; + $initialPosY = 0.4*$height - 5; + + $changelog = $this->getChangeLogArray(); + if (empty($changelog)) { + // TODO error + } + + $i = 0; + $numLines = 15; + $pageFrame = null; + foreach ($changelog as $line) { + if ($i % $numLines == 0 || substr($line, 0, 3) === '###') { + // page full, or new version number + $pageFrame = new Frame(); + $frame->addChild($pageFrame); + $paging->addPageControl($pageFrame); + + $posY = $initialPosY; + $i = 0; + } + + $label = new Label_Text(); + $pageFrame->addChild($label); + $label->setHorizontalAlign($label::LEFT); + $label->setPosition($posX, $posY); + $label->setStyle($label::STYLE_TextCardMedium); + $label->setText(str_replace('$', '$$', $line)); // prevent ManiaPlanet formatting + $label->setTextSize(2); + + $posY -= 4; + $i++; + } + + // Display manialink + $this->maniaControl->getManialinkManager()->sendManialink($manialink, $player); + } + + /** + * Reads the changelog.txt in the root-directory into an array + */ + private function readChangeLog() { + $changelog = file_get_contents('changelog.txt'); + if ($changelog === false) { + return array(); + } + + return preg_split('/[\r\n]/', $changelog); + } +} \ No newline at end of file diff --git a/core/Update/UpdateManager.php b/core/Update/UpdateManager.php index ca37d6ce..637bf95b 100644 --- a/core/Update/UpdateManager.php +++ b/core/Update/UpdateManager.php @@ -402,7 +402,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener, // Set the build date $this->setBuildDate($updateData->releaseDate); - $message = 'Update finished!'; + $message = 'Update finished! See what we updated with $<$fff//chatlog$>!'; if ($player) { $this->maniaControl->getChat()->sendSuccess($message, $player); } From a8e571d00221bf89f138ed827d8787bcafe35632 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Mon, 16 Mar 2020 10:56:38 +0100 Subject: [PATCH 22/98] Hide Widget when widget or plugin deactivated --- plugins/MCTeam/Dedimania/DedimaniaPlugin.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php index c08cfe2b..2fa011ef 100644 --- a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php +++ b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php @@ -153,8 +153,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene $this->recordWidget = new RecordWidget($this->maniaControl); - if ($this->maniaControl->getServer()->getGameMode() == 0) - { + if ($this->maniaControl->getServer()->getGameMode() == 0) { $gameMode = $this->maniaControl->getClient()->getScriptName()['CurrentValue']; $this->isMultilap = ($gameMode == 'Laps.Script.txt' || $this->maniaControl->getMapManager()->getCurrentMap()->nbLaps > 0); $this->isRounds = ($gameMode == 'Rounds.Script.txt'); @@ -178,6 +177,8 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_ENABLE)) { $this->sendManialink(); + } else { + $this->maniaControl->getManialinkManager()->hideManialink(self::MLID_DEDIMANIA); } } @@ -748,6 +749,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene * @see \ManiaControl\Plugins\Plugin::unload() */ public function unload() { + $this->maniaControl->getManialinkManager()->hideManialink(self::MLID_DEDIMANIA); } /** From 60a4e9760f7d1effa86336b9abecaca9f4580cdd Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Mon, 16 Mar 2020 11:10:21 +0100 Subject: [PATCH 23/98] Bump up Dedimania Version Number --- plugins/MCTeam/Dedimania/DedimaniaPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php index 2fa011ef..e5a3ea08 100644 --- a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php +++ b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php @@ -36,7 +36,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene * Constants */ const ID = 8; - const VERSION = 0.6; + const VERSION = 0.61; const AUTHOR = 'MCTeam'; const NAME = 'Dedimania Plugin'; const MLID_DEDIMANIA = 'Dedimania.ManialinkId'; From eba2b566538c2c34aa81a226b2e4aed7f8e9ed17 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Mon, 16 Mar 2020 11:11:17 +0100 Subject: [PATCH 24/98] Same bug disabling widgets for donations and general widgets fixed --- plugins/MCTeam/DonationPlugin.php | 21 ++++++++++++++++++++- plugins/MCTeam/WidgetPlugin.php | 12 ++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/plugins/MCTeam/DonationPlugin.php b/plugins/MCTeam/DonationPlugin.php index 1587e7af..f35858b9 100644 --- a/plugins/MCTeam/DonationPlugin.php +++ b/plugins/MCTeam/DonationPlugin.php @@ -24,6 +24,8 @@ use ManiaControl\Manialinks\SidebarMenuManager; use ManiaControl\Players\Player; use ManiaControl\Players\PlayerManager; use ManiaControl\Plugins\Plugin; +use ManiaControl\Settings\Setting; +use ManiaControl\Settings\SettingManager; /** * ManiaControl Donation Plugin @@ -37,7 +39,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb * Constants */ const ID = 3; - const VERSION = 0.1; + const VERSION = 0.11; const AUTHOR = 'MCTeam'; const NAME = 'Donation Plugin'; const SETTING_ANNOUNCE_SERVER_DONATION = 'Enable Server-Donation Announcements'; @@ -113,6 +115,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb // Register for callbacks $this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); $this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer'); + $this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'handleSettingChanged'); // Define player stats $this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_PLAYER_DONATIONS); @@ -137,6 +140,8 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb public function displayWidget() { if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATE_WIDGET_ACTIVATED)) { $this->displayDonateWidget(); + } else { + $this->maniaControl->getManialinkManager()->hideManialink(self::MLID_DONATE_WIDGET); } } @@ -237,6 +242,20 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb $this->maniaControl->getManialinkManager()->hideManialink(self::MLID_DONATE_WIDGET); } + /** + * Handle Setting Changed Callback + * + * @internal + * @param Setting $setting + */ + public function handleSettingChanged(Setting $setting) { + if (!$setting->belongsToClass($this)) { + return; + } + + $this->displayWidget(); + } + /** * Handle ManialinkPageAnswer Callback * diff --git a/plugins/MCTeam/WidgetPlugin.php b/plugins/MCTeam/WidgetPlugin.php index 3647ca65..f8d0632c 100644 --- a/plugins/MCTeam/WidgetPlugin.php +++ b/plugins/MCTeam/WidgetPlugin.php @@ -36,7 +36,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { * Constants */ const PLUGIN_ID = 1; - const PLUGIN_VERSION = 0.11; + const PLUGIN_VERSION = 0.12; const PLUGIN_NAME = 'WidgetPlugin'; const PLUGIN_AUTHOR = 'MCTeam'; @@ -213,12 +213,20 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED)) { $this->maniaControl->getModeScriptEventManager()->setSiegeProgressionUIPosition("160.", "-67.", "0."); $this->displayMapWidget(); + } else { + $this->closeWidget(self::MLID_MAP_WIDGET); } + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) { $this->displayClockWidget(); + } else { + $this->closeWidget(self::MLID_CLOCK_WIDGET); } + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) { $this->displayServerInfoWidget(); + } else { + $this->closeWidget(self::MLID_SERVERINFO_WIDGET); } } @@ -619,7 +627,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { */ public function updateSettings(Setting $setting) { if ($setting->belongsToClass($this)) { - $this->displayWIdgets(); + $this->displayWidgets(); //Update Nadeo Default Widgets if ($setting->setting == self::SETTING_TM_LIVE_INFO_WIDGET_POSX || $setting->setting == self::SETTING_TM_LIVE_INFO_WIDGET_POSY) { From 68edd009fc7c2ebced881e9f2668a797186848c8 Mon Sep 17 00:00:00 2001 From: kremsy Date: Thu, 26 Mar 2020 21:40:20 +0100 Subject: [PATCH 25/98] fixed pause vote and start for combo --- core/Server/Commands.php | 5 +++-- plugins/MCTeam/CustomVotesPlugin.php | 3 ++- plugins/MCTeam/LocalRecordsPlugin.php | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/Server/Commands.php b/core/Server/Commands.php index 6595bef8..49fe572a 100644 --- a/core/Server/Commands.php +++ b/core/Server/Commands.php @@ -16,6 +16,7 @@ use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Players\Player; +use Maniaplanet\DedicatedServer\Xmlrpc\FaultException; use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; /** @@ -225,7 +226,7 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer try { $this->maniaControl->getClient()->sendModeScriptCommands(array('Command_ForceWarmUp' => true)); $this->maniaControl->getChat()->sendInformation($player->getEscapedNickname() . ' paused the Game!'); - } catch (GameModeException $e) { + } catch (GameModeException | FaultException $e) { } try { @@ -235,7 +236,7 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer //Especially for chase, force end of the round to reach a draw $this->maniaControl->getClient()->sendModeScriptCommands(array('Command_ForceEndRound' => true)); - } catch (GameModeException $ex) { + } catch (GameModeException | FaultException $ex) { } //TODO verify if not everything is replaced through the new pause diff --git a/plugins/MCTeam/CustomVotesPlugin.php b/plugins/MCTeam/CustomVotesPlugin.php index 4ff6f0ee..32af0d4a 100644 --- a/plugins/MCTeam/CustomVotesPlugin.php +++ b/plugins/MCTeam/CustomVotesPlugin.php @@ -37,6 +37,7 @@ use ManiaControl\Settings\SettingManager; use ManiaControl\Utils\ColorUtil; use Maniaplanet\DedicatedServer\Structures\VoteRatio; use Maniaplanet\DedicatedServer\Xmlrpc\ChangeInProgressException; +use Maniaplanet\DedicatedServer\Xmlrpc\FaultException; use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; @@ -524,7 +525,7 @@ class CustomVotesPlugin implements SidebarMenuEntryListener, CommandListener, Ca //Gamemodes like Elite, Speedball $this->maniaControl->getClient()->sendModeScriptCommands(array('Command_ForceWarmUp' => true)); $this->maniaControl->getChat()->sendInformation('$f8fVote to $fffpause the current Game$f8f has been successful!'); - } catch (GameModeException $ex) { + } catch (GameModeException | FaultException $ex) { } //TODO verify if not everything is replaced through the new pause diff --git a/plugins/MCTeam/LocalRecordsPlugin.php b/plugins/MCTeam/LocalRecordsPlugin.php index ce26e97e..8bf952c4 100644 --- a/plugins/MCTeam/LocalRecordsPlugin.php +++ b/plugins/MCTeam/LocalRecordsPlugin.php @@ -34,7 +34,7 @@ use MCTeam\Common\RecordWidget; * ManiaControl Local Records Plugin * * @author ManiaControl Team - * @copyright 2014-2019 ManiaControl Team + * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, CommandListener, ManialinkPageAnswerListener, TimerListener, Plugin { From ed250af5464092237f3d3790a4791563569b60e7 Mon Sep 17 00:00:00 2001 From: kremsy Date: Sat, 28 Mar 2020 18:08:05 +0100 Subject: [PATCH 26/98] added unkown command to gamemodeexception --- core/Server/Commands.php | 3 +-- libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php | 3 +++ plugins/MCTeam/CustomVotesPlugin.php | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/core/Server/Commands.php b/core/Server/Commands.php index 49fe572a..0608b7c8 100644 --- a/core/Server/Commands.php +++ b/core/Server/Commands.php @@ -226,7 +226,7 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer try { $this->maniaControl->getClient()->sendModeScriptCommands(array('Command_ForceWarmUp' => true)); $this->maniaControl->getChat()->sendInformation($player->getEscapedNickname() . ' paused the Game!'); - } catch (GameModeException | FaultException $e) { + } catch (GameModeException $e) { } try { @@ -242,7 +242,6 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer //TODO verify if not everything is replaced through the new pause $this->maniaControl->getModeScriptEventManager()->startPause(); $this->maniaControl->getChat()->sendInformation('$f8fVote to $fffpause the current Game$f8f has been successful!'); - } /** diff --git a/libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php b/libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php index b4fbfdf1..851443fa 100755 --- a/libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php +++ b/libs/Maniaplanet/DedicatedServer/Xmlrpc/FaultException.php @@ -96,6 +96,9 @@ class FaultException extends Exception { case 'No map to export in playlist.': return new FileException($faultString, $faultCode); } + if (preg_match('~^Unknown command \'.*\'\.$~iu', $faultString)) { + return new GameModeException($faultString, $faultCode); + } if (preg_match('~^Unknown setting \'.*\'\.$~iu', $faultString)) { return new GameModeException($faultString, $faultCode); } diff --git a/plugins/MCTeam/CustomVotesPlugin.php b/plugins/MCTeam/CustomVotesPlugin.php index 32af0d4a..ac950ce9 100644 --- a/plugins/MCTeam/CustomVotesPlugin.php +++ b/plugins/MCTeam/CustomVotesPlugin.php @@ -525,7 +525,7 @@ class CustomVotesPlugin implements SidebarMenuEntryListener, CommandListener, Ca //Gamemodes like Elite, Speedball $this->maniaControl->getClient()->sendModeScriptCommands(array('Command_ForceWarmUp' => true)); $this->maniaControl->getChat()->sendInformation('$f8fVote to $fffpause the current Game$f8f has been successful!'); - } catch (GameModeException | FaultException $ex) { + } catch (GameModeException $ex) { } //TODO verify if not everything is replaced through the new pause From 324cbdce503b1b7d89235953055301e9d22ad94a Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 21 Apr 2020 17:37:42 +0200 Subject: [PATCH 27/98] Removed multi-catch for PHP5 and bumped MC-Version --- core/ManiaControl.php | 2 +- core/Server/Commands.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/ManiaControl.php b/core/ManiaControl.php index f5a83926..9e8a42df 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -55,7 +55,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, /* * Constants */ - const VERSION = '0.251'; + const VERSION = '0.252'; const API_VERSION = '2013-04-16'; const MIN_DEDIVERSION = '2017-05-03_21_00'; const SCRIPT_TIMEOUT = 40; diff --git a/core/Server/Commands.php b/core/Server/Commands.php index 0608b7c8..882e31d2 100644 --- a/core/Server/Commands.php +++ b/core/Server/Commands.php @@ -236,7 +236,7 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer //Especially for chase, force end of the round to reach a draw $this->maniaControl->getClient()->sendModeScriptCommands(array('Command_ForceEndRound' => true)); - } catch (GameModeException | FaultException $ex) { + } catch (GameModeException $e) { } //TODO verify if not everything is replaced through the new pause From ffd46c3cdd1acfd74f8a1344c7701bf29c5b07a5 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 21 Apr 2020 17:41:01 +0200 Subject: [PATCH 28/98] Ignore all contents in config/ except server.default.xml --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 12e91612..cc90f965 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,8 @@ !/.git !/.gitignore !/.idea -/configs/server.xml +/configs/* +!/configs/server.default.xml /logs/ /ManiaControl.log /ManiaControl.pid From 06b3893a27d9aba1afbc04f826ca01bcfed17af1 Mon Sep 17 00:00:00 2001 From: kremsy Date: Tue, 21 Apr 2020 17:44:41 +0200 Subject: [PATCH 29/98] fixed number mismatch declerations --- core/Maps/MapActions.php | 2 +- core/Update/UpdateManager.php | 5 ++--- libs/FML/Script/Features/Paging.php | 4 +--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/core/Maps/MapActions.php b/core/Maps/MapActions.php index da96a7b7..2049f2ee 100644 --- a/core/Maps/MapActions.php +++ b/core/Maps/MapActions.php @@ -107,7 +107,7 @@ class MapActions implements CommunicationListener, UsageInformationAble { //TODO message // Force an EndMap on the MapQueue to set the next Map - $this->maniaControl->getMapManager()->getMapQueue()->endMap(null); + $this->maniaControl->getMapManager()->getMapQueue()->endMap(); // Ignore EndMap on MapQueue $this->maniaControl->getMapManager()->getMapQueue()->dontQueueNextMapChange(); diff --git a/core/Update/UpdateManager.php b/core/Update/UpdateManager.php index 637bf95b..6b4b54be 100644 --- a/core/Update/UpdateManager.php +++ b/core/Update/UpdateManager.php @@ -462,9 +462,8 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener, if (!$setting->setting != self::SETTING_UPDATECHECK_INTERVAL) { return; } - - $updateInterval = $setting->value; - $this->maniaControl->getTimerManager()->updateTimerListening($this, 'hourlyUpdateCheck', 1000 * 60 * 60, $updateInterval); + + $this->maniaControl->getTimerManager()->updateTimerListening($this, 'hourlyUpdateCheck', 1000 * 60 * 60); } /** diff --git a/libs/FML/Script/Features/Paging.php b/libs/FML/Script/Features/Paging.php index bb4fb1a9..553b1d55 100644 --- a/libs/FML/Script/Features/Paging.php +++ b/libs/FML/Script/Features/Paging.php @@ -387,9 +387,7 @@ class Paging extends ScriptFeature if (!is_int($maxPageNumber)) { $maxPageNumber = $maxPage->getPageNumber(); } - - $pagingId = $maxPage->getControl() - ->getId(true, true); + $pagingId = Builder::escapeText($maxPage->getControl() ->getId()); $pageLabelId = Builder::EMPTY_STRING; From 567c6a0aa222a8c90391053c9f6e1bd8ba0b2152 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 21 Apr 2020 17:52:15 +0200 Subject: [PATCH 30/98] Fixed undefined variable errors --- core/Admin/ColorManager.php | 2 +- core/Update/ChangeLog.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core/Admin/ColorManager.php b/core/Admin/ColorManager.php index e6f7da07..b8ade092 100644 --- a/core/Admin/ColorManager.php +++ b/core/Admin/ColorManager.php @@ -72,7 +72,7 @@ class ColorManager implements UsageInformationAble { * @return string */ public function getColorByName($authName) { - switch ($authLevel) { + switch ($authName) { case AuthenticationManager::AUTH_NAME_PLAYER: return $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_COLOR_PLAYER); case AuthenticationManager::AUTH_NAME_MODERATOR: diff --git a/core/Update/ChangeLog.php b/core/Update/ChangeLog.php index eea13b15..aad6611e 100644 --- a/core/Update/ChangeLog.php +++ b/core/Update/ChangeLog.php @@ -84,6 +84,7 @@ class ChangeLog implements CommandListener { $posX = -0.45*$width; $initialPosY = 0.4*$height - 5; + $posY = $initialPosY; $changelog = $this->getChangeLogArray(); if (empty($changelog)) { From f31a1c178225e60ba6f4ec309db017de45e14489 Mon Sep 17 00:00:00 2001 From: kremsy Date: Tue, 21 Apr 2020 17:57:36 +0200 Subject: [PATCH 31/98] fixed number mismatch declerations code cleanups --- .../Common/CommonCommandStructure.php | 2 - .../Common/CommonDefaultEventStructure.php | 1 - .../Common/CommonScoresStructure.php | 2 - .../ManiaPlanet/StartEndStructure.php | 2 +- .../ShootMania/OnArmorEmptyStructure.php | 2 +- .../ShootMania/OnCaptureStructure.php | 4 +- .../ShootMania/OnDefaultEventStructure.php | 4 +- .../ShootMania/OnNearMissStructure.php | 2 +- .../OnPlayerRequestRespawnStructure.php | 4 +- .../ShootMania/OnScoresStructure.php | 2 +- .../ShootMania/OnShootStructure.php | 2 +- .../ShootMania/OnShotDenyStructure.php | 2 +- .../TrackMania/OnDefaultEventStructure.php | 6 +- .../TrackMania/OnRespawnStructure.php | 2 +- core/ManiaExchange/MXMapInfo.php | 2 +- core/Manialinks/StyleManager.php | 2 +- core/Plugins/InstallMenu.php | 1 - core/Server/Commands.php | 24 ++- core/Server/RankingManager.php | 5 +- core/Server/ServerUIPropertiesMenu.php | 6 +- core/Statistics/SimpleStatsList.php | 4 +- core/Utils/Formatter.php | 2 +- libs/FML/Controls/Graph.php | 165 +++++++++--------- libs/React/Socket/ConnectionInterface.php | 6 +- .../core/Manialinks/CustomUIManagerTest.php | 2 - plugins/MCTeam/CustomVotesPlugin.php | 4 +- plugins/MCTeam/DonationPlugin.php | 3 +- plugins/MCTeam/KarmaPlugin.php | 4 +- 28 files changed, 121 insertions(+), 146 deletions(-) diff --git a/core/Callbacks/Structures/Common/CommonCommandStructure.php b/core/Callbacks/Structures/Common/CommonCommandStructure.php index 96146e02..3d497f8c 100644 --- a/core/Callbacks/Structures/Common/CommonCommandStructure.php +++ b/core/Callbacks/Structures/Common/CommonCommandStructure.php @@ -3,8 +3,6 @@ namespace ManiaControl\Callbacks\Structures\Common; -use ManiaControl\Callbacks\Structures\Common\BaseStructure; -use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure; use ManiaControl\ManiaControl; /** diff --git a/core/Callbacks/Structures/Common/CommonDefaultEventStructure.php b/core/Callbacks/Structures/Common/CommonDefaultEventStructure.php index 6a0e1c79..5d2670ec 100644 --- a/core/Callbacks/Structures/Common/CommonDefaultEventStructure.php +++ b/core/Callbacks/Structures/Common/CommonDefaultEventStructure.php @@ -3,7 +3,6 @@ namespace ManiaControl\Callbacks\Structures\ShootMania; -use ManiaControl\Callbacks\Structures\Common\BaseStructure; use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure; use ManiaControl\ManiaControl; diff --git a/core/Callbacks/Structures/Common/CommonScoresStructure.php b/core/Callbacks/Structures/Common/CommonScoresStructure.php index a988ab25..91447bd7 100644 --- a/core/Callbacks/Structures/Common/CommonScoresStructure.php +++ b/core/Callbacks/Structures/Common/CommonScoresStructure.php @@ -5,8 +5,6 @@ namespace ManiaControl\Callbacks\Structures\Common; use ManiaControl\Callbacks\Structures\Common\Models\CommonPlayerScore; use ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore; -use ManiaControl\General\JsonSerializable; -use ManiaControl\General\JsonSerializeTrait; use ManiaControl\ManiaControl; /** diff --git a/core/Callbacks/Structures/ManiaPlanet/StartEndStructure.php b/core/Callbacks/Structures/ManiaPlanet/StartEndStructure.php index ddf37ab3..88da64dc 100644 --- a/core/Callbacks/Structures/ManiaPlanet/StartEndStructure.php +++ b/core/Callbacks/Structures/ManiaPlanet/StartEndStructure.php @@ -3,7 +3,7 @@ namespace ManiaControl\Callbacks\Structures\ManiaPlanet; -use ManiaControl\Callbacks\Structures\Common\BaseStructure; + use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure; use ManiaControl\ManiaControl; diff --git a/core/Callbacks/Structures/ShootMania/OnArmorEmptyStructure.php b/core/Callbacks/Structures/ShootMania/OnArmorEmptyStructure.php index d6f5b0e1..1b278611 100644 --- a/core/Callbacks/Structures/ShootMania/OnArmorEmptyStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnArmorEmptyStructure.php @@ -2,7 +2,7 @@ namespace ManiaControl\Callbacks\Structures\ShootMania; -use ManiaControl\ManiaControl; + /** * Structure Class for the OnArmorEmpty Structure Callback diff --git a/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php b/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php index c98e1812..f80dba1a 100644 --- a/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnCaptureStructure.php @@ -4,8 +4,8 @@ namespace ManiaControl\Callbacks\Structures\ShootMania; use ManiaControl\Callbacks\Structures\Common\BaseStructure; -use ManiaControl\Callbacks\Structures\ShootMania\Models\Landmark; -use ManiaControl\Callbacks\Structures\ShootMania\Models\Position; + + use ManiaControl\ManiaControl; use ManiaControl\Players\Player; diff --git a/core/Callbacks/Structures/ShootMania/OnDefaultEventStructure.php b/core/Callbacks/Structures/ShootMania/OnDefaultEventStructure.php index 46d5be7e..511cc3d4 100644 --- a/core/Callbacks/Structures/ShootMania/OnDefaultEventStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnDefaultEventStructure.php @@ -3,8 +3,8 @@ namespace ManiaControl\Callbacks\Structures\ShootMania; -use ManiaControl\Callbacks\Structures\Common\BaseStructure; -use ManiaControl\ManiaControl; + + /** * Structure Class for the Default Event Structure Callback diff --git a/core/Callbacks/Structures/ShootMania/OnNearMissStructure.php b/core/Callbacks/Structures/ShootMania/OnNearMissStructure.php index e0f2147f..10a7be3e 100644 --- a/core/Callbacks/Structures/ShootMania/OnNearMissStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnNearMissStructure.php @@ -3,7 +3,7 @@ namespace ManiaControl\Callbacks\Structures\ShootMania; -use ManiaControl\ManiaControl; + /** * Structure Class for the OnNearMiss Structure Callback diff --git a/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php b/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php index a94cc2f0..033e617c 100644 --- a/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnPlayerRequestRespawnStructure.php @@ -4,9 +4,7 @@ namespace ManiaControl\Callbacks\Structures\ShootMania; use ManiaControl\Callbacks\Structures\Common\BasePlayerTimeStructure; -use ManiaControl\Callbacks\Structures\Common\BaseStructure; -use ManiaControl\ManiaControl; -use ManiaControl\Players\Player; + /** * Structure Class for the OnPlayerRequestRespawnStructure Structure Callback diff --git a/core/Callbacks/Structures/ShootMania/OnScoresStructure.php b/core/Callbacks/Structures/ShootMania/OnScoresStructure.php index c1aaaa24..29d91752 100644 --- a/core/Callbacks/Structures/ShootMania/OnScoresStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnScoresStructure.php @@ -5,7 +5,7 @@ namespace ManiaControl\Callbacks\Structures\ShootMania; use ManiaControl\Callbacks\Structures\Common\CommonScoresStructure; use ManiaControl\Callbacks\Structures\ShootMania\Models\PlayerScore; -use ManiaControl\Callbacks\Structures\ShootMania\Models\TeamScore; + use ManiaControl\ManiaControl; diff --git a/core/Callbacks/Structures/ShootMania/OnShootStructure.php b/core/Callbacks/Structures/ShootMania/OnShootStructure.php index ec4d8a1c..4ca33824 100644 --- a/core/Callbacks/Structures/ShootMania/OnShootStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnShootStructure.php @@ -3,7 +3,7 @@ namespace ManiaControl\Callbacks\Structures\ShootMania; -use ManiaControl\Callbacks\Structures\Common\BaseStructure; + use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; diff --git a/core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php b/core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php index 04f20b0a..a9c434a3 100644 --- a/core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php +++ b/core/Callbacks/Structures/ShootMania/OnShotDenyStructure.php @@ -3,7 +3,7 @@ namespace ManiaControl\Callbacks\Structures\ShootMania; -use ManiaControl\Callbacks\Structures\Common\BaseStructure; + use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure; use ManiaControl\ManiaControl; diff --git a/core/Callbacks/Structures/TrackMania/OnDefaultEventStructure.php b/core/Callbacks/Structures/TrackMania/OnDefaultEventStructure.php index 76b71db8..3adc04a0 100644 --- a/core/Callbacks/Structures/TrackMania/OnDefaultEventStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnDefaultEventStructure.php @@ -3,10 +3,10 @@ namespace ManiaControl\Callbacks\Structures\TrackMania; -use ManiaControl\Callbacks\Structures\Common\BaseStructure; -use ManiaControl\Callbacks\Structures\Common\BaseTimeStructure; + + use ManiaControl\Callbacks\Structures\ShootMania\CommonDefaultEventStructure; -use ManiaControl\ManiaControl; + /** * Structure Class for the Default Event Structure Callback diff --git a/core/Callbacks/Structures/TrackMania/OnRespawnStructure.php b/core/Callbacks/Structures/TrackMania/OnRespawnStructure.php index 7d76b129..96070671 100644 --- a/core/Callbacks/Structures/TrackMania/OnRespawnStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnRespawnStructure.php @@ -6,7 +6,7 @@ namespace ManiaControl\Callbacks\Structures\TrackMania; use ManiaControl\Callbacks\Models\RecordCallback; use ManiaControl\Callbacks\Structures\Common\BasePlayerTimeStructure; use ManiaControl\ManiaControl; -use ManiaControl\Utils\Formatter; + /** * Structure Class for the On Respawn Structure Callback diff --git a/core/ManiaExchange/MXMapInfo.php b/core/ManiaExchange/MXMapInfo.php index ed9c6a2f..2ede42f9 100644 --- a/core/ManiaExchange/MXMapInfo.php +++ b/core/ManiaExchange/MXMapInfo.php @@ -28,7 +28,7 @@ class MXMapInfo { * * @param String $prefix MX URL prefix * @param $mx - * @return MXMapInfo + * @return \ManiaControl\ManiaExchange\MXMapInfo|void */ public function __construct($prefix, $mx) { $this->prefix = $prefix; diff --git a/core/Manialinks/StyleManager.php b/core/Manialinks/StyleManager.php index 0d98d21b..62243cb5 100644 --- a/core/Manialinks/StyleManager.php +++ b/core/Manialinks/StyleManager.php @@ -12,7 +12,7 @@ use FML\Controls\Quads\Quad_BgRaceScore2; use FML\Controls\Quads\Quad_Bgs1InRace; use FML\Controls\Quads\Quad_BgsPlayerCard; use FML\Controls\Quads\Quad_Icons64x64_1; -use FML\Controls\Quads\Quad_UIConstruction_Buttons; + use FML\Script\Features\Paging; use FML\Script\Script; use ManiaControl\General\UsageInformationAble; diff --git a/core/Plugins/InstallMenu.php b/core/Plugins/InstallMenu.php index 0be42d8e..679d28de 100644 --- a/core/Plugins/InstallMenu.php +++ b/core/Plugins/InstallMenu.php @@ -11,7 +11,6 @@ use FML\Script\Features\Paging; use FML\Script\Script; use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Configurator\ConfiguratorMenu; -use ManiaControl\Files\AsyncHttpRequest; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Players\Player; diff --git a/core/Server/Commands.php b/core/Server/Commands.php index 882e31d2..a26b38dc 100644 --- a/core/Server/Commands.php +++ b/core/Server/Commands.php @@ -9,14 +9,12 @@ use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\Callbacks; use ManiaControl\Callbacks\Structures\Common\StatusCallbackStructure; -use ManiaControl\Callbacks\Structures\TrackMania\OnPointsRepartitionStructure; use ManiaControl\Callbacks\TimerListener; use ManiaControl\Commands\CommandListener; use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Players\Player; -use Maniaplanet\DedicatedServer\Xmlrpc\FaultException; use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; /** @@ -30,17 +28,17 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer /* * Constants */ - const ACTION_SET_PAUSE = 'ServerCommands.SetPause'; - const ACTION_EXTEND_WARMUP = 'ServerCommands.ExtendWarmup'; - const ACTION_END_WARMUP = 'ServerCommands.EndWarmup'; - const ACTION_CANCEL_VOTE = 'ServerCommands.CancelVote'; - const CB_VOTE_CANCELLED = 'ServerCommands.VoteCancelled'; - const SETTING_PERMISSION_CANCEL_VOTE = 'Cancel Vote'; - const SETTING_PERMISSION_SET_PAUSE = 'Set Pause'; - const SETTING_PERMISSION_HANDLE_WARMUP = 'Handle Warmup'; - const SETTING_PERMISSION_SHOW_SYSTEMINFO = 'Show SystemInfo'; - const SETTING_PERMISSION_SHUTDOWN_SERVER = 'Shutdown Server'; - const SETTING_PERMISSION_CHANGE_SERVERSETTINGS = 'Change ServerSettings'; + const ACTION_SET_PAUSE = 'ServerCommands.SetPause'; + const ACTION_EXTEND_WARMUP = 'ServerCommands.ExtendWarmup'; + const ACTION_END_WARMUP = 'ServerCommands.EndWarmup'; + const ACTION_CANCEL_VOTE = 'ServerCommands.CancelVote'; + const CB_VOTE_CANCELLED = 'ServerCommands.VoteCancelled'; + const SETTING_PERMISSION_CANCEL_VOTE = 'Cancel Vote'; + const SETTING_PERMISSION_SET_PAUSE = 'Set Pause'; + const SETTING_PERMISSION_HANDLE_WARMUP = 'Handle Warmup'; + const SETTING_PERMISSION_SHOW_SYSTEMINFO = 'Show SystemInfo'; + const SETTING_PERMISSION_SHUTDOWN_SERVER = 'Shutdown Server'; + const SETTING_PERMISSION_CHANGE_SERVERSETTINGS = 'Change ServerSettings'; /* * Private properties diff --git a/core/Server/RankingManager.php b/core/Server/RankingManager.php index 33cb440b..ececf934 100644 --- a/core/Server/RankingManager.php +++ b/core/Server/RankingManager.php @@ -11,6 +11,7 @@ use ManiaControl\ManiaControl; use ManiaControl\Maps\Map; use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; +//TODO delete this class /** * Class managing Rankings * @@ -109,7 +110,7 @@ class RankingManager implements CallbackListener, UsageInformationAble { array_multisort($this->rankings, SORT_DESC, SORT_NUMERIC); //TODO if Local Records activated-> sort asc - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::RANKINGSUPDATED, $this->getRankings()); + //$this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::RANKINGSUPDATED, $this->getRankings()); } /** @@ -134,7 +135,7 @@ class RankingManager implements CallbackListener, UsageInformationAble { return $leaders; } // FIXME: $leader doesn't exist - array_push($leaders, $leader); + //array_push($leaders, $leader); $prev = $score; } return null; diff --git a/core/Server/ServerUIPropertiesMenu.php b/core/Server/ServerUIPropertiesMenu.php index 8cc5560f..56e7674d 100644 --- a/core/Server/ServerUIPropertiesMenu.php +++ b/core/Server/ServerUIPropertiesMenu.php @@ -5,19 +5,19 @@ namespace ManiaControl\Server; use FML\Components\CheckBox; use FML\Controls\Entry; use FML\Controls\Frame; -use FML\Controls\Label; + use FML\Controls\Labels\Label_Text; use FML\Controls\Quad; use FML\Controls\Quads\Quad_Icons64x64_1; use FML\Script\Features\Paging; use FML\Script\Script; -use FML\XmlRpc\UIProperties; + use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\Callbacks; use ManiaControl\Callbacks\TimerListener; use ManiaControl\Callbacks\Structures\Common\UIPropertiesBaseStructure; -use ManiaControl\Configurator\Configurator; + use ManiaControl\Configurator\ConfiguratorMenu; use ManiaControl\Logger; use ManiaControl\ManiaControl; diff --git a/core/Statistics/SimpleStatsList.php b/core/Statistics/SimpleStatsList.php index dfa979d9..e11d7bde 100644 --- a/core/Statistics/SimpleStatsList.php +++ b/core/Statistics/SimpleStatsList.php @@ -3,7 +3,7 @@ namespace ManiaControl\Statistics; use FML\Controls\Frame; -use FML\Controls\Label; + use FML\Controls\Labels\Label_Text; use FML\Controls\Quad; use FML\Controls\Quads\Quad_BgsPlayerCard; @@ -15,7 +15,7 @@ use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\Callbacks; use ManiaControl\Commands\CommandListener; -use ManiaControl\Logger; + use ManiaControl\ManiaControl; use ManiaControl\Manialinks\LabelLine; use ManiaControl\Manialinks\ManialinkManager; diff --git a/core/Utils/Formatter.php b/core/Utils/Formatter.php index 39900534..c26ae575 100644 --- a/core/Utils/Formatter.php +++ b/core/Utils/Formatter.php @@ -225,7 +225,7 @@ abstract class Formatter implements UsageInformationAble { * Make sure the given Text is encoded in UTF-8 * * @param string $text - * @return string + * @return array|string */ public static function utf8($text) { if (is_array($text)) { diff --git a/libs/FML/Controls/Graph.php b/libs/FML/Controls/Graph.php index 64e3f319..4335b066 100644 --- a/libs/FML/Controls/Graph.php +++ b/libs/FML/Controls/Graph.php @@ -4,7 +4,6 @@ namespace FML\Controls; use FML\Script\Features\GraphCurve; use FML\Script\Features\GraphSettings; -use FML\Script\Features\ScriptFeature; /** * Graph Control @@ -14,100 +13,92 @@ use FML\Script\Features\ScriptFeature; * @copyright FancyManiaLinks Copyright © 2017 Steffen Schröder * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class Graph extends Control -{ +class Graph extends Control { - /** - * @var GraphSettings $graphSettings Graph settings - */ - protected $graphSettings = null; + /** + * @var GraphSettings $graphSettings Graph settings + */ + protected $graphSettings = null; - /** - * @var GraphCurve[] $curves Curves - */ - protected $curves = array(); + /** + * @var GraphCurve[] $curves Curves + */ + protected $curves = array(); - /** - * Get the graph settings - * - * @api - * @return GraphSettings - */ - public function getSettings() - { - if (!$this->graphSettings) { - $this->createSettings(); - } - return $this->graphSettings; - } + /** + * Get the graph settings + * + * @api + * @return GraphSettings + */ + public function getSettings() { + if (!$this->graphSettings) { + $this->createSettings(); + } + return $this->graphSettings; + } - /** - * Create new graph settings - * - * @return GraphSettings - */ - protected function createSettings() - { - $this->graphSettings = new GraphSettings($this); - $this->addScriptFeature($this->graphSettings); - return $this->graphSettings; - } + /** + * Create new graph settings + * + * @return GraphSettings + */ + protected function createSettings() { + $this->graphSettings = new GraphSettings($this); + $this->addScriptFeature($this->graphSettings); + return $this->graphSettings; + } - /** - * Get curves - * - * @api - * @return GraphCurve[] - */ - public function getCurves() - { - return $this->curves; - } + /** + * Get curves + * + * @api + * @return GraphCurve[] + */ + public function getCurves() { + return $this->curves; + } - /** - * Add curve - * - * @api - * @param GraphCurve $curve Curve - * @return static - */ - public function addCurve(GraphCurve $curve) - { - $curve->setGraph($this); - $this->addScriptFeature($curve); - array_push($this->curves, $curve); - return $this; - } + /** + * Add curve + * + * @api + * @param GraphCurve $curve Curve + * @return static + */ + public function addCurve(GraphCurve $curve) { + $curve->setGraph($this); + $this->addScriptFeature($curve); + array_push($this->curves, $curve); + return $this; + } - /** - * Add curves - * - * @api - * @param GraphCurve[] $curves Curves - * @return static - */ - public function addCurves(array $curves) - { - foreach ($curves as $curve) { - $this->addCurve($curve); - } - return $this; - } + /** + * Add curves + * + * @api + * @param GraphCurve[] $curves Curves + * @return static + */ + public function addCurves(array $curves) { + foreach ($curves as $curve) { + $this->addCurve($curve); + } + return $this; + } - /** - * @see Control::getTagName() - */ - public function getTagName() - { - return "graph"; - } + /** + * @see Control::getTagName() + */ + public function getTagName() { + return "graph"; + } - /** - * @see Control::getManiaScriptClass() - */ - public function getManiaScriptClass() - { - return "CMlGraph"; - } + /** + * @see Control::getManiaScriptClass() + */ + public function getManiaScriptClass() { + return "CMlGraph"; + } } diff --git a/libs/React/Socket/ConnectionInterface.php b/libs/React/Socket/ConnectionInterface.php index 70dd8b1c..1339e562 100644 --- a/libs/React/Socket/ConnectionInterface.php +++ b/libs/React/Socket/ConnectionInterface.php @@ -2,11 +2,9 @@ namespace React\Socket; -use Evenement\EventEmitterInterface; use React\Stream\ReadableStreamInterface; use React\Stream\WritableStreamInterface; -interface ConnectionInterface extends ReadableStreamInterface, WritableStreamInterface -{ - public function getRemoteAddress(); +interface ConnectionInterface extends ReadableStreamInterface, WritableStreamInterface { + public function getRemoteAddress(); } diff --git a/phpunittests/core/Manialinks/CustomUIManagerTest.php b/phpunittests/core/Manialinks/CustomUIManagerTest.php index 241d28ee..e89ac555 100644 --- a/phpunittests/core/Manialinks/CustomUIManagerTest.php +++ b/phpunittests/core/Manialinks/CustomUIManagerTest.php @@ -1,7 +1,5 @@ maniaControl->getSettingManager()->initSetting($this, self::SETTING_SPECTATOR_ALLOW_START_VOTE, true); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_VOTE_TIME, 40); - $this->maniaControl->getManialinkManager()->getSidebarMenuManager()->addMenuEntry(SidebarMenuManager::ORDER_PLAYER_MENU + 5, self::CUSTOMVOTES_MENU_ID,$this,'showIcon'); + $this->maniaControl->getManialinkManager()->getSidebarMenuManager()->addMenuEntry(SidebarMenuManager::ORDER_PLAYER_MENU + 5, self::CUSTOMVOTES_MENU_ID, $this, 'showIcon'); //Define Votes $this->defineVote("teambalance", "Vote for Team Balance"); $this->defineVote("skipmap", "Vote for Skip Map")->setStopCallback(Callbacks::ENDMAP); diff --git a/plugins/MCTeam/DonationPlugin.php b/plugins/MCTeam/DonationPlugin.php index f35858b9..4c01eb07 100644 --- a/plugins/MCTeam/DonationPlugin.php +++ b/plugins/MCTeam/DonationPlugin.php @@ -10,7 +10,6 @@ use FML\Controls\Quads\Quad_BgRaceScore2; use FML\Controls\Quads\Quad_BgsPlayerCard; use FML\ManiaLink; use FML\Script\Features\Paging; -use ManiaControl\Admin\ActionsMenu; use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Bills\BillManager; use ManiaControl\Callbacks\CallbackListener; @@ -120,7 +119,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb // Define player stats $this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_PLAYER_DONATIONS); - $this->maniaControl->getManialinkManager()->getSidebarMenuManager()->addMenuEntry(SidebarMenuManager::ORDER_PLAYER_MENU + 5,self::DONATIONPLUGIN_MENU_ID,$this,'displayDonateWidget'); + $this->maniaControl->getManialinkManager()->getSidebarMenuManager()->addMenuEntry(SidebarMenuManager::ORDER_PLAYER_MENU + 5, self::DONATIONPLUGIN_MENU_ID, $this, 'displayDonateWidget'); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DONATE_WIDGET_ACTIVATED, true); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DONATION_VALUES, "20,50,100,500,1000,2000"); diff --git a/plugins/MCTeam/KarmaPlugin.php b/plugins/MCTeam/KarmaPlugin.php index c3df7883..f1d34978 100644 --- a/plugins/MCTeam/KarmaPlugin.php +++ b/plugins/MCTeam/KarmaPlugin.php @@ -736,7 +736,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { * Get all players votes * * @param Map $map - * @return array + * @return array|bool */ public function getMapPlayerVotes(Map $map) { $mysqli = $this->maniaControl->getDatabase()->getMysqli(); @@ -893,7 +893,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { * Get the current Votes for the Map * * @param Map $map - * @return array + * @return array|bool */ public function getMapVotes(Map $map) { $mysqli = $this->maniaControl->getDatabase()->getMysqli(); From 8d9af397973aea4393e62be0f5d1eb63bc5ce5ef Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 21 Apr 2020 18:34:51 +0200 Subject: [PATCH 32/98] Remove unused variables --- core/Update/ChangeLog.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/Update/ChangeLog.php b/core/Update/ChangeLog.php index aad6611e..5fe8970b 100644 --- a/core/Update/ChangeLog.php +++ b/core/Update/ChangeLog.php @@ -57,10 +57,8 @@ class ChangeLog implements CommandListener { */ public function handle_ChangeLog(array $chatCallback, Player $player) { // Build Manialink - $height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight(); - $width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth(); - $quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowStyle(); - $quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowSubStyle(); + $height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight(); + $width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth(); $manialink = new ManiaLink(ManialinkManager::MAIN_MLID); $script = $manialink->getScript(); From c2064c8d786c20c808e94a13ac657c9125f005ec Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Fri, 24 Apr 2020 18:51:38 +0200 Subject: [PATCH 33/98] Renamed //restart to //reboot --- core/Callbacks/Callbacks.php | 2 ++ core/Callbacks/EchoManager.php | 5 +-- core/Communication/CommunicationMethods.php | 4 +-- core/ErrorHandler.php | 4 +-- core/ManiaControl.php | 38 ++++++++++----------- core/Maps/MapCommands.php | 2 +- core/Update/UpdateManager.php | 2 +- 7 files changed, 30 insertions(+), 27 deletions(-) diff --git a/core/Callbacks/Callbacks.php b/core/Callbacks/Callbacks.php index 34c74067..aa23f0da 100644 --- a/core/Callbacks/Callbacks.php +++ b/core/Callbacks/Callbacks.php @@ -16,7 +16,9 @@ interface Callbacks { const ONINIT = 'Callbacks.OnInit'; const AFTERINIT = 'Callbacks.AfterInit'; const ONSHUTDOWN = 'Callbacks.OnShutdown'; + /** @deprecated */ const ONRESTART = 'Callbacks.OnRestart'; + const ONREBOOT = 'Callbacks.OnReboot'; const PRELOOP = 'Callbacks.PreLoop'; const AFTERLOOP = 'Callbacks.AfterLoop'; diff --git a/core/Callbacks/EchoManager.php b/core/Callbacks/EchoManager.php index 5bad9475..b095f2af 100644 --- a/core/Callbacks/EchoManager.php +++ b/core/Callbacks/EchoManager.php @@ -143,8 +143,9 @@ class EchoManager implements CallbackListener, EchoListener, UsageInformationAbl } switch ($name) { - case 'ManiaControl.Restart': - $this->maniaControl->restart($message); + case Callbacks::ONRESTART: + case Callbacks::ONREBOOT: + $this->maniaControl->reboot($message); break; default: $this->triggerEchoCallback($name, $message); diff --git a/core/Communication/CommunicationMethods.php b/core/Communication/CommunicationMethods.php index 8f47de38..33120016 100644 --- a/core/Communication/CommunicationMethods.php +++ b/core/Communication/CommunicationMethods.php @@ -10,11 +10,11 @@ namespace ManiaControl\Communication; * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ interface CommunicationMethods { - /** Restarts Mania Control + /** Reboots Mania Control * Optional Params * - message */ - const RESTART_MANIA_CONTROL = "ManiaControl.Restart"; + const REBOOT_MANIA_CONTROL = "ManiaControl.Reboot"; /** Update the ManiaControl Core */ const UPDATE_MANIA_CONTROL_CORE = "UpdateManager.CoreUpdate"; diff --git a/core/ErrorHandler.php b/core/ErrorHandler.php index 611dd772..05de9916 100644 --- a/core/ErrorHandler.php +++ b/core/ErrorHandler.php @@ -199,7 +199,7 @@ class ErrorHandler { if ($isFatalError) { if ($isPluginError) { - $this->maniaControl->restart(); + $this->maniaControl->reboot(); } else { $this->maniaControl->quit('Quitting ManiaControl after Fatal Error.'); } @@ -513,7 +513,7 @@ class ErrorHandler { if ($shutdown) { if ($this->shouldRestart()) { - $this->maniaControl->restart(); + $this->maniaControl->reboot(); } try { $this->maniaControl->quit('Quitting ManiaControl after Exception.'); diff --git a/core/ManiaControl.php b/core/ManiaControl.php index 9e8a42df..c6694d39 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -61,7 +61,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, const SCRIPT_TIMEOUT = 40; const URL_WEBSERVICE = 'https://ws.maniacontrol.com/'; const SETTING_PERMISSION_SHUTDOWN = 'Shutdown ManiaControl'; - const SETTING_PERMISSION_RESTART = 'Restart ManiaControl'; + const SETTING_PERMISSION_REBOOT = 'Reboot ManiaControl'; /* * Public properties @@ -223,24 +223,24 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, // Permissions $this->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_SHUTDOWN, AuthenticationManager::AUTH_LEVEL_SUPERADMIN); - $this->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_RESTART, AuthenticationManager::AUTH_LEVEL_SUPERADMIN); + $this->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_REBOOT, AuthenticationManager::AUTH_LEVEL_SUPERADMIN); // Commands $this->getCommandManager()->registerCommandListener('version', $this, 'commandVersion', false, 'Shows ManiaControl version.'); - $this->getCommandManager()->registerCommandListener('restart', $this, 'commandRestart', true, 'Restarts ManiaControl.'); + $this->getCommandManager()->registerCommandListener('reboot', $this, 'commandReboot', true, 'Reboots ManiaControl.'); $this->getCommandManager()->registerCommandListener('shutdown', $this, 'commandShutdown', true, 'Shuts ManiaControl down.'); // Check connection every 30 seconds $this->getTimerManager()->registerTimerListening($this, 'checkConnection', 1000 * 30); // Communication Methods - $this->getCommunicationManager()->registerCommunicationListener(CommunicationMethods::RESTART_MANIA_CONTROL, $this, function ($data) { + $this->getCommunicationManager()->registerCommunicationListener(CommunicationMethods::REBOOT_MANIA_CONTROL, $this, function ($data) { //Delay Shutdown to send answer first $this->getTimerManager()->registerOneTimeListening($this, function () use ($data) { if (is_object($data) && property_exists($data, "message")) { - $this->restart($data->message); + $this->reboot($data->message); } else { - $this->restart(); + $this->reboot(); } }, 3000); return new CommunicationAnswer(); @@ -536,42 +536,42 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, } /** - * Handle Restart AdminCommand + * Handle Reboot AdminCommand * * @param array $chatCallback * @param Player $player */ - public function commandRestart(array $chatCallback, Player $player) { - if (!$this->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_RESTART)) { + public function commandReboot(array $chatCallback, Player $player) { + if (!$this->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_REBOOT)) { $this->getAuthenticationManager()->sendNotAllowed($player); return; } - $this->restart("ManiaControl Restart requested by '{$player->login}'!"); + $this->reboot("ManiaControl Reboot requested by '{$player->login}'!"); } /** - * Restart ManiaControl + * Reboot ManiaControl * * @param string $message */ - public function restart($message = null) { - // Trigger callback on Restart - $this->getCallbackManager()->triggerCallback(Callbacks::ONRESTART); + public function reboot($message = null) { + // Trigger callback on Reboot + $this->getCallbackManager()->triggerCallback(Callbacks::ONREBOOT); - // Announce restart + // Announce reboot try { - $this->getChat()->sendInformation('Restarting ManiaControl...', null, true, false); + $this->getChat()->sendInformation('Rebooting ManiaControl...', null, true, false); } catch (TransportException $e) { } - Logger::log('Restarting ManiaControl... ' . $message); + Logger::log('Rebooting ManiaControl... ' . $message); // Start new instance if (!defined('PHP_UNIT_TEST')) { - SystemUtil::restart(); + SystemUtil::reboot(); } // Quit old instance - $this->quit('Quitting ManiaControl to restart.'); + $this->quit('Quitting ManiaControl to reboot.'); } /** diff --git a/core/Maps/MapCommands.php b/core/Maps/MapCommands.php index 0550c636..6226505f 100644 --- a/core/Maps/MapCommands.php +++ b/core/Maps/MapCommands.php @@ -51,7 +51,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb // Admin commands $this->maniaControl->getCommandManager()->registerCommandListener(array('nextmap', 'next', 'skip'), $this, 'command_NextMap', true, 'Skips to the next map.'); - $this->maniaControl->getCommandManager()->registerCommandListener(array('restartmap', 'resmap', 'res'), $this, 'command_RestartMap', true, 'Restarts the current map.'); + $this->maniaControl->getCommandManager()->registerCommandListener(array('restartmap', 'resmap', 'restart', 'res'), $this, 'command_RestartMap', true, 'Restarts the current map.'); $this->maniaControl->getCommandManager()->registerCommandListener(array('replaymap', 'replay'), $this, 'command_ReplayMap', true, 'Replays the current map (after the end of the map).'); $this->maniaControl->getCommandManager()->registerCommandListener(array('addmap', 'add'), $this, 'command_AddMap', true, 'Adds map from ManiaExchange.'); $this->maniaControl->getCommandManager()->registerCommandListener(array('removemap', 'removethis'), $this, 'command_RemoveMap', true, 'Removes the current map.'); diff --git a/core/Update/UpdateManager.php b/core/Update/UpdateManager.php index 6b4b54be..a8ffabf1 100644 --- a/core/Update/UpdateManager.php +++ b/core/Update/UpdateManager.php @@ -408,7 +408,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener, } Logger::log($message); - $this->maniaControl->restart(); + $this->maniaControl->reboot(); }); $asyncHttpRequest->getData(); From 66eb685688e119154c38afba08e99f69411d0717 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Fri, 24 Apr 2020 18:52:18 +0200 Subject: [PATCH 34/98] Unified usages of Karma-Gauge in new ElementBuilder --- changelog.txt | 5 + core/ManiaExchange/ManiaExchangeList.php | 32 +- core/Manialinks/ElementBuilder.php | 376 +++++++++++++++++++++++ core/Manialinks/ManialinkManager.php | 13 + core/Manialinks/StyleManager.php | 4 +- core/Maps/MapList.php | 68 +--- core/Utils/ColorUtil.php | 11 +- plugins/MCTeam/KarmaPlugin.php | 105 ++----- 8 files changed, 448 insertions(+), 166 deletions(-) create mode 100644 core/Manialinks/ElementBuilder.php diff --git a/changelog.txt b/changelog.txt index 08bea907..361f8b83 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,8 @@ +###v0.253### +#Changes +- //restart got replaced by //reboot +- Unified Creations of a Karma-Gauge in new Manialinks\ElementBuilder + ###v0.252### #Additions - Ingame-Changelog diff --git a/core/ManiaExchange/ManiaExchangeList.php b/core/ManiaExchange/ManiaExchangeList.php index d6e0723e..4b6e9fa7 100644 --- a/core/ManiaExchange/ManiaExchangeList.php +++ b/core/ManiaExchange/ManiaExchangeList.php @@ -294,31 +294,13 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener } //Map Karma - $karma = $map->ratingVoteAverage / 100; - $voteCount = $map->ratingVoteCount; - if (is_numeric($karma) && $voteCount > 0) { - $karmaGauge = new Gauge(); - $mapFrame->addChild($karmaGauge); - $karmaGauge->setZ(-0.05); - $karmaGauge->setX($posX + 87); - $karmaGauge->setY(0.2); - $karmaGauge->setSize(20, 10); - $karmaGauge->setDrawBackground(false); - $karma = floatval($karma); - $karmaGauge->setRatio($karma + 0.15 - $karma * 0.15); - $karmaColor = ColorUtil::floatToStatusColor($karma); - $karmaGauge->setColor($karmaColor . '9'); - - $karmaLabel = new Label(); - $mapFrame->addChild($karmaLabel); - $karmaLabel->setZ(1); - $karmaLabel->setX($posX + 87); - $karmaLabel->setSize(20 * 0.9, 5); - $karmaLabel->setY(-0.2); - $karmaLabel->setTextSize(0.9); - $karmaLabel->setTextColor('000'); - $karmaLabel->setText(' ' . round($karma * 100.) . '% (' . $voteCount . ')'); - } + $karmaGauge = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildKarmaGauge( + $map, + 20, + 10 + ); + $mapFrame->addChild($karmaGauge); + $karmaGauge->setX($posX + 87); $posY -= 4; diff --git a/core/Manialinks/ElementBuilder.php b/core/Manialinks/ElementBuilder.php new file mode 100644 index 00000000..8c295577 --- /dev/null +++ b/core/Manialinks/ElementBuilder.php @@ -0,0 +1,376 @@ + + * @copyright 2014-2020 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class ElementBuilder { + /** + * Constants + */ + const COLUMN_ACTION_WIDTH = 4; + const COLUMN_ACTION_WIDTH_MIN = 20; + const COLUMN_ENTRY_WIDTH = 4; + const FOOTER_BUTTON_HEIGHT = 4; + const FOOTER_HEIGHT = 5; + const FOOTER_SPACING = 2; + const FOOTER_SPACING_BOTTOM = 10; + const HEADER_HEIGHT = 5; + const HEADER_SPACING = 2; + const HEADER_WIDTH_FACTOR = 0.9; + const ROW_LINE_HEIGHT = 4; + const ROW_SPACING_BOTTOM = 5; + const ROW_SPACING_SIDES = 2; + const ROW_SPACING_TOP = 5; + + const DEFAULT_KARMA_PLUGIN = 'MCTeam\KarmaPlugin'; + + /** + * Private Properties + */ + /** @var array $actions */ + private $actions = array(); + /** @var array $columns */ + private $columns = array(); + /** @var callable $entryCurrent */ + private $entryCurrent = null; + /** @var array $footerButtons */ + private $footerButtons = array(); + /** @var Frame $headerFrame */ + private $headerFrame = null; + /** @var array $rowData */ + private $rowData = array(); + + /** + * Construct a new ElementBuilder instance + * + * @param ManiaControl $maniaControl + */ + public function __construct(ManiaControl $maniaControl) { + $this->maniaControl = $maniaControl; + } + + /** + * Adds actions to list entry + * @param string $icon + * @param bool $confirmation + * @param callable $tooltipFunction + */ + public function addAction($icon, $confirmation, $tooltipFunction) { + array_push($this->actions, array($icon, $confirmation, $tooltipFunction)); + } + + /** + * Adds a column to the list + * @param string $name + * @param float $widthFactor + * @param callable $dataFunction + */ + public function addColumn($name, $widthFactor, $dataFunction) { + array_push($this->columns, array($name, $widthFactor, $dataFunction)); + } + + /** + * Adds a arrow to point to the current/personal entry + * @param callable $function + */ + public function addEntryCurrent($function) { + $this->entryCurrent = $function; + } + + /** + * Adds a footer button to the list + * @param string $description + * @param string $action + * @param callable $tooltipFunction + */ + public function addFooterButton($description, $action, $tooltipFunction = null) { + array_push($this->footerButtons, array($description, $action, $tooltipFunction)); + } + + /** + * Adds a header frame to the list + * @param Frame $headerFrame + */ + public function addHeaderFrame(Frame $headerFrame) { + $this->headerFrame = $headerFrame; + $this->headerFrame->setHeight(self::HEADER_HEIGHT); + $this->headerFrame->setWidth($this->getHeaderFrameWidth()); + } + + /** + * Adds rows to the list + * @param array $rows + */ + public function addRows(array $rows) { + $this->rowData = array_merge($this->rowData, $rows); + } + + /** + * Build Karma Gauge + * @param Map|MXMapInfo $map + * @param float $width + * @param float $height + * @param float $textSize + */ + public function buildKarmaGauge($map, $width, $height, $textSize = 0.9) { + $karmaPlugin = $this->maniaControl->getPluginManager()->getPlugin(self::DEFAULT_KARMA_PLUGIN); + if (!$karmaPlugin) { + return null; + } + + // default elements + $frame = new Frame(); + + $karmaGauge = new Gauge(); + $frame->addChild($karmaGauge); + $karmaGauge->setDrawBackground(false); + $karmaGauge->setSize($width, $height); + $karmaGauge->setZ(-1); + + $karmaLabel = new Label_Text(); + $frame->addChild($karmaLabel); + $karmaLabel->setSize($width/2, $height * $textSize); + $karmaLabel->setStyle($this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultLabelStyle()); + $karmaLabel->setTextColor('fff'); + $karmaLabel->setTextSize($textSize); + $karmaLabel->setY(-$height/50); + $karmaLabel->setZ(1); + + // fetch MX Karma + $displayMxKarma = $this->maniaControl->getSettingManager()->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_WIDGET_DISPLAY_MX); + $karma = null; + $votes = null; + $mxInfo = null; + if ($map instanceof Map && isset($map->mx)) { + $mxInfo = $map->mx; + } elseif ($map instanceof MXMapInfo) { + $mxInfo = $map; + } + + if ($displayMxKarma && $mxInfo) { + $karma = $mxInfo->ratingVoteAverage / 100; + $votes = array("count" => $mxInfo->ratingVoteCount); + } elseif ($map instanceof Map) { + $karma = $karmaPlugin->getMapKarma($map); + $votes = $karmaPlugin->getMapVotes($map); + } + + if (!is_numeric($karma) || $votes['count'] <= 0) { + // No Karma + $karmaGauge->setColor('00fb'); + $karmaGauge->setRatio(0.); + + $karmaLabel->setText('-'); + return $frame; + } + + // Karma available + $karma = floatval($karma); + $karmaText = ''; + if ($this->maniaControl->getSettingManager()->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA)) { + $karmaText = ' ' . round($karma * 100.) . '% (' . $votes['count'] . ')'; + } else { + $minus = 0; + $plus = 0; + foreach ($votes as $vote) { + if (!isset($vote->vote) || $vote->vote === 0.5) { + continue; + } + + if ($vote->vote < 0.5) { + $minus += $vote->count; + } else { + $plus += $vote->count; + } + } + $endKarma = $plus - $minus; + $karmaText = ' ' . $endKarma . ' (' . $votes['count'] . 'x / ' . round($karma * 100.) . '%)'; + } + + $karmaColor = ColorUtil::floatToStatusColor($karma); + $karmaGauge->setColor($karmaColor . '8'); + $karmaGauge->setRatio(0.15 + 0.85*$karma); + + $karmaLabel->setText($karmaText); + + return $frame; + } + + /** + * Returns the width of the optional header frame + * + * @return int + */ + public function getHeaderFrameWidth() { + return (int) (self::HEADER_WIDTH_FACTOR * $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth()); + } + + public function renderList(Player $player) { + $nbActions = count($this->actions); + $nbFooterButtons = count($this->footerButtons); + + $hasActions = $nbActions > 0; + $hasEntryCurrent = $this->entryCurrent !== null; + $hasFooter = $nbFooterButtons > 0; + $hasHeader = $this->headerFrame !== null; + + $height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight(); + $width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth(); + + $heightRows = $height - self::ROW_SPACING_TOP - self::ROW_SPACING_BOTTOM; + $posYRows = $height/2 - self::ROW_SPACING_TOP - self::ROW_LINE_HEIGHT/2; + + // Create ManiaLink + $maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID); + $script = $maniaLink->getScript(); + $paging = new Paging(); + $script->addFeature($paging); + + // Main frame + $frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script, $paging); + $maniaLink->addChild($frame); + + // Header frame + if ($hasHeader) { + $frame->addChild($this->headerFrame); + $this->headerFrame->setY($height/2 - self::HEADER_SPACING - self::HEADER_HEIGHT/2); + + $headerSize = 2*self::HEADER_SPACING + self::HEADER_HEIGHT; + $heightRows -= $headerSize; + if ($posYRows > $height/2 - $headerSize) + $posYRows = $height/2 - $headerSize; + } + + // Footer + if ($hasFooter) { + $nbFooterSections = 3*$nbFooterButtons + 1; + $buttonSpacing = (1. / $nbFooterSections) * $width; + $buttonWidth = $buttonSpacing * 2; + for ($i = 0; $i < $nbFooterButtons; $i++) { + list($description, $action, $tooltipFunction) = $this->footerButtons[$i]; + + $label = new Label_Button(); + $frame->addChild($label); + $label->setHeight(self::FOOTER_HEIGHT); + $label->setText($description); + $label->setTextSize(1); + $label->setWidth($buttonWidth); + $label->setX(-$width/2 + ($i+1)*$buttonSpacing + $i*$buttonWidth + $buttonWidth/2); + $label->setY(-$height/2 + self::FOOTER_SPACING_BOTTOM); + $label->setZ(0.1); + + $quad = new Quad_BgsPlayerCard(); + $frame->addChild($quad); + $quad->setAction($action); + $quad->setHeight(self::FOOTER_HEIGHT); + $quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig); + $quad->setWidth($buttonWidth); + $quad->setX(-$width/2 + ($i+1)*$buttonSpacing + $i*$buttonWidth + $buttonWidth/2); + $quad->setY(-$height/2 + self::FOOTER_SPACING_BOTTOM); + $quad->setZ(0.01); + } + + $footerSize = self::FOOTER_SPACING_BOTTOM + self::FOOTER_HEIGHT + self::FOOTER_SPACING; + $heightRows -= $footerSize; + } + + $actionsWidth = max(self::COLUMN_ACTION_WIDTH_MIN, $nbActions * self::COLUMN_ACTION_WIDTH); + $baseColumnPosX = -$width / 2 + self::ROW_SPACING_SIDES + self::COLUMN_ENTRY_WIDTH; + $baseRowPosY = $posYRows; + $baseColumnWidth = $width - 2*self::ROW_SPACING_SIDES - self::COLUMN_ENTRY_WIDTH - $actionsWidth; + $nbRows = (int) ($heightRows / self::ROW_LINE_HEIGHT) - 1; + + // Description Row + $descriptionFrame = new Frame(); + $frame->addChild($descriptionFrame); + $descriptionFrame->setX($baseColumnPosX); + $descriptionFrame->setY($baseRowPosY); + + $labelLine = new LabelLine($descriptionFrame); + $columnPosX = self::ROW_SPACING_SIDES; + if ($hasEntryCurrent) { + $columnPosX += self::COLUMN_ENTRY_WIDTH; + } + + foreach ($this->columns as $column) { + list($name, $widthFactor, $dataFunction) = $column; + $labelLine->addLabelEntryText($name, $columnPosX); + $columnPosX += $widthFactor * $baseColumnWidth; + } + $labelLine->addLabelEntryText('Actions', $columnPosX); + $labelLine->render(); + + // Data Rows + $pageFrame = null; + $columnPosX = self::ROW_SPACING_SIDES; + $baseRowPosY -= self::ROW_LINE_HEIGHT; + $rowPosY = $baseRowPosY; + $pageNumber = 1; + for ($i = 0; $i < count($this->rowData); $i++) { + $data = $this->rowData[$i]; + + if ($i % $nbRows === 0) { + $pageFrame = new Frame(); + $frame->addChild($pageFrame); + + $paging->addPageControl($pageFrame, $pageNumber); + $pageNumber++; + $rowPosY = $baseRowPosY; + } + + $playerFrame = new Frame(); + $pageFrame->addChild($playerFrame); + $playerFrame->setX($baseColumnPosX); + $playerFrame->setY($rowPosY); + + if ($i % 2 === 1) { + $lineQuad = new Quad_BgsPlayerCard(); + $playerFrame->addChild($lineQuad); + $lineQuad->setSize($width, self::ROW_LINE_HEIGHT); + $lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig); + $lineQuad->setZ(-1); + } + + if ($hasEntryCurrent) { + + } + + $rowPosY -= self::ROW_LINE_HEIGHT; + } + + $this->maniaControl->getManialinkManager()->sendManialink($maniaLink, $player); + $this->reset(); + } + + /** + * Resets the internal builder data + */ + private function reset() { + $this->actions = array(); + $this->columns = array(); + $this->entryCurrent = null; + $this->footerButtons = array(); + $this->headerFrame = null; + $this->rowData = array(); + } +} diff --git a/core/Manialinks/ManialinkManager.php b/core/Manialinks/ManialinkManager.php index 03b1a5b4..85cafef0 100644 --- a/core/Manialinks/ManialinkManager.php +++ b/core/Manialinks/ManialinkManager.php @@ -55,6 +55,9 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener, /** @var SidebarMenuManager $sidebarMenuManager */ private $sidebarMenuManager = null; + /** @var ElementBuilder $elementBuilder */ + private $elementBuilder = null; + // TODO: use listening class private $pageAnswerListeners = array(); private $pageAnswerRegexListener = array(); @@ -72,6 +75,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener, $this->customUIManager = new CustomUIManager($maniaControl); $this->iconManager = new IconManager($maniaControl); $this->sidebarMenuManager = new SidebarMenuManager($maniaControl); + $this->elementBuilder = new ElementBuilder($maniaControl); // Callbacks $this->registerManialinkPageAnswerListener(self::ACTION_CLOSEWIDGET, $this, 'closeWidgetCallback'); @@ -133,6 +137,15 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener, return $this->iconManager; } + /** + * Return the element builder + * + * @return ElementBuilder + */ + public function getElementBuilder() { + return $this->elementBuilder; + } + /** * Register a new manialink page answer reg ex listener * diff --git a/core/Manialinks/StyleManager.php b/core/Manialinks/StyleManager.php index 62243cb5..02b4c9b8 100644 --- a/core/Manialinks/StyleManager.php +++ b/core/Manialinks/StyleManager.php @@ -142,7 +142,7 @@ class StyleManager implements UsageInformationAble { $entry->setName('SearchString'); if ($actionReset) { - $quad = new Quad_Icons64x64_1();; + $quad = new Quad_Icons64x64_1(); $frame->addChild($quad); $quad->setSubStyle($quad::SUBSTYLE_QuitRace); $quad->setColorize('aaa'); @@ -150,7 +150,7 @@ class StyleManager implements UsageInformationAble { $quad->setPosition(-$width / 2 + 15 + $width * 0.25 - 2, 0); $quad->setZ(1); $quad->setAction($actionReset); -} + } //Search for Map-Name $label = new Label_Button(); diff --git a/core/Maps/MapList.php b/core/Maps/MapList.php index ce1669a2..14859680 100644 --- a/core/Maps/MapList.php +++ b/core/Maps/MapList.php @@ -57,7 +57,6 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { const ACTION_RESET = 'MapList.ResetMapList'; const MAX_MAPS_PER_PAGE = 13; const MAX_PAGES_PER_CHUNK = 2; - const DEFAULT_KARMA_PLUGIN = 'MCTeam\KarmaPlugin'; const DEFAULT_CUSTOM_VOTE_PLUGIN = 'MCTeam\CustomVotesPlugin'; const CACHE_CURRENT_PAGE = 'CurrentPage'; const WIDGET_NAME = 'MapList'; @@ -249,8 +248,6 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $frame->addChild($descriptionLabel); $queuedMaps = $this->maniaControl->getMapManager()->getMapQueue()->getQueuedMapsRanking(); - /** @var KarmaPlugin $karmaPlugin */ - $karmaPlugin = $this->maniaControl->getPluginManager()->getPlugin(self::DEFAULT_KARMA_PLUGIN); $pageNumber = 1 + $chunkIndex * self::MAX_PAGES_PER_CHUNK; $paging->setStartPageNumber($pageIndex + 1); @@ -460,63 +457,14 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { } // Display Karma bar - if ($karmaPlugin) { - $displayMxKarma = $this->maniaControl->getSettingManager()->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_WIDGET_DISPLAY_MX); - - //Display Mx Karma - if ($displayMxKarma && $map->mx) { - $karma = $map->mx->ratingVoteAverage / 100; - $votes = array("count" => $map->mx->ratingVoteCount); - - //Display Local Karma - } else { - $karma = $karmaPlugin->getMapKarma($map); - $votes = $karmaPlugin->getMapVotes($map); - } - - if (is_numeric($karma) && $votes['count'] > 0) { - if ($this->maniaControl->getSettingManager()->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA)) { - $karmaText = ' ' . round($karma * 100.) . '% (' . $votes['count'] . ')'; - } else { - $min = 0; - $plus = 0; - foreach ($votes as $vote) { - if (isset($vote->vote)) { - if ($vote->vote !== 0.5) { - if ($vote->vote < 0.5) { - $min = $min + $vote->count; - } else { - $plus = $plus + $vote->count; - } - } - } - } - $endKarma = $plus - $min; - $karmaText = ' ' . $endKarma . ' (' . $votes['count'] . 'x / ' . round($karma * 100.) . '%)'; - } - - $karmaGauge = new Gauge(); - $mapFrame->addChild($karmaGauge); - $karmaGauge->setZ(0.2); - $karmaGauge->setX($posX + 120); - $karmaGauge->setY(0.2); - $karmaGauge->setSize(20, 10); - $karmaGauge->setDrawBackground(false); - $karma = floatval($karma); - $karmaGauge->setRatio($karma + 0.15 - $karma * 0.15); - $karmaColor = ColorUtil::floatToStatusColor($karma); - $karmaGauge->setColor($karmaColor . '9'); - - $karmaLabel = new Label(); - $mapFrame->addChild($karmaLabel); - $karmaLabel->setZ(2); - $karmaLabel->setX($posX + 120); - $karmaLabel->setSize(20 * 0.9, 5); - $karmaLabel->setY(-0.2); - $karmaLabel->setTextSize(0.9); - $karmaLabel->setTextColor('000'); - $karmaLabel->setText($karmaText); - } + $karmaGauge = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildKarmaGauge( + $map, + 20, + 10 + ); + if ($karmaGauge) { + $mapFrame->addChild($karmaGauge); + $karmaGauge->setX($posX + 120); } $posY -= 4; diff --git a/core/Utils/ColorUtil.php b/core/Utils/ColorUtil.php index 25d0bb79..ed7e7da7 100644 --- a/core/Utils/ColorUtil.php +++ b/core/Utils/ColorUtil.php @@ -21,7 +21,7 @@ abstract class ColorUtil implements UsageInformationAble { * @param float $value * @return string */ - public static function floatToStatusColor($value) { + public static function floatToStatusColor($value, $addBlue = true) { $value = floatval($value); $red = 1.; $green = 1.; @@ -33,7 +33,12 @@ abstract class ColorUtil implements UsageInformationAble { } $red = ColorUtil::floatToCode($red); $green = ColorUtil::floatToCode($green); - return $red . $green . '0'; + + if ($addBlue) { + return $red . $green . '0'; + } else { + return $red . $green; + } } /** @@ -55,7 +60,7 @@ abstract class ColorUtil implements UsageInformationAble { if ($value < 10) { return (string) $value; } - $codes = array(10 => 'a', 11 => 'b', 12 => 'c', 13 => 'd', 14 => 'e', 15 => 'f'); + static $codes = array(10 => 'a', 11 => 'b', 12 => 'c', 13 => 'd', 14 => 'e', 15 => 'f'); return $codes[$value]; } } diff --git a/plugins/MCTeam/KarmaPlugin.php b/plugins/MCTeam/KarmaPlugin.php index f1d34978..b1be99af 100644 --- a/plugins/MCTeam/KarmaPlugin.php +++ b/plugins/MCTeam/KarmaPlugin.php @@ -3,7 +3,6 @@ namespace MCTeam; use FML\Controls\Frame; -use FML\Controls\Gauge; use FML\Controls\Label; use FML\Controls\Quad; use FML\ManiaLink; @@ -71,8 +70,6 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { /** @var ManiaControl $maniaControl */ private $maniaControl = null; private $updateManialink = false; - /** @var ManiaLink $manialink */ - private $manialink = null; // TODO: use some sort of model class instead of various array keys that you can't remember private $mxKarma = array(); @@ -150,9 +147,9 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_ENABLE, true); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_TITLE, 'Map-Karma'); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_POSX, 160 - 27.5); - $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_POSY, 90 - 10 - 6); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_POSY, 90 - 9 - 5); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_WIDTH, 25.); - $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_HEIGHT, 12.); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_HEIGHT, 10.); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NEWKARMA, true); // Callbacks @@ -270,9 +267,9 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { } else { Logger::logError("Error while authenticating on Mania-Exchange Karma"); - if($data->data->message == "invalid server"){ + if ($data->data->message == "invalid server") { Logger::log("You need to get a Karma Key from MX with registering your server"); - }else{ + } else { // TODO remove temp trigger $this->maniaControl->getErrorHandler()->triggerDebugNotice('auth error ' . json_encode($data->data->message)); } @@ -775,6 +772,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { return; } + $this->updateManialink = true; $serverLogin = $this->maniaControl->getServer()->login; $karmaSettingName = self::buildKarmaSettingName($serverLogin); @@ -785,10 +783,8 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { } case self::SETTING_WIDGET_ENABLE: { if ($setting->value) { - $this->updateManialink = true; $this->handle1Second(); } else { - $this->updateManialink = false; $this->maniaControl->getManialinkManager()->hideManialink(self::MLID_KARMA); } break; @@ -806,58 +802,21 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $displayMxKarma = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_DISPLAY_MX); - // Get players - $players = $this->updateManialink; - if ($players === true) { - $players = $this->maniaControl->getPlayerManager()->getPlayers(); - } - $this->updateManialink = false; - // Get map karma $map = $this->maniaControl->getMapManager()->getCurrentMap(); // Display the mx Karma if the setting is chosen and the MX session is available if ($displayMxKarma && isset($this->mxKarma['session']) && isset($this->mxKarma['voteCount'])) { - $karma = $this->mxKarma['modeVoteAverage'] / 100; - $voteCount = $this->mxKarma['modeVoteCount']; - } else { - $karma = $this->getMapKarma($map); - $votes = $this->getMapVotes($map); - $voteCount = $votes['count']; + $map->mx->ratingVoteAverage = $this->mxKarma['modeVoteAverage']; + $map->mx->ratingVoteCount = $this->mxKarma['modeVoteCount']; } if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_WIDGET_ENABLE)) { // Build karma manialink - $this->buildManialink(); - - // Update karma gauge & label - /** - * @var Gauge $karmaGauge - */ - $karmaGauge = $this->manialink->karmaGauge; - /** - * @var Label $karmaLabel - */ - $karmaLabel = $this->manialink->karmaLabel; - if (is_numeric($karma) && $voteCount > 0) { - $karma = floatval($karma); - $karmaGauge->setRatio($karma + 0.15 - $karma * 0.15); - $karmaColor = ColorUtil::floatToStatusColor($karma); - $karmaGauge->setColor($karmaColor . '7'); - $karmaLabel->setText(' ' . round($karma * 100.) . '% (' . $voteCount . ')'); - } else { - $karmaGauge->setRatio(0.); - $karmaGauge->setColor('00fb'); - $karmaLabel->setText('-'); - } - - - $this->maniaControl->getManialinkManager()->sendManialink($this->manialink, $players); - // TODO: show the player his own vote in some way - // $vote = $this->getPlayerVote($player, $map); - // $votesFrame = $this->manialink->votesFrame; - // $votesFrame->removeChildren(); + $this->buildManialink($map, $this->updateManialink); } + + $this->updateManialink = false; } /** @@ -920,10 +879,11 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { /** * Build Karma Voting Manialink if necessary * + * @param Map $map * @param bool $forceBuild */ - private function buildManialink($forceBuild = false) { - if (is_object($this->manialink) && !$forceBuild) { + private function buildManialink(Map $map = null, $forceBuild = false) { + if (!$forceBuild) { return; } @@ -944,39 +904,32 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $backgroundQuad = new Quad(); $frame->addChild($backgroundQuad); - $backgroundQuad->setY($height * 0.15); $backgroundQuad->setSize($width, $height); $backgroundQuad->setStyles($quadStyle, $quadSubstyle); $titleLabel = new Label(); $frame->addChild($titleLabel); - $titleLabel->setY($height * 0.36); - $titleLabel->setWidth($width * 0.85); + $titleLabel->setScale(0.9); $titleLabel->setStyle($labelStyle); - $titleLabel->setTranslate(true); - $titleLabel->setTextSize(1); - $titleLabel->setScale(0.90); $titleLabel->setText($title); + $titleLabel->setTextSize(1); + $titleLabel->setTranslate(true); + $titleLabel->setWidth(0.85*$width); + $titleLabel->setY(0.2*$height); - $karmaGauge = new Gauge(); + if ($map === null) { + $map = $this->maniaControl->getMapManager()->getCurrentMap(); + } + + $karmaGauge = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildKarmaGauge( + $map, + 0.95*$width, + 0.95*$height + ); + $karmaGauge->setY(-0.15*$height); $frame->addChild($karmaGauge); - $karmaGauge->setSize($width * 0.95, $height * 0.92); - $karmaGauge->setDrawBackground(false); - $manialink->karmaGauge = $karmaGauge; - $karmaLabel = new Label(); - $frame->addChild($karmaLabel); - $karmaLabel->setPosition(0, -0.4, 1); - $karmaLabel->setSize($width * 0.9, $height * 0.9); - $karmaLabel->setStyle($labelStyle); - $karmaLabel->setTextSize(1); - $manialink->karmaLabel = $karmaLabel; - - $votesFrame = new Frame(); - $frame->addChild($votesFrame); - $manialink->votesFrame = $votesFrame; - - $this->manialink = $manialink; + $this->maniaControl->getManialinkManager()->sendManialink($manialink); } /** From c04f39a05628685e2ccda757bb1b812e2bf602ee Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Sat, 25 Apr 2020 16:53:16 +0200 Subject: [PATCH 35/98] Show temporary loading screen on MX-List --- core/ManiaExchange/ManiaExchangeList.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/core/ManiaExchange/ManiaExchangeList.php b/core/ManiaExchange/ManiaExchangeList.php index 4b6e9fa7..ee7b5a9f 100644 --- a/core/ManiaExchange/ManiaExchangeList.php +++ b/core/ManiaExchange/ManiaExchangeList.php @@ -165,6 +165,21 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener } $this->showManiaExchangeList($maps, $player); }); + + // show temporary list to wait for Async + $labelStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultLabelStyle(); + + $maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID); + $frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame(); + $maniaLink->addChild($frame); + + $loadingLabel = new Label_Text(); + $frame->addChild($loadingLabel); + $loadingLabel->setStyle($labelStyle); + $loadingLabel->setText('Loading maps, please wait ...'); + $loadingLabel->setTextSize(2); + + $this->maniaControl->getManialinkManager()->sendManialink($maniaLink, $player); } From 9dc455774f4e8a4311ebf124858818e5e0e44128 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Sun, 26 Apr 2020 09:47:33 +0200 Subject: [PATCH 36/98] Disabled //restart , restored backwards compatibility for the backend on restart --- core/Communication/CommunicationMethods.php | 2 ++ core/ManiaControl.php | 25 +++++++++++++++++++++ core/Maps/MapCommands.php | 2 +- core/Utils/SystemUtil.php | 22 +++++++++--------- 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/core/Communication/CommunicationMethods.php b/core/Communication/CommunicationMethods.php index 33120016..252c9e75 100644 --- a/core/Communication/CommunicationMethods.php +++ b/core/Communication/CommunicationMethods.php @@ -15,6 +15,8 @@ interface CommunicationMethods { * - message */ const REBOOT_MANIA_CONTROL = "ManiaControl.Reboot"; + /** @deprecated */ + const RESTART_MANIA_CONTROL = "ManiaControl.Restart"; /** Update the ManiaControl Core */ const UPDATE_MANIA_CONTROL_CORE = "UpdateManager.CoreUpdate"; diff --git a/core/ManiaControl.php b/core/ManiaControl.php index c6694d39..e289e2e2 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -228,6 +228,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, // Commands $this->getCommandManager()->registerCommandListener('version', $this, 'commandVersion', false, 'Shows ManiaControl version.'); $this->getCommandManager()->registerCommandListener('reboot', $this, 'commandReboot', true, 'Reboots ManiaControl.'); + $this->getCommandManager()->registerCommandListener('restart', $this, 'commandRestart', true, 'Restarts ManiaControl.'); $this->getCommandManager()->registerCommandListener('shutdown', $this, 'commandShutdown', true, 'Shuts ManiaControl down.'); // Check connection every 30 seconds @@ -549,6 +550,30 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, $this->reboot("ManiaControl Reboot requested by '{$player->login}'!"); } + /** + * Handle Restart AdminCommand + * + * @param array $chatCallback + * @param Player $player + */ + public function commandRestart(array $chatCallback, Player $player) { + if (!$this->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_REBOOT)) { + $this->getAuthenticationManager()->sendNotAllowed($player); + return; + } + $this->getChat->sendError('The command //restart got disabled, reboot ManiaControl with //reboot instead', $player); + } + + /** + * @deprecated + * Restart ManiaControl + * + * @param string $message + */ + public function restart($message = null) { + $this->reboot($message); + } + /** * Reboot ManiaControl * diff --git a/core/Maps/MapCommands.php b/core/Maps/MapCommands.php index 6226505f..0550c636 100644 --- a/core/Maps/MapCommands.php +++ b/core/Maps/MapCommands.php @@ -51,7 +51,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb // Admin commands $this->maniaControl->getCommandManager()->registerCommandListener(array('nextmap', 'next', 'skip'), $this, 'command_NextMap', true, 'Skips to the next map.'); - $this->maniaControl->getCommandManager()->registerCommandListener(array('restartmap', 'resmap', 'restart', 'res'), $this, 'command_RestartMap', true, 'Restarts the current map.'); + $this->maniaControl->getCommandManager()->registerCommandListener(array('restartmap', 'resmap', 'res'), $this, 'command_RestartMap', true, 'Restarts the current map.'); $this->maniaControl->getCommandManager()->registerCommandListener(array('replaymap', 'replay'), $this, 'command_ReplayMap', true, 'Replays the current map (after the end of the map).'); $this->maniaControl->getCommandManager()->registerCommandListener(array('addmap', 'add'), $this, 'command_AddMap', true, 'Adds map from ManiaExchange.'); $this->maniaControl->getCommandManager()->registerCommandListener(array('removemap', 'removethis'), $this, 'command_RemoveMap', true, 'Removes the current map.'); diff --git a/core/Utils/SystemUtil.php b/core/Utils/SystemUtil.php index d647eff2..9c96b8d5 100644 --- a/core/Utils/SystemUtil.php +++ b/core/Utils/SystemUtil.php @@ -134,13 +134,13 @@ class SystemUtil { } /** - * Restart ManiaControl immediately + * Reboot ManiaControl immediately */ - public static function restart() { + public static function reboot() { if (SystemUtil::isUnix()) { - self::restartUnix(); + self::rebootUnix(); } else { - self::restartWindows(); + self::rebootWindows(); } } @@ -156,9 +156,9 @@ class SystemUtil { /** * Perform restart on Unix */ - private static function restartUnix() { + private static function rebootUnix() { if (!SystemUtil::checkFunctionAvailability('exec')) { - Logger::log("Can't restart ManiaControl because the function 'exec' is disabled!"); + Logger::log("Can't reboot ManiaControl because the function 'exec' is disabled!"); return; } $fileName = null; @@ -169,7 +169,7 @@ class SystemUtil { } $filePath = MANIACONTROL_PATH . $fileName; if (!is_readable($filePath)) { - Logger::log("Can't restart ManiaControl because the file '{$fileName}' doesn't exist or isn't readable!"); + Logger::log("Can't reboot ManiaControl because the file '{$fileName}' doesn't exist or isn't readable!"); return; } $command = 'sh ' . escapeshellarg($filePath) . ' > /dev/null &'; @@ -197,11 +197,11 @@ class SystemUtil { } /** - * Perform restart on Windows + * Perform reboot on Windows */ - private static function restartWindows() { + private static function rebootWindows() { if (!SystemUtil::checkFunctionAvailability('system')) { - Logger::log("Can't restart ManiaControl because the function 'system' is disabled!"); + Logger::log("Can't reboot ManiaControl because the function 'system' is disabled!"); return; } $fileName = null; @@ -212,7 +212,7 @@ class SystemUtil { } $filePath = MANIACONTROL_PATH . $fileName; if (!is_readable($filePath)) { - Logger::log("Can't restart ManiaControl because the file '{$fileName}' doesn't exist or isn't readable!"); + Logger::log("Can't reboot ManiaControl because the file '{$fileName}' doesn't exist or isn't readable!"); return; } $command = escapeshellarg($filePath); From 6a95184759e5d2c81d9f6454071d366ad24b0ab8 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Sun, 26 Apr 2020 10:01:22 +0200 Subject: [PATCH 37/98] Fixed Syntax-Error on getChat --- core/ManiaControl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ManiaControl.php b/core/ManiaControl.php index e289e2e2..ecf00a16 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -561,7 +561,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, $this->getAuthenticationManager()->sendNotAllowed($player); return; } - $this->getChat->sendError('The command //restart got disabled, reboot ManiaControl with //reboot instead', $player); + $this->getChat()->sendError('The command //restart got disabled, reboot ManiaControl with //reboot instead', $player); } /** From 4ec8e1e1decef6990407efcf31a9c3dd6daf444a Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Sun, 26 Apr 2020 10:09:58 +0200 Subject: [PATCH 38/98] Version Bump --- core/ManiaControl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ManiaControl.php b/core/ManiaControl.php index ecf00a16..238fa564 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -55,7 +55,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, /* * Constants */ - const VERSION = '0.252'; + const VERSION = '0.253'; const API_VERSION = '2013-04-16'; const MIN_DEDIVERSION = '2017-05-03_21_00'; const SCRIPT_TIMEOUT = 40; From 38c239202fc0f3ecffdd172e85c2401b6f99409c Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Mon, 27 Apr 2020 15:49:34 +0200 Subject: [PATCH 39/98] Add missing Legacy-Callbacks --- core/Callbacks/CallbackManager.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/Callbacks/CallbackManager.php b/core/Callbacks/CallbackManager.php index 0c8e2a4c..5bbeade1 100644 --- a/core/Callbacks/CallbackManager.php +++ b/core/Callbacks/CallbackManager.php @@ -31,6 +31,8 @@ class CallbackManager implements UsageInformationAble { const CB_MP_ENDMATCH = 'ManiaPlanet.EndMatch'; const CB_MP_BEGINMAP = 'ManiaPlanet.BeginMap'; const CB_MP_ENDMAP = 'ManiaPlanet.EndMap'; + const CB_MP_BEGINROUND = 'ManiaPlanet.BeginRound'; + const CB_MP_ENDROUND = 'ManiaPlanet.EndRound'; const CB_MP_MAPLISTMODIFIED = 'ManiaPlanet.MapListModified'; const CB_MP_ECHO = 'ManiaPlanet.Echo'; const CB_MP_BILLUPDATED = 'ManiaPlanet.BillUpdated'; From 4532f2f5e725832606559798745a9f03c41a0ca7 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 28 Apr 2020 17:52:17 +0200 Subject: [PATCH 40/98] Add graphical support for Legacy-Modes --- core/Communication/CommunicationMethods.php | 17 +- core/Configurator/Configurator.php | 8 +- ...criptSettings.php => GameModeSettings.php} | 279 +++++++++++++----- 3 files changed, 217 insertions(+), 87 deletions(-) rename core/Configurator/{ScriptSettings.php => GameModeSettings.php} (60%) diff --git a/core/Communication/CommunicationMethods.php b/core/Communication/CommunicationMethods.php index 252c9e75..a4b0ea1b 100644 --- a/core/Communication/CommunicationMethods.php +++ b/core/Communication/CommunicationMethods.php @@ -45,12 +45,25 @@ interface CommunicationMethods { */ const SET_SERVER_OPTIONS = "ServerOptions.SetServerOptions"; - /** Provides the ModeScriptSettings + /** Provides the GameModeSettings + * no Parameters + */ + const GET_GAMEMODE_SETTINGS = "GameModeSettings.GetGameModeSettings"; + + /** Set GameModeSettings + * Required Parameter + * - gameModeSettings (array(settingName1 => value1, settingName2 => value2...)) + */ + const SET_GAMEMODE_SETTINGS = "GameModeSettings.SetGameModeSettings"; + + /** @deprecated + * Provides the ModeScriptSettings * no Parameters */ const GET_SCRIPT_SETTINGS = "ScriptSettings.GetScriptSettings"; - /** Set ModeScriptSettings + /** @deprecated + * Set ModeScriptSettings * Required Parameter * - scriptSettings (array(settingName1 => value1, settingName2 => value2...)) */ diff --git a/core/Configurator/Configurator.php b/core/Configurator/Configurator.php index cf437f8a..c26d6fe5 100644 --- a/core/Configurator/Configurator.php +++ b/core/Configurator/Configurator.php @@ -54,8 +54,8 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn private $serverOptionsMenu = null; /** @var ServerUIPropertiesMenu $serverUIPropertiesMenu */ private $serverUIPropertiesMenu = null; - /** @var ScriptSettings $scriptSettings */ - private $scriptSettings = null; + /** @var GameModeSettings $gameModeSettings */ + private $gameModeSettings = null; /** @var VoteRatiosMenu $voteRatiosMenu */ private $voteRatiosMenu = null; /** @var ManiaControlSettings $maniaControlSettings */ @@ -101,8 +101,8 @@ class Configurator implements CallbackListener, CommandListener, ManialinkPageAn $this->addMenu($this->serverUIPropertiesMenu); // Create script settings - $this->scriptSettings = new ScriptSettings($maniaControl); - $this->addMenu($this->scriptSettings); + $this->gameModeSettings = new GameModeSettings($maniaControl); + $this->addMenu($this->gameModeSettings); // Create vote ratios menu $this->voteRatiosMenu = new VoteRatiosMenu($maniaControl); diff --git a/core/Configurator/ScriptSettings.php b/core/Configurator/GameModeSettings.php similarity index 60% rename from core/Configurator/ScriptSettings.php rename to core/Configurator/GameModeSettings.php index 45e936ae..3de32b66 100644 --- a/core/Configurator/ScriptSettings.php +++ b/core/Configurator/GameModeSettings.php @@ -20,25 +20,34 @@ use ManiaControl\Communication\CommunicationMethods; use ManiaControl\Logger; use ManiaControl\ManiaControl; use ManiaControl\Players\Player; +use Maniaplanet\DedicatedServer\Structures\GameInfos; use Maniaplanet\DedicatedServer\Xmlrpc\FaultException; use Maniaplanet\DedicatedServer\Xmlrpc\GameModeException; /** - * Class offering a Configurator for Script Settings + * Class offering a Configurator for Mode Settings * * @author ManiaControl Team * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class ScriptSettings implements ConfiguratorMenu, CallbackListener, CommunicationListener { +class GameModeSettings implements ConfiguratorMenu, CallbackListener, CommunicationListener { /* * Constants */ - const ACTION_PREFIX_SETTING = 'ScriptSetting.'; - const CB_SCRIPTSETTING_CHANGED = 'ScriptSettings.SettingChanged'; - const CB_SCRIPTSETTINGS_CHANGED = 'ScriptSettings.SettingsChanged'; + const ACTION_PREFIX_SETTING = 'GameModeSetting.'; + const CB_GAMEMODESETTING_CHANGED = 'GameModeSettings.SettingChanged'; + const CB_GAMEMODESETTINGS_CHANGED = 'GameModeSettings.SettingsChanged'; + /** @deprecated */ + const CB_SCRIPTSETTING_CHANGED = 'GameModeSettings.SettingChanged'; + /** @deprecated */ + const CB_SCRIPTSETTINGS_CHANGED = 'GameModeSettings.SettingsChanged'; + const TABLE_GAMEMODE_SETTINGS = 'mc_gamemodesettings'; + /** @deprecated */ const TABLE_SCRIPT_SETTINGS = 'mc_scriptsettings'; - const SETTING_LOAD_DEFAULT_SETTINGS_MAP_BEGIN = 'Load Stored Script-Settings on Map-Begin'; + const SETTING_LOAD_DEFAULT_SETTINGS_MAP_BEGIN = 'Load Stored GameMode-Settings on Map-Begin'; + const SETTING_PERMISSION_CHANGE_MODE_SETTINGS = 'Change GameMode-Settings'; + /** @deprecated */ const SETTING_PERMISSION_CHANGE_SCRIPT_SETTINGS = 'Change Script-Settings'; /* @@ -64,7 +73,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_LOAD_DEFAULT_SETTINGS_MAP_BEGIN, false); // Permissions - $this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_SCRIPT_SETTINGS, AuthenticationManager::AUTH_LEVEL_ADMIN); + $this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_MODE_SETTINGS, AuthenticationManager::AUTH_LEVEL_ADMIN); //TODO remove to somewhere cleaner //Communication Listenings @@ -78,14 +87,14 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio */ private function initTables() { $mysqli = $this->maniaControl->getDatabase()->getMysqli(); - $query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_SCRIPT_SETTINGS . "` ( + $query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_GAMEMODE_SETTINGS . "` ( `index` int(11) NOT NULL AUTO_INCREMENT, `serverIndex` int(11) NOT NULL, `settingName` varchar(100) NOT NULL DEFAULT '', `settingValue` varchar(500) NOT NULL DEFAULT '', PRIMARY KEY (`index`), UNIQUE KEY `setting` (`serverIndex`, `settingName`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Script Settings' AUTO_INCREMENT=1;"; + ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Mode Settings' AUTO_INCREMENT=1;"; $statement = $mysqli->prepare($query); if ($mysqli->error) { @@ -98,17 +107,8 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio return false; } - //TODO remove later again (added in v0.165) - //For Mysql 5.7 add Default Values - $alterQuery = "ALTER TABLE `" . self::TABLE_SCRIPT_SETTINGS . "` CHANGE settingName settingName varchar(100) DEFAULT ''"; - $result = $mysqli->query($alterQuery); - if (!$result) { - trigger_error($mysqli->error); - return false; - } - - $alterQuery = "ALTER TABLE `" . self::TABLE_SCRIPT_SETTINGS . "` CHANGE settingValue settingValue varchar(500) DEFAULT ''"; - $result = $mysqli->query($alterQuery); + $dropQuery = "DROP TABLE IF EXISTS `" . self::TABLE_SCRIPT_SETTINGS . "`;"; + $result = $mysqli->query($dropQuery); if (!$result) { trigger_error($mysqli->error); return false; @@ -122,7 +122,42 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio * @see \ManiaControl\Configurator\ConfiguratorMenu::getTitle() */ public static function getTitle() { - return 'Script Settings'; + return 'GameMode-Settings'; + } + + /** + * Get the settings of the GameMode into an Array + * @return array|false + */ + public function getGameModeSettingsArray() { + if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { + return $this->maniaControl->getClient()->getModeScriptSettings(); + } else { + $gameModeSettings = get_object_vars($this->maniaControl->getClient()->getCurrentGameInfo()); + foreach ($gameModeSettings as $name => $value) { + unset($gameModeSettings[$name]); + $gameModeSettings[ucfirst($name)] = $value; + } + return $gameModeSettings; + } + } + + /** + * Set the settings of the GameMode from an Array. + * Returns true, if successful. + * @param array $settings + * @return bool + */ + public function setGameModeSettingsArray(array $settings) { + if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { + return $this->maniaControl->getClient()->setModeScriptSettings($settings); + } else { + $success = true; + foreach ($settings as $key => $value) { + $success &= $this->maniaControl->getClient()->execute('Set'.$key, array($value)); + } + return $success; + } } /** @@ -138,15 +173,16 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio * @return bool */ public function loadSettingsFromDatabase() { + $gameModeSettings = null; try { - $scriptSettings = $this->maniaControl->getClient()->getModeScriptSettings(); - } catch (GameModeException $e) { + $gameModeSettings = $this->getGameModeSettingsArray(); + } catch (\Exception $e) { return false; } $mysqli = $this->maniaControl->getDatabase()->getMysqli(); $serverIndex = $this->maniaControl->getServer()->index; - $query = "SELECT * FROM `" . self::TABLE_SCRIPT_SETTINGS . "` + $query = "SELECT * FROM `" . self::TABLE_GAMEMODE_SETTINGS . "` WHERE serverIndex = {$serverIndex};"; $result = $mysqli->query($query); if ($mysqli->error) { @@ -156,18 +192,24 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio $loadedSettings = array(); while ($row = $result->fetch_object()) { - if (!isset($scriptSettings[$row->settingName])) { + if (!isset($gameModeSettings[$row->settingName])) { continue; } $loadedSettings[$row->settingName] = $row->settingValue; - settype($loadedSettings[$row->settingName], gettype($scriptSettings[$row->settingName])); + settype($loadedSettings[$row->settingName], gettype($gameModeSettings[$row->settingName])); } $result->free(); if (empty($loadedSettings)) { return true; } - return $this->maniaControl->getClient()->setModeScriptSettings($loadedSettings); + try { + $this->setGameModeSettingsArray($loadedSettings); + } catch (\Exception $e) { + return false; + } + + return true; } /** @@ -187,22 +229,25 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio $script->addFeature($paging); $frame = new Frame(); + $scriptParams = null; + $gameModeSettings = null; + $error = null; try { - $scriptInfo = $this->maniaControl->getClient()->getModeScriptInfo(); - } catch (GameModeException $e) { + $gameModeSettings = $this->getGameModeSettingsArray(); + + if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { + $scriptInfo = $this->maniaControl->getClient()->getModeScriptInfo(); + $scriptParams = $scriptInfo->paramDescs; + } else { + $scriptParams = $gameModeSettings; + } + } catch (\Exception $e) { $label = new Label(); $frame->addChild($label); $label->setText($e->getMessage()); return $frame; } - $scriptParams = $scriptInfo->paramDescs; - - try { - $scriptSettings = $this->maniaControl->getClient()->getModeScriptSettings(); - } catch (GameModeException $e) { - } - // Config $pagerSize = 9.; $settingHeight = 5.; @@ -236,12 +281,17 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio // Setting pages $pageFrame = null; $posY = 0.; + $index = 0; - foreach ($scriptParams as $index => $scriptParam) { - /** @var \Maniaplanet\DedicatedServer\Structures\ScriptSettings $scriptParam */ - $settingName = $scriptParam->name; + foreach ($scriptParams as $key => $scriptParam) { + $settingName = null; + if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { + $settingName = $scriptParam->name; + } else { + $settingName = $key; + } - if (!isset($scriptSettings[$settingName])) { + if (!isset($gameModeSettings[$settingName])) { continue; } @@ -259,43 +309,46 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio $nameLabel = new Label_Text(); $settingFrame->addChild($nameLabel); $nameLabel->setHorizontalAlign($nameLabel::LEFT); - $nameLabel->setX($width * -0.46); $nameLabel->setSize($width * 0.4, $settingHeight); $nameLabel->setStyle($nameLabel::STYLE_TextCardSmall); - $nameLabel->setTextSize($labelTextSize); $nameLabel->setText($settingName); + $nameLabel->setTextSize($labelTextSize); + $nameLabel->setX($width * -0.46); - $settingValue = $scriptSettings[$settingName]; + $settingValue = $gameModeSettings[$settingName]; if (is_bool($settingValue)) { // Boolean checkbox $quad = new Quad(); - $quad->setX($width / 2 * 0.545); $quad->setSize(4, 4); + $quad->setX($width / 2 * 0.545); $checkBox = new CheckBox(self::ACTION_PREFIX_SETTING . $settingName, $settingValue, $quad); $settingFrame->addChild($checkBox); } else { // Value entry $entry = new Entry(); $settingFrame->addChild($entry); - $entry->setStyle(Label_Text::STYLE_TextValueSmall); - $entry->setX($width / 2 * 0.55); - $entry->setTextSize(1); - $entry->setSize($width * 0.3, $settingHeight * 0.9); - $entry->setName(self::ACTION_PREFIX_SETTING . $settingName); $entry->setDefault($settingValue); + $entry->setName(self::ACTION_PREFIX_SETTING . $settingName); + $entry->setSize($width * 0.3, $settingHeight * 0.9); + $entry->setStyle(Label_Text::STYLE_TextValueSmall); + $entry->setTextSize(1); + $entry->setX($width / 2 * 0.55); } - $descriptionLabel = new Label(); - $pageFrame->addChild($descriptionLabel); - $descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT); - $descriptionLabel->setPosition($width * -0.45, $height * -0.44); - $descriptionLabel->setSize($width * 0.7, $settingHeight); - $descriptionLabel->setTextSize($labelTextSize); - $descriptionLabel->setTranslate(true); - $nameLabel->addTooltipLabelFeature($descriptionLabel, $scriptParam->desc); + if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { + $descriptionLabel = new Label(); + $pageFrame->addChild($descriptionLabel); + $descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT); + $descriptionLabel->setPosition($width * -0.45, $height * -0.44); + $descriptionLabel->setSize($width * 0.7, $settingHeight); + $descriptionLabel->setTextSize($labelTextSize); + $descriptionLabel->setTranslate(true); + $nameLabel->addTooltipLabelFeature($descriptionLabel, $scriptParam->desc); + } $posY -= $settingHeight; + $index++; } return $frame; @@ -305,17 +358,18 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio * @see \ManiaControl\Configurator\ConfiguratorMenu::saveConfigData() */ public function saveConfigData(array $configData, Player $player) { - if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CHANGE_SCRIPT_SETTINGS)) { + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CHANGE_MODE_SETTINGS)) { $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } if (!$configData[3] || strpos($configData[3][0]['Name'], self::ACTION_PREFIX_SETTING) !== 0) { return; } - + + $gameModeSettings = null; try { - $scriptSettings = $this->maniaControl->getClient()->getModeScriptSettings(); - } catch (GameModeException $e) { + $gameModeSettings = $this->getGameModeSettingsArray(); + } catch (\Exception $e) { return; } @@ -324,25 +378,25 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio $newSettings = array(); foreach ($configData[3] as $setting) { $settingName = substr($setting['Name'], $prefixLength); - if (!isset($scriptSettings[$settingName])) { + if (!isset($gameModeSettings[$settingName])) { var_dump('no setting ' . $settingName); continue; } - if ($setting['Value'] == $scriptSettings[$settingName]) { + if ($setting['Value'] == $gameModeSettings[$settingName]) { // Not changed continue; } $newSettings[$settingName] = $setting['Value']; - settype($newSettings[$settingName], gettype($scriptSettings[$settingName])); + settype($newSettings[$settingName], gettype($gameModeSettings[$settingName])); } - $success = $this->applyNewScriptSettings($newSettings, $player); + $success = $this->applyNewModeSettings($newSettings, $player); if ($success) { - $this->maniaControl->getChat()->sendSuccess('Script Settings saved!', $player); + $this->maniaControl->getChat()->sendSuccess('GameMode-Settings saved!', $player); } else { - $this->maniaControl->getChat()->sendError('Script Settings Saving failed!', $player); + $this->maniaControl->getChat()->sendError('GameMode-Settings Saving failed!', $player); } // Reopen the Menu @@ -357,21 +411,24 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio * @param Player $player * @return bool */ - private function applyNewScriptSettings(array $newSettings, Player $player) { + private function applyNewModeSettings(array $newSettings, Player $player) { if (empty($newSettings)) { return true; } try { - $this->maniaControl->getClient()->setModeScriptSettings($newSettings); - } catch (FaultException $e) { + $success = $this->setGameModeSettingsArray($newSettings); + if (!$success) { + return false; + } + } catch (\Exception $e) { + $this->maniaControl->getChat()->sendException($e, $player); return false; } - // Save Settings into Database $mysqli = $this->maniaControl->getDatabase()->getMysqli(); - $query = "INSERT INTO `" . self::TABLE_SCRIPT_SETTINGS . "` ( + $query = "INSERT INTO `" . self::TABLE_GAMEMODE_SETTINGS . "` ( `serverIndex`, `settingName`, `settingValue` @@ -389,13 +446,17 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio $statement->bind_param('iss', $this->maniaControl->getServer()->index, $settingName, $settingValue); // Notifications + if (!$this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { + $this->maniaControl->getChat()->sendInformation('Changes will only take effect after a map skip or restart!', $player); + } + $settingsCount = count($newSettings); $settingIndex = 0; $title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($player); - $chatMessage = '$ff0' . $title . ' ' . $player->getEscapedNickname() . ' set ScriptSetting' . ($settingsCount > 1 ? 's' : '') . ' '; - foreach ($newSettings as $setting => $value) { - $chatMessage .= '$<' . '$fff' . preg_replace('/^S_/', '', $setting) . '$z$s$ff0 '; - $chatMessage .= 'to $fff' . $this->parseSettingValue($value) . '$>'; + $chatMessage = '$ff0' . $title . ' ' . $player->getEscapedNickname() . ' set GameMode-Setting' . ($settingsCount > 1 ? 's' : '') . ' '; + foreach ($newSettings as $settingName => $settingValue) { + $chatMessage .= '$<' . '$fff' . preg_replace('/^S_/', '', $settingName) . '$z$ff0 '; + $chatMessage .= 'to $fff' . $this->parseSettingValue($settingValue) . '$>'; if ($settingIndex <= $settingsCount - 2) { $chatMessage .= ', '; @@ -408,13 +469,13 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio } // Trigger own callback - $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_SCRIPTSETTING_CHANGED, $setting, $value); + $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_GAMEMODESETTING_CHANGED, $settingName, $settingValue); $settingIndex++; } $statement->close(); - $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_SCRIPTSETTINGS_CHANGED); + $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_GAMEMODESETTINGS_CHANGED); $chatMessage .= '!'; $this->maniaControl->getChat()->sendInformation($chatMessage); @@ -439,17 +500,73 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio * Initializes the communication Listenings */ private function initalizeCommunicationListenings() { - //Communication Listenings + $this->maniaControl->getCommunicationManager()->registerCommunicationListener(CommunicationMethods::GET_GAMEMODE_SETTINGS, $this, function ($data) { + try { + $gameModeSettings = $this->getGameModeSettingsArray(); + } catch (\Exception $e) { + return new CommunicationAnswer($e->getMessage(), true); + } + + return new CommunicationAnswer($gameModeSettings); + }); + + $this->maniaControl->getCommunicationManager()->registerCommunicationListener(CommunicationMethods::SET_GAMEMODE_SETTINGS, $this, function ($data) { + if (!is_object($data) || !property_exists($data, "gameModeSettings")) { + return new CommunicationAnswer("No valid GameMode-Settings provided!", true); + } + + $gameModeSettings = null; + try { + $gameModeSettings = $this->getGameModeSettingsArray(); + } catch (\Exception $e) { + return new CommunicationAnswer($e->getMessage(), true); + } + + $newSettings = array(); + foreach ($data->gameModeSettings as $name => $value) { + if (!isset($gameModeSettings[$name])) { + var_dump('no setting ' . $name); + continue; + } + + if ($value == $gameModeSettings[$name]) { + // unchanged + continue; + } + + $newSettings[$name] = $value; + settype($newSettings[$name], gettype($gameModeSettings[$name])); + } + + // No new Settings + if (empty($newSettings)) { + return new CommunicationAnswer(array("success" => true)); + } + + // Trigger GameModeSettings Changed Callback + $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_GAMEMODESETTINGS_CHANGED); + + // Set the Settings + try { + $success = $this->setGameModeSettingsArray($newSettings); + return new CommunicationAnswer(array("success" => $success)); + } catch (\Exception $e) { + return new CommunicationAnswer($e->getMessage(), true); + } + }); + + /** @deprecated */ $this->maniaControl->getCommunicationManager()->registerCommunicationListener(CommunicationMethods::GET_SCRIPT_SETTINGS, $this, function ($data) { try { $scriptSettings = $this->maniaControl->getClient()->getModeScriptSettings(); - } catch (GameModeException $e) { + } catch (\Exception $e) { return new CommunicationAnswer($e->getMessage(), true); } return new CommunicationAnswer($scriptSettings); }); + /** @deprecated */ $this->maniaControl->getCommunicationManager()->registerCommunicationListener(CommunicationMethods::SET_SCRIPT_SETTINGS, $this, function ($data) { if (!is_object($data) || !property_exists($data, "scriptSettings")) { return new CommunicationAnswer("No valid ScriptSettings provided!", true); @@ -457,7 +574,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener, Communicatio try { $scriptSettings = $this->maniaControl->getClient()->getModeScriptSettings(); - } catch (GameModeException $e) { + } catch (\Exception $e) { return new CommunicationAnswer($e->getMessage(), true); } From 2e6dd5efd58419770df39af6aac659cb319e381c Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Thu, 30 Apr 2020 12:04:48 +0200 Subject: [PATCH 41/98] Display Current- and Next-GameInfos in Configurator --- core/Configurator/GameModeSettings.php | 103 ++++++++++++++++++++----- 1 file changed, 85 insertions(+), 18 deletions(-) diff --git a/core/Configurator/GameModeSettings.php b/core/Configurator/GameModeSettings.php index 3de32b66..a790bcba 100644 --- a/core/Configurator/GameModeSettings.php +++ b/core/Configurator/GameModeSettings.php @@ -133,11 +133,24 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { return $this->maniaControl->getClient()->getModeScriptSettings(); } else { - $gameModeSettings = get_object_vars($this->maniaControl->getClient()->getCurrentGameInfo()); - foreach ($gameModeSettings as $name => $value) { - unset($gameModeSettings[$name]); - $gameModeSettings[ucfirst($name)] = $value; + $gameModeSettings = $this->maniaControl->getClient()->getGameInfos(); + + $currentGameModeSettings = get_object_vars($gameModeSettings['CurrentGameInfos']); + unset($gameModeSettings['CurrentGameInfos']); + foreach ($currentGameModeSettings as $name => $value) { + unset($currentGameModeSettings[$name]); + $currentGameModeSettings[ucfirst($name)] = $value; } + $gameModeSettings[0] = $currentGameModeSettings; + + $nextGameModeSettings = get_object_vars($gameModeSettings['NextGameInfos']); + unset($gameModeSettings['NextGameInfos']); + foreach ($nextGameModeSettings as $name => $value) { + unset($nextGameModeSettings[$name]); + $nextGameModeSettings[ucfirst($name)] = $value; + } + $gameModeSettings[1] = $nextGameModeSettings; + return $gameModeSettings; } } @@ -176,6 +189,9 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat $gameModeSettings = null; try { $gameModeSettings = $this->getGameModeSettingsArray(); + if (!$this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { + $gameModeSettings = $gameModeSettings[0]; + } } catch (\Exception $e) { return false; } @@ -239,7 +255,7 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat $scriptInfo = $this->maniaControl->getClient()->getModeScriptInfo(); $scriptParams = $scriptInfo->paramDescs; } else { - $scriptParams = $gameModeSettings; + $scriptParams = $gameModeSettings[0]; } } catch (\Exception $e) { $label = new Label(); @@ -278,6 +294,18 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat $paging->setLabel($pageCountLabel); + if (!$this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { + $descriptionLabel = new Label(); + $frame->addChild($descriptionLabel); + $descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT); + $descriptionLabel->setPosition($width * -0.45, $height * -0.44); + $descriptionLabel->setSize($width * 0.7, $settingHeight); + $descriptionLabel->setText('Changes only apply with map skip/restart'); + $descriptionLabel->setTextColor('ff0'); + $descriptionLabel->setTextSize($labelTextSize); + $descriptionLabel->setTranslate(true); + } + // Setting pages $pageFrame = null; $posY = 0.; @@ -285,20 +313,28 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat foreach ($scriptParams as $key => $scriptParam) { $settingName = null; + $settingValue = null; if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { $settingName = $scriptParam->name; + if (!isset($gameModeSettings[$settingName])) { + continue; + } + $settingValue = $gameModeSettings[$settingName]; } else { $settingName = $key; - } - - if (!isset($gameModeSettings[$settingName])) { - continue; + if (!isset($gameModeSettings[0][$settingName]) && !isset($gameModeSettings[1][$settingName])) { + continue; + } + $settingValue = array( + 0 => $gameModeSettings[0][$settingName], + 1 => $gameModeSettings[1][$settingName] + ); } if ($index % 13 === 0) { $pageFrame = new Frame(); $frame->addChild($pageFrame); - $posY = $height * 0.41; + $posY = 0.41 * $height; $paging->addPageControl($pageFrame); } @@ -309,19 +345,44 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat $nameLabel = new Label_Text(); $settingFrame->addChild($nameLabel); $nameLabel->setHorizontalAlign($nameLabel::LEFT); - $nameLabel->setSize($width * 0.4, $settingHeight); + $nameLabel->setSize(0.4 * $width, $settingHeight); $nameLabel->setStyle($nameLabel::STYLE_TextCardSmall); $nameLabel->setText($settingName); $nameLabel->setTextSize($labelTextSize); - $nameLabel->setX($width * -0.46); + $nameLabel->setX(-0.46 * $width); - $settingValue = $gameModeSettings[$settingName]; + if (!$this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { + if (is_bool($settingValue[0])) { + $activeQuad = new Quad_Icons64x64_1(); + $settingFrame->addChild($activeQuad); + $activeQuad->setSize(0.9 * $settingHeight, 0.9 * $settingHeight); + if ($settingValue[0]) { + $activeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_LvlGreen); + } else { + $activeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_LvlRed); + } + $activeQuad->setX(0.1 * $width); + } else { + $currentLabel = new Label_Text(); + $settingFrame->addChild($currentLabel); + $currentLabel->setHorizontalAlign(Label_Text::RIGHT); + $currentLabel->setSize(0.2 * $width, 0.9 * $settingHeight); + $currentLabel->setStyle(Label_Text::STYLE_TextValueSmall); + $currentLabel->setText($settingValue[0]); + $currentLabel->setTextColor('aaa'); + $currentLabel->setTextPrefix('$i'); + $currentLabel->setTextSize(1); + $currentLabel->setX(0.11 * $width); + } + + $settingValue = $settingValue[1]; + } if (is_bool($settingValue)) { // Boolean checkbox $quad = new Quad(); $quad->setSize(4, 4); - $quad->setX($width / 2 * 0.545); + $quad->setX(0.27 * $width); $checkBox = new CheckBox(self::ACTION_PREFIX_SETTING . $settingName, $settingValue, $quad); $settingFrame->addChild($checkBox); } else { @@ -330,18 +391,18 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat $settingFrame->addChild($entry); $entry->setDefault($settingValue); $entry->setName(self::ACTION_PREFIX_SETTING . $settingName); - $entry->setSize($width * 0.3, $settingHeight * 0.9); + $entry->setSize(0.3 * $width, 0.9 * $settingHeight); $entry->setStyle(Label_Text::STYLE_TextValueSmall); $entry->setTextSize(1); - $entry->setX($width / 2 * 0.55); + $entry->setX(0.275 * $width); } if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { $descriptionLabel = new Label(); $pageFrame->addChild($descriptionLabel); $descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT); - $descriptionLabel->setPosition($width * -0.45, $height * -0.44); - $descriptionLabel->setSize($width * 0.7, $settingHeight); + $descriptionLabel->setPosition(-0.45 * $width, -0.44 * $height); + $descriptionLabel->setSize(0.7 * $width, $settingHeight); $descriptionLabel->setTextSize($labelTextSize); $descriptionLabel->setTranslate(true); $nameLabel->addTooltipLabelFeature($descriptionLabel, $scriptParam->desc); @@ -369,6 +430,9 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat $gameModeSettings = null; try { $gameModeSettings = $this->getGameModeSettingsArray(); + if (!$this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { + $gameModeSettings = $gameModeSettings[0]; + } } catch (\Exception $e) { return; } @@ -518,6 +582,9 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat $gameModeSettings = null; try { $gameModeSettings = $this->getGameModeSettingsArray(); + if (!$this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { + $gameModeSettings = $gameModeSettings[0]; + } } catch (\Exception $e) { return new CommunicationAnswer($e->getMessage(), true); } From 047f05124b3e3cd5b252e5a0fdd433208cf8f13a Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Thu, 30 Apr 2020 14:40:45 +0200 Subject: [PATCH 42/98] Removed now unnecessary Chat-Notification for new GameMode-Settings --- core/Configurator/GameModeSettings.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/core/Configurator/GameModeSettings.php b/core/Configurator/GameModeSettings.php index a790bcba..faaeecc6 100644 --- a/core/Configurator/GameModeSettings.php +++ b/core/Configurator/GameModeSettings.php @@ -510,10 +510,6 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat $statement->bind_param('iss', $this->maniaControl->getServer()->index, $settingName, $settingValue); // Notifications - if (!$this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { - $this->maniaControl->getChat()->sendInformation('Changes will only take effect after a map skip or restart!', $player); - } - $settingsCount = count($newSettings); $settingIndex = 0; $title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($player); From 9a7952811a93d50feb797349b9b789a9a3dfed35 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Thu, 7 May 2020 12:55:58 +0200 Subject: [PATCH 43/98] TMCallbacks registered itself to trigger more sophisticated callbacks now, otherwise they were swallowed up --- core/Callbacks/TrackManiaCallbacks.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/Callbacks/TrackManiaCallbacks.php b/core/Callbacks/TrackManiaCallbacks.php index 3e81b997..d48acf8e 100644 --- a/core/Callbacks/TrackManiaCallbacks.php +++ b/core/Callbacks/TrackManiaCallbacks.php @@ -41,6 +41,7 @@ class TrackManiaCallbacks implements CallbackListener { // Register for script callbacks $callbackManager->registerCallbackListener(Callbacks::SCRIPTCALLBACK, $this, 'handleScriptCallbacks'); + $callbackManager->registerCallbackListener(Callbacks::TM_ONWAYPOINT, $this, 'handleWayPointCallback'); } /** @@ -73,9 +74,7 @@ class TrackManiaCallbacks implements CallbackListener { $this->maniaControl->getCallbackManager()->triggerCallback($name, new BasePlayerTimeStructure($this->maniaControl, $data)); break; case Callbacks::TM_ONWAYPOINT: - $this->handleWayPointCallback(new OnWayPointEventStructure($this->maniaControl, $data)); - - //$this->maniaControl->getCallbackManager()->triggerCallback($name, $wayPointStructure); + $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnWayPointEventStructure($this->maniaControl, $data)); break; case Callbacks::TM_ONRESPAWN: $this->maniaControl->getCallbackManager()->triggerCallback($name, new OnRespawnStructure($this->maniaControl, $data)); @@ -103,9 +102,11 @@ class TrackManiaCallbacks implements CallbackListener { /** * Trigger the three different Types of Callbacks * - * @param \ManiaControl\Callbacks\Structures\TrackMania\OnWayPointEventStructure $structure + * @param $data */ - private function handleWayPointCallback(OnWayPointEventStructure $structure) { + public function handleWayPointCallback($data) { + $structure = new OnWayPointEventStructure($this->maniaControl, $data); + if ($structure->getIsEndRace()) { $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONFINISHLINE, $structure); } else if ($structure->getIsEndLap()) { From 0db1636a38cf6e3e5f3b43e8c0b4f5a8ef7eaea0 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Thu, 7 May 2020 12:58:35 +0200 Subject: [PATCH 44/98] WayPoint-Callback already takes a Structure --- core/Callbacks/TrackManiaCallbacks.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/Callbacks/TrackManiaCallbacks.php b/core/Callbacks/TrackManiaCallbacks.php index d48acf8e..1047a5f3 100644 --- a/core/Callbacks/TrackManiaCallbacks.php +++ b/core/Callbacks/TrackManiaCallbacks.php @@ -102,11 +102,9 @@ class TrackManiaCallbacks implements CallbackListener { /** * Trigger the three different Types of Callbacks * - * @param $data + * @param \ManiaControl\Callbacks\Structures\TrackMania\OnWayPointEventStructure $structure */ - public function handleWayPointCallback($data) { - $structure = new OnWayPointEventStructure($this->maniaControl, $data); - + public function handleWayPointCallback(OnWayPointEventStructure $structure) { if ($structure->getIsEndRace()) { $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONFINISHLINE, $structure); } else if ($structure->getIsEndLap()) { From 860678e57f584d8b0c661c969950eeda016eebd2 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Thu, 7 May 2020 13:05:39 +0200 Subject: [PATCH 45/98] Do not call the Waypoint-Callback itself again --- core/Callbacks/TrackManiaCallbacks.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/Callbacks/TrackManiaCallbacks.php b/core/Callbacks/TrackManiaCallbacks.php index 1047a5f3..9e7d362b 100644 --- a/core/Callbacks/TrackManiaCallbacks.php +++ b/core/Callbacks/TrackManiaCallbacks.php @@ -109,8 +109,6 @@ class TrackManiaCallbacks implements CallbackListener { $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONFINISHLINE, $structure); } else if ($structure->getIsEndLap()) { $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONLAPFINISH, $structure); - } else { - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONWAYPOINT, $structure); } } } From 67c9180f9ca4e1578971184a16eda0dab26d79d5 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Thu, 7 May 2020 18:39:27 +0200 Subject: [PATCH 46/98] Unified Creations of round Text-Buttons --- changelog.txt | 30 +++-- core/Manialinks/ElementBuilder.php | 40 ++++++ core/Manialinks/StyleManager.php | 43 +++---- core/Maps/MapList.php | 78 ++++-------- core/Players/PlayerList.php | 189 +++++++++++++---------------- 5 files changed, 186 insertions(+), 194 deletions(-) diff --git a/changelog.txt b/changelog.txt index 361f8b83..bccae2a2 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,18 +1,31 @@ +###v0.254### +#Additions +- added first support of Legacy-Modes + +#Bug Fixes +- solved Finish-/Lap-Callback not getting triggered when Waypoint-Callback is not registered + +#Changes +- additional Waypoint-Callback on Finish-/Lap-Callback +- 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 +- 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 +- new customizations for Join&Leave-Messages +- symbolic Link resolving in ServerManager - Times in Map Widget #Bug Fixes -- GReplay for Dedimania-Records not being sent -- non-numeric value warning on self-triggered debug notice +- GReplay for Dedimania-Records are now being sent +- solved non-numeric value warning on self-triggered debug notice ###v0.250### #Additions @@ -24,18 +37,19 @@ #Bug Fixes - //delrec can delete every local record (Permission-Setting) -- Replaced deprecated code +- replaced deprecated code #Changes -- Format milliseconds with dot instead of double colon (1:02:375 -> 1:02.375) +- format milliseconds with dot instead of double colon (1:02:375 -> 1:02.375) - Notification-System of Local Records ###v0.16x### #Additions - updated mx links to https + #Changes - CommunicationMethod SET_SERVER_OPTIONS sets the changed values also in database on call -- Changed Copyright label to 2014-2016 +- changed Copyright label to 2014-2016 ###v0.163### #Additions diff --git a/core/Manialinks/ElementBuilder.php b/core/Manialinks/ElementBuilder.php index 8c295577..af84843b 100644 --- a/core/Manialinks/ElementBuilder.php +++ b/core/Manialinks/ElementBuilder.php @@ -6,6 +6,7 @@ use FML\Controls\Frame; use FML\Controls\Gauge; use FML\Controls\Labels\Label_Button; use FML\Controls\Labels\Label_Text; +use FML\Controls\Quad; use FML\Controls\Quads\Quad_BgsPlayerCard; use FML\ManiaLink; use FML\Script\Features\Paging; @@ -125,6 +126,45 @@ class ElementBuilder { $this->rowData = array_merge($this->rowData, $rows); } + /** + * Build Round Text Button + * @param string $description + * @param float $width + * @param float $height + * @param string $action + * @param string $logoUrl + */ + public function buildRoundTextButton($description, $width, $height, $action, $logoUrl = null) { + $frame = new Frame(); + + $quad = new Quad_BgsPlayerCard(); + $frame->addChild($quad); + $quad->setAction($action); + $quad->setSize($width, $height); + $quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig); + $quad->setZ(-1); + + $label = new Label_Button(); + $frame->addChild($label); + $label->setText($description); + $label->setTextSize($height / 4); + $label->setZ(1); + + if ($logoUrl) { + $logoQuad = new Quad(); + $frame->addChild($logoQuad); + $logoQuad->setImageUrl($logoUrl); + $logoQuad->setSize(0.75*$height, 0.75*$height); + $logoQuad->setX(-$width/2 + 0.75*$height); + $logoQuad->setZ(1); + + $label->setHorizontalAlign($label::RIGHT); + $label->setX($width/2 - 0.5*$height); + } + + return $frame; + } + /** * Build Karma Gauge * @param Map|MXMapInfo $map diff --git a/core/Manialinks/StyleManager.php b/core/Manialinks/StyleManager.php index 02b4c9b8..ca8349b1 100644 --- a/core/Manialinks/StyleManager.php +++ b/core/Manialinks/StyleManager.php @@ -153,37 +153,26 @@ class StyleManager implements UsageInformationAble { } //Search for Map-Name - $label = new Label_Button(); - $frame->addChild($label); - $label->setPosition(-$width / 2 + 63, 0); - $label->setText('MapName'); - $label->setTextSize(1.3); - - $quad = new Quad_BgsPlayerCard(); - $frame->addChild($quad); - $quad->setPosition(-$width / 2 + 63, 0); - $quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig); - $quad->setSize(18, 5); - $quad->setAction($actionMapNameSearch); - $quad->setZ(-0.1); + $mapNameButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton( + 'MapName', + 18, + 5, + $actionMapNameSearch + ); + $frame->addChild($mapNameButton); + $mapNameButton->setX(-$width / 2 + 63); //Search for Author - $label = new Label_Button(); - $frame->addChild($label); - $label->setPosition(-$width / 2 + 82, 0); - $label->setText('Author'); - $label->setTextSize(1.3); - - $quad = new Quad_BgsPlayerCard(); - $frame->addChild($quad); - $quad->setPosition(-$width / 2 + 82, 0); - $quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig); - $quad->setSize(18, 5); - $quad->setAction($actionAuthorSearch); - $quad->setZ(-0.1); + $authorButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton( + 'Author', + 18, + 5, + $actionAuthorSearch + ); + $frame->addChild($authorButton); + $authorButton->setX(-$width / 2 + 82); return $frame; - } /** diff --git a/core/Maps/MapList.php b/core/Maps/MapList.php index 14859680..ec500dc4 100644 --- a/core/Maps/MapList.php +++ b/core/Maps/MapList.php @@ -162,67 +162,37 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { // Admin Buttons if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapQueue::SETTING_PERMISSION_CLEAR_MAPQUEUE)) { - // Clear Map-Queue - $label = new Label_Button(); - $frame->addChild($label); - $label->setText('Clear Map-Queue'); - $label->setTextSize(1); - $label->setPosition($width / 2 - 8, $buttonY, 0.1); - $label->setHorizontalAlign($label::RIGHT); - - $quad = new Quad_BgsPlayerCard(); - $frame->addChild($quad); - $quad->setPosition($width / 2 - 5, $buttonY, 0.01); - $quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig); - $quad->setHorizontalAlign($quad::RIGHT); - $quad->setSize(29, 4); - $quad->setAction(self::ACTION_CLEAR_MAPQUEUE); + $clearMapQueueButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton( + 'Clear Map-Queue', + 30, + 4, + self::ACTION_CLEAR_MAPQUEUE + ); + $frame->addChild($clearMapQueueButton); + $clearMapQueueButton->setPosition($width/2 - 5 - 30/2, $buttonY); } if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_CHECK_UPDATE)) { - $mxCheckForUpdatesX = $width / 2 - 37; - $buttonWidth = 35; - $iconSize = 3; - // Check Update - $label = new Label_Button(); - $frame->addChild($label); - $label->setText('Check MX for Updates'); - $label->setPosition($mxCheckForUpdatesX - 1.5, $buttonY, 0.02); - $label->setTextSize(1); - $label->setWidth(30); - $label->setHorizontalAlign($label::RIGHT); - - $quad = new Quad_BgsPlayerCard(); - $frame->addChild($quad); - $quad->setPosition($mxCheckForUpdatesX, $buttonY, 0.01); - $quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig); - $quad->setHorizontalAlign($quad::RIGHT); - $quad->setSize($buttonWidth, 4); - $quad->setAction(self::ACTION_CHECK_UPDATE); - - $mxQuad = new Quad(); - $frame->addChild($mxQuad); - $mxQuad->setSize($iconSize, $iconSize); - $mxQuad->setImageUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_GREEN)); - $mxQuad->setImageFocusUrl($this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_GREEN_MOVER)); - $mxQuad->setPosition($mxCheckForUpdatesX - $buttonWidth + 3, $buttonY); - $mxQuad->setZ(0.2); + $mxCheckForUpdatesButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton( + 'Check MX for Updates', + 36, + 4, + self::ACTION_CHECK_UPDATE, + $this->maniaControl->getManialinkManager()->getIconManager()->getIcon(IconManager::MX_ICON_GREEN) + ); + $frame->addChild($mxCheckForUpdatesButton); + $mxCheckForUpdatesButton->setPosition($width/2 - 5 - 30 - 5 - 36/2, $buttonY); } if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) { - // Directory browser - $browserButton = new Label_Button(); + $browserButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton( + 'Directory Browser', + 36, + 4, + DirectoryBrowser::ACTION_SHOW + ); $frame->addChild($browserButton); - $browserButton->setPosition($width / -2 + 20, $buttonY, 0.01); - $browserButton->setTextSize(1); - $browserButton->setText('Directory Browser'); - - $browserQuad = new Quad_BgsPlayerCard(); - $frame->addChild($browserQuad); - $browserQuad->setPosition($width / -2 + 20, $buttonY, 0.01); - $browserQuad->setSubStyle($browserQuad::SUBSTYLE_BgPlayerCardBig); - $browserQuad->setSize(35, 4); - $browserQuad->setAction(DirectoryBrowser::ACTION_SHOW); + $browserButton->setPosition(-$width/2 + 5 + 36/2, $buttonY); } // Headline diff --git a/core/Players/PlayerList.php b/core/Players/PlayerList.php index 33225cfa..93d1c4e2 100644 --- a/core/Players/PlayerList.php +++ b/core/Players/PlayerList.php @@ -50,7 +50,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer const ACTION_KICK_PLAYER = 'PlayerList.KickPlayer'; const ACTION_KICK_PLAYER_VOTE = 'PlayerList.KickPlayerVote'; const ACTION_BAN_PLAYER = 'PlayerList.BanPlayer'; + /** @deprecated */ const ACTION_ADD_AS_MASTER = 'PlayerList.PlayerAddAsMaster'; + const ACTION_ADD_AS_SUPER = 'PlayerList.PlayerAddAsSuper'; const ACTION_ADD_AS_ADMIN = 'PlayerList.PlayerAddAsAdmin'; const ACTION_ADD_AS_MOD = 'PlayerList.PlayerAddAsModerator'; const ACTION_REVOKE_RIGHTS = 'PlayerList.RevokeRights'; @@ -289,9 +291,10 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer // Level Quad $rightQuad = new Quad_BgRaceScore2(); $playerFrame->addChild($rightQuad); - $rightQuad->setX($posX + 13); + // TODO colorize to player personally $rightQuad->setSize(7, 3.5); $rightQuad->setSubStyle($rightQuad::SUBSTYLE_CupFinisher); + $rightQuad->setX($posX + 13); $rightLabel = new Label_Text(); $playerFrame->addChild($rightLabel); @@ -496,8 +499,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $label->setText('Advanced Actions'); $label->setTextColor($textColor); - - //Nickname background + // Nickname background $quad = new Quad(); $frame->addChild($quad); $quad->setPosition(0, $height / 2 - 10, -0.1); @@ -515,129 +517,105 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $label->setTextColor($textColor); $label->setHorizontalAlign($label::CENTER); + // Buttons + $buttonHeight = 5; $buttonSpacing = 6.5; - - // Background for Buttons + $buttonWidth = $quadWidth; $posY = $height / 2 - 20; - $quad = new Quad_BgsPlayerCard(); - $frame->addChild($quad); - $quad->setX(0); - $quad->setY($posY); - $quad->setZ(-0.1); - $quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig); - $quad->setSize($quadWidth, 5); - // Mute Button - $label = new Label_Text(); - $frame->addChild($label); - $label->setX(0); - $label->setY($posY); - $label->setStyle($label::STYLE_TextCardSmall); - $label->setTextSize($textSize); - $label->setTextColor($textColor); - - if (!$player->isMuted()) { - $label->setText('Mute'); - $quad->setAction(self::ACTION_MUTE_PLAYER . '.' . $login); - } else { - $label->setText('UnMute'); - $quad->setAction(self::ACTION_UNMUTE_PLAYER . '.' . $login); - } - - // Warn Player - $posY -= $buttonSpacing; - $quad = clone $quad; - $frame->addChild($quad); - $quad->setY($posY); - $quad->setAction(self::ACTION_WARN_PLAYER . '.' . $login); - - $label = clone $label; - $frame->addChild($label); - $label->setY($posY); - $label->setText('Warn'); - $label->setTextColor($textColor); + $muteUnmuteButtonDescription = $player->isMuted() ? 'UnMute' : 'Mute'; + $muteUnmuteButtonAction = ($player->isMuted() ? self::ACTION_UNMUTE_PLAYER : self::ACTION_MUTE_PLAYER) . '.' . $login; + $muteUnmuteButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton( + $muteUnmuteButtonDescription, + $buttonWidth, + $buttonHeight, + $muteUnmuteButtonAction + ); + $frame->addChild($muteUnmuteButton); + $muteUnmuteButton->setY($posY); $posY -= $buttonSpacing; - // Show Kick - $quad = clone $quad; - $frame->addChild($quad); - $quad->setY($posY); - $quad->setAction(self::ACTION_KICK_PLAYER . '.' . $login); - - $label = clone $label; - $frame->addChild($label); - $label->setY($posY); - $label->setText('Kick'); - $label->setTextColor('f90'); + $warnButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton( + 'Warn', + $buttonWidth, + $buttonHeight, + self::ACTION_WARN_PLAYER . '.' . $login + ); + $frame->addChild($warnButton); + $warnButton->setY($posY); $posY -= $buttonSpacing; - // Show Ban - $quad = clone $quad; - $frame->addChild($quad); - $quad->setY($posY); - $quad->setAction(self::ACTION_BAN_PLAYER . '.' . $login); - $label = clone $label; - $frame->addChild($label); - $label->setY($posY); - $label->setText('Ban'); - $label->setTextColor('700'); - - $posY -= $buttonSpacing * 2; - // Show Add as Master-Admin - $quad = clone $quad; - $frame->addChild($quad); - $quad->setY($posY); - $quad->setAction(self::ACTION_ADD_AS_MASTER . '.' . $login); - - $label = clone $label; - $frame->addChild($label); - $label->setY($posY); - $label->setText('Set SuperAdmin'); - $label->setTextColor($textColor); + $kickButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton( + '$f90Kick', + $buttonWidth, + $buttonHeight, + self::ACTION_KICK_PLAYER . '.' . $login + ); + $frame->addChild($kickButton); + $kickButton->setY($posY); $posY -= $buttonSpacing; - // Show Add as Admin - $quad = clone $quad; - $frame->addChild($quad); - $quad->setY($posY); - $quad->setAction(self::ACTION_ADD_AS_ADMIN . '.' . $login); - $label = clone $label; - $frame->addChild($label); - $label->setY($posY); - $label->setText('Set Admin'); - $label->setTextColor($textColor); + $banButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton( + '$700Kick', + $buttonWidth, + $buttonHeight, + self::ACTION_BAN_PLAYER . '.' . $login + ); + $frame->addChild($banButton); + $banButton->setY($posY); + + $posY -= 2 * $buttonSpacing; + + $superColor = $this->maniaControl->getColorManager()->getColorByLevel(AuthenticationManager::AUTH_LEVEL_SUPERADMIN); + $superButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton( + "{$superColor}Set SuperAdmin", + $buttonWidth, + $buttonHeight, + self::ACTION_ADD_AS_SUPER . '.' . $login + ); + $frame->addChild($superButton); + $superButton->setY($posY); $posY -= $buttonSpacing; - // Show Add as Moderator - $quad = clone $quad; - $frame->addChild($quad); - $quad->setY($posY); - $quad->setAction(self::ACTION_ADD_AS_MOD . '.' . $login); - $label = clone $label; - $frame->addChild($label); - $label->setY($posY); - $label->setText('Set Moderator'); - $label->setTextColor($textColor); + $adminColor = $this->maniaControl->getColorManager()->getColorByLevel(AuthenticationManager::AUTH_LEVEL_ADMIN); + $adminButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton( + "{$adminColor}Set Admin", + $buttonWidth, + $buttonHeight, + self::ACTION_ADD_AS_ADMIN . '.' . $login + ); + $frame->addChild($adminButton); + $adminButton->setY($posY); + + $posY -= $buttonSpacing; + + $modColor = $this->maniaControl->getColorManager()->getColorByLevel(AuthenticationManager::AUTH_LEVEL_MODERATOR); + $modButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton( + "{$modColor}Set Moderator", + $buttonWidth, + $buttonHeight, + self::ACTION_ADD_AS_MOD . '.' . $login + ); + $frame->addChild($modButton); + $modButton->setY($posY); if ($player->authLevel > 0 && $this->maniaControl->getAuthenticationManager()->checkRight($admin, $player->authLevel + 1) ) { $posY -= $buttonSpacing; - // Revoke Rights - $quad = clone $quad; - $frame->addChild($quad); - $quad->setY($posY); - $quad->setAction(self::ACTION_REVOKE_RIGHTS . '.' . $login); - $label = clone $label; - $frame->addChild($label); - $label->setY($posY); - $label->setText('Revoke Rights'); - $label->setTextColor('700'); + $revokeButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton( + '$700Revoke Rights', + $buttonWidth, + $buttonHeight, + self::ACTION_REVOKE_RIGHTS . '.' . $login + ); + $frame->addChild($revokeButton); + $revokeButton->setY($posY); } return $frame; @@ -735,6 +713,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $this->advancedPlayerWidget($admin, $targetLogin); break; case self::ACTION_ADD_AS_MASTER: + case self::ACTION_ADD_AS_SUPER: $this->maniaControl->getPlayerManager()->getPlayerActions()->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_SUPERADMIN); break; case self::ACTION_ADD_AS_ADMIN: From 5956bb292df1e080143ae7771059da18643509a7 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Sat, 9 May 2020 21:44:44 +0200 Subject: [PATCH 47/98] Settings of Legacy-Modes and client-functions have sometimes different names, calls could not be executed, fixed now --- core/Configurator/GameModeSettings.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/core/Configurator/GameModeSettings.php b/core/Configurator/GameModeSettings.php index faaeecc6..93b13b72 100644 --- a/core/Configurator/GameModeSettings.php +++ b/core/Configurator/GameModeSettings.php @@ -162,12 +162,27 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat * @return bool */ public function setGameModeSettingsArray(array $settings) { + static $settingToMethodReplace = array( + 'LapsNbLaps' => 'SetNbLaps', + 'RoundsForcedLaps' => 'SetRoundForcedLaps', + 'RoundsPointsLimit' => 'SetRoundPointsLimit', + 'RoundsUseNewRules' => 'SetUseNewRulesRound', + 'TeamMaxPoints' => 'SetMaxPointsTeam', + 'TeamUseNewRules' => 'SetUseNewRulesTeam', + ); + if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { return $this->maniaControl->getClient()->setModeScriptSettings($settings); } else { $success = true; foreach ($settings as $key => $value) { - $success &= $this->maniaControl->getClient()->execute('Set'.$key, array($value)); + if (array_key_exists($key, $settingToMethodReplace)) { + $key = $settingToMethodReplace[$key]; + } else { + $key = 'Set'.$key; + } + + $success &= $this->maniaControl->getClient()->execute($key, array($value)); } return $success; } From bd90714ed39dde4f16454cc0f5207997475c5d41 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Mon, 11 May 2020 17:05:56 +0200 Subject: [PATCH 48/98] Null-checks on KarmaGauge --- core/ManiaExchange/ManiaExchangeList.php | 6 ++++-- plugins/MCTeam/KarmaPlugin.php | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/ManiaExchange/ManiaExchangeList.php b/core/ManiaExchange/ManiaExchangeList.php index ee7b5a9f..cfc3709e 100644 --- a/core/ManiaExchange/ManiaExchangeList.php +++ b/core/ManiaExchange/ManiaExchangeList.php @@ -314,8 +314,10 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener 20, 10 ); - $mapFrame->addChild($karmaGauge); - $karmaGauge->setX($posX + 87); + if ($karmaGauge) { + $mapFrame->addChild($karmaGauge); + $karmaGauge->setX($posX + 87); + } $posY -= 4; diff --git a/plugins/MCTeam/KarmaPlugin.php b/plugins/MCTeam/KarmaPlugin.php index b1be99af..226d74a1 100644 --- a/plugins/MCTeam/KarmaPlugin.php +++ b/plugins/MCTeam/KarmaPlugin.php @@ -926,8 +926,10 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { 0.95*$width, 0.95*$height ); - $karmaGauge->setY(-0.15*$height); - $frame->addChild($karmaGauge); + if ($karmaGauge) { + $frame->addChild($karmaGauge); + $karmaGauge->setY(-0.15*$height); + } $this->maniaControl->getManialinkManager()->sendManialink($manialink); } From 7354ed278c1803a1262df7ff3255a1fd1adcbb6b Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Mon, 11 May 2020 17:14:10 +0200 Subject: [PATCH 49/98] Moved Default-Karma-Plugin constant --- core/Maps/MapCommands.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/Maps/MapCommands.php b/core/Maps/MapCommands.php index 0550c636..7a3c74f6 100644 --- a/core/Maps/MapCommands.php +++ b/core/Maps/MapCommands.php @@ -11,6 +11,7 @@ use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Commands\CommandListener; use ManiaControl\Logger; use ManiaControl\ManiaControl; +use ManiaControl\Manialinks\ElementBuilder; use ManiaControl\Manialinks\IconManager; use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Players\Player; @@ -427,7 +428,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb */ private function showMapListKarma($best, Player $player) { /** @var \MCTeam\KarmaPlugin $karmaPlugin */ - $karmaPlugin = $this->maniaControl->getPluginManager()->getPlugin(MapList::DEFAULT_KARMA_PLUGIN); + $karmaPlugin = $this->maniaControl->getPluginManager()->getPlugin(ElementBuilder::DEFAULT_KARMA_PLUGIN); if ($karmaPlugin) { $displayMxKarma = $this->maniaControl->getSettingManager()->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_WIDGET_DISPLAY_MX); From 9a259d79133c815aa32c4f1d0734c8bb9f14fb76 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Mon, 11 May 2020 17:19:35 +0200 Subject: [PATCH 50/98] Resolve Crash on //unban without login --- core/Players/PlayerActions.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/Players/PlayerActions.php b/core/Players/PlayerActions.php index f0038036..8a8ac27a 100644 --- a/core/Players/PlayerActions.php +++ b/core/Players/PlayerActions.php @@ -628,7 +628,7 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma //Todo Validate (Problem: Not connected player isFakePlayer) if ($target->isOfficial && $target->isFakePlayer()) { - $this->maniaControl->getChat()->sendError('It is not possible to Ban a bot', $admin); + $this->maniaControl->getChat()->sendError('It is not possible to Ban a bot!', $admin); return; } @@ -661,6 +661,17 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma return; } + $target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin); + if (!$target) { + return; + } + + //Todo Validate (Problem: Not connected player isFakePlayer) + if ($target->isOfficial && $target->isFakePlayer()) { + $this->maniaControl->getChat()->sendError('It is not possible to unban a bot!', $admin); + return; + } + try { $this->maniaControl->getClient()->unBan($targetLogin); } catch (NotInListException $e) { From fda5790af5fd93286c9bdeb2333dffef7da66ef4 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Mon, 11 May 2020 17:40:37 +0200 Subject: [PATCH 51/98] Rename table of gamemode-settings, if possible --- core/Configurator/GameModeSettings.php | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/core/Configurator/GameModeSettings.php b/core/Configurator/GameModeSettings.php index 93b13b72..96dd69ff 100644 --- a/core/Configurator/GameModeSettings.php +++ b/core/Configurator/GameModeSettings.php @@ -87,15 +87,26 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat */ private function initTables() { $mysqli = $this->maniaControl->getDatabase()->getMysqli(); - $query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_GAMEMODE_SETTINGS . "` ( + + $renameQuery = "ALTER TABLE `" . self::TABLE_SCRIPT_SETTINGS . "` RENAME TO `" . self::TABLE_GAMEMODE_SETTINGS . "`;"; + $result = $mysqli->query($renameQuery); + if (!$result) { + if ($mysqli->error === "Table '" . self::TABLE_GAMEMODE_SETTINGS . "' already exists") { + return true; + } else { + trigger_error($mysqli->error); + // can't rename, so continue + } + } + + $query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_GAMEMODE_SETTINGS . "` ( `index` int(11) NOT NULL AUTO_INCREMENT, `serverIndex` int(11) NOT NULL, `settingName` varchar(100) NOT NULL DEFAULT '', `settingValue` varchar(500) NOT NULL DEFAULT '', PRIMARY KEY (`index`), UNIQUE KEY `setting` (`serverIndex`, `settingName`) - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='Mode Settings' AUTO_INCREMENT=1;"; - + ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='GameMode-Settings' AUTO_INCREMENT=1;"; $statement = $mysqli->prepare($query); if ($mysqli->error) { trigger_error($mysqli->error, E_USER_ERROR); @@ -106,15 +117,8 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat trigger_error($statement->error, E_USER_ERROR); return false; } - - $dropQuery = "DROP TABLE IF EXISTS `" . self::TABLE_SCRIPT_SETTINGS . "`;"; - $result = $mysqli->query($dropQuery); - if (!$result) { - trigger_error($mysqli->error); - return false; - } - $statement->close(); + return true; } From 2257e4340487140b5d4a8653f3ec61632cbc6b47 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Sat, 16 May 2020 22:16:07 +0200 Subject: [PATCH 52/98] Improve Database-Rename --- core/Configurator/GameModeSettings.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/core/Configurator/GameModeSettings.php b/core/Configurator/GameModeSettings.php index 96dd69ff..97e55231 100644 --- a/core/Configurator/GameModeSettings.php +++ b/core/Configurator/GameModeSettings.php @@ -91,13 +91,23 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat $renameQuery = "ALTER TABLE `" . self::TABLE_SCRIPT_SETTINGS . "` RENAME TO `" . self::TABLE_GAMEMODE_SETTINGS . "`;"; $result = $mysqli->query($renameQuery); if (!$result) { - if ($mysqli->error === "Table '" . self::TABLE_GAMEMODE_SETTINGS . "' already exists") { - return true; + if (strpos($mysqli->error, "doesn't exist") !== false) { + // old doesn't exist, good, continue to force creation + } elseif (strpos($mysqli->error, "already exists") !== false) { + // new one exists, drop the old table, get out + $dropQuery = "DROP TABLE `" . self::TABLE_SCRIPT_SETTINGS . "`;"; + $result = $mysqli->query($dropQuery); + if (!$result) { + trigger_error($mysqli->error, E_USER_ERROR); + return false; + } } else { - trigger_error($mysqli->error); - // can't rename, so continue + // other error (successful rename would not have us got here) + trigger_error($mysqli->error, E_USER_ERROR); + return false; } } + // else rename happened, continue to force creation $query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_GAMEMODE_SETTINGS . "` ( `index` int(11) NOT NULL AUTO_INCREMENT, From 2f85e6bfcca374cde2169c0d40ece88c55394e61 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Sat, 16 May 2020 22:41:09 +0200 Subject: [PATCH 53/98] Updated Changelog & Version --- changelog.txt | 70 ++++++++++++++++++++++++++++++++++++++++++- core/ManiaControl.php | 2 +- 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index bccae2a2..e79fa438 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,12 +1,15 @@ ###v0.254### #Additions -- added first support of Legacy-Modes +- 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 @@ -43,6 +46,71 @@ - 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 diff --git a/core/ManiaControl.php b/core/ManiaControl.php index 238fa564..64d9c52b 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -55,7 +55,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, /* * Constants */ - const VERSION = '0.253'; + const VERSION = '0.254'; const API_VERSION = '2013-04-16'; const MIN_DEDIVERSION = '2017-05-03_21_00'; const SCRIPT_TIMEOUT = 40; From 01efa96f835a35b52df3c11f9922d5a34753a9ee Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Sun, 17 May 2020 19:43:58 +0200 Subject: [PATCH 54/98] Implemented first version of PresetPlugin for GameModes --- plugins/MCTeam/GameModePresetsPlugin.php | 380 +++++++++++++++++++++++ 1 file changed, 380 insertions(+) create mode 100644 plugins/MCTeam/GameModePresetsPlugin.php diff --git a/plugins/MCTeam/GameModePresetsPlugin.php b/plugins/MCTeam/GameModePresetsPlugin.php new file mode 100644 index 00000000..bc900f0d --- /dev/null +++ b/plugins/MCTeam/GameModePresetsPlugin.php @@ -0,0 +1,380 @@ + + * @copyright 2014-2020 ManiaControl Team + * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 + */ +class GameModePresetsPlugin implements Plugin, CommandListener, TimerListener { + /* + * Constants + */ + const PLUGIN_ID = 9; + const PLUGIN_VERSION = 0.1; + const PLUGIN_NAME = 'GameMode Presets Plugin'; + const PLUGIN_AUTHOR = 'MCTeam'; + + const PRESET_SETTING_MODE_NUMBER = 'Mode Number'; + const PRESET_SETTING_SCRIPT_NAME = 'Script Name'; + + const SETTING_MAP_ACTION_ON_LOADMODE = 'Map Action on //loadmode'; + const SETTING_MAP_ACTION_DELAY_ON_LOADMODE = 'Map Action Delay on //loadmode (in ms)'; + const SETTING_PERMISSION_LOAD_GAMEMODE_PRESET = 'Permission load GameMode Preset'; + const SETTING_PERMISSION_SAVE_GAMEMODE_PRESET = 'Permission save GameMode Preset'; + + const MAP_ACTION_ON_LOADMODE_NONE = 'None'; + const MAP_ACTION_ON_LOADMODE_RESTART = 'Restart Map'; + const MAP_ACTION_ON_LOADMODE_SKIP = 'Skip Map'; + + const TABLE_GAMEMODEPRESETS = 'mc_gamemodepresets'; + + /* + * Private properties + */ + /** @var ManiaControl $maniaControl * */ + private $maniaControl = null; + + + /** + * @see \ManiaControl\Plugins\Plugin::prepare() + */ + public static function prepare(ManiaControl $maniaControl) { + } + + /** + * @see \ManiaControl\Plugins\Plugin::load() + */ + public function load(ManiaControl $maniaControl) { + $this->maniaControl = $maniaControl; + + // Authentication Permission Level + $this->maniaControl->getAuthenticationManager()->definePluginPermissionLevel( + $this, + self::SETTING_PERMISSION_LOAD_GAMEMODE_PRESET, + AuthenticationManager::AUTH_LEVEL_ADMIN, + AuthenticationManager::AUTH_LEVEL_MODERATOR + ); + $this->maniaControl->getAuthenticationManager()->definePluginPermissionLevel( + $this, + self::SETTING_PERMISSION_SAVE_GAMEMODE_PRESET, + AuthenticationManager::AUTH_LEVEL_SUPERADMIN, + AuthenticationManager::AUTH_LEVEL_MODERATOR + ); + + // Settings + $this->maniaControl->getSettingManager()->initSetting( + $this, + self::SETTING_MAP_ACTION_ON_LOADMODE, + array( + self::MAP_ACTION_ON_LOADMODE_NONE, + self::MAP_ACTION_ON_LOADMODE_RESTART, + self::MAP_ACTION_ON_LOADMODE_SKIP, + ) + ); + $this->maniaControl->getSettingManager()->initSetting( + $this, + self::SETTING_MAP_ACTION_DELAY_ON_LOADMODE, + 1000 + ); + + // Commands + $this->maniaControl->getCommandManager()->registerCommandListener(array('loadmode', 'modeload'), $this, 'commandLoadMode', true, 'Loads the mode settings from the given preset name.'); + $this->maniaControl->getCommandManager()->registerCommandListener(array('savemode', 'modesave'), $this, 'commandSaveMode', true, 'Saves the mode settings under the given preset name.'); + + $this->initTables(); + } + + /** + * Initialize needed database tables + */ + private function initTables() { + $mysqli = $this->maniaControl->getDatabase()->getMysqli(); + $query = "CREATE TABLE IF NOT EXISTS `" . self::TABLE_GAMEMODEPRESETS . "` ( + `index` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(20) NOT NULL, + `settings` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, + PRIMARY KEY (`index`), + UNIQUE KEY (`name`) + ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;"; + $mysqli->query($query); + if ($mysqli->error) { + trigger_error($mysqli->error, E_USER_ERROR); + } + } + + /** + * Fetch preset from database + * @param string $name + * @return array|null + */ + private function fetchPreset($name) { + $mysqli = $this->maniaControl->getDatabase()->getMysqli(); + $query = "SELECT `settings` + FROM `" . self::TABLE_GAMEMODEPRESETS . "` + WHERE `name` LIKE ?;"; + + $statement = $mysqli->prepare($query); + if ($mysqli->error || !$statement) { + trigger_error($mysqli->error, E_USER_ERROR); + return null; + } + + $statement->bind_param('s', $name); + $statement->execute(); + if ($statement->error) { + trigger_error($statement->error); + $statement->close(); + return null; + } + + $settings = null; + $statement->store_result(); + $statement->bind_result($settings); + $statement->fetch(); + $statement->free_result(); + + return json_decode($settings, true); + } + + /** + * Fetch preset from database + * @param string $name + * @return array|null + */ + private function storePreset($name) { + $modeNumber = $this->maniaControl->getClient()->getGameMode(); + $scriptName = $this->maniaControl->getClient()->getScriptName()['CurrentValue']; + $settings = null; + if ($modeNumber === 0) { + $settings = $this->maniaControl->getClient()->getModeScriptSettings(); + } else { + $settings = $this->maniaControl->getClient()->execute('GetCurrentGameInfo'); + } + + $settings[self::PRESET_SETTING_MODE_NUMBER] = $modeNumber; + $settings[self::PRESET_SETTING_SCRIPT_NAME] = $scriptName; + $settings = json_encode($settings); + + $mysqli = $this->maniaControl->getDatabase()->getMysqli(); + $query = "INSERT INTO `" . self::TABLE_GAMEMODEPRESETS . "` + (`name`, `settings`) VALUES (?, ?) + ON DUPLICATE KEY UPDATE `settings` = VALUES(`settings`);"; + + $statement = $mysqli->prepare($query); + if ($mysqli->error || !$statement) { + trigger_error($mysqli->error, E_USER_ERROR); + return false; + } + + $statement->bind_param('ss', $name, $settings); + $statement->execute(); + if ($statement->error) { + trigger_error($statement->error); + return false; + } + + $statement->close(); + return true; + } + + /** + * Load Script + * @param string $scriptName + */ + private function loadScript($scriptName) { + static $scriptsDir = null; + if ($scriptsDir === null) + { + $scriptsDataDir = FileUtil::shortenPath($this->maniaControl->getServer()->getDirectory()->getScriptsFolder()); + if ($this->maniaControl->getServer()->checkAccess($scriptsDataDir)) + { + $gameShort = $this->maniaControl->getMapManager()->getCurrentMap()->getGame(); + $game = ''; + switch ($gameShort) + { + case 'qm': $game = 'QuestMania'; break; + case 'sm': $game = 'ShootMania'; break; + case 'tm': $game = 'TrackMania'; break; + } + + if ($game != '') + { + $scriptsDir = $scriptsDataDir.DIRECTORY_SEPARATOR.'Modes'.DIRECTORY_SEPARATOR.$game.DIRECTORY_SEPARATOR; + if (!$this->maniaControl->getServer()->checkAccess($scriptsDir)) + $scriptsDir = null; + } + } + + if ($scriptsDir === null) + throw new \Exception('Scripts directory not found, unable to load different scripts!'); + } + + $scriptPath = $scriptsDir.$scriptName; + if (!file_exists($scriptPath)) + throw new \Exception('Script not found ('.$scriptPath.').'); + + $scriptText = file_get_contents($scriptPath); + + $this->maniaControl->getClient()->setModeScriptText($scriptText); + $this->maniaControl->getClient()->setScriptName($scriptName); + } + + /** + * Handle //loadmode command + * + * @param array $chatCallback + * @param \ManiaControl\Players\Player $player + */ + public function commandLoadMode(array $chatCallback, Player $player) { + if (!$this->maniaControl->getAuthenticationManager()->checkPluginPermission($this, $player, self::SETTING_PERMISSION_LOAD_GAMEMODE_PRESET)) { + $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); + return; + } + + // Check for delayed shutdown + $params = explode(' ', $chatCallback[1][2]); + if (count($params) < 2) { + $this->maniaControl->getChat()->sendError('You must provide a gamemode preset name to load settings from!', $player); + return; + } elseif (count($params) > 2) { + $this->maniaControl->getChat()->sendError('You can only provide one gamemode preset name to load settings from!', $player); + return; + } + + $presetName = strtolower($params[1]); + $presetSettings = $this->fetchPreset($presetName); + if (!$presetSettings) { + $this->maniaControl->getChat()->sendError('The gamemode preset $<$fff' . $presetName . '$> does not exist!', $player); + return; + } + + $modeNumber = $presetSettings[self::PRESET_SETTING_MODE_NUMBER]; + $scriptName = $presetSettings[self::PRESET_SETTING_SCRIPT_NAME]; + unset($presetSettings[self::PRESET_SETTING_MODE_NUMBER]); + unset($presetSettings[self::PRESET_SETTING_SCRIPT_NAME]); + + // this is a hack, because this setting always throws errors otherwise + $presetSettings['S_MatchmakingRematchRatio'] = floatval($presetSettings['S_MatchmakingRematchRatio']); + + try { + $this->maniaControl->getClient()->setGameMode($modeNumber); + if ($modeNumber === 0) { + $this->loadScript($scriptName); + $this->maniaControl->getClient()->setModeScriptSettings($presetSettings); + } else { + $this->maniaControl->getClient()->setScriptName($scriptName); + $this->maniaControl->getClient()->execute('SetGameInfos', $presetSettings); + } + } catch (\Exception $e) { + $this->maniaControl->getChat()->sendException($e, $player); + $this->maniaControl->getChat()->sendError('Unable to load gamemode preset $<$fff' . $presetName . '$>!', $player); + return; + } + + $this->maniaControl->getChat()->sendSuccess($player->getEscapedNickname() . ' loaded gamemode preset $<$fff' . $presetName . '$>!'); + $this->maniaControl->getTimerManager()->registerOneTimeListening( + $this, + function () { + $mapActionOnLoadmode = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_ACTION_ON_LOADMODE); + switch ($mapActionOnLoadmode) { + case self::MAP_ACTION_ON_LOADMODE_NONE: + break; + case self::MAP_ACTION_ON_LOADMODE_RESTART: + $this->maniaControl->getMapManager()->getMapActions()->restartMap(); + break; + case self::MAP_ACTION_ON_LOADMODE_SKIP: + $this->maniaControl->getMapManager()->getMapActions()->skipMap(); + break; + } + }, + $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_ACTION_DELAY_ON_LOADMODE) + ); + } + + /** + * Handle //savemode command + * + * @param array $chatCallback + * @param \ManiaControl\Players\Player $player + */ + public function commandSaveMode(array $chatCallback, Player $player) { + if (!$this->maniaControl->getAuthenticationManager()->checkPluginPermission($this, $player, self::SETTING_PERMISSION_LOAD_GAMEMODE_PRESET)) { + $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); + return; + } + + // Check for delayed shutdown + $params = explode(' ', $chatCallback[1][2]); + if (count($params) < 2) { + $this->maniaControl->getChat()->sendError('You must provide a gamemode preset name to save settings into!', $player); + return; + } elseif (count($params) > 2) { + $this->maniaControl->getChat()->sendError('You can only provide one gamemode preset name to save settings into!', $player); + return; + } + + $presetName = strtolower($params[1]); + try { + $this->storePreset($presetName); + } catch (\Exception $e) { + $this->maniaControl->getChat()->sendException($e, $player); + $this->maniaControl->getChat()->sendError('Unable to save gamemode preset $<$fff' . $presetName . '$>!', $player); + return; + } + + $this->maniaControl->getChat()->sendSuccess($player->getEscapedNickname() . ' saved gamemode settings in preset $<$fff"' . $presetName . '"$>!'); + } + + /** + * @see \ManiaControl\Plugins\Plugin::getId() + */ + public static function getId() { + return self::PLUGIN_ID; + } + + /** + * @see \ManiaControl\Plugins\Plugin::getName() + */ + public static function getName() { + return self::PLUGIN_NAME; + } + + /** + * @see \ManiaControl\Plugins\Plugin::getVersion() + */ + public static function getVersion() { + return self::PLUGIN_VERSION; + } + + /** + * @see \ManiaControl\Plugins\Plugin::getAuthor() + */ + public static function getAuthor() { + return self::PLUGIN_AUTHOR; + } + + /** + * @see \ManiaControl\Plugins\Plugin::getDescription() + */ + public static function getDescription() { + return "Plugin offers presets functionalites for GameModes"; + } + + /** + * @see \ManiaControl\Plugins\Plugin::unload() + */ + public function unload() { + } +} From 014892326814e9d725d48855d1f6350e1ca8bb65 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Mon, 18 May 2020 08:06:41 +0200 Subject: [PATCH 55/98] Added filter and sort settings to GameMode-Settings --- core/Configurator/GameModeSettings.php | 51 ++++++++++++++++++-------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/core/Configurator/GameModeSettings.php b/core/Configurator/GameModeSettings.php index 97e55231..97f54912 100644 --- a/core/Configurator/GameModeSettings.php +++ b/core/Configurator/GameModeSettings.php @@ -35,20 +35,26 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat /* * Constants */ - const ACTION_PREFIX_SETTING = 'GameModeSetting.'; - const CB_GAMEMODESETTING_CHANGED = 'GameModeSettings.SettingChanged'; - const CB_GAMEMODESETTINGS_CHANGED = 'GameModeSettings.SettingsChanged'; + const ACTION_PREFIX_SETTING = 'GameModeSetting.'; + const CB_GAMEMODESETTING_CHANGED = 'GameModeSettings.SettingChanged'; + const CB_GAMEMODESETTINGS_CHANGED = 'GameModeSettings.SettingsChanged'; /** @deprecated */ - const CB_SCRIPTSETTING_CHANGED = 'GameModeSettings.SettingChanged'; + const CB_SCRIPTSETTING_CHANGED = 'GameModeSettings.SettingChanged'; /** @deprecated */ - const CB_SCRIPTSETTINGS_CHANGED = 'GameModeSettings.SettingsChanged'; - const TABLE_GAMEMODE_SETTINGS = 'mc_gamemodesettings'; + const CB_SCRIPTSETTINGS_CHANGED = 'GameModeSettings.SettingsChanged'; + + const TABLE_GAMEMODE_SETTINGS = 'mc_gamemodesettings'; /** @deprecated */ - const TABLE_SCRIPT_SETTINGS = 'mc_scriptsettings'; - const SETTING_LOAD_DEFAULT_SETTINGS_MAP_BEGIN = 'Load Stored GameMode-Settings on Map-Begin'; - const SETTING_PERMISSION_CHANGE_MODE_SETTINGS = 'Change GameMode-Settings'; + const TABLE_SCRIPT_SETTINGS = 'mc_scriptsettings'; + + const DESCRIPTION_HIDDEN = ''; + + const SETTING_HIDE_SETTINGS_WITH_DESCRIPTION_HIDDEN = 'Hide Settings with Description "' . self::DESCRIPTION_HIDDEN . '"'; + const SETTING_LOAD_DEFAULT_SETTINGS_MAP_BEGIN = 'Load Stored GameMode-Settings on Map-Begin'; + const SETTING_PERMISSION_CHANGE_MODE_SETTINGS = 'Change GameMode-Settings'; /** @deprecated */ - const SETTING_PERMISSION_CHANGE_SCRIPT_SETTINGS = 'Change Script-Settings'; + const SETTING_PERMISSION_CHANGE_SCRIPT_SETTINGS = 'Change Script-Settings'; + const SETTING_SORT_SETTINGS = 'Sort Settings'; /* * Private properties @@ -70,7 +76,9 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat $this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'onBeginMap'); // Settings + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_HIDE_SETTINGS_WITH_DESCRIPTION_HIDDEN, true); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_LOAD_DEFAULT_SETTINGS_MAP_BEGIN, false); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SORT_SETTINGS, true); // Permissions $this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_MODE_SETTINGS, AuthenticationManager::AUTH_LEVEL_ADMIN); @@ -270,6 +278,8 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat * @see \ManiaControl\Configurator\ConfiguratorMenu::getMenu() */ public function getMenu($width, $height, Script $script, Player $player) { + $isScriptMode = $this->maniaControl->getServer()->getScriptManager()->isScriptMode(); + $paging = new Paging(); $script->addFeature($paging); $frame = new Frame(); @@ -280,11 +290,22 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat try { $gameModeSettings = $this->getGameModeSettingsArray(); - if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { + if ($isScriptMode) { $scriptInfo = $this->maniaControl->getClient()->getModeScriptInfo(); $scriptParams = $scriptInfo->paramDescs; + + $hideSettingsWithDescriptionHidden = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_HIDE_SETTINGS_WITH_DESCRIPTION_HIDDEN); + if ($hideSettingsWithDescriptionHidden) { + $scriptParams = array_filter($scriptParams, function ($scriptParam) { + return $scriptParam->desc !== self::DESCRIPTION_HIDDEN; + }); + } + usort($scriptParams, function ($a, $b) { + return $a->name === $b->name ? 0 : ($a->name < $b->name ? -1 : 1); + }); } else { $scriptParams = $gameModeSettings[0]; + ksort($scriptParams); } } catch (\Exception $e) { $label = new Label(); @@ -323,7 +344,7 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat $paging->setLabel($pageCountLabel); - if (!$this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { + if (!$isScriptMode) { $descriptionLabel = new Label(); $frame->addChild($descriptionLabel); $descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT); @@ -343,7 +364,7 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat foreach ($scriptParams as $key => $scriptParam) { $settingName = null; $settingValue = null; - if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { + if ($isScriptMode) { $settingName = $scriptParam->name; if (!isset($gameModeSettings[$settingName])) { continue; @@ -380,7 +401,7 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat $nameLabel->setTextSize($labelTextSize); $nameLabel->setX(-0.46 * $width); - if (!$this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { + if (!$isScriptMode) { if (is_bool($settingValue[0])) { $activeQuad = new Quad_Icons64x64_1(); $settingFrame->addChild($activeQuad); @@ -426,7 +447,7 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat $entry->setX(0.275 * $width); } - if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) { + if ($isScriptMode) { $descriptionLabel = new Label(); $pageFrame->addChild($descriptionLabel); $descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT); From 50408c75f676ef7cb37a08a8becc987c06b883e8 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Mon, 18 May 2020 08:46:19 +0200 Subject: [PATCH 56/98] Add CSV-export of local records --- core/Utils/DataUtil.php | 26 ++++++++++ plugins/MCTeam/LocalRecordsPlugin.php | 69 +++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/core/Utils/DataUtil.php b/core/Utils/DataUtil.php index 0a3d2d70..9c815ee4 100644 --- a/core/Utils/DataUtil.php +++ b/core/Utils/DataUtil.php @@ -63,6 +63,32 @@ abstract class DataUtil { } } + /** + * Checks, if a string ends with the given substring. + * @param string $haystack + * @param string $needle + * @return bool + */ + public static function endsWith($haystack, $needle) { + $length = strlen($needle); + if ($length == 0) { + return true; + } + + return (substr($haystack, -$length) === $needle); + } + + /** + * Checks, if a string starts with the given substring. + * @param string $haystack + * @param string $needle + * @return bool + */ + public static function startsWith($haystack, $needle) { + $length = strlen($needle); + return (substr($haystack, 0, $length) === $needle); + } + /** * Implodes sub-arrays with position properties. * diff --git a/plugins/MCTeam/LocalRecordsPlugin.php b/plugins/MCTeam/LocalRecordsPlugin.php index 8bf952c4..ab23c79b 100644 --- a/plugins/MCTeam/LocalRecordsPlugin.php +++ b/plugins/MCTeam/LocalRecordsPlugin.php @@ -27,6 +27,7 @@ use ManiaControl\Players\PlayerManager; use ManiaControl\Plugins\Plugin; use ManiaControl\Settings\Setting; use ManiaControl\Settings\SettingManager; +use ManiaControl\Utils\DataUtil; use ManiaControl\Utils\Formatter; use MCTeam\Common\RecordWidget; @@ -64,6 +65,7 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command const SETTING_RECORDS_BEFORE_AFTER = 'Number of Records displayed before and after a player'; const CB_LOCALRECORDS_CHANGED = 'LocalRecords.Changed'; const ACTION_SHOW_RECORDSLIST = 'LocalRecords.ShowRecordsList'; + const CSV_SPLITTER = ';'; /* @@ -171,6 +173,7 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command $this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_ONFINISHLINE, $this, 'handleFinishCallback'); $this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::TM_ONLAPFINISH, $this, 'handleFinishLapCallback'); + $this->maniaControl->getCommandManager()->registerCommandListener(array('exportrecs', 'exportrecords', 'recexport'), $this, 'exportRecordsList', true, 'Exports the records of a map to a CSV-file.'); $this->maniaControl->getCommandManager()->registerCommandListener(array('recs', 'records'), $this, 'showRecordsList', false, 'Shows a list of Local Records on the current map.'); $this->maniaControl->getCommandManager()->registerCommandListener('delrec', $this, 'deletePersonalRecord', false, 'Removes your record from the database.'); $this->maniaControl->getCommandManager()->registerCommandListener('delrec', $this, 'deleteAnyRecord', true, 'Removes any record from the database.'); @@ -691,6 +694,72 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command $this->showRecordsList(array(), $player); } + /** + * Exports the Records of a map to a CSV-file + * + * @api + * @param array $chat + * @param Player $player + */ + public function exportRecordsList(array $chat, Player $player) { + if (!$this->maniaControl->getAuthenticationManager()->checkPluginPermission($this, $player, self::PERMISSION_DELETE_ANY_RECORD)) { + $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); + return; + } + + $commandParts = explode(' ', $chat[1][2]); + if (count($commandParts) < 2 || strlen($commandParts[1]) == 0) { + $this->maniaControl->getChat()->sendUsageInfo('Missing CSV-Filename ID! (Example: //exportrecs locals.csv)', $player); + return; + } + + $filename = $commandParts[1]; + if (!DataUtil::endsWith($filename, '.csv')) { + $filename .= '.csv'; + } + + $map = null; + if (count($commandParts) >= 3) { + $mapId = (int) $commandParts[2]; + if ($mapId <= 0) { + $this->maniaControl->getChat()->sendUsageInfo('Map-Id below 1!', $player); + return; + } + + $mapIndex = $mapId-1; + $map = $this->maniaControl->getMapManager()->getMapByIndex($mapIndex); + if (!$map) { + $this->maniaControl->getChat()->sendUsageInfo('Map-Id too high!', $player); + return; + } + } else { + $map = $this->maniaControl->getMapManager()->getCurrentMap(); + } + + $records = $this->getLocalRecords($map); + $lines = array(); + $header = array('rank', 'login', 'time', 'checkpoints'); + array_push($lines, implode(self::CSV_SPLITTER, $header)); + + foreach ($records as $record) { + $line = array( + $record->rank, + $record->login, + $record->time, + $record->checkpoints, + ); + array_push($lines, implode(self::CSV_SPLITTER, $line)); + } + + try { + file_put_contents($filename, implode(PHP_EOL, $lines)); + } catch (\Exception $e) { + $this->maniaControl->getChat()->sendException($e, $player); + } + + $this->maniaControl->getChat()->sendSuccess('Successfully exported Local Records of map ' . $map->getEscapedName() . ' to $<$fff' . $filename . '$>!'); + } + /** * Shows a ManiaLink list with the local records. * From c4c47d0f9e9a47956c12419adf17d33a95e0d495 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Mon, 18 May 2020 08:46:26 +0200 Subject: [PATCH 57/98] Update Changelog --- changelog.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/changelog.txt b/changelog.txt index e79fa438..edfaddd3 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,9 @@ +###v0.255### +#Additions +- add Setting to hide Script-Settings which have the description "" +- add Setting to sort GameMode-Settings +- CSV-Export of Locals (//exportrecs [map-id]) + ###v0.254### #Additions - added small scale support for Legacy-Modes From 85435c1b4ba31a2a8cc939978d9913342af793ea Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Mon, 18 May 2020 18:54:55 +0200 Subject: [PATCH 58/98] Fixed Typo in Actions Panel of Player List --- core/Players/PlayerList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/Players/PlayerList.php b/core/Players/PlayerList.php index 93d1c4e2..6e4f91fa 100644 --- a/core/Players/PlayerList.php +++ b/core/Players/PlayerList.php @@ -559,7 +559,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $posY -= $buttonSpacing; $banButton = $this->maniaControl->getManialinkManager()->getElementBuilder()->buildRoundTextButton( - '$700Kick', + '$700Ban', $buttonWidth, $buttonHeight, self::ACTION_BAN_PLAYER . '.' . $login From 64e136e9e414b748a54d62d6b595011479550c53 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 19 May 2020 13:45:42 +0200 Subject: [PATCH 59/98] Check on error number rather than error message --- core/Configurator/GameModeSettings.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/Configurator/GameModeSettings.php b/core/Configurator/GameModeSettings.php index 97f54912..8c9b59cb 100644 --- a/core/Configurator/GameModeSettings.php +++ b/core/Configurator/GameModeSettings.php @@ -98,10 +98,11 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat $renameQuery = "ALTER TABLE `" . self::TABLE_SCRIPT_SETTINGS . "` RENAME TO `" . self::TABLE_GAMEMODE_SETTINGS . "`;"; $result = $mysqli->query($renameQuery); + var_dump($mysqli); if (!$result) { - if (strpos($mysqli->error, "doesn't exist") !== false) { + if ($mysqli->errno === 1146) { // old doesn't exist, good, continue to force creation - } elseif (strpos($mysqli->error, "already exists") !== false) { + } elseif ($mysqli->errno === 1050) { // new one exists, drop the old table, get out $dropQuery = "DROP TABLE `" . self::TABLE_SCRIPT_SETTINGS . "`;"; $result = $mysqli->query($dropQuery); From fea298cf583e3d6b13e4076f2824e7c55e0caee5 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 19 May 2020 13:46:45 +0200 Subject: [PATCH 60/98] Remove left over var_dump --- core/Configurator/GameModeSettings.php | 1 - 1 file changed, 1 deletion(-) diff --git a/core/Configurator/GameModeSettings.php b/core/Configurator/GameModeSettings.php index 8c9b59cb..47a21a5b 100644 --- a/core/Configurator/GameModeSettings.php +++ b/core/Configurator/GameModeSettings.php @@ -98,7 +98,6 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat $renameQuery = "ALTER TABLE `" . self::TABLE_SCRIPT_SETTINGS . "` RENAME TO `" . self::TABLE_GAMEMODE_SETTINGS . "`;"; $result = $mysqli->query($renameQuery); - var_dump($mysqli); if (!$result) { if ($mysqli->errno === 1146) { // old doesn't exist, good, continue to force creation From ace0782d7c7a0f7a2c4bc5b7977d4b8604069818 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 19 May 2020 14:00:52 +0200 Subject: [PATCH 61/98] Fixed database migration error handling on local records --- plugins/MCTeam/LocalRecordsPlugin.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/MCTeam/LocalRecordsPlugin.php b/plugins/MCTeam/LocalRecordsPlugin.php index ab23c79b..949b4a26 100644 --- a/plugins/MCTeam/LocalRecordsPlugin.php +++ b/plugins/MCTeam/LocalRecordsPlugin.php @@ -206,7 +206,8 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command $mysqli->query("ALTER TABLE `" . self::TABLE_RECORDS . "` ADD `checkpoints` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL"); if ($mysqli->error) { - if (!strstr($mysqli->error, 'Duplicate')) { + if ($mysqli->errno === 1062) { + // Duplicate trigger_error($mysqli->error, E_USER_ERROR); } } From 037534411ec0b4a2f7c603fe8097ae05c354fa69 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 19 May 2020 14:30:31 +0200 Subject: [PATCH 62/98] Add setting to change dedi message format --- plugins/MCTeam/Dedimania/DedimaniaPlugin.php | 22 ++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php index e5a3ea08..ebc81d40 100644 --- a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php +++ b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php @@ -49,8 +49,9 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene const SETTING_WIDGET_LINE_COUNT = 'Widget Displayed Lines Count'; const SETTING_WIDGET_LINE_HEIGHT = 'Widget Line Height'; const SETTING_DEDIMANIA_CODE = '$l[http://dedimania.net/tm2stats/?do=register]Dedimania Code for '; - const SETTING_NOTIFY_BEST_RECORDS_PUBLIC = 'Notify Publicly only for the X Best Records'; + const SETTING_NOTIFICATION_MESSAGE_PREFIX = 'Notification Message Prefix'; const SETTING_NOTIFY_BEST_RECORDS_PRIVATE = 'Notify Privately only for the X Best Records'; + const SETTING_NOTIFY_BEST_RECORDS_PUBLIC = 'Notify Publicly only for the X Best Records'; const SETTING_MAX_RECORDS = 'Max Records, only increase if you bought a rank update from Dedimania!'; const CB_DEDIMANIA_CHANGED = 'Dedimania.Changed'; @@ -104,6 +105,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_WIDTH, 40); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_LINE_HEIGHT, 4); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_LINE_COUNT, 12); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NOTIFICATION_MESSAGE_PREFIX, '$3c0'); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NOTIFY_BEST_RECORDS_PRIVATE, 30); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NOTIFY_BEST_RECORDS_PUBLIC, 15); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAX_RECORDS, 30); @@ -382,15 +384,27 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene $notifyName = 'You'; } - $message = '$390$<$fff' . $notifyName . '$> ' . $improvement . ' $<$ff0' . $newRecord->rank . '.$> Dedimania Record: $<$fff' . Formatter::formatTime($newRecord->best) . '$>'; + $messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NOTIFICATION_MESSAGE_PREFIX); + $message = $messagePrefix . '$<$fff' . $notifyName . '$> ' . $improvement . ' $<$ff0' . $newRecord->rank . '.$> Dedimania Record: $<$fff' . Formatter::formatTime($newRecord->best) . '$>'; if (!$oldRecord->nullRecord) { $message .= ' ($<$ff0' . $oldRecord->rank . '.$> $<$fff-' . Formatter::formatTime(($oldRecord->best - $recTime)) . '$>)'; } + $message .= '!'; if ($newRecord->rank <= $notifyOnlyBestRecordsPublic) { - $this->maniaControl->getChat()->sendInformation($message . '!'); + $this->maniaControl->getCallQueueManager()->registerListening( + $this, + function () use ($message) { + $this->maniaControl->getChat()->sendInformation($message); + } + ); } elseif ($newRecord->rank <= $notifyOnlyBestRecordsPrivate) { - $this->maniaControl->getChat()->sendInformation($message . '!', $player); + $this->maniaControl->getCallQueueManager()->registerListening( + $this, + function () use ($message, $player) { + $this->maniaControl->getChat()->sendInformation($message, $player); + } + ); } $this->webHandler->maniaLinkUpdateNeeded(); From d6487953fee11dd8387f5095c8c2e6fb9351e8bb Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 19 May 2020 14:40:19 +0200 Subject: [PATCH 63/98] Fixed Dedimania-Crash & Message-Format-Default --- plugins/MCTeam/Dedimania/DedimaniaPlugin.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php index ebc81d40..99f82da5 100644 --- a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php +++ b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php @@ -11,6 +11,7 @@ use FML\Script\Features\Paging; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\Callbacks; +use ManiaControl\Callbacks\CallQueueListener; use ManiaControl\Callbacks\Structures\TrackMania\OnWayPointEventStructure; use ManiaControl\Callbacks\TimerListener; use ManiaControl\Commands\CommandListener; @@ -31,7 +32,7 @@ use MCTeam\Common\RecordWidget; * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListener, Plugin { +class DedimaniaPlugin implements CallbackListener, CallQueueListener, CommandListener, TimerListener, Plugin { /* * Constants */ @@ -105,7 +106,7 @@ class DedimaniaPlugin implements CallbackListener, CommandListener, TimerListene $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_WIDTH, 40); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_LINE_HEIGHT, 4); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_LINE_COUNT, 12); - $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NOTIFICATION_MESSAGE_PREFIX, '$3c0'); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NOTIFICATION_MESSAGE_PREFIX, '$390'); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NOTIFY_BEST_RECORDS_PRIVATE, 30); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_NOTIFY_BEST_RECORDS_PUBLIC, 15); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAX_RECORDS, 30); From ab3e39086c55ac3f9c7ae032da6abdf3b1ffeff9 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 19 May 2020 14:41:35 +0200 Subject: [PATCH 64/98] New Plugin-Install-Filter for MC-version eligibility --- core/Plugins/InstallMenu.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/core/Plugins/InstallMenu.php b/core/Plugins/InstallMenu.php index 679d28de..2ee1e66f 100644 --- a/core/Plugins/InstallMenu.php +++ b/core/Plugins/InstallMenu.php @@ -31,6 +31,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener { const ACTION_PREFIX_INSTALL_PLUGIN = 'PluginInstallMenu.Install.'; const ACTION_REFRESH_LIST = 'PluginInstallMenu.RefreshList'; const SETTING_GAME_ONLY = 'Display only Plugins eligible for your game'; + const SETTING_VERSION_ONLY = 'Display only Plugins eligible for your MC-version'; /* * Private properties @@ -51,6 +52,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener { //Settings $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_GAME_ONLY, true); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_VERSION_ONLY, true); // Callbacks $this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_REFRESH_LIST, $this, 'handleRefreshListAction'); @@ -67,8 +69,8 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener { * @see \ManiaControl\Configurator\ConfiguratorMenu::getMenu() */ public function getMenu($width, $height, Script $script, Player $player) { - - $gameOnly = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_GAME_ONLY); + $gameOnly = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_GAME_ONLY); + $versionOnly = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_VERSION_ONLY); $paging = new Paging(); $script->addFeature($paging); @@ -128,6 +130,11 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener { continue; } + $isPluginCompatible = $this->isPluginCompatible($plugin); + if ($versionOnly && !$isPluginCompatible) { + continue; + } + if ($index % 10 === 0) { // New page $pageFrame = new Frame(); @@ -148,7 +155,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener { $infoTooltipLabel->setLineSpacing(1); $nameLabel->addTooltipLabelFeature($infoTooltipLabel, $description); - if (!$this->isPluginCompatible($plugin)) { + if (!$isPluginCompatible) { // Incompatibility label $infoLabel = new Label_Text(); $pluginFrame->addChild($infoLabel); From 7dd6aa096e6178de5ea906038b848f5a62e43deb Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 19 May 2020 14:53:05 +0200 Subject: [PATCH 65/98] Bump Plugin Version --- plugins/MCTeam/Dedimania/DedimaniaPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php index 99f82da5..cbe76e4a 100644 --- a/plugins/MCTeam/Dedimania/DedimaniaPlugin.php +++ b/plugins/MCTeam/Dedimania/DedimaniaPlugin.php @@ -37,7 +37,7 @@ class DedimaniaPlugin implements CallbackListener, CallQueueListener, CommandLis * Constants */ const ID = 8; - const VERSION = 0.61; + const VERSION = 0.62; const AUTHOR = 'MCTeam'; const NAME = 'Dedimania Plugin'; const MLID_DEDIMANIA = 'Dedimania.ManialinkId'; From 7089fa1de6a20f6412e82a67e3753dd625a89df8 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 19 May 2020 15:19:42 +0200 Subject: [PATCH 66/98] New setting for local-only votes --- plugins/MCTeam/KarmaPlugin.php | 52 +++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/plugins/MCTeam/KarmaPlugin.php b/plugins/MCTeam/KarmaPlugin.php index 226d74a1..1d2337a3 100644 --- a/plugins/MCTeam/KarmaPlugin.php +++ b/plugins/MCTeam/KarmaPlugin.php @@ -33,23 +33,25 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { /* * Constants */ - const ID = 2; - const VERSION = 0.1; - const NAME = 'Karma Plugin'; - const AUTHOR = 'MCTeam'; - const MLID_KARMA = 'KarmaPlugin.MLID'; - const TABLE_KARMA = 'mc_karma'; - const CB_KARMA_CHANGED = 'KarmaPlugin.Changed'; - const CB_KARMA_MXUPDATED = 'KarmaPlugin.MXUpdated'; - const SETTING_AVAILABLE_VOTES = 'Available Votes (X-Y: Comma separated)'; - const SETTING_WIDGET_ENABLE = 'Enable Karma Widget'; - const SETTING_WIDGET_TITLE = 'Widget-Title'; - const SETTING_WIDGET_POSX = 'Widget-Position: X'; - const SETTING_WIDGET_POSY = 'Widget-Position: Y'; - const SETTING_WIDGET_WIDTH = 'Widget-Size: Width'; - const SETTING_WIDGET_HEIGHT = 'Widget-Size: Height'; - const SETTING_NEWKARMA = 'Enable "new karma" (percentage), disable = RASP karma'; - const STAT_PLAYER_MAPVOTES = 'Voted Maps'; + const ID = 2; + const VERSION = 0.2; + const NAME = 'Karma Plugin'; + const AUTHOR = 'MCTeam'; + const MLID_KARMA = 'KarmaPlugin.MLID'; + const TABLE_KARMA = 'mc_karma'; + const CB_KARMA_CHANGED = 'KarmaPlugin.Changed'; + const CB_KARMA_MXUPDATED = 'KarmaPlugin.MXUpdated'; + const DEFAULT_LOCAL_RECORDS_PLUGIN = 'MCTeam\LocalRecordsPlugin'; + const SETTING_ALLOW_ON_LOCAL = 'Player can only vote when having a local record'; + const SETTING_AVAILABLE_VOTES = 'Available Votes (X-Y: Comma separated)'; + const SETTING_WIDGET_ENABLE = 'Enable Karma Widget'; + const SETTING_WIDGET_TITLE = 'Widget-Title'; + const SETTING_WIDGET_POSX = 'Widget-Position: X'; + const SETTING_WIDGET_POSY = 'Widget-Position: Y'; + const SETTING_WIDGET_WIDTH = 'Widget-Size: Width'; + const SETTING_WIDGET_HEIGHT = 'Widget-Size: Height'; + const SETTING_NEWKARMA = 'Enable "new karma" (percentage), disable = RASP karma'; + const STAT_PLAYER_MAPVOTES = 'Voted Maps'; /* * Constants MX Karma @@ -143,6 +145,7 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { $this->initTables(); // Settings + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_ALLOW_ON_LOCAL, false); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_AVAILABLE_VOTES, '-2,2'); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_ENABLE, true); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_TITLE, 'Map-Karma'); @@ -587,6 +590,21 @@ class KarmaPlugin implements CallbackListener, TimerListener, Plugin { if ($countPositive <= 0 && $countNegative <= 0) { return; } + // we have a vote-message + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_ALLOW_ON_LOCAL)) { + $localRecordPlugin = $this->maniaControl->getPluginManager()->getPlugin(self::DEFAULT_LOCAL_RECORDS_PLUGIN); + if (!$localRecordPlugin) { + return; + } + + $currentMap = $this->maniaControl->getMapManager()->getCurrentMap(); + $localRecord = $localRecordPlugin->getLocalRecord($currentMap, $player); + if ($localRecord === null) { + $this->maniaControl->getChat()->sendError('You need to have a local record on this map before voting.', $player->login); + return; + } + } + $vote = $countPositive - $countNegative; $success = $this->handleVote($player, $vote); if (!$success) { From 7b0e16bfdf400f380dfe0db97a84d09f00b01ac9 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 19 May 2020 15:22:17 +0200 Subject: [PATCH 67/98] Update Changelog --- changelog.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/changelog.txt b/changelog.txt index edfaddd3..2cc0e508 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,9 +1,16 @@ ###v0.255### #Additions +- add Setting to allow Karma-Votes only if player has local +- add Setting to change Dedimania-Message formatting +- add Setting to hide Plugins to install for incompatible version of ManiaControl - add Setting to hide Script-Settings which have the description "" - add Setting to sort GameMode-Settings - CSV-Export of Locals (//exportrecs [map-id]) +#Bug Fixes +- 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 From 8760364d826c72acb88346cc491a63a25ba09b9d Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 19 May 2020 20:48:56 +0200 Subject: [PATCH 68/98] Deactivate a plugin, if it throws an exception --- core/ErrorHandler.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/core/ErrorHandler.php b/core/ErrorHandler.php index 05de9916..d139e481 100644 --- a/core/ErrorHandler.php +++ b/core/ErrorHandler.php @@ -122,13 +122,12 @@ class ErrorHandler { $report['FileLine'] = self::stripBaseDir($fileLine); } - if ($sourceClass) { $report['SourceClass'] = $sourceClass; $pluginId = PluginManager::getPluginId($sourceClass); if ($pluginId > 0) { $report['PluginId'] = $pluginId; - + $report['PluginVersion'] = PluginManager::getPluginVersion($sourceClass); if ($isFatalError) { $this->maniaControl->getPluginManager()->deactivatePlugin($sourceClass); @@ -137,9 +136,6 @@ class ErrorHandler { $isPluginError = true; } } - - $report['PluginId'] = $pluginId; - $report['PluginVersion'] = PluginManager::getPluginVersion($sourceClass); } if ($traceString) { @@ -478,9 +474,19 @@ class ErrorHandler { $report['Message'] = $message; $report['Class'] = $exceptionClass; $report['FileLine'] = self::stripBaseDir($exception->getFile()) . ': ' . $exception->getLine(); - $report['SourceClass'] = $sourceClass; - $report['PluginId'] = PluginManager::getPluginId($sourceClass); - $report['PluginVersion'] = PluginManager::getPluginVersion($sourceClass); + if ($sourceClass) { + $report['SourceClass'] = $sourceClass; + $pluginId = PluginManager::getPluginId($sourceClass); + if ($pluginId > 0) { + $report['PluginId'] = $pluginId; + $report['PluginVersion'] = PluginManager::getPluginVersion($sourceClass); + + $this->maniaControl->getPluginManager()->deactivatePlugin($sourceClass); + $this->maniaControl->getChat()->sendError("Plugin " . $sourceClass . " has an Error -> The Plugin will be deactivated and ManiaControl restarted"); + Logger::logError("Plugin " . $sourceClass . " has an Error -> The Plugin will be deactivated and ManiaControl restarted"); + } + } + $report['Backtrace'] = $traceString; $report['OperatingSystem'] = php_uname(); $report['PHPVersion'] = phpversion(); From 748dafa6910ffdf27a3fcc0d6c610501ebee0388 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 19 May 2020 21:32:14 +0200 Subject: [PATCH 69/98] Added author login to nickname switch --- plugins/MCTeam/WidgetPlugin.php | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/plugins/MCTeam/WidgetPlugin.php b/plugins/MCTeam/WidgetPlugin.php index f8d0632c..c301d80c 100644 --- a/plugins/MCTeam/WidgetPlugin.php +++ b/plugins/MCTeam/WidgetPlugin.php @@ -8,6 +8,7 @@ use FML\Controls\Quad; use FML\Controls\Quads\Quad_Icons128x128_1; use FML\Controls\Quads\Quad_Icons128x32_1; use FML\Controls\Quads\Quad_Icons64x64_1; +use FML\Elements\SimpleScript; use FML\ManiaLink; use FML\Script\Script; use FML\XmlRpc\TMUIProperties; @@ -36,13 +37,14 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { * Constants */ const PLUGIN_ID = 1; - const PLUGIN_VERSION = 0.12; + const PLUGIN_VERSION = 0.13; const PLUGIN_NAME = 'WidgetPlugin'; const PLUGIN_AUTHOR = 'MCTeam'; // MapWidget Properties const MLID_MAP_WIDGET = 'WidgetPlugin.MapWidget'; const SETTING_MAP_WIDGET_ACTIVATED = 'Map-Widget Activated'; + const SETTING_MAP_WIDGET_NICKNAME = 'Map-Widget display Author Nickname instead of Login'; const SETTING_MAP_WIDGET_POSX = 'Map-Widget-Position: X'; const SETTING_MAP_WIDGET_POSY = 'Map-Widget-Position: Y'; const SETTING_MAP_WIDGET_HEIGHT = 'Map-Widget-Size: Height'; @@ -145,6 +147,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { // Settings $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED, true); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_NICKNAME, false); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_POSX, 160 - 20); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_POSY, 90 - 4.5); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAP_WIDGET_HEIGHT, 9.); @@ -270,14 +273,27 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { $label->setTextColor('fff'); $label->setSize($width - 5, $height); - $label = new Label_Text(); + $label = new Label_Text('author_label'); $frame->addChild($label); $label->setPosition(0, $height/2 - 6, 0.2); - $label->setTextSize(1); $label->setScale(0.8); - $label->setText($map->authorLogin); - $label->setTextColor('fff'); $label->setSize($width - 5, $height); + $label->setTextSize(1); + + if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_NICKNAME)) { + $nicknameScript = array( + 'declare CMlLabel Author_Label <=> (Page.GetFirstChild("author_label") as CMlLabel);', + 'if (Map != Null) {', + ' Author_Label.SetText(Map.AuthorNickName);', + '}' + ); + $simpleScript = new SimpleScript(); + $simpleScript->setText(implode(PHP_EOL, $nicknameScript)); + $frame->addChild($simpleScript); + } else { + $label->setText($map->authorLogin); + $label->setTextColor('fff'); + } $displayTimeAuthor = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_TIME_AUTHOR); $displayTimeGold = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_TIME_GOLD ); From b7993052f72b58edf45cf7ed4246d559001296c5 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 19 May 2020 21:33:38 +0200 Subject: [PATCH 70/98] Wrong comparison on Duplicate Alter-Table call fixed --- plugins/MCTeam/LocalRecordsPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/MCTeam/LocalRecordsPlugin.php b/plugins/MCTeam/LocalRecordsPlugin.php index 949b4a26..01ff3117 100644 --- a/plugins/MCTeam/LocalRecordsPlugin.php +++ b/plugins/MCTeam/LocalRecordsPlugin.php @@ -206,7 +206,7 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command $mysqli->query("ALTER TABLE `" . self::TABLE_RECORDS . "` ADD `checkpoints` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL"); if ($mysqli->error) { - if ($mysqli->errno === 1062) { + if ($mysqli->errno !== 1062) { // Duplicate trigger_error($mysqli->error, E_USER_ERROR); } From 9b46a6e7f77cafbc0a6d5e42b84a92e80a2ab49c Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 19 May 2020 21:37:43 +0200 Subject: [PATCH 71/98] Checked on the wrong error number all along --- plugins/MCTeam/LocalRecordsPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/MCTeam/LocalRecordsPlugin.php b/plugins/MCTeam/LocalRecordsPlugin.php index 01ff3117..6929fa21 100644 --- a/plugins/MCTeam/LocalRecordsPlugin.php +++ b/plugins/MCTeam/LocalRecordsPlugin.php @@ -206,7 +206,7 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command $mysqli->query("ALTER TABLE `" . self::TABLE_RECORDS . "` ADD `checkpoints` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL"); if ($mysqli->error) { - if ($mysqli->errno !== 1062) { + if ($mysqli->errno !== 1060) { // Duplicate trigger_error($mysqli->error, E_USER_ERROR); } From 7c04504e6acddc77233340712a9c2dcb3ee8420a Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 19 May 2020 22:07:18 +0200 Subject: [PATCH 72/98] Add optional descriptions to settings --- core/Configurator/ManiaControlSettings.php | 14 ++++++- core/Plugins/PluginMenu.php | 15 +++++-- core/Settings/Setting.php | 27 +++++++------ core/Settings/SettingManager.php | 46 ++++++++++++++++------ 4 files changed, 73 insertions(+), 29 deletions(-) diff --git a/core/Configurator/ManiaControlSettings.php b/core/Configurator/ManiaControlSettings.php index 1ba57175..b017462a 100644 --- a/core/Configurator/ManiaControlSettings.php +++ b/core/Configurator/ManiaControlSettings.php @@ -97,7 +97,7 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener { $pagerSize = 9.; $settingHeight = 5.; $labelTextSize = 2; - $pageMaxCount = 11; + $pageMaxCount = 10; // Pagers $pagerPrev = new Quad_Icons64x64_1(); @@ -127,8 +127,9 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener { $backLabel = new Label_Button(); $frame->addChild($backLabel); $backLabel->setStyle($backLabel::STYLE_CardMain_Quit); - $backLabel->setPosition(-$width / 2 + 7, -$height / 2 + 7); + $backLabel->setPosition(-$width / 2 + 5, -$height / 2 + 5); $backLabel->setHorizontalAlign($backLabel::LEFT); + $backLabel->setScale(0.5); $backLabel->setTextSize(2); $backLabel->setText('Back'); $backLabel->setAction(self::ACTION_SETTINGCLASS_BACK); @@ -168,6 +169,15 @@ class ManiaControlSettings implements ConfiguratorMenu, CallbackListener { $nameLabel->setText($setting->setting); $nameLabel->setTextColor('fff'); + $descriptionLabel = new Label_Text(); + $pageFrame->addChild($descriptionLabel); + $descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT); + $descriptionLabel->setPosition(-0.45 * $width, -0.35 * $height); + $descriptionLabel->setSize(0.9 * $width, $settingHeight); + $descriptionLabel->setTextSize($labelTextSize); + $descriptionLabel->setTranslate(true); + $nameLabel->addTooltipLabelFeature($descriptionLabel, $setting->description); + $settingName = self::ACTION_PREFIX_SETTING . $setting->index; if ($setting->type === Setting::TYPE_BOOL) { // Boolean checkbox diff --git a/core/Plugins/PluginMenu.php b/core/Plugins/PluginMenu.php index e4ea5d7f..df322271 100644 --- a/core/Plugins/PluginMenu.php +++ b/core/Plugins/PluginMenu.php @@ -256,7 +256,7 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns // TODO: centralize menu code to use by mc settings and plugin settings $settings = $this->maniaControl->getSettingManager()->getSettingsByClass($settingClass); - $pageSettingsMaxCount = 11; + $pageSettingsMaxCount = 10; $posY = 0; $index = 0; $settingHeight = 5.; @@ -295,6 +295,15 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns $nameLabel->setText($setting->setting); $nameLabel->setTextColor('fff'); + $descriptionLabel = new Label_Text(); + $pageFrame->addChild($descriptionLabel); + $descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT); + $descriptionLabel->setPosition(-0.45 * $width, -0.35 * $height); + $descriptionLabel->setSize(0.9 * $width, $settingHeight); + $descriptionLabel->setTextSize(2); + $descriptionLabel->setTranslate(true); + $nameLabel->addTooltipLabelFeature($descriptionLabel, $setting->description); + if ($setting->type === Setting::TYPE_BOOL) { // Boolean checkbox $quad = new Quad(); @@ -332,9 +341,9 @@ class PluginMenu implements CallbackListener, ConfiguratorMenu, ManialinkPageAns $frame->addChild($backButton); $backButton->setStyle($backButton::STYLE_CardMain_Quit); $backButton->setHorizontalAlign($backButton::LEFT); - $backButton->setScale(0.75); + $backButton->setScale(0.5); $backButton->setText('Back'); - $backButton->setPosition(-$width / 2 + 7, -$height / 2 + 7); + $backButton->setPosition(-$width / 2 + 5, -$height / 2 + 5); $backButton->setAction(self::ACTION_BACK_TO_PLUGINS); return $frame; diff --git a/core/Settings/Setting.php b/core/Settings/Setting.php index 8e4edb89..9787bf97 100644 --- a/core/Settings/Setting.php +++ b/core/Settings/Setting.php @@ -30,23 +30,25 @@ class Setting implements UsageInformationAble { /* * Public properties */ - public $index = null; - public $class = null; - public $setting = null; - public $type = null; - public $value = null; - public $default = null; - public $set = null; - public $fetchTime = null; + public $index = null; + public $class = null; + public $setting = null; + public $type = null; + public $value = null; + public $default = null; + public $set = null; + public $fetchTime = null; + public $description = null; /** * Construct a new setting instance * - * @param mixed $object - * @param string $settingName - * @param mixed $defaultValue + * @param mixed $object + * @param string $settingName + * @param mixed $defaultValue + * @param string|null $description */ - public function __construct($object, $settingName, $defaultValue) { + public function __construct($object, $settingName, $defaultValue, $description = null) { if ($object === false) { // Fetched from Database $this->value = $this->castValue($this->value); @@ -68,6 +70,7 @@ class Setting implements UsageInformationAble { $this->value = $defaultValue; } $this->default = $this->value; + $this->description = $description; } } diff --git a/core/Settings/SettingManager.php b/core/Settings/SettingManager.php index bde44b34..3d205a74 100644 --- a/core/Settings/SettingManager.php +++ b/core/Settings/SettingManager.php @@ -70,6 +70,15 @@ class SettingManager implements CallbackListener, UsageInformationAble { if ($mysqli->error) { trigger_error($mysqli->error, E_USER_ERROR); } + + $mysqli->query("ALTER TABLE `" . self::TABLE_SETTINGS . "` ADD `description` VARCHAR(500) DEFAULT NULL;"); + if ($mysqli->error) { + // If not Duplicate + if ($mysqli->errno !== 1060) { + trigger_error($mysqli->error, E_USER_ERROR); + } + } + return $result; } @@ -172,12 +181,13 @@ class SettingManager implements CallbackListener, UsageInformationAble { /** * Set a Setting for the given Object * - * @param mixed $object - * @param string $settingName - * @param mixed $value + * @param mixed $object + * @param string $settingName + * @param mixed $value + * @param string|null $description * @return bool */ - public function setSetting($object, $settingName, $value) { + public function setSetting($object, $settingName, $value, $description = null) { //TODO nowhere used, everywhere saveSettings used, is it depreciated? $setting = $this->getSettingObject($object, $settingName); if ($setting) { @@ -187,7 +197,7 @@ class SettingManager implements CallbackListener, UsageInformationAble { return false; } } else { - $saved = $this->initSetting($object, $settingName, $value); + $saved = $this->initSetting($object, $settingName, $value, $description); if (!$saved) { return false; } @@ -266,13 +276,14 @@ class SettingManager implements CallbackListener, UsageInformationAble { /** * Initialize a Setting for the given Object * - * @param mixed $object - * @param string $settingName - * @param mixed $defaultValue + * @param mixed $object + * @param string $settingName + * @param mixed $defaultValue + * @param string|null $description * @return bool */ - public function initSetting($object, $settingName, $defaultValue) { - $setting = new Setting($object, $settingName, $defaultValue); + public function initSetting($object, $settingName, $defaultValue, $description = null) { + $setting = new Setting($object, $settingName, $defaultValue, $description); return $this->saveSetting($setting, true); } @@ -296,17 +307,19 @@ class SettingManager implements CallbackListener, UsageInformationAble { `class`, `setting`, `type`, + `description`, `value`, `default`, `set` ) VALUES ( - ?, ?, ?, ?, ?, ? + ?, ?, ?, ?, ?, ?, ? ) ON DUPLICATE KEY UPDATE `index` = LAST_INSERT_ID(`index`), `type` = VALUES(`type`), {$valueUpdateString}, `default` = VALUES(`default`), `set` = VALUES(`set`), + `description` = VALUES(`description`), `changed` = NOW();"; $settingStatement = $mysqli->prepare($settingQuery); if ($mysqli->error) { @@ -316,7 +329,16 @@ class SettingManager implements CallbackListener, UsageInformationAble { $formattedValue = $setting->getFormattedValue(); $formattedDefault = $setting->getFormattedDefault(); $formattedSet = $setting->getFormattedSet(); - $settingStatement->bind_param('ssssss', $setting->class, $setting->setting, $setting->type, $formattedValue, $formattedDefault, $formattedSet); + $settingStatement->bind_param( + 'sssssss', + $setting->class, + $setting->setting, + $setting->type, + $setting->description, + $formattedValue, + $formattedDefault, + $formattedSet + ); $settingStatement->execute(); if ($settingStatement->error) { trigger_error($settingStatement->error); From 6c9607e8c768d208261f9278c9d7c2c7df41d87d Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 19 May 2020 22:09:11 +0200 Subject: [PATCH 73/98] Updated Changelog --- changelog.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog.txt b/changelog.txt index 2cc0e508..f5c3f650 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,13 +1,16 @@ ###v0.255### #Additions +- added optional descriptions to Settings (but no MC-settings have descriptions yet) - add Setting to allow Karma-Votes only if player has local - add Setting to change Dedimania-Message formatting +- add Setting to display author nickname instead of author login - add Setting to hide Plugins to install for incompatible version of ManiaControl - add Setting to hide Script-Settings which have the description "" - add Setting to sort GameMode-Settings - CSV-Export of Locals (//exportrecs [map-id]) #Bug Fixes +- deactivate Plugins if they cause uncaught exceptions - fixed typo in actions panel of players list - fixed crashing GameMode-Settings table on other languages than english From 20485acf29babbda96fd577e2cec74062c216ff1 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 19 May 2020 22:13:44 +0200 Subject: [PATCH 74/98] Added GameModePresetPlugin to Changelog --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index f5c3f650..46402e10 100644 --- a/changelog.txt +++ b/changelog.txt @@ -8,6 +8,7 @@ - add Setting to hide Script-Settings which have the description "" - add Setting to sort GameMode-Settings - CSV-Export of Locals (//exportrecs [map-id]) +- new Plugin to save and load GameMode-Settings (//loadmode & //savemode ) #Bug Fixes - deactivate Plugins if they cause uncaught exceptions From 705b1de132e7ac46a8f7b156c2b17e44f3325476 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 19 May 2020 22:14:31 +0200 Subject: [PATCH 75/98] Added GameModePresetsPlugin to Changelog --- changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 46402e10..ebbf5e54 100644 --- a/changelog.txt +++ b/changelog.txt @@ -8,7 +8,7 @@ - add Setting to hide Script-Settings which have the description "" - add Setting to sort GameMode-Settings - CSV-Export of Locals (//exportrecs [map-id]) -- new Plugin to save and load GameMode-Settings (//loadmode & //savemode ) +- new GameModePresetPlugin to save and load GameMode-Settings (//loadmode & //savemode ) #Bug Fixes - deactivate Plugins if they cause uncaught exceptions From f6a2c179af7a43f13bca10f95244b50a04036a25 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Thu, 21 May 2020 15:26:50 +0200 Subject: [PATCH 76/98] Guarantee order of checkpoint/finish-callback-triggers, so finish triggers after CPs --- changelog.txt | 3 +++ core/Callbacks/TrackManiaCallbacks.php | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/changelog.txt b/changelog.txt index ebbf5e54..43e56256 100644 --- a/changelog.txt +++ b/changelog.txt @@ -12,6 +12,9 @@ #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 ", or simply drive a better time - fixed typo in actions panel of players list - fixed crashing GameMode-Settings table on other languages than english diff --git a/core/Callbacks/TrackManiaCallbacks.php b/core/Callbacks/TrackManiaCallbacks.php index 9e7d362b..4dedae7e 100644 --- a/core/Callbacks/TrackManiaCallbacks.php +++ b/core/Callbacks/TrackManiaCallbacks.php @@ -22,7 +22,7 @@ use ManiaControl\ManiaControl; * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class TrackManiaCallbacks implements CallbackListener { +class TrackManiaCallbacks implements CallbackListener, CallQueueListener { /* * Private properties */ @@ -106,9 +106,13 @@ class TrackManiaCallbacks implements CallbackListener { */ public function handleWayPointCallback(OnWayPointEventStructure $structure) { if ($structure->getIsEndRace()) { - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONFINISHLINE, $structure); + $this->maniaControl->getCallQueueManager()->registerListening($this, function () use ($structure) { + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONFINISHLINE, $structure); + }); } else if ($structure->getIsEndLap()) { - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONLAPFINISH, $structure); + $this->maniaControl->getCallQueueManager()->registerListening($this, function () use ($structure) { + $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONLAPFINISH, $structure); + }); } } } From 3084f4b5b593420d5e9c37e50fa85bb5e91b01b5 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Thu, 21 May 2020 15:36:14 +0200 Subject: [PATCH 77/98] Bump LocalRecordsPlugin Version --- plugins/MCTeam/LocalRecordsPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/MCTeam/LocalRecordsPlugin.php b/plugins/MCTeam/LocalRecordsPlugin.php index 6929fa21..ab6808d7 100644 --- a/plugins/MCTeam/LocalRecordsPlugin.php +++ b/plugins/MCTeam/LocalRecordsPlugin.php @@ -43,7 +43,7 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command * Constants */ const ID = 7; - const VERSION = 0.8; + const VERSION = 0.81; const NAME = 'Local Records Plugin'; const AUTHOR = 'MCTeam'; const MLID_RECORDS = 'ml_local_records'; From 14c03d632313f05ba091fee0134adb6ab98a4a10 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Thu, 21 May 2020 15:43:48 +0200 Subject: [PATCH 78/98] Bump ManiaControl Version to v0.255 --- core/ManiaControl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ManiaControl.php b/core/ManiaControl.php index 64d9c52b..20a3c819 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -55,7 +55,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, /* * Constants */ - const VERSION = '0.254'; + const VERSION = '0.255'; const API_VERSION = '2013-04-16'; const MIN_DEDIVERSION = '2017-05-03_21_00'; const SCRIPT_TIMEOUT = 40; From 2c9ea14b785741ba551c7b9b75da92fa695fa99b Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Thu, 21 May 2020 20:51:51 +0200 Subject: [PATCH 79/98] New Adhoc-Callbacks which get triggered after the callback that added them --- changelog.txt | 1 + core/Callbacks/CallbackManager.php | 41 +++++++++++++++++++++++++- core/Callbacks/TrackManiaCallbacks.php | 10 ++----- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/changelog.txt b/changelog.txt index 43e56256..51772c09 100644 --- a/changelog.txt +++ b/changelog.txt @@ -8,6 +8,7 @@ - add Setting to hide Script-Settings which have the description "" - add Setting to sort GameMode-Settings - CSV-Export of Locals (//exportrecs [map-id]) +- new Adhoc-Callbacks, which get executed after the Callback that added them - new GameModePresetPlugin to save and load GameMode-Settings (//loadmode & //savemode ) #Bug Fixes diff --git a/core/Callbacks/CallbackManager.php b/core/Callbacks/CallbackManager.php index 5bbeade1..83dce9ff 100644 --- a/core/Callbacks/CallbackManager.php +++ b/core/Callbacks/CallbackManager.php @@ -63,6 +63,8 @@ class CallbackManager implements UsageInformationAble { /** @var ManiaControl $maniaControl */ private $maniaControl = null; + /** @var Listening[] $adhocCallbacks */ + private $adhocCallbacks = array(); /** @var Listening[][] $callbackListenings */ private $callbackListenings = array(); /** @var Listening[][] $scriptCallbackListenings */ @@ -221,6 +223,42 @@ class CallbackManager implements UsageInformationAble { return $this->removeCallbackListener($this->scriptCallbackListenings, $listener); } + /** + * @internal + * Adds an adhoc Callback to be executed immediately after other callbacks. + * Should be used for more specialized Callbacks, which need to be executed soon after a more general callback. + * + * @param mixed $callbackName + */ + public function addAdhocCallback($callbackName) { + if (!$this->callbackListeningExists($callbackName)) { + return; + } + + $params = func_get_args(); + $params = array_slice($params, 1, null, true); + array_push($this->adhocCallbacks, array($callbackName, $params)); + } + + /** + * @internal + * Trigger internal adhoc Callbacks between manageCallbacks() + */ + private function manageAdhocCallbacks() { + // TODO add some timing method to determine long loop issues + // currently it adds to the non-specialized callback which added the adhoc callback + + foreach ($this->adhocCallbacks as $callback) { + list($callbackName, $params) = $callback; + foreach ($this->callbackListenings[$callbackName] as $listening) { + /** @var Listening $listening */ + $listening->triggerCallbackWithParams($params); + } + } + + $this->adhocCallbacks = array(); + } + /** * Trigger internal Callbacks and manage Server Callbacks */ @@ -253,6 +291,8 @@ class CallbackManager implements UsageInformationAble { foreach ($callbacks as $key => $callback) { $time1 = microtime(true); $this->handleCallback($callback); + // manage any callbacks added by the previous callback + $this->manageAdhocCallbacks(); $timings[$key] = array($callback[0], microtime(true) - $time1); } @@ -314,7 +354,6 @@ class CallbackManager implements UsageInformationAble { * @param mixed $callbackName */ public function triggerCallback($callbackName) { - if (!$this->callbackListeningExists($callbackName)) { return; } diff --git a/core/Callbacks/TrackManiaCallbacks.php b/core/Callbacks/TrackManiaCallbacks.php index 4dedae7e..5d92e0b8 100644 --- a/core/Callbacks/TrackManiaCallbacks.php +++ b/core/Callbacks/TrackManiaCallbacks.php @@ -22,7 +22,7 @@ use ManiaControl\ManiaControl; * @copyright 2014-2020 ManiaControl Team * @license http://www.gnu.org/licenses/ GNU General Public License, Version 3 */ -class TrackManiaCallbacks implements CallbackListener, CallQueueListener { +class TrackManiaCallbacks implements CallbackListener { /* * Private properties */ @@ -106,13 +106,9 @@ class TrackManiaCallbacks implements CallbackListener, CallQueueListener { */ public function handleWayPointCallback(OnWayPointEventStructure $structure) { if ($structure->getIsEndRace()) { - $this->maniaControl->getCallQueueManager()->registerListening($this, function () use ($structure) { - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONFINISHLINE, $structure); - }); + $this->maniaControl->getCallbackManager()->addAdhocCallback(Callbacks::TM_ONFINISHLINE, $structure); } else if ($structure->getIsEndLap()) { - $this->maniaControl->getCallQueueManager()->registerListening($this, function () use ($structure) { - $this->maniaControl->getCallbackManager()->triggerCallback(Callbacks::TM_ONLAPFINISH, $structure); - }); + $this->maniaControl->getCallbackManager()->addAdhocCallback(Callbacks::TM_ONLAPFINISH, $structure); } } } From 74d94ea6dcd4b07fa2560cdea4b291d16bb73ea2 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Fri, 22 May 2020 16:55:05 +0200 Subject: [PATCH 80/98] New //showmode command, which shows all available presets --- plugins/MCTeam/GameModePresetsPlugin.php | 56 ++++++++++++++++++------ 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/plugins/MCTeam/GameModePresetsPlugin.php b/plugins/MCTeam/GameModePresetsPlugin.php index bc900f0d..95e91786 100644 --- a/plugins/MCTeam/GameModePresetsPlugin.php +++ b/plugins/MCTeam/GameModePresetsPlugin.php @@ -22,7 +22,7 @@ class GameModePresetsPlugin implements Plugin, CommandListener, TimerListener { * Constants */ const PLUGIN_ID = 9; - const PLUGIN_VERSION = 0.1; + const PLUGIN_VERSION = 0.11; const PLUGIN_NAME = 'GameMode Presets Plugin'; const PLUGIN_AUTHOR = 'MCTeam'; @@ -63,14 +63,12 @@ class GameModePresetsPlugin implements Plugin, CommandListener, TimerListener { $this->maniaControl->getAuthenticationManager()->definePluginPermissionLevel( $this, self::SETTING_PERMISSION_LOAD_GAMEMODE_PRESET, - AuthenticationManager::AUTH_LEVEL_ADMIN, - AuthenticationManager::AUTH_LEVEL_MODERATOR + AuthenticationManager::AUTH_LEVEL_ADMIN ); $this->maniaControl->getAuthenticationManager()->definePluginPermissionLevel( $this, self::SETTING_PERMISSION_SAVE_GAMEMODE_PRESET, - AuthenticationManager::AUTH_LEVEL_SUPERADMIN, - AuthenticationManager::AUTH_LEVEL_MODERATOR + AuthenticationManager::AUTH_LEVEL_SUPERADMIN ); // Settings @@ -92,6 +90,7 @@ class GameModePresetsPlugin implements Plugin, CommandListener, TimerListener { // Commands $this->maniaControl->getCommandManager()->registerCommandListener(array('loadmode', 'modeload'), $this, 'commandLoadMode', true, 'Loads the mode settings from the given preset name.'); $this->maniaControl->getCommandManager()->registerCommandListener(array('savemode', 'modesave'), $this, 'commandSaveMode', true, 'Saves the mode settings under the given preset name.'); + $this->maniaControl->getCommandManager()->registerCommandListener(array('showmode', 'modeshow'), $this, 'commandSaveMode', true, 'Shows the available game mode presets.'); $this->initTables(); } @@ -134,7 +133,7 @@ class GameModePresetsPlugin implements Plugin, CommandListener, TimerListener { $statement->bind_param('s', $name); $statement->execute(); if ($statement->error) { - trigger_error($statement->error); + trigger_error($statement->error, E_USER_ERROR); $statement->close(); return null; } @@ -181,7 +180,7 @@ class GameModePresetsPlugin implements Plugin, CommandListener, TimerListener { $statement->bind_param('ss', $name, $settings); $statement->execute(); if ($statement->error) { - trigger_error($statement->error); + trigger_error($statement->error, E_USER_ERROR); return false; } @@ -243,7 +242,6 @@ class GameModePresetsPlugin implements Plugin, CommandListener, TimerListener { return; } - // Check for delayed shutdown $params = explode(' ', $chatCallback[1][2]); if (count($params) < 2) { $this->maniaControl->getChat()->sendError('You must provide a gamemode preset name to load settings from!', $player); @@ -256,7 +254,7 @@ class GameModePresetsPlugin implements Plugin, CommandListener, TimerListener { $presetName = strtolower($params[1]); $presetSettings = $this->fetchPreset($presetName); if (!$presetSettings) { - $this->maniaControl->getChat()->sendError('The gamemode preset $<$fff' . $presetName . '$> does not exist!', $player); + $this->maniaControl->getChat()->sendError('The gamemode preset $<$g$z$fff' . $presetName . '$> does not exist, use $<$g$z$fff//showmode$> to see the available presets!', $player); return; } @@ -282,8 +280,9 @@ class GameModePresetsPlugin implements Plugin, CommandListener, TimerListener { $this->maniaControl->getChat()->sendError('Unable to load gamemode preset $<$fff' . $presetName . '$>!', $player); return; } - - $this->maniaControl->getChat()->sendSuccess($player->getEscapedNickname() . ' loaded gamemode preset $<$fff' . $presetName . '$>!'); + + $authLevel = AuthenticationManager::getAuthLevelInt($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_PERMISSION_LOAD_GAMEMODE_PRESET)); + $this->maniaControl->getChat()->sendSuccessToAdmins($player->getEscapedNickname() . ' loaded gamemode preset $<$fff' . $presetName . '$>!', $authLevel); $this->maniaControl->getTimerManager()->registerOneTimeListening( $this, function () { @@ -310,12 +309,11 @@ class GameModePresetsPlugin implements Plugin, CommandListener, TimerListener { * @param \ManiaControl\Players\Player $player */ public function commandSaveMode(array $chatCallback, Player $player) { - if (!$this->maniaControl->getAuthenticationManager()->checkPluginPermission($this, $player, self::SETTING_PERMISSION_LOAD_GAMEMODE_PRESET)) { + if (!$this->maniaControl->getAuthenticationManager()->checkPluginPermission($this, $player, self::SETTING_PERMISSION_SAVE_GAMEMODE_PRESET)) { $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } - // Check for delayed shutdown $params = explode(' ', $chatCallback[1][2]); if (count($params) < 2) { $this->maniaControl->getChat()->sendError('You must provide a gamemode preset name to save settings into!', $player); @@ -334,7 +332,37 @@ class GameModePresetsPlugin implements Plugin, CommandListener, TimerListener { return; } - $this->maniaControl->getChat()->sendSuccess($player->getEscapedNickname() . ' saved gamemode settings in preset $<$fff"' . $presetName . '"$>!'); + $authLevel = AuthenticationManager::getAuthLevelInt($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_PERMISSION_SAVE_GAMEMODE_PRESET)); + $this->maniaControl->getChat()->sendSuccessToAdmins($player->getEscapedNickname() . ' saved gamemode settings in preset $<$fff' . $presetName . '$>!', $authLevel); + } + + /** + * Handle //showmode command + * + * @param array $chatCallback + * @param \ManiaControl\Players\Player $player + */ + public function commandShowMode(array $chatCallback, Player $player) { + if (!$this->maniaControl->getAuthenticationManager()->checkPluginPermission($this, $player, self::SETTING_PERMISSION_LOAD_GAMEMODE_PRESET)) { + $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); + return; + } + + $mysqli = $this->maniaControl->getDatabase()->getMysqli(); + $query = "SELECT `name` + FROM `" . self::TABLE_GAMEMODEPRESETS . "`;"; + $result = $mysqli->query($query); + if ($mysqli->error) { + trigger_error($mysqli->error); + return null; + } + $presets = array(); + while ($preset = $result->fetch_object()) { + array_push($presets, $preset); + } + $result->free(); + + $this->maniaControl->getChat()->sendInformation('Available presets: $<$g$z$fff' . implode(', ', $presets) . '$>', $player); } /** From 43fa2fac6b92a693e85c188b2b198dcfafaeb640 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Sun, 24 May 2020 12:34:02 +0200 Subject: [PATCH 81/98] Fix method execution on command //showmode --- plugins/MCTeam/GameModePresetsPlugin.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/MCTeam/GameModePresetsPlugin.php b/plugins/MCTeam/GameModePresetsPlugin.php index 95e91786..a1fec90d 100644 --- a/plugins/MCTeam/GameModePresetsPlugin.php +++ b/plugins/MCTeam/GameModePresetsPlugin.php @@ -22,7 +22,7 @@ class GameModePresetsPlugin implements Plugin, CommandListener, TimerListener { * Constants */ const PLUGIN_ID = 9; - const PLUGIN_VERSION = 0.11; + const PLUGIN_VERSION = 0.12; const PLUGIN_NAME = 'GameMode Presets Plugin'; const PLUGIN_AUTHOR = 'MCTeam'; @@ -90,7 +90,7 @@ class GameModePresetsPlugin implements Plugin, CommandListener, TimerListener { // Commands $this->maniaControl->getCommandManager()->registerCommandListener(array('loadmode', 'modeload'), $this, 'commandLoadMode', true, 'Loads the mode settings from the given preset name.'); $this->maniaControl->getCommandManager()->registerCommandListener(array('savemode', 'modesave'), $this, 'commandSaveMode', true, 'Saves the mode settings under the given preset name.'); - $this->maniaControl->getCommandManager()->registerCommandListener(array('showmode', 'modeshow'), $this, 'commandSaveMode', true, 'Shows the available game mode presets.'); + $this->maniaControl->getCommandManager()->registerCommandListener(array('showmode', 'modeshow'), $this, 'commandShowMode', true, 'Shows the available game mode presets.'); $this->initTables(); } @@ -315,7 +315,7 @@ class GameModePresetsPlugin implements Plugin, CommandListener, TimerListener { } $params = explode(' ', $chatCallback[1][2]); - if (count($params) < 2) { + if (count($params) < 2 || empty($params[1])) { $this->maniaControl->getChat()->sendError('You must provide a gamemode preset name to save settings into!', $player); return; } elseif (count($params) > 2) { From f91d93ba2ae972ab6fd4bf1bb6200feaca5c4c8c Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Sun, 24 May 2020 12:36:33 +0200 Subject: [PATCH 82/98] Select only name from preset --- plugins/MCTeam/GameModePresetsPlugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/MCTeam/GameModePresetsPlugin.php b/plugins/MCTeam/GameModePresetsPlugin.php index a1fec90d..bc58a0ce 100644 --- a/plugins/MCTeam/GameModePresetsPlugin.php +++ b/plugins/MCTeam/GameModePresetsPlugin.php @@ -358,7 +358,7 @@ class GameModePresetsPlugin implements Plugin, CommandListener, TimerListener { } $presets = array(); while ($preset = $result->fetch_object()) { - array_push($presets, $preset); + array_push($presets, $preset->name); } $result->free(); From 1071c46b5ba2828d5f60d4653232eea37982b9af Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Mon, 25 May 2020 10:52:36 +0200 Subject: [PATCH 83/98] Reorder Functions by Name --- core/Chat.php | 324 +++++++++++++++++++++++++------------------------- 1 file changed, 161 insertions(+), 163 deletions(-) diff --git a/core/Chat.php b/core/Chat.php index ba49aeec..f058d4b1 100644 --- a/core/Chat.php +++ b/core/Chat.php @@ -67,51 +67,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 * @@ -134,123 +89,6 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA return ''; } - /** - * Send an Error Message to all Connected Admins - * - * @param string $message - * @param int $minLevel - * @param bool $prefix - */ - public function sendErrorToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) { - $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_ERROR); - $this->sendMessageToAdmins($format . $message, $minLevel, $prefix); - } - - /** - * Send a Message to all connected Admins - * - * @param string $message - * @param int $minLevel - * @param bool|string $prefix - * @return bool - */ - public function sendMessageToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) { - $admins = $this->maniaControl->getAuthenticationManager()->getConnectedAdmins($minLevel); - return $this->sendChat($message, $admins, $prefix); - } - - /** - * Send a success message to the given login - * - * @param string $message - * @param string $login - * @param bool|string $prefix - * @return bool - */ - public function sendSuccess($message, $login = null, $prefix = true) { - $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_SUCCESS); - return $this->sendChat($format . $message, $login, $prefix); - } - - /** - * Sends a Information Message to all connected Admins - * - * @param string $message - * @param int $minLevel - * @param bool|string $prefix - * @return bool - */ - public function sendInformationToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) { - $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_INFORMATION); - return $this->sendMessageToAdmins($format . $message, $minLevel, $prefix); - } - - - /** - * Sends a Success Message to all connected Admins - * - * @param string $message - * @param int $minLevel - * @param bool|string $prefix - * @return bool - */ - public function sendSuccessToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) { - $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_SUCCESS); - return $this->sendMessageToAdmins($format . $message, $minLevel, $prefix); - } - - /** - * Send the Exception Information to the Chat - * - * @param \Exception $exception - * @param string $login - * @return bool - */ - public function sendException(\Exception $exception, $login = null) { - $message = "Exception occurred: '{$exception->getMessage()}' ({$exception->getCode()})"; - return $this->sendError($message, $login); - } - - /** - * Send an Error Message to the Chat - * - * @param string $message - * @param string $login - * @param string|bool $prefix - * @return bool - */ - public function sendError($message, $login = null, $prefix = true) { - $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_ERROR); - return $this->sendChat($format . $message, $login, $prefix); - } - - /** - * Send a Exception Message to all Connected Admins - * - * @param \Exception $exception - * @param int $minLevel - * @param bool|string $prefix - */ - public function sendExceptionToAdmins(\Exception $exception, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) { - $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_ERROR); - $message = $format . "Exception: '{$exception->getMessage()}' ({$exception->getCode()})"; - $this->sendMessageToAdmins($message, $minLevel, $prefix); - } - - /** - * Send an usage info message to the given login - * - * @param string $message - * @param string $login - * @param string|bool $prefix - * @return bool - */ - public function sendUsageInfo($message, $login = null, $prefix = false) { - $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_USAGEINFO); - return $this->sendChat($format . $message, $login, $prefix); - } - - /** * Handles SendChat Communication Request * @@ -318,7 +156,6 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA return new CommunicationAnswer(); } - /** * Stores the ChatMessage in the Buffer * @@ -337,4 +174,165 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA array_shift($this->chatBuffer); } } + + /** + * Send a chat message to the given login + * + * @param string $message + * @param string $login + * @param string|bool $prefix + * @param bool $multiCall + * @return bool + */ + public function sendChat($message, $login = null, $prefix = true, $multiCall = true) { + if (!$this->maniaControl->getClient()) { + return false; + } + + $prefix = $this->buildPrefix($prefix, $login); + $chatMessage = '$<$z$ff0' . $prefix . $message . '$>'; + + if ($login) { + if (!is_array($login)) { + $login = Player::parseLogin($login); + } + try { + return $this->maniaControl->getClient()->chatSendServerMessage($chatMessage, $login, $multiCall); + } catch (UnknownPlayerException $e) { + return false; + } + } + + return $this->maniaControl->getClient()->chatSendServerMessage($chatMessage, null, $multiCall); + } + + /** + * Send an Error Message to all Connected Admins + * + * @param string $message + * @param int $minLevel + * @param bool $prefix + */ + public function sendErrorToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) { + $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_ERROR); + $this->sendMessageToAdmins($format . $message, $minLevel, $prefix); + } + + /** + * Send an Error Message to the Chat + * + * @param string $message + * @param string $login + * @param string|bool $prefix + * @return bool + */ + public function sendError($message, $login = null, $prefix = true) { + $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_ERROR); + return $this->sendChat($format . $message, $login, $prefix); + } + + /** + * Send the Exception Information to the Chat + * + * @param \Exception $exception + * @param string $login + * @return bool + */ + public function sendException(\Exception $exception, $login = null) { + $message = "Exception occurred: '{$exception->getMessage()}' ({$exception->getCode()})"; + return $this->sendError($message, $login); + } + + /** + * Send a Exception Message to all Connected Admins + * + * @param \Exception $exception + * @param int $minLevel + * @param bool|string $prefix + */ + public function sendExceptionToAdmins(\Exception $exception, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) { + $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_ERROR); + $message = $format . "Exception: '{$exception->getMessage()}' ({$exception->getCode()})"; + $this->sendMessageToAdmins($message, $minLevel, $prefix); + } + + /** + * Send an information message to the given login + * + * @param string $message + * @param string $login + * @param string|bool $prefix + * @param bool $multiCall + * @return bool + */ + public function sendInformation($message, $login = null, $prefix = true, $multiCall = true) { + $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_INFORMATION); + return $this->sendChat($format . $message, $login, $prefix, $multiCall); + } + + /** + * Sends a Information Message to all connected Admins + * + * @param string $message + * @param int $minLevel + * @param bool|string $prefix + * @return bool + */ + public function sendInformationToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) { + $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_INFORMATION); + return $this->sendMessageToAdmins($format . $message, $minLevel, $prefix); + } + + /** + * Send a Message to all connected Admins + * + * @param string $message + * @param int $minLevel + * @param bool|string $prefix + * @return bool + */ + public function sendMessageToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) { + $admins = $this->maniaControl->getAuthenticationManager()->getConnectedAdmins($minLevel); + return $this->sendChat($message, $admins, $prefix); + } + + /** + * Send a success message to the given login + * + * @param string $message + * @param string $login + * @param bool|string $prefix + * @return bool + */ + public function sendSuccess($message, $login = null, $prefix = true) { + $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_SUCCESS); + return $this->sendChat($format . $message, $login, $prefix); + } + + + /** + * Sends a Success Message to all connected Admins + * + * @param string $message + * @param int $minLevel + * @param bool|string $prefix + * @return bool + */ + public function sendSuccessToAdmins($message, $minLevel = AuthenticationManager::AUTH_LEVEL_MODERATOR, $prefix = true) { + $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_SUCCESS); + return $this->sendMessageToAdmins($format . $message, $minLevel, $prefix); + } + + /** + * Send an usage info message to the given login + * + * @param string $message + * @param string $login + * @param string|bool $prefix + * @return bool + */ + public function sendUsageInfo($message, $login = null, $prefix = false) { + $format = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_USAGEINFO); + return $this->sendChat($format . $message, $login, $prefix); + } } From cb84df401a1b9f87e68d93555d11f1b8e9bfb810 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 26 May 2020 17:49:29 +0200 Subject: [PATCH 84/98] Added formatMessage to Chat, and used it in LocalRecordsPlugin first --- core/Chat.php | 59 +++++++++++++++-- plugins/MCTeam/LocalRecordsPlugin.php | 92 ++++++++++++++++++--------- 2 files changed, 115 insertions(+), 36 deletions(-) diff --git a/core/Chat.php b/core/Chat.php index f058d4b1..61493482 100644 --- a/core/Chat.php +++ b/core/Chat.php @@ -10,7 +10,9 @@ use ManiaControl\Communication\CommunicationListener; use ManiaControl\Communication\CommunicationMethods; use ManiaControl\General\UsageInformationAble; use ManiaControl\General\UsageInformationTrait; +use ManiaControl\Maps\Map; use ManiaControl\Players\Player; +use ManiaControl\Utils\Formatter; use Maniaplanet\DedicatedServer\Xmlrpc\UnknownPlayerException; /** @@ -26,13 +28,16 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA /* * Constants */ - const SETTING_FORMAT_ERROR = 'Error Format'; - const SETTING_FORMAT_INFORMATION = 'Information Format'; - const SETTING_FORMAT_SUCCESS = 'Success Format'; - const SETTING_FORMAT_USAGEINFO = 'UsageInfo Format'; - const SETTING_PUBLIC_PREFIX = 'Public Messages Prefix'; - const SETTING_PRIVATE_PREFIX = 'Privat Messages Prefix'; - const CHAT_BUFFER_SIZE = 200; + const SETTING_FORMAT_ERROR = 'Error Format'; + const SETTING_FORMAT_INFORMATION = 'Information Format'; + const SETTING_FORMAT_SUCCESS = 'Success Format'; + const SETTING_FORMAT_USAGEINFO = 'UsageInfo Format'; + const SETTING_FORMAT_MESSAGE_INPUT_COLOR = 'Format Message Input Color'; + const SETTING_FORMAT_MESSAGE_MAP_AUTHOR = 'Format Message Add Map Author'; + 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 @@ -54,6 +59,9 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA $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_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, false); + $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, '»» '); @@ -156,6 +164,43 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA return new CommunicationAnswer(); } + /** + * Format the given message with the given inputs and colors the inputs. + * @param string $message + * @param mixed ...$inputs + * @return string + */ + public function formatMessage($message, ...$inputs) { + $addMapAuthor = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_MESSAGE_MAP_AUTHOR); + $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 ($addMapAuthor) { + $strInput .= " (by {$input->authorLogin})"; + } + } elseif ($input instanceof Player) { + $strInput = $input->getEscapedNickname(); + if ($addPlayerLogin) { + $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 * diff --git a/plugins/MCTeam/LocalRecordsPlugin.php b/plugins/MCTeam/LocalRecordsPlugin.php index ab6808d7..5d8dafec 100644 --- a/plugins/MCTeam/LocalRecordsPlugin.php +++ b/plugins/MCTeam/LocalRecordsPlugin.php @@ -43,7 +43,7 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command * Constants */ const ID = 7; - const VERSION = 0.81; + const VERSION = 0.82; const NAME = 'Local Records Plugin'; const AUTHOR = 'MCTeam'; const MLID_RECORDS = 'ml_local_records'; @@ -516,7 +516,7 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command $checkpointsString = $this->getCheckpoints($player->login); $this->checkpoints[$player->login] = array(); - $message = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NOTIFICATION_MESSAGE_PREFIX); + $messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NOTIFICATION_MESSAGE_PREFIX); $notifyPrivatelyAt = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NOTIFY_BEST_RECORDS_PRIVATE); $notifyPubliclyAt = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_NOTIFY_BEST_RECORDS_PUBLIC); @@ -528,13 +528,13 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command return; } else if ($oldRecord->time == $time) { // Same time - if ($notifyPubliclyAt < $oldRecord->rank && $oldRecord->rank <= $notifyPrivatelyAt) { - $message .= 'You'; - } else { - $message .= '$<$fff' . $player->nickname . '$>'; - } - $message .= ' equalized the $<$ff0' . $oldRecord->rank . '.$> Local Record:'; - $message .= ' $<$fff' . Formatter::formatTime($oldRecord->time) . '$>!'; + $isPM = ($notifyPubliclyAt < $oldRecord->rank && $oldRecord->rank <= $notifyPrivatelyAt); + $message = $this->maniaControl->getChat()->formatMessage( + $messagePrefix . '%s equalized the %s Local Record: %s!', + ($isPM ? 'You' : $player), + '$ff0' . $oldRecord->rank . '.', + Formatter::formatTime($oldRecord->time) + ); if ($oldRecord->rank <= $notifyPubliclyAt) { $this->maniaControl->getCallQueueManager()->registerListening( @@ -581,21 +581,20 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command $newRecord = $this->getLocalRecord($map, $player); $improvedRank = ($oldRecord && $newRecord->rank >= $oldRecord->rank); - if ($notifyPubliclyAt < $newRecord->rank && $newRecord->rank <= $notifyPrivatelyAt) { - $message .= 'You'; - } else { - $message .= '$<$fff' . $player->nickname . '$>'; - } - $message .= ' ' . ($improvedRank ? 'improved' : 'gained') . ' the'; - $message .= ' $<$ff0' . $newRecord->rank . '.$> Local Record:'; - $message .= ' $<$fff' . Formatter::formatTime($newRecord->time) . '$>!'; + $isPM = ($notifyPubliclyAt < $newRecord->rank && $newRecord->rank <= $notifyPrivatelyAt); + $message = $this->maniaControl->getChat()->formatMessage( + $messagePrefix . '%s ' . ($improvedRank ? 'improved' : 'gained') . ' the %s Local Record: %s!', + ($isPM ? 'You' : $player), + '$ff0' . $newRecord->rank . '.', + Formatter::formatTime($newRecord->time) + ); if ($oldRecord) { - $message .= ' ('; - if ($improvedRank) { - $message .= '$<$ff0' . $oldRecord->rank . '.$> '; - } $timeDiff = $oldRecord->time - $newRecord->time; - $message .= '$<$fff-' . Formatter::formatTime($timeDiff) . '$>)'; + $message .= $this->maniaControl->getChat()->formatMessage( + ' (%s%s)', + ($improvedRank ? '$ff0'.$oldRecord->rank.'. ' : ''), + '-'.Formatter::formatTime($timeDiff) + ); } if ($newRecord->rank <= $notifyPubliclyAt) { @@ -710,7 +709,11 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command $commandParts = explode(' ', $chat[1][2]); if (count($commandParts) < 2 || strlen($commandParts[1]) == 0) { - $this->maniaControl->getChat()->sendUsageInfo('Missing CSV-Filename ID! (Example: //exportrecs locals.csv)', $player); + $message = $this->maniaControl->getChat()->formatMessage( + 'Missing CSV-Filename! (Example %s)', + '//exportrecs locals.csv' + ); + $this->maniaControl->getChat()->sendUsageInfo($message, $player); return; } @@ -758,7 +761,12 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command $this->maniaControl->getChat()->sendException($e, $player); } - $this->maniaControl->getChat()->sendSuccess('Successfully exported Local Records of map ' . $map->getEscapedName() . ' to $<$fff' . $filename . '$>!'); + $message = $this->maniaControl->getChat()->formatMessage( + 'Exported Local Records of %s to %s!', + $map, + $filename + ); + $this->maniaControl->getChat()->sendSuccess($message, $player); } /** @@ -872,7 +880,11 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command $commandParts = explode(' ', $chat[1][2]); if (count($commandParts) < 2 || strlen($commandParts[1]) == 0) { - $this->maniaControl->getChat()->sendUsageInfo('Missing Record ID! (Example: //delrec 3)', $player); + $message = $this->maniaControl->getChat()->formatMessage( + 'Missing Record ID! (Example: %s)', + '//delrec 3' + ); + $this->maniaControl->getChat()->sendUsageInfo($message, $player); return; } @@ -880,13 +892,26 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command $currentMap = $this->maniaControl->getMapManager()->getCurrentMap(); $records = $this->getLocalRecords($currentMap); if ($recordRank <= 0 || count($records) < $recordRank) { - $this->maniaControl->getChat()->sendError('Cannot remove record $<$fff' . $recordRank . '$>!', $player); + $message = $this->maniaControl->getChat()->formatMessage( + 'Cannot remove record no. %s, does not exist!', + $recordRank + ); + $this->maniaControl->getChat()->sendError($message, $player); return; } assert($recordRank == $records[$recordRank-1]->rank); $playerIndex = $records[$recordRank-1]->playerIndex; - $playerNick = $records[$recordRank-1]->nickname; + $recordPlayer = $this->maniaControl->getPlayerManager()->getPlayerByIndex($playerIndex); + if (!$recordPlayer) { + // should never happen, but you never know + $message = $this->maniaControl->getChat()->formatMessage( + 'Cannot remove record no. %s, player does not exist!', + $recordRank + ); + $this->maniaControl->getChat()->sendError($message, $player); + return; + } $mysqli = $this->maniaControl->getDatabase()->getMysqli(); $query = "DELETE FROM `" . self::TABLE_RECORDS . "` @@ -899,7 +924,12 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command } $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_LOCALRECORDS_CHANGED, null); - $this->maniaControl->getChat()->sendSuccess('Record no. $<$fff' . $recordRank . '$> by $<$fff' . $playerNick . '$> has been removed!'); + $message = $this->maniaControl->getChat()->formatMessage( + 'Record no. %s by %s has been removed!', + $recordRank, + $recordPlayer + ); + $this->maniaControl->getChat()->sendSuccess($message); } /** @@ -941,7 +971,11 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command } $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_LOCALRECORDS_CHANGED, null); - $this->maniaControl->getChat()->sendSuccess('$<$fff'.$player->getEscapedNickname().'$> removed his personal record!'); + $message = $this->maniaControl->getChat()->formatMessage( + '%s removed his personal record!', + $player + ); + $this->maniaControl->getChat()->sendSuccess($message); } /** From cfaa114daa9142c25417f8124b68af38e29043d8 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 26 May 2020 18:14:50 +0200 Subject: [PATCH 85/98] Force authLevel to be interpreted as integer --- core/Players/Player.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/Players/Player.php b/core/Players/Player.php index 3df19746..b65891f0 100644 --- a/core/Players/Player.php +++ b/core/Players/Player.php @@ -373,7 +373,7 @@ class Player implements Dumpable, UsageInformationAble { * @return string */ public function getAuthLevelName(){ - return AuthenticationManager::getAuthLevelName($this->authLevel); + return AuthenticationManager::getAuthLevelName(intval($this->authLevel)); } /** @@ -383,7 +383,7 @@ class Player implements Dumpable, UsageInformationAble { * @return string */ public function getAuthLevelAbbreviation(){ - return AuthenticationManager::getAuthLevelAbbreviation($this->authLevel); + return AuthenticationManager::getAuthLevelAbbreviation(intval($this->authLevel)); } /** From a311dcdbd9626f41d32427b4ddb05f78c54c6f10 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 26 May 2020 18:15:18 +0200 Subject: [PATCH 86/98] Unified implementation of AuthCommands --- core/Admin/AuthCommands.php | 207 +++++++++++++++--------------------- 1 file changed, 86 insertions(+), 121 deletions(-) diff --git a/core/Admin/AuthCommands.php b/core/Admin/AuthCommands.php index 1352f700..1b5997e4 100644 --- a/core/Admin/AuthCommands.php +++ b/core/Admin/AuthCommands.php @@ -40,6 +40,57 @@ class AuthCommands implements CommandListener, UsageInformationAble { $this->maniaControl->getCommandManager()->registerCommandListener('removerights', $this, 'command_RemoveRights', true, 'Remove Player from the AdminList.'); } + /** + * Handle all //add commands + * @internal + * @param array $chatCallback + * @param Player $player + * @param string $targetAuthLevel + */ + private function command_Add(array $chatCallback, Player $player, $targetAuthLevel) { + // $player needs to be at least one AuthLevel higher as the one to be granted + if (!AuthenticationManager::checkRight($player, $targetAuthLevel+1)) { + $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); + return; + } + + $text = $chatCallback[1][2]; + $commandParts = explode(' ', $text); + if (!array_key_exists(1, $commandParts)) { + $message = $this->maniaControl->getChat()->formatMessage( + 'Usage Example: %s %s', + $commandParts[0], + 'login' + ); + $this->maniaControl->getChat()->sendUsageInfo($message, $player); + return; + } + + $target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]); + if (!$target) { + $message = $this->maniaControl->getChat()->formatMessage( + 'Player %s not found!', + $commandParts[1] + ); + $this->maniaControl->getChat()->sendError($message, $player); + return; + } + + $success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, $targetAuthLevel); + if (!$success) { + $this->maniaControl->getChat()->sendError('Error occurred!', $player); + return; + } + + $authName = AuthenticationManager::getAuthLevelName($targetAuthLevel); + $message = $this->maniaControl->getChat()->formatMessage( + "%s added %s as {$authName}.", + $player, + $target + ); + $this->maniaControl->getChat()->sendSuccess($message); + } + /** * Handle //addsuperadmin command * @@ -48,39 +99,7 @@ class AuthCommands implements CommandListener, UsageInformationAble { * @param Player $player */ public function command_AddSuperAdmin(array $chatCallback, Player $player) { - if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)) { - $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); - return; - } - $text = $chatCallback[1][2]; - $commandParts = explode(' ', $text); - if (!array_key_exists(1, $commandParts)) { - $this->sendAddSuperAdminUsageInfo($player); - return; - } - $target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]); - if (!$target) { - $this->maniaControl->getChat()->sendError("Player '{$commandParts[1]}' not found!", $player); - return; - } - $success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_SUPERADMIN); - if (!$success) { - $this->maniaControl->getChat()->sendError('Error occurred.', $player); - return; - } - $message = $player->getEscapedNickname() . ' added ' . $target->getEscapedNickname() . ' as SuperAdmin!'; - $this->maniaControl->getChat()->sendSuccess($message); - } - - /** - * Send usage example for //addsuperadmin command - * - * @param Player $player - * @return bool - */ - private function sendAddSuperAdminUsageInfo(Player $player) { - $message = "Usage Example: '//addsuperadmin login'"; - return $this->maniaControl->getChat()->sendUsageInfo($message, $player); + $this->command_Add($chatCallback, $player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN); } /** @@ -91,39 +110,7 @@ class AuthCommands implements CommandListener, UsageInformationAble { * @param Player $player */ public function command_AddAdmin(array $chatCallback, Player $player) { - if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_SUPERADMIN)) { - $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); - return; - } - $text = $chatCallback[1][2]; - $commandParts = explode(' ', $text); - if (!array_key_exists(1, $commandParts)) { - $this->sendAddAdminUsageInfo($player); - return; - } - $target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]); - if (!$target) { - $this->maniaControl->getChat()->sendError("Player '{$commandParts[1]}' not found!", $player); - return; - } - $success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_ADMIN); - if (!$success) { - $this->maniaControl->getChat()->sendError('Error occurred.', $player); - return; - } - $message = $player->getEscapedNickname() . ' added ' . $target->getEscapedNickname() . ' as Admin!'; - $this->maniaControl->getChat()->sendSuccess($message); - } - - /** - * Send usage example for //addadmin command - * - * @param Player $player - * @return bool - */ - private function sendAddAdminUsageInfo(Player $player) { - $message = "Usage Example: '//addadmin login'"; - return $this->maniaControl->getChat()->sendUsageInfo($message, $player); + $this->command_Add($chatCallback, $player, AuthenticationManager::AUTH_LEVEL_ADMIN); } /** @@ -134,42 +121,9 @@ class AuthCommands implements CommandListener, UsageInformationAble { * @param Player $player */ public function command_AddModerator(array $chatCallback, Player $player) { - if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) { - $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); - return; - } - $text = $chatCallback[1][2]; - $commandParts = explode(' ', $text); - if (!array_key_exists(1, $commandParts)) { - $this->sendAddModeratorUsageInfo($player); - return; - } - $target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]); - if (!$target) { - $this->maniaControl->getChat()->sendError("Player '{$commandParts[1]}' not found!", $player); - return; - } - $success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_MODERATOR); - if (!$success) { - $this->maniaControl->getChat()->sendError('Error occurred.', $player); - return; - } - $message = $player->getEscapedNickname() . ' added ' . $target->getEscapedNickname() . ' as Moderator!'; - $this->maniaControl->getChat()->sendSuccess($message); + $this->command_Add($chatCallback, $player, AuthenticationManager::AUTH_LEVEL_MODERATOR); } - /** - * Send usage example for //addmod command - * - * @param Player $player - * @return bool - */ - private function sendAddModeratorUsageInfo(Player $player) { - $message = "Usage Example: '//addmod login'"; - return $this->maniaControl->getChat()->sendUsageInfo($message, $player); - } - - /** * Handle //removerights command * @@ -178,44 +132,55 @@ class AuthCommands implements CommandListener, UsageInformationAble { * @param Player $player */ public function command_RemoveRights(array $chatCallback, Player $player) { - if (!AuthenticationManager::checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) { - $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); - return; - } $text = $chatCallback[1][2]; $commandParts = explode(' ', $text); if (!array_key_exists(1, $commandParts)) { - $this->sendRemoveRightsUsageInfo($player); + $message = $this->maniaControl->getChat()->formatMessage( + 'Usage Example: %s %s', + $commandParts[0], + 'login' + ); + $this->maniaControl->getChat()->sendUsageInfo($message, $player); return; } + $target = $this->maniaControl->getPlayerManager()->getPlayer($commandParts[1]); if (!$target) { - $this->maniaControl->getChat()->sendError("Player '{$commandParts[1]}' not found!", $player); + $message = $this->maniaControl->getChat()->formatMessage( + 'Player %s not found!', + $commandParts[1] + ); + $this->maniaControl->getChat()->sendError($message, $player); return; } - if ($target->authLevel == AuthenticationManager::AUTH_LEVEL_MASTERADMIN) { - $this->maniaControl->getChat()->sendError("You can't remove an MasterAdmin from the Adminlists", $player); + if ($target->authLevel >= AuthenticationManager::AUTH_LEVEL_MASTERADMIN) { + $this->maniaControl->getChat()->sendError('You cannot remove rights of a MasterAdmin!', $player); return; } + if ($target->authLevel <= AuthenticationManager::AUTH_LEVEL_PLAYER) { + $this->maniaControl->getChat()->sendError('Cannot remove rights of a player!', $player); + return; + } + + if ($player->authLevel <= $target->authLevel) { + $this->maniaControl->getChat()->sendError('You cannot remove rights of a higher privileged player!', $player); + return; + } + + $targetAuthName = $target->getAuthLevelName(); $success = $this->maniaControl->getAuthenticationManager()->grantAuthLevel($target, AuthenticationManager::AUTH_LEVEL_PLAYER); if (!$success) { - $this->maniaControl->getChat()->sendError('Error occurred.', $player); + $this->maniaControl->getChat()->sendError('Error occurred!', $player); return; } - $message = $player->getEscapedNickname() . ' removed ' . $target->getEscapedNickname() . ' from the Adminlists!'; + + $message = $this->maniaControl->getChat()->formatMessage( + "%s removed %s from {$targetAuthName}s.", + $player, + $target + ); $this->maniaControl->getChat()->sendSuccess($message); } - - /** - * Send usage example for //removerights command - * - * @param Player $player - * @return bool - */ - private function sendRemoveRightsUsageInfo(Player $player) { - $message = "Usage Example: '//addadmin login'"; - return $this->maniaControl->getChat()->sendUsageInfo($message, $player); - } } From 1d0215df529bf7cf5a787d139a38a001841b5ea5 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 26 May 2020 21:56:00 +0200 Subject: [PATCH 87/98] use Chat::formatMessage in Commands-namespace --- core/Commands/CommandManager.php | 7 ++++- core/Commands/HelpManager.php | 52 ++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/core/Commands/CommandManager.php b/core/Commands/CommandManager.php index 2fc1219e..311cb5a7 100644 --- a/core/Commands/CommandManager.php +++ b/core/Commands/CommandManager.php @@ -352,7 +352,12 @@ class CommandManager implements CallbackListener, UsageInformationAble { if (!$this->isCommandEnabled($command, $isAdminCommand)) { $prefix = $isAdminCommand ? '//' : '/'; - $this->maniaControl->getChat()->sendError('The command $<$fff'.$prefix.$command.'$> is currently disabled!', $player); + $message = $this->maniaControl->getChat()->formatMessage( + 'The command %s%s is currently disabled!', + $prefix, + $command + ); + $this->maniaControl->getChat()->sendError($message, $player); return; } diff --git a/core/Commands/HelpManager.php b/core/Commands/HelpManager.php index 4706f542..08fb768f 100644 --- a/core/Commands/HelpManager.php +++ b/core/Commands/HelpManager.php @@ -53,7 +53,7 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns $this->maniaControl->getActionsMenu()->addMenuItem($itemQuad, true, 0, 'Available commands'); $itemQuad = clone $itemQuad; $itemQuad->setAction(self::ACTION_OPEN_ADMIN_HELP_ALL); - $this->maniaControl->getActionsMenu()->addAdminMenuItem($itemQuad,0,'Available admin commands'); + $this->maniaControl->getActionsMenu()->addAdminMenuItem($itemQuad, 0, 'Available admin commands'); // Callbacks $this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ONINIT, $this, 'handleOnInit'); @@ -79,9 +79,13 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns // Parse list from array $message = $this->parseHelpList($this->adminCommands); - // Show message when it's not empty - if ($message != null) { - $message = 'Supported Admin Commands: ' . $message; + if ($message === null) { + $this->maniaControl->getChat()->sendError('No Admin Commands supported!', $player); + } else { + $message = $this->maniaControl->getChat()->formatMessage( + 'Supported Admin Commands: %s', + $message + ); $this->maniaControl->getChat()->sendChat($message, $player); } } @@ -96,13 +100,27 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns // Parse list from array $message = $this->parseHelpList($this->playerCommands); - // Show message when it's not empty - if ($message != null) { - $message = 'Supported Player Commands: ' . $message; + if ($message === null) { + $this->maniaControl->getChat()->sendError('No Player Commands supported!', $player); + } else { + $message = $this->maniaControl->getChat()->formatMessage( + 'Supported Player Commands: %s', + $message + ); $this->maniaControl->getChat()->sendChat($message, $player); } } + /** + * Show a ManiaLink list of Admin Commands + * + * @param array $chatCallback + * @param Player $player + */ + public function command_adminHelpAll(array $chatCallback, Player $player) { + $this->parseHelpList($this->adminCommands, true, $player); + } + /** * Show a ManiaLink list of Player Commands * @@ -120,8 +138,8 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns * @param \ManiaControl\Players\Player $player * @internal */ - public function maniaLink_helpAll(array $callback, Player $player) { - $this->parseHelpList($this->playerCommands, true, $player); + public function maniaLink_adminHelpAll(array $callback, Player $player){ + $this->parseHelpList($this->adminCommands,true, $player); } /** @@ -131,8 +149,8 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns * @param \ManiaControl\Players\Player $player * @internal */ - public function maniaLink_adminHelpAll(array $callback, Player $player){ - $this->parseHelpList($this->adminCommands,true, $player); + public function maniaLink_helpAll(array $callback, Player $player) { + $this->parseHelpList($this->playerCommands, true, $player); } /** @@ -185,7 +203,7 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns * @param array $commands * @param mixed $player */ - public function showHelpAllList(array $commands, $player) { + public function showHelpAllList(array $commands, $player) { $width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth(); $height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight(); @@ -254,16 +272,6 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns $this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $player, 'HelpAllList'); } - /** - * Show a ManiaLink list of Admin Commands - * - * @param array $chatCallback - * @param Player $player - */ - public function command_adminHelpAll(array $chatCallback, Player $player) { - $this->parseHelpList($this->adminCommands, true, $player); - } - /** * Register a new Command * From 06f24a1bfb0d1c7ae332843c13d029030bd9055a Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Wed, 27 May 2020 00:01:36 +0200 Subject: [PATCH 88/98] Use Chat::formatMessage in Configurator/*, ManiaExchange/* and Maps/* --- core/Chat.php | 39 ++++--- core/Commands/HelpManager.php | 1 + core/Configurator/GameModeSettings.php | 12 ++- core/ManiaExchange/ManiaExchangeList.php | 2 +- core/Maps/DirectoryBrowser.php | 18 +++- core/Maps/MapCommands.php | 130 +++++++++++++++-------- core/Maps/MapList.php | 29 +++-- core/Maps/MapManager.php | 89 +++++++++++----- core/Maps/MapQueue.php | 99 +++++++++++++---- 9 files changed, 292 insertions(+), 127 deletions(-) diff --git a/core/Chat.php b/core/Chat.php index 61493482..edf3bbdc 100644 --- a/core/Chat.php +++ b/core/Chat.php @@ -28,16 +28,17 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA /* * Constants */ - const SETTING_FORMAT_ERROR = 'Error Format'; - const SETTING_FORMAT_INFORMATION = 'Information Format'; - const SETTING_FORMAT_SUCCESS = 'Success Format'; - const SETTING_FORMAT_USAGEINFO = 'UsageInfo Format'; - const SETTING_FORMAT_MESSAGE_INPUT_COLOR = 'Format Message Input Color'; - const SETTING_FORMAT_MESSAGE_MAP_AUTHOR = 'Format Message Add Map Author'; - 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; + const SETTING_FORMAT_ERROR = 'Error Format'; + const SETTING_FORMAT_INFORMATION = 'Information Format'; + const SETTING_FORMAT_SUCCESS = 'Success Format'; + const SETTING_FORMAT_USAGEINFO = 'UsageInfo Format'; + const SETTING_FORMAT_MESSAGE_INPUT_COLOR = 'Format Message Input Color'; + const SETTING_FORMAT_MESSAGE_MAP_AUTHOR_LOGIN = 'Format Message Add Map Author Login'; + const SETTING_FORMAT_MESSAGE_MAP_AUTHOR_NICKNAME = 'Format Message Add Map Author Nickname'; + const SETTING_FORMAT_MESSAGE_PLAYER_LOGIN = 'Format Message Add Player Login'; + const SETTING_PUBLIC_PREFIX = 'Public Messages Prefix'; + const SETTING_PRIVATE_PREFIX = 'Private Messages Prefix'; + const CHAT_BUFFER_SIZE = 200; /* * Private properties @@ -60,7 +61,8 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_FORMAT_SUCCESS, '$0f0'); $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, false); + $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, '»» '); @@ -171,7 +173,8 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA * @return string */ public function formatMessage($message, ...$inputs) { - $addMapAuthor = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_FORMAT_MESSAGE_MAP_AUTHOR); + $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); @@ -183,12 +186,18 @@ class Chat implements CallbackListener, CommunicationListener, UsageInformationA $strInput = $input ? 'true' : 'false'; } elseif ($input instanceof Map) { $strInput = $input->getEscapedName(); - if ($addMapAuthor) { - $strInput .= " (by {$input->authorLogin})"; + 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) { + if ($addPlayerLogin && $input->login) { $strInput .= " ({$input->login})"; } } else { diff --git a/core/Commands/HelpManager.php b/core/Commands/HelpManager.php index 08fb768f..6de5c72a 100644 --- a/core/Commands/HelpManager.php +++ b/core/Commands/HelpManager.php @@ -281,6 +281,7 @@ class HelpManager implements CommandListener, CallbackListener, ManialinkPageAns * @param string $method */ public function registerCommand($name, $adminCommand = false, $description = '', $method) { + // TODO replace with new class Command if ($adminCommand) { array_push($this->adminCommands, array("Name" => $name, "Description" => $description, "Method" => $method)); } else { diff --git a/core/Configurator/GameModeSettings.php b/core/Configurator/GameModeSettings.php index 47a21a5b..86f9d7a2 100644 --- a/core/Configurator/GameModeSettings.php +++ b/core/Configurator/GameModeSettings.php @@ -563,10 +563,16 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat $settingsCount = count($newSettings); $settingIndex = 0; $title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($player); - $chatMessage = '$ff0' . $title . ' ' . $player->getEscapedNickname() . ' set GameMode-Setting' . ($settingsCount > 1 ? 's' : '') . ' '; + $chatMessage = $this->maniaControl->getChat()->formatMessage( + "\$ff0{$title} %s set GameMode-Setting" . ($settingsCount > 1 ? "s" : "") . " ", + $player + ); foreach ($newSettings as $settingName => $settingValue) { - $chatMessage .= '$<' . '$fff' . preg_replace('/^S_/', '', $settingName) . '$z$ff0 '; - $chatMessage .= 'to $fff' . $this->parseSettingValue($settingValue) . '$>'; + $chatMessage .= $this->maniaControl->getChat()->formatMessage( + '%s to %s', + preg_replace('/^S_/', '', $settingName), + $this->parseSettingValue($settingValue) + ); if ($settingIndex <= $settingsCount - 2) { $chatMessage .= ', '; diff --git a/core/ManiaExchange/ManiaExchangeList.php b/core/ManiaExchange/ManiaExchangeList.php index cfc3709e..2a322831 100644 --- a/core/ManiaExchange/ManiaExchangeList.php +++ b/core/ManiaExchange/ManiaExchangeList.php @@ -160,7 +160,7 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener $mxSearch->fetchMapsAsync(function (array $maps) use (&$player) { if (!$maps) { - $this->maniaControl->getChat()->sendError('No maps found, or MX is down!', $player->login); + $this->maniaControl->getChat()->sendError('No maps found, or MX is down!', $player); return; } $this->showManiaExchangeList($maps, $player); diff --git a/core/Maps/DirectoryBrowser.php b/core/Maps/DirectoryBrowser.php index ac3859ac..d1c4c190 100644 --- a/core/Maps/DirectoryBrowser.php +++ b/core/Maps/DirectoryBrowser.php @@ -371,7 +371,11 @@ class DirectoryBrowser implements ManialinkPageAnswerListener { $this->maniaControl->getMapManager()->updateMapTimestamp($map->uid); // Message - $message = $player->getEscapedNickname() . ' added ' . $map->getEscapedName() . '!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s added %s!', + $player, + $map + ); $this->maniaControl->getChat()->sendSuccess($message); Logger::logInfo($message, true); @@ -391,10 +395,18 @@ class DirectoryBrowser implements ManialinkPageAnswerListener { $folderPath = $player->getCache($this, self::CACHE_FOLDER_PATH); $filePath = $folderPath . $fileName; if (@unlink($filePath)) { - $this->maniaControl->getChat()->sendSuccess("Erased {$fileName}!"); + $message = $this->maniaControl->getChat()->formatMessage( + 'Erased %s!', + $fileName + ); + $this->maniaControl->getChat()->sendSuccess($message, $player); $this->showManiaLink($player); } else { - $this->maniaControl->getChat()->sendError("Couldn't erase {$fileName}!"); + $message = $this->maniaControl->getChat()->formatMessage( + 'Could not erase %s!', + $fileName + ); + $this->maniaControl->getChat()->sendError($message, $player); } } } diff --git a/core/Maps/MapCommands.php b/core/Maps/MapCommands.php index 7a3c74f6..bfc49130 100644 --- a/core/Maps/MapCommands.php +++ b/core/Maps/MapCommands.php @@ -15,6 +15,7 @@ use ManiaControl\Manialinks\ElementBuilder; use ManiaControl\Manialinks\IconManager; use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Players\Player; +use ManiaControl\Utils\DataUtil; use Maniaplanet\DedicatedServer\Xmlrpc\ChangeInProgressException; use Maniaplanet\DedicatedServer\Xmlrpc\FaultException; @@ -62,7 +63,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb $this->maniaControl->getCommandManager()->registerCommandListener(array('readmaplist', 'rml'), $this, 'command_ReadMapList', true, 'Loads a maplist into the server.'); // Player commands - $this->maniaControl->getCommandManager()->registerCommandListener('nextmap', $this, 'command_showNextMap', false, 'Shows which map is next.'); + $this->maniaControl->getCommandManager()->registerCommandListener(array('nextmap', 'next'), $this, 'command_showNextMap', false, 'Shows which map is next.'); $this->maniaControl->getCommandManager()->registerCommandListener(array('maps', 'list'), $this, 'command_List', false, 'Shows the current maplist (or variations).'); $this->maniaControl->getCommandManager()->registerCommandListener(array('xmaps', 'xlist'), $this, 'command_xList', false, 'Shows maps from ManiaExchange.'); @@ -117,12 +118,20 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb $requester = $nextQueued[0]; /** @var Map $map */ $map = $nextQueued[1]; - $this->maniaControl->getChat()->sendInformation("Next Map is $<{$map->name}$> from $<{$map->authorNick}$> requested by $<{$requester->nickname}$>.", $player); + $message = $this->maniaControl->getChat()->formatMessage( + 'Next Map is %s, requested by %s.', + $map, + $requester + ); + $this->maniaControl->getChat()->sendInformation($message, $player); } else { $mapIndex = $this->maniaControl->getClient()->getNextMapIndex(); - $maps = $this->maniaControl->getMapManager()->getMaps(); - $map = $maps[$mapIndex]; - $this->maniaControl->getChat()->sendInformation("Next Map is $<{$map->name}$> from $<{$map->authorNick}$>.", $player); + $map = $this->maniaControl->getMapManager()->getMapByIndex($mapIndex); + $message = $this->maniaControl->getChat()->formatMessage( + 'Next Map is %s.', + $map + ); + $this->maniaControl->getChat()->sendInformation($message, $player); } } @@ -137,14 +146,14 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } - // Get map + $map = $this->maniaControl->getMapManager()->getCurrentMap(); if (!$map) { - $this->maniaControl->getChat()->sendError("Couldn't remove map.", $player); + $this->maniaControl->getChat()->sendError('Could not fetch current map to remove!', $player); return; } - // Remove map + // no chat message necessary, the MapManager will do that $this->maniaControl->getMapManager()->removeMap($player, $map->uid); } @@ -159,14 +168,14 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } - // Get map + $map = $this->maniaControl->getMapManager()->getCurrentMap(); if (!$map) { - $this->maniaControl->getChat()->sendError("Couldn't erase map.", $player); + $this->maniaControl->getChat()->sendError('Could not fetch current map to erase!', $player); return; } - // Erase map + // no chat message necessary, the MapManager will do that $this->maniaControl->getMapManager()->removeMap($player, $map->uid, true); } @@ -182,7 +191,7 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb return; } - // Shuffles the maps + // no chat message necessary, the MapManager will do that $this->maniaControl->getMapManager()->shuffleMapList($player); } @@ -197,13 +206,17 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } + $params = explode(' ', $chatCallback[1][2], 2); if (count($params) < 2) { - $this->maniaControl->getChat()->sendUsageInfo('Usage example: //addmap 1234', $player); + $message = $this->maniaControl->getChat()->formatMessage( + 'Usage example: %s', + '//addmap 1234' + ); + $this->maniaControl->getChat()->sendUsageInfo($message, $player); return; } - // add Map from Mania Exchange $this->maniaControl->getMapManager()->addMapFromMx($params[1], $player->login); } @@ -221,7 +234,10 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb $this->maniaControl->getMapManager()->getMapActions()->skipMap(); - $message = $player->getEscapedNickname() . ' skipped the current Map!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s skipped the current Map!', + $player + ); $this->maniaControl->getChat()->sendSuccess($message); Logger::logInfo($message, true); } @@ -237,17 +253,21 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } - $message = $player->getEscapedNickname() . ' restarted the current Map!'; - $this->maniaControl->getChat()->sendSuccess($message); - Logger::logInfo($message, true); try { $this->maniaControl->getClient()->restartMap(); } catch (ChangeInProgressException $e) { + $this->maniaControl->getChat()->sendException($e, $player); + return; } - } - ////$this->maniaControl->mapManager->mapQueue->addFirstMapToMapQueue($this->currentVote->voter, $this->maniaControl->mapManager->getCurrentMap()); + $message = $this->maniaControl->getChat()->formatMessage( + '%s restarted the current Map!', + $player + ); + $this->maniaControl->getChat()->sendSuccess($message); + Logger::logInfo($message, true); + } /** * Handle replaymap command @@ -260,11 +280,15 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } - $message = $player->getEscapedNickname() . ' replays the current Map!'; - $this->maniaControl->getChat()->sendSuccess($message); - Logger::logInfo($message, true); $this->maniaControl->getMapManager()->getMapQueue()->addFirstMapToMapQueue($player, $this->maniaControl->getMapManager()->getCurrentMap()); + + $message = $this->maniaControl->getChat()->formatMessage( + '%s queued the current Map to replay!', + $player + ); + $this->maniaControl->getChat()->sendSuccess($message); + Logger::logInfo($message, true); } /** @@ -280,26 +304,35 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb } $chatCommand = explode(' ', $chat[1][2]); + $maplist = 'MatchSettings' . DIRECTORY_SEPARATOR; if (isset($chatCommand[1])) { - if (strstr($chatCommand[1], '.txt')) { - $maplist = $chatCommand[1]; + if (!DataUtil::endsWith($chatCommand[1], '.txt')) { + $maplist .= $chatCommand[1] . '.txt'; } else { - $maplist = $chatCommand[1] . '.txt'; + $maplist .= $chatCommand[1]; } } else { - $maplist = 'maplist.txt'; + $maplist .= 'maplist.txt'; } - $maplist = 'MatchSettings' . DIRECTORY_SEPARATOR . $maplist; try { $this->maniaControl->getClient()->saveMatchSettings($maplist); - - $message = 'Maplist $<$fff' . $maplist . '$> written.'; - $this->maniaControl->getChat()->sendSuccess($message, $player); - Logger::logInfo($message, true); } catch (FaultException $e) { - $this->maniaControl->getChat()->sendError('Cannot write maplist $<$fff' . $maplist . '$>!', $player); + $this->maniaControl->getChat()->sendException($e, $player); + $message = $this->maniaControl->getChat()->formatMessage( + 'Cannot write maplist %s!', + $maplist + ); + $this->maniaControl->getChat()->sendError($message, $player); + return; } + + $message = $this->maniaControl->getChat()->formatMessage( + 'Maplist %s written.', + $maplist + ); + $this->maniaControl->getChat()->sendSuccess($message, $player); + Logger::logInfo($message, true); } /** @@ -315,27 +348,36 @@ class MapCommands implements CommandListener, ManialinkPageAnswerListener, Callb } $chatCommand = explode(' ', $chat[1][2]); + $maplist = 'MatchSettings' . DIRECTORY_SEPARATOR; if (isset($chatCommand[1])) { - if (strstr($chatCommand[1], '.txt')) { - $maplist = $chatCommand[1]; + if (!DataUtil::endsWith($chatCommand[1], '.txt')) { + $maplist .= $chatCommand[1] . '.txt'; } else { - $maplist = $chatCommand[1] . '.txt'; + $maplist .= $chatCommand[1]; } } else { - $maplist = 'maplist.txt'; + $maplist .= 'maplist.txt'; } - $maplist = 'MatchSettings' . DIRECTORY_SEPARATOR . $maplist; try { $this->maniaControl->getClient()->loadMatchSettings($maplist); - - $message = 'Maplist $<$fff' . $maplist . '$> loaded.'; - $this->maniaControl->getMapManager()->restructureMapList(); - $this->maniaControl->getChat()->sendSuccess($message, $player); - Logger::logInfo($message, true); } catch (FaultException $e) { - $this->maniaControl->getChat()->sendError('Cannot load maplist $<$fff' . $maplist . '$>!', $player); + $this->maniaControl->getChat()->sendException($e, $player); + $message = $this->maniaControl->getChat()->formatMessage( + 'Cannot load maplist %s!', + $maplist + ); + $this->maniaControl->getChat()->sendError($message, $player); + return; } + + $message = $this->maniaControl->getChat()->formatMessage( + 'Maplist %s loaded.', + $maplist + ); + $this->maniaControl->getMapManager()->restructureMapList(); + $this->maniaControl->getChat()->sendSuccess($message, $player); + Logger::logInfo($message, true); } /** diff --git a/core/Maps/MapList.php b/core/Maps/MapList.php index ec500dc4..5c7de992 100644 --- a/core/Maps/MapList.php +++ b/core/Maps/MapList.php @@ -588,18 +588,22 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $this->maniaControl->getMapManager()->getMapQueue()->dontQueueNextMapChange(); try { $this->maniaControl->getClient()->jumpToMapIdent($mapUid); - } catch (NextMapException $exception) { - $this->maniaControl->getChat()->sendError('Error on Jumping to Map Ident: ' . $exception->getMessage(), $player); + } catch (NextMapException $e) { + $this->maniaControl->getChat()->sendException($e, $player); break; - } catch (NotInListException $exception) { + } catch (NotInListException $e) { // TODO: "Map not found." -> how is that possible? - $this->maniaControl->getChat()->sendError('Error on Jumping to Map Ident: ' . $exception->getMessage(), $player); + $this->maniaControl->getChat()->sendException($e, $player); break; } $map = $this->maniaControl->getMapManager()->getMapByUid($mapUid); - $message = $player->getEscapedNickname() . ' skipped to Map $z' . $map->getEscapedName() . '!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s skipped to Map %s!', + $player, + $map + ); $this->maniaControl->getChat()->sendSuccess($message); Logger::logInfo($message, true); @@ -610,14 +614,19 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { $votesPlugin = $this->maniaControl->getPluginManager()->getPlugin(self::DEFAULT_CUSTOM_VOTE_PLUGIN); $map = $this->maniaControl->getMapManager()->getMapByUid($mapUid); - $message = $player->getEscapedNickname() . '$s started a vote to switch to ' . $map->getEscapedName() . '!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s started a vote to switch to Map %s!', + $player, + $map + ); $votesPlugin->defineVote('switchmap', 'Goto ' . $map->name, true, $message)->setStopCallback(Callbacks::ENDMAP); - $votesPlugin->startVote($player, 'switchmap', function ($result) use (&$votesPlugin, &$map) { - $votesPlugin->undefineVote('switchmap'); + // will be only called, if successful - //Don't queue on Map-Change + $votesPlugin->undefineVote('switchmap'); + + // Don't queue on Map-Change $this->maniaControl->getMapManager()->getMapQueue()->dontQueueNextMapChange(); try { @@ -631,7 +640,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener { return; } - $this->maniaControl->getChat()->sendInformation('$sVote Successful -> Map switched!'); + $this->maniaControl->getChat()->sendSuccess('Vote Successful -> Map switched!'); }); break; case self::ACTION_QUEUED_MAP: diff --git a/core/Maps/MapManager.php b/core/Maps/MapManager.php index 95fe83d6..3aabcb1a 100644 --- a/core/Maps/MapManager.php +++ b/core/Maps/MapManager.php @@ -192,7 +192,11 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform if (!isset($uid) || !isset($this->maps[$uid])) { if ($admin) { - $this->maniaControl->getChat()->sendError("Error updating Map: Unknown UID '{$uid}'!", $admin); + $message = $this->maniaControl->getChat()->formatMessage( + 'Error updating Map, unknown UID %s!', + $uid + ); + $this->maniaControl->getChat()->sendError($message, $admin); } return; } @@ -278,16 +282,22 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform // Check if ManiaControl can even write to the maps dir $mapDir = $this->maniaControl->getClient()->getMapsDirectory(); if ($this->maniaControl->getServer()->checkAccess($mapDir)) { + $mapFile = $mapDir . $map->fileName; + // Delete map file - if (!@unlink($mapDir . $map->fileName)) { + if (!@unlink($mapFile)) { if ($admin) { - $this->maniaControl->getChat()->sendError("Couldn't erase the map file.", $admin); + $message = $this->maniaControl->getChat()->formatMessage( + 'Could not erase the map file %s.', + $mapFile + ); + $this->maniaControl->getChat()->sendError($message, $admin); } $eraseFile = false; } } else { if ($admin) { - $this->maniaControl->getChat()->sendError("Couldn't erase the map file (no access).", $admin); + $this->maniaControl->getChat()->sendError('Could not erase the map file (no access to Maps-Directory).', $admin); } $eraseFile = false; } @@ -297,9 +307,16 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform if ($message) { $action = ($eraseFile ? 'erased' : 'removed'); if ($admin) { - $message = $admin->getEscapedNickname() . ' ' . $action . ' ' . $map->getEscapedName() . '!'; + $message = $this->maniaControl->getChat()->formatMessage( + "%s {$action} %s!", + $admin, + $map + ); } else { - $message = $map->getEscapedName() . ' got ' . $action . '!'; + $message = $this->maniaControl->getChat()->formatMessage( + "%s got {$action}!", + $map + ); } $this->maniaControl->getChat()->sendSuccess($message); Logger::logInfo($message, true); @@ -363,7 +380,7 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform if (!$file || $error) { if ($login) { // Download error - $this->maniaControl->getChat()->sendError("Download failed: '{$error}'!", $login); + $this->maniaControl->getChat()->sendError("Download failed: {$error}!", $login); } return; } @@ -406,7 +423,11 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform if ($this->maniaControl->getServer()->checkAccess($mapDir)) { // Create download directory if necessary if (!is_dir($downloadDirectory) && !mkdir($downloadDirectory) || !is_writable($downloadDirectory)) { - $this->maniaControl->getChat()->sendError("ManiaControl doesn't have to rights to save maps in '{$downloadDirectory}'.", $login); + $message = $this->maniaControl->getChat()->formatMessage( + 'ManiaControl does not have to rights to save maps in %s!', + $downloadDirectory + ); + $this->maniaControl->getChat()->sendError($message, $login); return; } @@ -421,12 +442,12 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform $this->maniaControl->getClient()->writeFile($relativeMapFileName, $file); } catch (InvalidArgumentException $e) { if ($e->getMessage() === 'data are too big') { - $this->maniaControl->getChat()->sendError("Map is too big for a remote save.", $login); + $this->maniaControl->getChat()->sendError('Map is too big for a remote save!', $login); return; } throw $e; } catch (FileException $e) { - $this->maniaControl->getChat()->sendError("Could not write file", $login); + $this->maniaControl->getChat()->sendError('Could not write file!', $login); return; } } @@ -434,26 +455,26 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform // Check for valid map try { $this->maniaControl->getClient()->checkMapForCurrentServerParams($relativeMapFileName); - } catch (InvalidMapException $exception) { - $this->maniaControl->getChat()->sendException($exception, $login); + } catch (InvalidMapException $e) { + $this->maniaControl->getChat()->sendException($e, $login); return; - } catch (FileException $exception) { - $this->maniaControl->getChat()->sendException($exception, $login); + } catch (FileException $e) { + $this->maniaControl->getChat()->sendException($e, $login); return; - }catch (FaultException $exception){ - $this->maniaControl->getChat()->sendException($exception, $login); + }catch (FaultException $e){ + $this->maniaControl->getChat()->sendException($e, $login); return; } // Add map to map list try { $this->maniaControl->getClient()->insertMap($relativeMapFileName); - } catch (AlreadyInListException $exception) { - $this->maniaControl->getChat()->sendException($exception, $login); + } catch (AlreadyInListException $e) { + $this->maniaControl->getChat()->sendException($e, $login); return; - } catch (InvalidMapException $exception) { - $this->maniaControl->getChat()->sendException($exception, $login); - if ($exception->getMessage() != 'Map lightmap is not up to date. (will still load for now)') { + } catch (InvalidMapException $e) { + $this->maniaControl->getChat()->sendException($e, $login); + if ($e->getMessage() != 'Map lightmap is not up to date. (will still load for now)') { return; } } @@ -482,14 +503,21 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform if ($login) { $player = $this->maniaControl->getPlayerManager()->getPlayer($login); if (!$update) { - // Message - $message = $player->getEscapedNickname() . ' added $<' . $mapInfo->name . '$>!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s added %s from MX!', + $player, + $map + ); $this->maniaControl->getChat()->sendSuccess($message); Logger::logInfo($message, true); - // Queue requested Map + $this->maniaControl->getMapManager()->getMapQueue()->addMapToMapQueue($login, $mapInfo->uid); } else { - $message = $player->getEscapedNickname() . ' updated $<' . $mapInfo->name . '$>!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s updated %s from MX!', + $player, + $map + ); $this->maniaControl->getChat()->sendSuccess($message); Logger::logInfo($message, true); } @@ -649,15 +677,18 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform $this->maniaControl->getClient()->chooseNextMapList($mapArray); } catch (Exception $e) { //TODO temp added 19.04.2014 - $this->maniaControl->getErrorHandler()->triggerDebugNotice("Exception line 331 MapManager" . $e->getMessage()); - trigger_error("Couldn't shuffle mapList. " . $e->getMessage()); + $this->maniaControl->getErrorHandler()->triggerDebugNotice('Exception line 331 MapManager' . $e->getMessage()); + trigger_error('Could not shuffle mapList. ' . $e->getMessage()); return false; } $this->fetchCurrentMap(); if ($admin) { - $message = $admin->getEscapedNickname() . ' shuffled the Maplist!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s shuffled the Maplist!', + $admin + ); $this->maniaControl->getChat()->sendSuccess($message); Logger::logInfo($message, true); } @@ -725,7 +756,7 @@ class MapManager implements CallbackListener, CommunicationListener, UsageInform try { $this->maniaControl->getClient()->chooseNextMapList($mapArray); } catch (Exception $e) { - trigger_error("Error restructuring the Maplist. " . $e->getMessage()); + trigger_error('Error restructuring the Maplist. ' . $e->getMessage()); return false; } return true; diff --git a/core/Maps/MapQueue.php b/core/Maps/MapQueue.php index d0cdff7d..c8984ed1 100644 --- a/core/Maps/MapQueue.php +++ b/core/Maps/MapQueue.php @@ -34,6 +34,7 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl const SETTING_SKIP_MAPQUEUE_ADMIN = 'Skip Map when admin leaves'; const SETTING_MAPLIMIT_PLAYER = 'Maximum maps per player in the Map-Queue (-1 = unlimited)'; const SETTING_MAPLIMIT_ADMIN = 'Maximum maps per admin (Admin+) in the Map-Queue (-1 = unlimited)'; + const SETTING_MESSAGE_FORMAT = 'Message Format'; const SETTING_BUFFERSIZE = 'Size of the Map-Queue buffer (recently played maps)'; const SETTING_PERMISSION_CLEAR_MAPQUEUE = 'Clear MapQueue'; const SETTING_PERMISSION_QUEUE_BUFFER = 'Queue maps in buffer'; @@ -69,6 +70,7 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SKIP_MAPQUEUE_ADMIN, false); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAPLIMIT_PLAYER, 1); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MAPLIMIT_ADMIN, -1); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MESSAGE_FORMAT, '$fa0'); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_BUFFERSIZE, 10); // Permissions @@ -117,17 +119,22 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl return; } + $messagePrefix = $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MESSAGE_FORMAT); if ($admin && empty($this->queuedMaps)) { - $this->maniaControl->getChat()->sendError('$fa0There are no maps in the jukebox!', $admin->login); + $this->maniaControl->getChat()->sendError($messagePrefix . 'There are no maps in the jukebox!', $admin); return; } - //Destroy map - queue list + // Destroy map - queue list $this->queuedMaps = array(); if ($admin) { - $title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel); - $message = '$fa0' . $title . ' $<$fff' . $admin->nickname . '$> cleared the Map-Queue!'; + $title = $admin->getAuthLevelName(); + $message = $this->maniaControl->getChat()->formatMessage( + $messagePrefix . '%s %s cleared the Map-Queue!', + $title, + $admin + ); $this->maniaControl->getChat()->sendInformation($message); Logger::logInfo($message, true); } @@ -172,15 +179,20 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl * @param Player $player */ public function showMapQueue(Player $player) { + $messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT); if (empty($this->queuedMaps)) { - $this->maniaControl->getChat()->sendError('$fa0There are no maps in the jukebox!', $player->login); + $this->maniaControl->getChat()->sendInformation($messagePrefix . 'There are no maps in the jukebox!', $player); return; } - $message = '$fa0Upcoming maps in the Map-Queue:'; + $message = $messagePrefix . 'Upcoming maps in the Map-Queue:'; $index = 1; foreach ($this->queuedMaps as $queuedMap) { - $message .= ' $<$fff' . $index . '$>. [$<$fff' . Formatter::stripCodes($queuedMap[1]->name) . '$>]'; + $message .= $this->maniaControl->getChat()->formatMessage( + ' %s. [%s]', + $index, + Formatter::stripCodes($queuedMap[1]->name) + ); $index++; } @@ -193,8 +205,9 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl * @param Player $player */ public function showMapQueueManialink(Player $player) { + $messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT); if (empty($this->queuedMaps)) { - $this->maniaControl->getChat()->sendError('There are no Maps in the Jukebox!', $player); + $this->maniaControl->getChat()->sendInformation($messagePrefix . 'There are no Maps in the Jukebox!', $player); return; } @@ -246,7 +259,12 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl $this->queuedMaps[$uid] = array(null, $map); - $this->maniaControl->getChat()->sendInformation('$fa0$<$fff' . $map->name . '$> has been added to the Map-Queue by the Server.'); + $messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT); + $message = $this->maniaControl->getChat()->formatMessage( + $messagePrefix . '%s has been added to the Map-Queue by the Server.', + $map + ); + $this->maniaControl->getChat()->sendInformation($message); // Trigger callback $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $this->queuedMaps[$uid])); @@ -285,13 +303,21 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl if ($isModerator) { $maxAdmin = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAPLIMIT_ADMIN); if ($maxAdmin >= 0 && $mapsForPlayer >= $maxAdmin) { - $this->maniaControl->getChat()->sendError('You already have $<$fff' . $maxAdmin . '$> map(s) in the Map-Queue!', $login); + $message = $this->maniaControl->getChat()->formatMessage( + 'You already have %s map(s) in the Map-Queue!', + $maxAdmin + ); + $this->maniaControl->getChat()->sendError($message, $player); return; } } else { $maxPlayer = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAPLIMIT_PLAYER); if ($maxPlayer >= 0 && $mapsForPlayer >= $maxPlayer) { - $this->maniaControl->getChat()->sendError('You already have $<$fff' . $maxPlayer . '$> map(s) in the Map-Queue!', $login); + $message = $this->maniaControl->getChat()->formatMessage( + 'You already have %s map(s) in the Map-Queue!', + $maxPlayer + ); + $this->maniaControl->getChat()->sendError($message, $player); return; } } @@ -303,14 +329,15 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl $uid = $map->uid; } if (array_key_exists($uid, $this->queuedMaps)) { - $this->maniaControl->getChat()->sendError('That map is already in the Map-Queue!', $login); + $this->maniaControl->getChat()->sendError('This map is already in the Map-Queue!', $player); return; } //TODO recently maps not able to add to queue-amps setting, and management // Check if map is in the buffer + $messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT); if (in_array($uid, $this->buffer)) { - $this->maniaControl->getChat()->sendError('That map has recently been played!', $login); + $this->maniaControl->getChat()->sendInformation($messagePrefix . 'This map has recently been played!', $player); if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_CLEAR_MAPQUEUE)) { return; } @@ -322,7 +349,12 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl $this->queuedMaps[$uid] = array($player, $map); - $this->maniaControl->getChat()->sendInformation('$fa0$<$fff' . $map->name . '$> has been added to the Map-Queue by $<$fff' . $player->nickname . '$>.'); + $message = $this->maniaControl->getChat()->formatMessage( + $messagePrefix . '%s has been added to the Map-Queue by %s.', + $map, + $player + ); + $this->maniaControl->getChat()->sendInformation($message); // Trigger callback $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_MAPQUEUE_CHANGED, array('add', $this->queuedMaps[$uid])); @@ -343,7 +375,13 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl unset($this->queuedMaps[$uid]); if ($player) { - $this->maniaControl->getChat()->sendInformation('$fa0$<$fff' . $map->name . '$> is removed from the Map-Queue by $<$fff' . $player->nickname . '$>.'); + $messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT); + $message = $this->maniaControl->getChat()->formatMessage( + $messagePrefix . '%s has been removed from the Map-Queue by %s.', + $map, + $player + ); + $this->maniaControl->getChat()->sendInformation($message); } // Trigger callback @@ -356,17 +394,22 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl * @internal */ public function endMap() { - //Don't queue next map (for example on skip to map) + // Don't queue next map (for example on skip to map) if ($this->nextNoQueue) { $this->nextNoQueue = false; return; } + + $messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT); $this->nextMap = null; if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SKIP_MAP_ON_LEAVE)) { // Skip Map if requester has left foreach ($this->queuedMaps as $queuedMap) { + /** @var Player $player */ $player = $queuedMap[0]; + /** @var Map $map */ + $map = $queuedMap[1]; // Check if map is added via replay vote/command if (isset($queuedMap[2]) && $queuedMap[2] === true) { @@ -391,22 +434,34 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl // Player not found, so remove the map from the mapqueue array_shift($this->queuedMaps); - $this->maniaControl->getChat()->sendInformation('$fa0$<$fff' . $queuedMap[0]->name . '$> is skipped because $<' . $player->nickname . '$> left the game!'); + $message = $this->maniaControl->getChat()->formatMessage( + $messagePrefix . '%s will be skipped, because %s left the game!', + $map, + $player + ); + $this->maniaControl->getChat()->sendInformation($message); } } $this->nextMap = array_shift($this->queuedMaps); - //Check if Map Queue is empty + // Check if Map Queue is empty if (!$this->nextMap || !isset($this->nextMap[1])) { return; } + /** @var Player $player */ + $player = $this->nextMap[0]; + /** @var Map $map */ $map = $this->nextMap[1]; - //Message only if it's juked by a player (not by the server) - if ($this->nextMap[0]) { - /** @var Map $map */ - $this->maniaControl->getChat()->sendInformation('$fa0Next map will be $<$fff' . $map->name . '$> as requested by $<' . $this->nextMap[0]->nickname . '$>.'); + // Message only if it's juked by a player (not by the server) + if ($player) { + $message = $this->maniaControl->getChat()->formatMessage( + $messagePrefix . 'Next map will be %s as requested by %s.', + $map, + $player + ); + $this->maniaControl->getChat()->sendInformation($message); } try { From 74dc8182bfa817af1409c189c3aa2043faa520bd Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Sat, 30 May 2020 22:42:39 +0200 Subject: [PATCH 89/98] Use Chat::formatMessage in Players/* --- core/Players/PlayerActions.php | 324 +++++++++++++++++++------------- core/Players/PlayerCommands.php | 180 ++++++++++++------ core/Players/PlayerList.php | 21 ++- core/Players/PlayerManager.php | 46 ++--- 4 files changed, 352 insertions(+), 219 deletions(-) diff --git a/core/Players/PlayerActions.php b/core/Players/PlayerActions.php index 8a8ac27a..f437b914 100644 --- a/core/Players/PlayerActions.php +++ b/core/Players/PlayerActions.php @@ -165,11 +165,11 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma public function forcePlayerToTeam($adminLogin, $targetLogin, $teamId, $calledByAdmin = true) { if ($calledByAdmin) { $admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin); - if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_TEAM)) { - $this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin); + if (!$admin) { return false; } - if (!$admin) { + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_TEAM)) { + $this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin); return false; } } @@ -183,52 +183,54 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma if (!$this->forcePlayerToPlay($adminLogin, $targetLogin, true, false, $calledByAdmin)) { return false; } - } catch (FaultException $exception) { - if ($calledByAdmin) { - $this->maniaControl->getChat()->sendException($exception, $admin); - } + } catch (FaultException $e) { + $this->maniaControl->getChat()->sendException($e, $adminLogin); } } try { $this->maniaControl->getClient()->forcePlayerTeam($target->login, $teamId); - } catch (ServerOptionsException $exception) { + } catch (ServerOptionsException $e) { $this->forcePlayerToPlay($adminLogin, $targetLogin); return false; - } catch (UnknownPlayerException $exception) { + } catch (UnknownPlayerException $e) { + $this->maniaControl->getChat()->sendException($e, $adminLogin); + return false; + } catch (GameModeException $e) { + $this->maniaControl->getChat()->sendException($e, $adminLogin); + return false; + } + + $message = false; + $teamName = ''; + if ($teamId === self::TEAM_BLUE) { + $teamName = '$00fBlue'; + } elseif ($teamId === self::TEAM_RED) { + $teamName = '$f00Red'; + } + + if ($teamName) { if ($calledByAdmin) { - $this->maniaControl->getChat()->sendException($exception, $admin); - } - return false; - } catch (GameModeException $exception) { - if ($calledByAdmin) { - $this->maniaControl->getChat()->sendException($exception, $admin); - } - return false; - } - - $chatMessage = false; - - if ($calledByAdmin) { - $title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel); - if ($teamId === self::TEAM_BLUE) { - $chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' forced ' . $target->getEscapedNickname() . ' into the Blue-Team!'; - } else if ($teamId === self::TEAM_RED) { - $chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' forced ' . $target->getEscapedNickname() . ' into the Red-Team!'; - } - } else { - if ($teamId === self::TEAM_BLUE) { - $chatMessage = $target->getEscapedNickname() . ' got forced into the Blue-Team!'; - } else if ($teamId === self::TEAM_RED) { - $chatMessage = $target->getEscapedNickname() . ' got forced into the Red-Team!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s %s forced %s into the %s-Team!', + $admin->getAuthLevelName(), + $admin, + $target, + $teamName + ); + } else { + $message = $this->maniaControl->getChat()->formatMessage( + '%s got forced %s into the %s-Team!', + $target, + $teamName + ); } } - if (!$chatMessage) { - return false; + if ($message) { + $this->maniaControl->getChat()->sendInformation($message); + Logger::logInfo($chatMessage, true); } - $this->maniaControl->getChat()->sendInformation($chatMessage); - Logger::logInfo($chatMessage, true); return true; } @@ -260,24 +262,20 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma try { $this->maniaControl->getClient()->forceSpectator($target->login, self::SPECTATOR_PLAYER); - } catch (ServerOptionsException $exception) { - if ($calledByAdmin) { - $this->maniaControl->getChat()->sendException($exception, $admin); - } + } catch (ServerOptionsException $e) { + $this->maniaControl->getChat()->sendException($e, $adminLogin); return false; - } catch (UnknownPlayerException $exception) { - if ($calledByAdmin) { - $this->maniaControl->getChat()->sendException($exception, $admin); - } + } catch (UnknownPlayerException $e) { + $this->maniaControl->getChat()->sendException($e, $adminLogin); return false; } if ($userIsAbleToSelect) { try { $this->maniaControl->getClient()->forceSpectator($target->login, self::SPECTATOR_USER_SELECTABLE); - } catch (ServerOptionsException $exception) { + } catch (ServerOptionsException $e) { if ($calledByAdmin) { - $this->maniaControl->getChat()->sendException($exception, $admin); + $this->maniaControl->getChat()->sendException($e, $admin); } return false; } @@ -286,13 +284,20 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma // Announce force if ($displayAnnouncement) { if ($calledByAdmin) { - $chatMessage = $admin->getEscapedNickname() . ' forced ' . $target->getEscapedNickname() . ' to Play!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s %s forced %s to Play!', + $admin->getAuthLevelName(), + $admin, + $target + ); } else { - $chatMessage = $target->getEscapedNickname() . ' got forced to Play!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s got forced to Play!', + $target + ); } - - $this->maniaControl->getChat()->sendInformation($chatMessage); + $this->maniaControl->getChat()->sendInformation($message); } return true; @@ -312,12 +317,12 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma public function forcePlayerToSpectator($adminLogin, $targetLogin, $spectatorState = self::SPECTATOR_BUT_KEEP_SELECTABLE, $releaseSlot = true, $calledByAdmin = true) { if ($calledByAdmin) { $admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin); - if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_SPEC)) { - $this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin); + if (!$admin) { return false; } - if (!$admin) { + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($admin, self::SETTING_PERMISSION_FORCE_PLAYER_SPEC)) { + $this->maniaControl->getAuthenticationManager()->sendNotAllowed($admin); return false; } } @@ -330,21 +335,27 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma try { $this->maniaControl->getClient()->forceSpectator($target->login, $spectatorState); - } catch (ServerOptionsException $exception) { - if ($calledByAdmin) { - $this->maniaControl->getChat()->sendException($exception, $admin->login); - } + } catch (ServerOptionsException $e) { + $this->maniaControl->getChat()->sendException($e, $adminLogin); return false; } if ($calledByAdmin) { - $title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel); - $chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' forced ' . $target->getEscapedNickname() . ' to Spectator!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s %s forced %s to Spectator!', + $admin->getAuthLevelName(), + $admin, + $target + ); } else { - $chatMessage = $target->getEscapedNickname() . ' got forced to Spectator!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s got forced to Spectator!', + $target + ); } - $this->maniaControl->getChat()->sendInformation($chatMessage); - Logger::logInfo($chatMessage, true); + + $this->maniaControl->getChat()->sendInformation($message); + Logger::logInfo($message, true); if ($releaseSlot) { // Free player slot @@ -375,8 +386,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma return false; } } - $target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin); + $target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin); if (!$target) { return false; } @@ -384,19 +395,30 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma try { $this->maniaControl->getClient()->unIgnore($targetLogin); } catch (NotInListException $e) { - $this->maniaControl->getChat()->sendError('Player is not ignored!', $adminLogin); + $message = $this->maniaControl->getChat()->formatMessage( + '%s is not muted!', + $player + ); + $this->maniaControl->getChat()->sendError($message, $adminLogin); return false; } if ($calledByAdmin) { - $title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel); - $chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' un-muted ' . $target->getEscapedNickname() . '!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s %s un-muted %s!', + $admin->getAuthLevelName(), + $admin, + $target + ); } else { - $chatMessage = $target->getEscapedNickname() . ' got un-muted!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s got un-muted!', + $target + ); } - $this->maniaControl->getChat()->sendInformation($chatMessage); - Logger::logInfo($chatMessage, true); + $this->maniaControl->getChat()->sendInformation($message); + Logger::logInfo($message, true); return true; } @@ -418,8 +440,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma return false; } } - $target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin); + $target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin); if (!$target) { return false; } @@ -427,20 +449,30 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma try { $this->maniaControl->getClient()->ignore($targetLogin); } catch (AlreadyInListException $e) { - $this->maniaControl->getChat()->sendError("Player already ignored!", $adminLogin); + $message = $this->maniaControl->getChat()->formatMessage( + '%s is already muted!', + $player + ); + $this->maniaControl->getChat()->sendError($message, $adminLogin); return false; } - // Announce warning if ($calledByAdmin) { - $title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel); - $chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' muted ' . $target->getEscapedNickname() . '!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s %s muted %s!', + $admin->getAuthLevelName(), + $admin, + $target + ); } else { - $chatMessage = $target->getEscapedNickname() . ' got muted!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s got muted!', + $target + ); } - $this->maniaControl->getChat()->sendInformation($chatMessage); - Logger::logInfo($chatMessage, true); + $this->maniaControl->getChat()->sendInformation($message); + Logger::logInfo($message, true); return true; } @@ -464,7 +496,6 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma } $target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin); - if (!$target) { return false; } @@ -527,16 +558,22 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma // Display manialink $this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $target); - // Announce warning if ($calledByAdmin) { - $title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel); - $chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' warned ' . $target->getEscapedNickname() . '!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s %s warned %s!', + $admin->getAuthLevelName(), + $admin, + $target + ); } else { - $chatMessage = $target->getEscapedNickname() . ' got an administrative warning!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s got warned!', + $target + ); } - $this->maniaControl->getChat()->sendInformation($chatMessage); - Logger::log($chatMessage, true); + $this->maniaControl->getChat()->sendInformation($message); + Logger::log($message, true); return true; } @@ -570,37 +607,37 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma try { $this->maniaControl->getClient()->disconnectFakePlayer($target->login); } catch (PlayerStateException $e) { - if ($calledByAdmin) { - $this->maniaControl->getChat()->sendException($e, $admin); - } + $this->maniaControl->getChat()->sendException($e, $adminLogin); return false; - } catch (UnknownPlayerException $e) { //TODO check why it's actually needed, but there was a crash at this place - if ($calledByAdmin) { - $this->maniaControl->getChat()->sendException($e, $admin); - } + } catch (UnknownPlayerException $e) { + $this->maniaControl->getChat()->sendException($e, $adminLogin); return false; } } else { try { $this->maniaControl->getClient()->kick($target->login, $message); } catch (UnknownPlayerException $e) { - if ($calledByAdmin) { - $this->maniaControl->getChat()->sendException($e, $admin); - } + $this->maniaControl->getChat()->sendException($e, $adminLogin); return false; } } - // Announce kick if ($calledByAdmin) { - $title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel); - $chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' kicked ' . $target->getEscapedNickname() . '!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s %s kicked %s!', + $admin->getAuthLevelName(), + $admin, + $target + ); } else { - $chatMessage = $target->getEscapedNickname() . ' got kicked!'; + $message = $this->maniaControl->getChat()->formatMessage( + '%s got kicked!', + $target + ); } - $this->maniaControl->getChat()->sendInformation($chatMessage); - Logger::logInfo($chatMessage, true); + $this->maniaControl->getChat()->sendInformation($message); + Logger::logInfo($message, true); return true; } @@ -639,12 +676,14 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma return; } - - // Announce ban - $title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel); - $chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' banned ' . $target->getEscapedNickname() . '!'; - $this->maniaControl->getChat()->sendInformation($chatMessage); - Logger::logInfo($chatMessage, true); + $message = $this->maniaControl->getChat()->formatMessage( + '%s %s banned %s!', + $admin->getAuthLevelName(), + $admin, + $target + ); + $this->maniaControl->getChat()->sendInformation($message); + Logger::logInfo($message, true); } /** @@ -679,35 +718,52 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma return; } - // Announce ban - $title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel); - $chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' unbanned ' . $targetLogin . '!'; - $this->maniaControl->getChat()->sendInformation($chatMessage); - Logger::logInfo($chatMessage, true); + $message = $this->maniaControl->getChat()->formatMessage( + '%s %s unbanned %s!', + $admin->getAuthLevelName(), + $admin, + $target + ); + $this->maniaControl->getChat()->sendInformation($message); + Logger::logInfo($message, true); } /** * Grands the Player an Authorization Level * * @api + * @deprecated * @param string $adminLogin * @param string $targetLogin * @param int $authLevel */ public function grandAuthLevel($adminLogin, $targetLogin, $authLevel) { + $this->grantAuthLevel($adminLogin, $targetLogin, $authLevel); + } + + /** + * Grants the Player an Authorization Level + * + * @api + * @deprecated + * @param string $adminLogin + * @param string $targetLogin + * @param int $authLevel + */ + public function grantAuthLevel($adminLogin, $targetLogin, $authLevel) { $admin = $this->maniaControl->getPlayerManager()->getPlayer($adminLogin); $target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin); if (!$admin || !$target) { return; } - $authLevelName = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($authLevel); - if (!$this->maniaControl->getAuthenticationManager()->checkRight($admin, $authLevel + 1)) { - $this->maniaControl->getChat()->sendError("You don't have the permission to add a {$authLevelName}!", $admin); + $authLevelName = AuthenticationManager::getAuthLevelName($authLevel); + if (!AuthenticationManager::checkRight($admin, $authLevel + 1)) { + $this->maniaControl->getChat()->sendError("You do not have the permission to add a {$authLevelName}!", $admin); return; } - if ($this->maniaControl->getAuthenticationManager()->checkRight($target, $authLevel)) { + if (AuthenticationManager::checkRight($target, $authLevel)) { $this->maniaControl->getChat()->sendError("This Player is already {$authLevelName}!", $admin); return; } @@ -718,11 +774,14 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma return; } - // Announce granting - $title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel); - $chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' added ' . $target->getEscapedNickname() . ' as $< ' . $authLevelName . '$>!'; - $this->maniaControl->getChat()->sendInformation($chatMessage); - Logger::logInfo($chatMessage, true); + $message = $this->maniaControl->getChat()->formatMessage( + "%s %s added %s as {$authLevelName}!", + $admin->getAuthLevelName(), + $admin, + $target + ); + $this->maniaControl->getChat()->sendInformation($message); + Logger::logInfo($message, true); } /** @@ -739,14 +798,13 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma return; } - if (!$this->maniaControl->getAuthenticationManager()->checkRight($admin, $target->authLevel + 1)) { - $title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($target->authLevel); - $this->maniaControl->getChat()->sendError("You can't revoke the Rights of a {$title}!", $admin); + if ($admin->authLevel <= $target->authLevel) { + $this->maniaControl->getChat()->sendError("You cannot revoke the Rights of a {$target->getAuthLevelName()}!", $admin); return; } - if ($this->maniaControl->getAuthenticationManager()->checkRight($target, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)) { - $this->maniaControl->getChat()->sendError("MasterAdmins can't be removed!", $admin); + if (AuthenticationManager::checkRight($target, AuthenticationManager::AUTH_LEVEL_MASTERADMIN)) { + $this->maniaControl->getChat()->sendError("MasterAdmins cannot be removed!", $admin); return; } @@ -756,11 +814,13 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma return; } - // Announce revoke - $title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($admin->authLevel); - $chatMessage = $title . ' ' . $admin->getEscapedNickname() . ' revoked the Rights of ' . $target->getEscapedNickname() . '!'; - $this->maniaControl->getChat()->sendInformation($chatMessage); - Logger::logInfo($chatMessage, true); + $message = $this->maniaControl->getChat()->formatMessage( + "%s %s revoked the Rights of %s!", + $admin->getAuthLevelName(), + $admin, + $target + ); + $this->maniaControl->getChat()->sendInformation($message); + Logger::logInfo($message, true); } - } diff --git a/core/Players/PlayerCommands.php b/core/Players/PlayerCommands.php index 1e5ec9da..ff902abd 100644 --- a/core/Players/PlayerCommands.php +++ b/core/Players/PlayerCommands.php @@ -45,6 +45,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca // Admin commands $this->maniaControl->getCommandManager()->registerCommandListener(array('balance', 'teambalance', 'autoteambalance'), $this, 'command_TeamBalance', true, 'Balances the teams.'); + $this->maniaControl->getCommandManager()->registerCommandListener('warn', $this, 'command_Warn', true, 'Warns a player from the server.'); $this->maniaControl->getCommandManager()->registerCommandListener('kick', $this, 'command_Kick', true, 'Kicks player from the server.'); $this->maniaControl->getCommandManager()->registerCommandListener('ban', $this, 'command_Ban', true, 'Bans a player from the server.'); $this->maniaControl->getCommandManager()->registerCommandListener('unban', $this, 'command_UnBan', true, 'Unbans a player from the server.'); @@ -112,7 +113,11 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca return; } - $this->maniaControl->getChat()->sendInformation($player->getEscapedNickname() . ' balanced Teams!'); + $message = $this->maniaControl->getChat()->formatMessage( + '%s balanced Teams!', + $player + ); + $this->maniaControl->getChat()->sendInformation($message); } /** @@ -122,22 +127,27 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca * @param Player $player */ public function command_Kick(array $chat, Player $player) { - if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_KICK_PLAYER) - ) { + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_KICK_PLAYER)) { $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } + $params = explode(' ', $chat[1][2], 3); if (count($params) <= 1) { - $this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//kick login'", $player->login); + $message = $this->maniaControl->getChat()->formatMessage( + 'No Login given! Example: %s', + '//kick login' + ); + $this->maniaControl->getChat()->sendUsageInfo($message, $player); return; } + $targetLogin = $params[1]; $message = ''; if (isset($params[2])) { $message = $params[2]; } - $this->maniaControl->getPlayerManager()->getPlayerActions()->kickPlayer($player->login, $targetLogin, $message); + $this->maniaControl->getPlayerManager()->getPlayerActions()->kickPlayer($player, $targetLogin, $message); } /** @@ -147,22 +157,27 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca * @param Player $player */ public function command_Ban(array $chat, Player $player) { - if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_BAN_PLAYER) - ) { + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_BAN_PLAYER)) { $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } + $params = explode(' ', $chat[1][2], 3); if (count($params) <= 1) { - $this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//ban login'", $player->login); + $message = $this->maniaControl->getChat()->formatMessage( + 'No Login given! Example: %s', + '//ban login' + ); + $this->maniaControl->getChat()->sendUsageInfo($message, $player); return; } + $targetLogin = $params[1]; $message = ''; if (isset($params[2])) { $message = $params[2]; } - $this->maniaControl->getPlayerManager()->getPlayerActions()->banPlayer($player->login, $targetLogin, $message); + $this->maniaControl->getPlayerManager()->getPlayerActions()->banPlayer($player, $targetLogin, $message); } /** @@ -172,18 +187,23 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca * @param Player $player */ public function command_UnBan(array $chat, Player $player) { - if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_BAN_PLAYER) - ) { + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_BAN_PLAYER)) { $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } + $params = explode(' ', $chat[1][2], 3); if (count($params) <= 1) { - $this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//ban login'", $player->login); + $message = $this->maniaControl->getChat()->formatMessage( + 'No Login given! Example: %s', + '//unban login' + ); + $this->maniaControl->getChat()->sendUsageInfo($message, $player); return; } + $targetLogin = $params[1]; - $this->maniaControl->getPlayerManager()->getPlayerActions()->unBanPlayer($player->login, $targetLogin); + $this->maniaControl->getPlayerManager()->getPlayerActions()->unBanPlayer($player, $targetLogin); } /** @@ -193,13 +213,23 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca * @param Player $player */ public function command_Warn(array $chatCallback, Player $player) { - $params = explode(' ', $chatCallback[1][2], 3); - if (count($params) <= 1) { - $this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//warn login'", $player->login); + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_WARN_PLAYER)) { + $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } + + $params = explode(' ', $chatCallback[1][2], 3); + if (count($params) <= 1) { + $message = $this->maniaControl->getChat()->formatMessage( + 'No Login given! Example: %s', + '//warn login' + ); + $this->maniaControl->getChat()->sendUsageInfo($message, $player); + return; + } + $targetLogin = $params[1]; - $this->maniaControl->getPlayerManager()->getPlayerActions()->warnPlayer($player->login, $targetLogin); + $this->maniaControl->getPlayerManager()->getPlayerActions()->warnPlayer($player, $targetLogin); } /** @@ -209,23 +239,27 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca * @param Player $player */ public function command_ForceSpectator(array $chat, Player $player) { - if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_SPEC) - ) { + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_SPEC)) { $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } + $params = explode(' ', $chat[1][2]); if (count($params) <= 1) { - $this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//forcespec login'", $player->login); + $message = $this->maniaControl->getChat()->formatMessage( + 'No Login given! Example: %s', + '//forcespec login' + ); + $this->maniaControl->getChat()->sendUsageInfo($message, $player); return; } - $targetLogin = $params[1]; + $targetLogin = $params[1]; if (isset($params[2]) && is_numeric($params[2])) { - $type = (int) $params[2]; - $this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToSpectator($player->login, $targetLogin, $type); + $type = intval($params[2]); + $this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToSpectator($player, $targetLogin, $type); } else { - $this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToSpectator($player->login, $targetLogin); + $this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToSpectator($player, $targetLogin); } } @@ -236,25 +270,29 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca * @param Player $player */ public function command_ForcePlay(array $chat, Player $player) { - if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_PLAY) - ) { + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_PLAY)) { $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } + $params = explode(' ', $chat[1][2]); if (!isset($params[1])) { - $this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//forceplay login'", $player->login); + $message = $this->maniaControl->getChat()->formatMessage( + 'No Login given! Example: %s', + '//forceplay login' + ); + $this->maniaControl->getChat()->sendUsageInfo($message, $player); return; } - $targetLogin = $params[1]; + $targetLogin = $params[1]; $type = 2; if (isset($params[2]) && is_numeric($params[2])) { - $type = (int) $params[2]; + $type = intval($params[2]); } $selectable = ($type === 2); - $this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToPlay($player->login, $targetLogin, $selectable); + $this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToPlay($player, $targetLogin, $selectable); } /** @@ -264,19 +302,23 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca * @param Player $player */ public function command_ForceBlue(array $chat, Player $player) { - if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM) - ) { + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)) { $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } + $params = explode(' ', $chat[1][2]); if (!isset($params[1])) { - $this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//forceblue login'", $player->login); + $message = $this->maniaControl->getChat()->formatMessage( + 'No Login given! Example: %s', + '//forceblue login' + ); + $this->maniaControl->getChat()->sendUsageInfo($message, $player); return; } - $targetLogin = $params[1]; - $this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_BLUE); + $targetLogin = $params[1]; + $this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToTeam($player, $targetLogin, PlayerActions::TEAM_BLUE); } /** @@ -286,19 +328,23 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca * @param Player $player */ public function command_ForceRed(array $chat, Player $player) { - if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM) - ) { + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_FORCE_PLAYER_TEAM)) { $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } + $params = explode(' ', $chat[1][2]); if (!isset($params[1])) { - $this->maniaControl->getChat()->sendUsageInfo("No Login given! Example: '//forcered login'", $player->login); + $message = $this->maniaControl->getChat()->formatMessage( + 'No Login given! Example: %s', + '//forcered login' + ); + $this->maniaControl->getChat()->sendUsageInfo($message, $player); return; } - $targetLogin = $params[1]; - $this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToTeam($player->login, $targetLogin, PlayerActions::TEAM_RED); + $targetLogin = $params[1]; + $this->maniaControl->getPlayerManager()->getPlayerActions()->forcePlayerToTeam($player, $targetLogin, PlayerActions::TEAM_RED); } /** @@ -308,11 +354,11 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca * @param Player $player */ public function command_AddFakePlayers(array $chatCallback, Player $player) { - if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_ADD_BOT) - ) { + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_ADD_BOT)) { $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } + $amount = 1; $messageParts = explode(' ', $chatCallback[1][2]); if (isset($messageParts[1]) && is_numeric($messageParts[1])) { @@ -325,7 +371,7 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca } $this->maniaControl->getChat()->sendSuccess('Fake players connected!', $player); } catch (UnavailableFeatureException $e) { - $this->maniaControl->getChat()->sendSuccess('Error while connecting a Fake-Player.', $player); + $this->maniaControl->getChat()->sendError('Error while connecting a Fake-Player.', $player); } } @@ -336,11 +382,11 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca * @param Player $player */ public function command_RemoveFakePlayers(array $chatCallback, Player $player) { - if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_ADD_BOT) - ) { + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, self::SETTING_PERMISSION_ADD_BOT)) { $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } + $this->maniaControl->getClient()->disconnectFakePlayer('*'); $this->maniaControl->getChat()->sendSuccess('Fake players disconnected!', $player); } @@ -349,32 +395,52 @@ class PlayerCommands implements CommandListener, ManialinkPageAnswerListener, Ca * Handle //mute Command * * @param array $chatCallback - * @param Player $admin + * @param Player $player */ - public function command_MutePlayer(array $chatCallback, Player $admin) { - $commandParts = explode(' ', $chatCallback[1][2]); - if (count($commandParts) <= 1) { - $this->maniaControl->getChat()->sendUsageInfo("No login specified! Example: '//mute login'", $admin); + public function command_MutePlayer(array $chatCallback, Player $player) { + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_MUTE_PLAYER)) { + $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } + + $commandParts = explode(' ', $chatCallback[1][2]); + if (count($commandParts) <= 1) { + $message = $this->maniaControl->getChat()->formatMessage( + 'No Login given! Example: %s', + '//mute login' + ); + $this->maniaControl->getChat()->sendUsageInfo($message, $player); + return; + } + $targetLogin = $commandParts[1]; - $this->maniaControl->getPlayerManager()->getPlayerActions()->mutePlayer($admin->login, $targetLogin); + $this->maniaControl->getPlayerManager()->getPlayerActions()->mutePlayer($player, $targetLogin); } /** * Handle //unmute Command * * @param array $chatCallback - * @param Player $admin + * @param Player $player */ - public function command_UnmutePlayer(array $chatCallback, Player $admin) { - $commandParts = explode(' ', $chatCallback[1][2]); - if (count($commandParts) <= 1) { - $this->maniaControl->getChat()->sendUsageInfo("No login specified! Example: '//unmute login'", $admin); + public function command_UnmutePlayer(array $chatCallback, Player $player) { + if (!$this->maniaControl->getAuthenticationManager()->checkPermission($player, PlayerActions::SETTING_PERMISSION_MUTE_PLAYER)) { + $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } + + $commandParts = explode(' ', $chatCallback[1][2]); + if (count($commandParts) <= 1) { + $message = $this->maniaControl->getChat()->formatMessage( + 'No Login given! Example: %s', + '//unmute login' + ); + $this->maniaControl->getChat()->sendUsageInfo($message, $player); + return; + } + $targetLogin = $commandParts[1]; - $this->maniaControl->getPlayerManager()->getPlayerActions()->unMutePlayer($admin->login, $targetLogin); + $this->maniaControl->getPlayerManager()->getPlayerActions()->unMutePlayer($player, $targetLogin); } /** diff --git a/core/Players/PlayerList.php b/core/Players/PlayerList.php index 6e4f91fa..62dacdae 100644 --- a/core/Players/PlayerList.php +++ b/core/Players/PlayerList.php @@ -714,13 +714,13 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer break; case self::ACTION_ADD_AS_MASTER: case self::ACTION_ADD_AS_SUPER: - $this->maniaControl->getPlayerManager()->getPlayerActions()->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_SUPERADMIN); + $this->maniaControl->getPlayerManager()->getPlayerActions()->grantAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_SUPERADMIN); break; case self::ACTION_ADD_AS_ADMIN: - $this->maniaControl->getPlayerManager()->getPlayerActions()->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_ADMIN); + $this->maniaControl->getPlayerManager()->getPlayerActions()->grantAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_ADMIN); break; case self::ACTION_ADD_AS_MOD: - $this->maniaControl->getPlayerManager()->getPlayerActions()->grandAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_MODERATOR); + $this->maniaControl->getPlayerManager()->getPlayerActions()->grantAuthLevel($adminLogin, $targetLogin, AuthenticationManager::AUTH_LEVEL_MODERATOR); break; case self::ACTION_REVOKE_RIGHTS: $this->maniaControl->getPlayerManager()->getPlayerActions()->revokeAuthLevel($adminLogin, $targetLogin); @@ -737,7 +737,11 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $votesPlugin->defineVote('forcespec', 'Force ' . $target->getEscapedNickname() . ' Spec', true, $startMessage); $votesPlugin->startVote($admin, 'forcespec', function ($result) use (&$votesPlugin, &$target) { - $this->maniaControl->getChat()->sendInformation('$sVote successful -> Player ' . $target->getEscapedNickname() . ' forced to Spectator!'); + $message = $this->maniaControl->getChat()->formatMessage( + 'Vote successful -> %s forced to Spectator!', + $target + ); + $this->maniaControl->getChat()->sendSuccess($message); $votesPlugin->undefineVote('forcespec'); try { @@ -761,10 +765,14 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $votesPlugin->defineVote('kick', 'Kick ' . $target->getEscapedNickname(), true, $startMessage); $votesPlugin->startVote($admin, 'kick', function ($result) use (&$votesPlugin, &$target) { - $this->maniaControl->getChat()->sendInformation('$sVote successful -> ' . $target->getEscapedNickname() . ' got Kicked!'); + $message = $this->maniaControl->getChat()->formatMessage( + 'Vote successful -> %s got kicked!', + $target + ); + $this->maniaControl->getChat()->sendSuccess($message); $votesPlugin->undefineVote('kick'); - $message = '$39F You got kicked due to a Public Vote!$z '; + $message = '$39FYou got kicked due to a Public Vote!'; try { $this->maniaControl->getClient()->kick($target->login, $message); } catch (UnknownPlayerException $e) { @@ -780,7 +788,6 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer $neededPage = (int) substr($action, strlen(self::ACTION_PAGING_CHUNKS)); $this->showPlayerList($player, $neededPage - 1); } - } } diff --git a/core/Players/PlayerManager.php b/core/Players/PlayerManager.php index 23ae47c7..72b9bf22 100644 --- a/core/Players/PlayerManager.php +++ b/core/Players/PlayerManager.php @@ -42,7 +42,6 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis const CB_SERVER_EMPTY = 'PlayerManagerCallback.ServerEmpty'; const TABLE_PLAYERS = 'mc_players'; const SETTING_JOIN_LEAVE_COLORING = 'Enable Join & Leave Coloring'; - const SETTING_JOIN_LEAVE_LOGIN = 'Enable Join & Leave Login'; const SETTING_JOIN_LEAVE_MESSAGES = 'Enable Join & Leave Messages'; const SETTING_JOIN_LEAVE_MESSAGES_SPECTATOR = 'Enable Join & Leave Messages for Spectators'; const STAT_JOIN_COUNT = 'Joins'; @@ -95,7 +94,6 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis // Settings $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_JOIN_LEAVE_COLORING, false); - $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_JOIN_LEAVE_LOGIN, false); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES, true); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_JOIN_LEAVE_MESSAGES_SPECTATOR, true); @@ -375,8 +373,8 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis return; } - $played = Formatter::formatTimeH(time() - $player->joinTime); - $logMessage = "Player left: {$player->login} / {$player->nickname} Playtime: {$played}"; + $playTime = Formatter::formatTimeH(time() - $player->joinTime); + $logMessage = "Player left: {$player->login} / {$player->nickname} Playtime: {$playTime}"; Logger::logInfo($logMessage, true); if (!$player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES) @@ -387,13 +385,13 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis $color = $this->maniaControl->getColorManager()->getColorByPlayer($player); } - $nickname = Formatter::escapeText('$fff' . $player->nickname); - if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_LOGIN)) { - $nickname .= 'Login: ' . Formatter::escapeText('$fff' . $player->login); - } - - $authname = AuthenticationManager::getAuthLevelName($player->authLevel); - $this->maniaControl->getChat()->sendChat("{$color}{$authname} {$nickname} has left after \$<\$fff{$played}\$>!"); + $authName = $player->getAuthLevelName(); + $message = $this->maniaControl->getChat()->formatMessage( + "{$color}{$authName} %s has left after %s!", + $player, + $playTime + ); + $this->maniaControl->getChat()->sendChat($message); } //Destroys stored PlayerData, after all Disconnect Callbacks got Handled @@ -504,24 +502,26 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_COLORING)) { $color = $this->maniaControl->getColorManager()->getColorByPlayer($player); } - - $nickname = Formatter::escapeText('$fff' . $player->nickname); - if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_LOGIN)) { - $nickname .= 'Login: ' . Formatter::escapeText('$fff' . $player->login); - } - $authname = AuthenticationManager::getAuthLevelName($player->authLevel); - $nation = '$<$fff' . $player->getCountry() . '$>'; + $authName = $player->getAuthLeveName(); if (!$player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) { - $chatMessage = "{$color}{$authname} {$nickname} Nation: {$nation} joined!"; - $this->maniaControl->getChat()->sendChat($chatMessage); + $message = $this->maniaControl->getChat()->formatMessage( + "{$color}{$authName} %s Nation: %s joined!", + $player, + $player->getCountry() + ); + $this->maniaControl->getChat()->sendChat($message); } else if ($player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES_SPECTATOR)) { - $chatMessage = "{$color}{$authname} {$nickname} Nation: {$nation} joined as Spectator!"; - $this->maniaControl->getChat()->sendChat($chatMessage); + $message = $this->maniaControl->getChat()->formatMessage( + "{$color}{$authName} %s Nation: %s joined as Spectator!", + $player, + $player->getCountry() + ); + $this->maniaControl->getChat()->sendChat($message); } - $this->maniaControl->getChat()->sendInformation('This server uses ManiaControl v' . ManiaControl::VERSION . '!', $player->login); + $this->maniaControl->getChat()->sendInformation('This server uses ManiaControl v' . ManiaControl::VERSION . '!', $player); $logMessage = "Player joined: {$player->login} / {$player->nickname} Nation: {$nation} IP: {$player->ipAddress}"; Logger::logInfo($logMessage, true); From ec93e56869eff8eb6954deed53557ea72f95bdce Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Sat, 30 May 2020 22:45:43 +0200 Subject: [PATCH 90/98] Use Chat::formatMessage in Plugins/* --- core/Plugins/PluginManager.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/Plugins/PluginManager.php b/core/Plugins/PluginManager.php index 695b9276..608eaeed 100644 --- a/core/Plugins/PluginManager.php +++ b/core/Plugins/PluginManager.php @@ -465,7 +465,11 @@ class PluginManager { //Unload the Plugin and all its features $this->unloadPlugin($plugin); - $message = "Error during Plugin Activation of '{$pluginClass}': '{$e->getMessage()}'"; + $this->maniaControl->getChat()->sendException($e, $adminLogin); + $message = $this->maniaControl->getChat()->formatMessage( + 'Error during Plugin Activation of %s!', + $pluginClass + ); $this->maniaControl->getChat()->sendError($message, $adminLogin); Logger::logError($message); $this->savePluginStatus($pluginClass, false); From 965ee220ba64c2479e3d04f1103bf09caa279ceb Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Sat, 30 May 2020 23:28:39 +0200 Subject: [PATCH 91/98] Use Chat::formatMessage in Updates/* --- core/Update/PluginUpdateManager.php | 27 +++++++++++---- core/Update/UpdateManager.php | 54 +++++++++++++++++++++++------ 2 files changed, 64 insertions(+), 17 deletions(-) diff --git a/core/Update/PluginUpdateManager.php b/core/Update/PluginUpdateManager.php index f9823677..94481c88 100644 --- a/core/Update/PluginUpdateManager.php +++ b/core/Update/PluginUpdateManager.php @@ -269,9 +269,12 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis &$pluginUpdateData, &$player, &$update ) { if (!$updateFileContent || $error) { - $message = "Error loading Update Data for '{$pluginUpdateData->pluginName}': {$error}!"; + $message = $this->maniaControl->getChat()->formatMessage( + "Error loading Update Data for %s: {$error}!", + $pluginUpdateData->pluginName + ); if ($player) { - $this->maniaControl->getChat()->sendInformation($message, $player); + $this->maniaControl->getChat()->sendError($message, $player); } Logger::logError($message); return; @@ -281,7 +284,10 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis $actionVerb = ($update ? 'Updating' : 'Installing'); $actionVerbDone = ($update ? 'updated' : 'installed'); - $message = "Now {$actionVerb} '{$pluginUpdateData->pluginName}'..."; + $message = $this->maniaControl->getChat()->formatMessage( + "Now {$actionVerb} %s ...", + $pluginUpdateData->pluginName + ); if ($player) { $this->maniaControl->getChat()->sendInformation($message, $player); } @@ -320,7 +326,10 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis if ($update) { $messageExtra = ' (Restart ManiaControl to load the new Version!)'; } - $message = "Successfully {$actionVerbDone} '{$pluginUpdateData->pluginName}'!{$messageExtra}"; + $message = $this->maniaControl->getChat()->formatMessage( + "Successfully {$actionVerbDone} %s!{$messageExtra}", + $pluginUpdateData->pluginName + ); if ($player) { $this->maniaControl->getChat()->sendSuccess($message, $player); } @@ -330,13 +339,19 @@ class PluginUpdateManager implements CallbackListener, CommandListener, TimerLis $newPluginClasses = $this->maniaControl->getPluginManager()->loadPlugins(); if (empty($newPluginClasses)) { - $message = "Loading fresh installed Plugin '{$pluginUpdateData->pluginName}' failed, try to restart ManiaControl!"; + $message = $this->maniaControl->getChat()->formatMessage( + "Loading fresh installed Plugin %s failed, try to restart ManiaControl!", + $pluginUpdateData->pluginName + ); if ($player) { $this->maniaControl->getChat()->sendError($message, $player); } Logger::log($message); } else { - $message = "Successfully loaded fresh installed Plugin '{$pluginUpdateData->pluginName}'!"; + $message = $this->maniaControl->getChat()->formatMessage( + "Successfully loaded fresh installed Plugin %s!", + $pluginUpdateData->pluginName + ); if ($player) { $this->maniaControl->getChat()->sendSuccess($message, $player); } diff --git a/core/Update/UpdateManager.php b/core/Update/UpdateManager.php index a8ffabf1..e67aeb8e 100644 --- a/core/Update/UpdateManager.php +++ b/core/Update/UpdateManager.php @@ -402,7 +402,10 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener, // Set the build date $this->setBuildDate($updateData->releaseDate); - $message = 'Update finished! See what we updated with $<$fff//chatlog$>!'; + $message = $this->maniaControl->getChat()->formatMessage( + 'Update finished! See what we updated with %s!', + '//changelog' + ); if ($player) { $this->maniaControl->getChat()->sendSuccess($message, $player); } @@ -442,11 +445,20 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener, return; } + $message = ''; if ($this->isNightlyUpdateChannel()) { - $this->maniaControl->getChat()->sendSuccess('New Nightly Build (' . $this->coreUpdateData->releaseDate . ') available!', $player->login); + $message = $this->maniaControl->getChat()->formatMessage( + 'New Nightly Build (%s) available!', + $this->coreUpdateData->releaseDate + ); } else { - $this->maniaControl->getChat()->sendInformation('New ManiaControl Version ' . $this->coreUpdateData->version . ' available!', $player->login); + $message = $this->maniaControl->getChat()->formatMessage( + 'New ManiaControl Version (%s) available!', + $this->coreUpdateData->version + ); } + + $this->maniaControl->getChat()->sendInformation($message, $player); } /** @@ -480,12 +492,16 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener, $this->checkCoreUpdateAsync(function (UpdateData $updateData = null) use (&$player) { if (!$this->checkUpdateData($updateData)) { - $this->maniaControl->getChat()->sendInformation('No Update available!', $player->login); + $this->maniaControl->getChat()->sendInformation('No Update available!', $player); return; } if (!$this->checkUpdateDataBuildVersion($updateData)) { - $this->maniaControl->getChat()->sendError("Please update Your Server to '{$updateData->minDedicatedBuild}' in order to receive further Updates!", $player->login); + $message = $this->maniaControl->getChat()->formatMessage( + 'Please update your server to %s in order to receive further ManiaControl updates!', + $updateData->minDedicatedBuild + ); + $this->maniaControl->getChat()->sendError($message, $player); return; } @@ -494,16 +510,32 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener, $buildDate = $this->getBuildDate(); if ($buildDate) { if ($updateData->isNewerThan($buildDate)) { - $this->maniaControl->getChat()->sendInformation("No new Build available! (Current Build: '{$buildDate}')", $player->login); - return; + $message = $this->maniaControl->getChat()->formatMessage( + 'No new Build available! (Current Build: %s)', + $buildDate + ); + $this->maniaControl->getChat()->sendInformation($message, $player); } else { - $this->maniaControl->getChat()->sendSuccess("New Nightly Build ({$updateData->releaseDate}) available! (Current Build: '{$buildDate}')", $player->login); + $message = $this->maniaControl->getChat()->formatMesssage( + 'New Nightly Build (%s) available! (Current Build: %s)', + $updateData->releaseDate, + $buildDate + ); + $this->maniaControl->getChat()->sendSuccess($message, $player); } } else { - $this->maniaControl->getChat()->sendSuccess("New Nightly Build ('{$updateData->releaseDate}') available!", $player->login); + $message = $this->maniaControl->getChat()->formatMesssage( + 'New Nightly Build (%s) available!', + $updateData->releaseDate + ); + $this->maniaControl->getChat()->sendSuccess($message, $player); } } else { - $this->maniaControl->getChat()->sendSuccess('Update for Version ' . $updateData->version . ' available!', $player->login); + $message = $this->maniaControl->getChat()->formatMesssage( + 'Update for Version %s available!', + $updateData->version + ); + $this->maniaControl->getChat()->sendSuccess($message, $player); } $this->coreUpdateData = $updateData; @@ -540,7 +572,7 @@ class UpdateManager implements CallbackListener, CommandListener, TimerListener, } if (!$this->checkUpdateDataBuildVersion($updateData)) { if ($player) { - $this->maniaControl->getChat()->sendError("The Next ManiaControl Update requires a newer Dedicated Server Version!", $player); + $this->maniaControl->getChat()->sendError('The Next ManiaControl Update requires a newer Dedicated Server Version!', $player); } return; } From 5717589588493cf60b6b964c3914300c8af23153 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Sat, 30 May 2020 23:33:52 +0200 Subject: [PATCH 92/98] Use Chat::formatMessage in Main-Files --- core/ErrorHandler.php | 16 ++++++++++++---- core/ManiaControl.php | 7 ++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/core/ErrorHandler.php b/core/ErrorHandler.php index d139e481..e64b160e 100644 --- a/core/ErrorHandler.php +++ b/core/ErrorHandler.php @@ -131,8 +131,12 @@ class ErrorHandler { if ($isFatalError) { $this->maniaControl->getPluginManager()->deactivatePlugin($sourceClass); - $this->maniaControl->getChat()->sendError("Plugin " . $sourceClass . " has an Error -> The Plugin will be deactivated and ManiaControl restarted"); - Logger::logError("Plugin " . $sourceClass . " has an Error -> The Plugin will be deactivated and ManiaControl restarted"); + $message = $this->maniaControl->getChat()->formatMessage( + 'Plugin %s has an Error -> The Plugin will be deactivated and ManiaControl restarted!', + $sourceClass + ); + $this->maniaControl->getChat()->sendError($message); + Logger::logError("Plugin {$sourceClass} has an Error -> The Plugin will be deactivated and ManiaControl restarted!"); $isPluginError = true; } } @@ -482,8 +486,12 @@ class ErrorHandler { $report['PluginVersion'] = PluginManager::getPluginVersion($sourceClass); $this->maniaControl->getPluginManager()->deactivatePlugin($sourceClass); - $this->maniaControl->getChat()->sendError("Plugin " . $sourceClass . " has an Error -> The Plugin will be deactivated and ManiaControl restarted"); - Logger::logError("Plugin " . $sourceClass . " has an Error -> The Plugin will be deactivated and ManiaControl restarted"); + $message = $this->maniaControl->getChat()->formatMessage( + 'Plugin %s has an Error -> The Plugin will be deactivated and ManiaControl restarted!', + $sourceClass + ); + $this->maniaControl->getChat()->sendError($message); + Logger::logError("Plugin {$sourceClass} has an Error -> The Plugin will be deactivated and ManiaControl restarted!"); } } diff --git a/core/ManiaControl.php b/core/ManiaControl.php index 20a3c819..6caf2345 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -561,7 +561,12 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, $this->getAuthenticationManager()->sendNotAllowed($player); return; } - $this->getChat()->sendError('The command //restart got disabled, reboot ManiaControl with //reboot instead', $player); + $message = $this->getChat()->formatMessage( + 'The command %s got disabled, reboot ManiaControl with %s instead!', + '//restart', + '//reboot' + ); + $this->getChat()->sendError($message, $player); } /** From 9abadac93285521d5bf6cd774c8a196634dab4b9 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Tue, 2 Jun 2020 17:30:30 +0200 Subject: [PATCH 93/98] Use Chat::formatMessage in Server/* --- core/Server/Commands.php | 203 +++++++++++++++++-------- core/Server/Server.php | 17 ++- core/Server/ServerOptionsMenu.php | 8 +- core/Server/ServerUIPropertiesMenu.php | 2 +- core/Server/VoteRatiosMenu.php | 6 +- 5 files changed, 159 insertions(+), 77 deletions(-) diff --git a/core/Server/Commands.php b/core/Server/Commands.php index a26b38dc..de9711bd 100644 --- a/core/Server/Commands.php +++ b/core/Server/Commands.php @@ -164,12 +164,16 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer return; } - if ($this->maniaControl->getClient()->cancelVote()) { - $this->maniaControl->getChat()->sendInformation($player->getEscapedNickname() . ' cancelled the Vote!'); - } else { - $this->maniaControl->getChat()->sendInformation("There's no vote running currently!", $player); + if (!$this->maniaControl->getClient()->cancelVote()) { + $this->maniaControl->getChat()->sendError("There is no vote running currently!", $player); + return; } + $message = $this->maniaControl->getChat()->formatMessage( + '%s cancelled the Vote!', + $player + ); + $this->maniaControl->getChat()->sendInformation($message); $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_VOTE_CANCELLED, $player); } @@ -186,10 +190,21 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer return; } - //TODO command paprameter for seconds - $this->maniaControl->getModeScriptEventManager()->extendManiaPlanetWarmup(10); - $this->maniaControl->getChat()->sendInformation($player->getEscapedNickname() . ' extended the WarmUp by 10 seconds!'); + $extension = 10; + $params = explode(' ', $chat[1][2]); + if (count($params) >= 2) { + $extension = $params[1]; + } + + $this->maniaControl->getModeScriptEventManager()->extendManiaPlanetWarmup($extension); + + $message = $this->maniaControl->getChat()->formatMessage( + '%s extended the WarmUp by %s seconds!', + $player, + $extension + ); + $this->maniaControl->getChat()->sendInformation($message); } /** @@ -205,7 +220,11 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer } $this->maniaControl->getModeScriptEventManager()->stopManiaPlanetWarmup(); - $this->maniaControl->getChat()->sendInformation($player->getEscapedNickname() . ' stopped the WarmUp!'); + $message = $this->maniaControl->getChat()->formatMessage( + '%s stopped the WarmUp!', + $player + ); + $this->maniaControl->getChat()->sendInformation($message); } /** @@ -220,17 +239,22 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer return; } + $message = $this->maniaControl->getChat()->formatMessage( + '%s paused the Game!', + $player + ); + //Normal Gamemodes try { $this->maniaControl->getClient()->sendModeScriptCommands(array('Command_ForceWarmUp' => true)); - $this->maniaControl->getChat()->sendInformation($player->getEscapedNickname() . ' paused the Game!'); + $this->maniaControl->getChat()->sendInformation($message); } catch (GameModeException $e) { } try { //Chase and Combo? $this->maniaControl->getClient()->sendModeScriptCommands(array('Command_SetPause' => true)); - $this->maniaControl->getChat()->sendInformation($player->getEscapedNickname() . ' paused the Game!'); + $this->maniaControl->getChat()->sendInformation($message); //Especially for chase, force end of the round to reach a draw $this->maniaControl->getClient()->sendModeScriptCommands(array('Command_ForceEndRound' => true)); @@ -239,7 +263,6 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer //TODO verify if not everything is replaced through the new pause $this->maniaControl->getModeScriptEventManager()->startPause(); - $this->maniaControl->getChat()->sendInformation('$f8fVote to $fffpause the current Game$f8f has been successful!'); } /** @@ -283,9 +306,17 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } + $systemInfo = $this->maniaControl->getClient()->getSystemInfo(); - $message = 'SystemInfo: ip=' . $systemInfo->publishedIp . ', port=' . $systemInfo->port . ', p2pPort=' . $systemInfo->p2PPort . ', title=' . $systemInfo->titleId . ', login=' . $systemInfo->serverLogin . '.'; - $this->maniaControl->getChat()->sendInformation($message, $player->login); + $message = $this->maniaControl->getChat()->formatMessage( + 'SystemInfo: ip=%s, port=%s, p2pPort=%s, title=%s, login=%s', + $systemInfo->publishedIp, + $systemInfo->port, + $systemInfo->p2PPort, + $systemInfo->titleId, + $systemInfo->serverLogin + ); + $this->maniaControl->getChat()->sendInformation($message, $player); } /** @@ -301,30 +332,38 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer } // Check for delayed shutdown $params = explode(' ', $chat[1][2]); - if (count($params) >= 2) { - $param = $params[1]; - if (strtolower($param) === 'empty') { - $this->serverShutdownEmpty = !$this->serverShutdownEmpty; - if ($this->serverShutdownEmpty) { - $this->maniaControl->getChat()->sendInformation("The server will shutdown as soon as it's empty!", $player); - return; - } - $this->maniaControl->getChat()->sendInformation("Empty-shutdown cancelled!", $player); - return; - } - $delay = (int) $param; - if ($delay <= 0) { - // Cancel shutdown - $this->serverShutdownTime = -1; - $this->maniaControl->getChat()->sendInformation("Delayed shutdown cancelled!", $player); - return; - } - // Trigger delayed shutdown - $this->serverShutdownTime = time() + $delay * 60.; - $this->maniaControl->getChat()->sendInformation("The server will shut down in {$delay} minutes!", $player); + if (count($params) < 2) { + $this->shutdownServer($player->login); return; } - $this->shutdownServer($player->login); + + $param = $params[1]; + if (strtolower($param) === 'empty') { + $this->serverShutdownEmpty = !$this->serverShutdownEmpty; + if ($this->serverShutdownEmpty) { + $this->maniaControl->getChat()->sendInformation("The server will shutdown as soon as it's empty!", $player); + return; + } + + $this->maniaControl->getChat()->sendInformation("Empty-shutdown cancelled!", $player); + return; + } + + $delay = (int) $param; + if ($delay <= 0) { + // Cancel shutdown + $this->serverShutdownTime = -1; + $this->maniaControl->getChat()->sendInformation("Delayed shutdown cancelled!", $player); + return; + } + + // Trigger delayed shutdown + $this->serverShutdownTime = time() + $delay * 60.; + $message = $this->maniaControl->getChat()->formatMessage( + 'The server will shut down in %s minutes!', + $delay + ); + $this->maniaControl->getChat()->sendInformation($message, $player); } /** @@ -338,14 +377,24 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } + $params = explode(' ', $chat[1][2], 2); if (count($params) < 2) { - $this->maniaControl->getChat()->sendUsageInfo('Usage example: //setservername ManiaPlanet Server', $player); + $message = $this->maniaControl->getChat()->formatMessage( + 'Usage example: %s', + '//setservername ManiaPlanet Server Name' + ); + $this->maniaControl->getChat()->sendUsageInfo($message, $player); return; } + $serverName = $params[1]; $this->maniaControl->getClient()->setServerName($serverName); - $this->maniaControl->getChat()->sendSuccess("Server name changed to: '{$serverName}'!", $player); + $message = $this->maniaControl->getChat()->formatMessage( + 'Server name changed to %s!', + $serverName + ); + $this->maniaControl->getChat()->sendSuccess($message, $player); } /** @@ -359,15 +408,20 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } - $messageParts = explode(' ', $chatCallback[1][2], 2); - $password = ''; - $successMessage = 'Password removed!'; + + $messageParts = explode(' ', $chatCallback[1][2], 2); + $password = ''; + $message = 'Password removed!'; if (isset($messageParts[1])) { - $password = $messageParts[1]; - $successMessage = "Password changed to: '{$password}'!"; + $password = $messageParts[1]; + $message = $this->maniaControl->getChat()->formatMessage( + 'Password changed to %s!', + $password + ); } + $this->maniaControl->getClient()->setServerPassword($password); - $this->maniaControl->getChat()->sendSuccess($successMessage, $player); + $this->maniaControl->getChat()->sendSuccess($message, $player); } /** @@ -381,15 +435,20 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } - $messageParts = explode(' ', $chatCallback[1][2], 2); - $password = ''; - $successMessage = 'Spectator password removed!'; + + $messageParts = explode(' ', $chatCallback[1][2], 2); + $password = ''; + $message = 'Spectator password removed!'; if (isset($messageParts[1])) { - $password = $messageParts[1]; - $successMessage = "Spectator password changed to: '{$password}'!"; + $password = $messageParts[1]; + $message = $this->maniaControl->getChat()->formatMessage( + 'Spectator password changed to %s!', + $password + ); } + $this->maniaControl->getClient()->setServerPasswordForSpectator($password); - $this->maniaControl->getChat()->sendSuccess($successMessage, $player); + $this->maniaControl->getChat()->sendSuccess($message, $player); } /** @@ -403,23 +462,28 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } + $messageParts = explode(' ', $chatCallback[1][2], 2); - if (!isset($messageParts[1])) { - $this->maniaControl->getChat()->sendUsageInfo('Usage example: //setmaxplayers 16', $player); + if (!isset($messageParts[1]) || !is_numeric($messageParts[1])) { + $message = $this->maniaControl->getChat()->formatMessage( + 'Usage example: %s', + '//setmaxplayers 16' + ); + $this->maniaControl->getChat()->sendUsageInfo($message, $player); return; } - $amount = $messageParts[1]; - if (!is_numeric($amount)) { - $this->maniaControl->getChat()->sendUsageInfo('Usage example: //setmaxplayers 16', $player); - return; - } - $amount = (int) $amount; + + $amount = intval($messageParts[1]); if ($amount < 0) { $amount = 0; } $this->maniaControl->getClient()->setMaxPlayers($amount); - $this->maniaControl->getChat()->sendSuccess("Changed max players to: {$amount}", $player); + $message = $this->maniaControl->getChat()->formatMessage( + 'Changed max players to %s!', + $amount + ); + $this->maniaControl->getChat()->sendSuccess($message, $player); } /** @@ -433,22 +497,27 @@ class Commands implements CallbackListener, CommandListener, ManialinkPageAnswer $this->maniaControl->getAuthenticationManager()->sendNotAllowed($player); return; } + $messageParts = explode(' ', $chatCallback[1][2], 2); - if (!isset($messageParts[1])) { - $this->maniaControl->getChat()->sendUsageInfo('Usage example: //setmaxspectators 16', $player); + if (!isset($messageParts[1]) || !is_numeric($messageParts[1])) { + $message = $this->maniaControl->getChat()->formatMessage( + 'Usage example: %s', + '//setmaxspectators 16' + ); + $this->maniaControl->getChat()->sendUsageInfo($message, $player); return; } - $amount = $messageParts[1]; - if (!is_numeric($amount)) { - $this->maniaControl->getChat()->sendUsageInfo('Usage example: //setmaxspectators 16', $player); - return; - } - $amount = (int) $amount; + + $amount = intval($messageParts[1]); if ($amount < 0) { $amount = 0; } $this->maniaControl->getClient()->setMaxSpectators($amount); - $this->maniaControl->getChat()->sendSuccess("Changed max spectators to: {$amount}", $player); + $message = $this->maniaControl->getChat()->formatMessage( + 'Changed max spectators to %s!', + $amount + ); + $this->maniaControl->getChat()->sendSuccess($message, $player); } } diff --git a/core/Server/Server.php b/core/Server/Server.php index 556521e1..5987e97c 100644 --- a/core/Server/Server.php +++ b/core/Server/Server.php @@ -100,11 +100,20 @@ class Server implements CallbackListener, CommandListener, UsageInformationAble $hours = intval($hourstotal - 24 * $days); $minutes = intval($minutestotal - 24 * 60 * $days - $hours * 60); - $days > 1 ? $dayString = 'days' : $dayString = 'day'; - $hours > 1 ? $hourString = 'hours' : $hourString = 'hour'; - $minutes > 1 ? $minuteString = 'minutes' : $minuteString = 'minute'; + $dayString = ($days == 1 ? 'day' : 'days' ); + $hourString = ($hours == 1 ? 'hour' : 'hours' ); + $minuteString = ($minutes == 1 ? 'minute' : 'minutes'); - $this->maniaControl->getChat()->sendChat('Server is running since $<$fff' . $days . '$> ' . $dayString . ', $<$fff' . $hours . '$> ' . $hourString . ' and $<$fff' . $minutes . '$> ' . $minuteString, $player); + $message = $this->maniaControl->getChat()->formatMessage( + 'Server is running since %s %s, %s %s and %s %s', + $days, + $dayString, + $hours, + $hourString, + $minutes, + $minuteString + ); + $this->maniaControl->getChat()->sendChat($message, $player); } /** diff --git a/core/Server/ServerOptionsMenu.php b/core/Server/ServerOptionsMenu.php index e35f6be2..8e046e9d 100644 --- a/core/Server/ServerOptionsMenu.php +++ b/core/Server/ServerOptionsMenu.php @@ -210,8 +210,8 @@ class ServerOptionsMenu implements CallbackListener, ConfiguratorMenu, TimerList $loaded = false; try { $loaded = $this->maniaControl->getClient()->setServerOptions($newServerOptions); - } catch (ServerOptionsException $exception) { - $this->maniaControl->getChat()->sendExceptionToAdmins($exception); + } catch (ServerOptionsException $e) { + $this->maniaControl->getChat()->sendExceptionToAdmins($e); } if ($loaded) { @@ -371,8 +371,8 @@ class ServerOptionsMenu implements CallbackListener, ConfiguratorMenu, TimerList private function applyNewServerOptions(ServerOptions $newServerOptions, $player = null) { try { $this->maniaControl->getClient()->setServerOptions($newServerOptions); - } catch (ServerOptionsException $exception) { - $this->maniaControl->getChat()->sendException($exception, $player); + } catch (ServerOptionsException $e) { + $this->maniaControl->getChat()->sendException($e, $player); return false; } diff --git a/core/Server/ServerUIPropertiesMenu.php b/core/Server/ServerUIPropertiesMenu.php index 56e7674d..fb52ebc7 100644 --- a/core/Server/ServerUIPropertiesMenu.php +++ b/core/Server/ServerUIPropertiesMenu.php @@ -440,7 +440,7 @@ class ServerUIPropertiesMenu implements ConfiguratorMenu, CallbackListener, Time // Notifications $uiPropertiesCount = count($newUIProperties); $uiPropertyIndex = 0; - $title = $this->maniaControl->getAuthenticationManager()->getAuthLevelName($player); + $title = $player->getAuthLevelName(); $chatMessage = '$ff0' . $title . ' ' . $player->getEscapedNickname() . ' set ServerUIPropert' . ($uiPropertiesCount > 1 ? 'ies' : 'y') . ' '; foreach ($newUIProperties as $uiPropertyName => $uiPropertyValue) { $chatMessage .= '$<$fff' . $uiPropertyName . '$>$ff0 '; diff --git a/core/Server/VoteRatiosMenu.php b/core/Server/VoteRatiosMenu.php index f3587dbb..aaabbbd8 100644 --- a/core/Server/VoteRatiosMenu.php +++ b/core/Server/VoteRatiosMenu.php @@ -172,6 +172,10 @@ class VoteRatiosMenu implements CallbackListener, ConfiguratorMenu, TimerListene * @param string $commandName */ private function sendInvalidValueError(Player $player, $commandName) { - $this->maniaControl->getChat()->sendError("Invalid Value given for '{$commandName}'!", $player); + $message = $this->maniaControl->getChat()->formatMessage( + 'Invalid Value given for %s!', + $commandName + ); + $this->maniaControl->getChat()->sendError($message, $player); } } From 650afc500a770212469ed8c38e96d778eb30c56c Mon Sep 17 00:00:00 2001 From: kremsy Date: Sun, 7 Jun 2020 16:17:20 +0200 Subject: [PATCH 94/98] added error messages on invalid incoming communication messages --- core/Communication/CommunicationManager.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/Communication/CommunicationManager.php b/core/Communication/CommunicationManager.php index 2362d740..2a094bbb 100644 --- a/core/Communication/CommunicationManager.php +++ b/core/Communication/CommunicationManager.php @@ -266,8 +266,10 @@ class CommunicationManager implements CallbackListener, UsageInformationAble { $data = json_decode($data); if ($data == null) { - $data = array("error" => true, "data" => "Data is not provided as an valid AES-196-encrypted encrypted JSON"); + Logger::log("[CommunicationManager] Error: Data is not provided as an valid AES-196 encrypted JSON"); + $data = array("error" => true, "data" => "Data is not provided as an valid AES-196 encrypted JSON"); } else if (!property_exists($data, "method") || !property_exists($data, "data")) { + Logger::log("[CommunicationManager] Invalid Communication Message Received"); $data = array("error" => true, "data" => "Invalid Message"); } else { $answer = $this->triggerCommuncationCallback($data->method, $data->data); From 566f77801f1b8cf3f76d2628037678401f138684 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Mon, 22 Jun 2020 04:53:31 +0200 Subject: [PATCH 95/98] Fix Chat::formatMessage issues after tests --- core/Maps/MapQueue.php | 5 +-- core/Players/PlayerActions.php | 54 ++++++++++++++------------- core/Players/PlayerManager.php | 7 ++-- plugins/MCTeam/LocalRecordsPlugin.php | 4 +- 4 files changed, 36 insertions(+), 34 deletions(-) diff --git a/core/Maps/MapQueue.php b/core/Maps/MapQueue.php index c8984ed1..18b9e4d0 100644 --- a/core/Maps/MapQueue.php +++ b/core/Maps/MapQueue.php @@ -119,7 +119,7 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl return; } - $messagePrefix = $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MESSAGE_FORMAT); + $messagePrefix = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MESSAGE_FORMAT); if ($admin && empty($this->queuedMaps)) { $this->maniaControl->getChat()->sendError($messagePrefix . 'There are no maps in the jukebox!', $admin); return; @@ -131,8 +131,7 @@ class MapQueue implements CallbackListener, CommandListener, UsageInformationAbl if ($admin) { $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - $messagePrefix . '%s %s cleared the Map-Queue!', - $title, + "{$messagePrefix}{$title} %s cleared the Map-Queue!", $admin ); $this->maniaControl->getChat()->sendInformation($message); diff --git a/core/Players/PlayerActions.php b/core/Players/PlayerActions.php index f437b914..c11cc2a5 100644 --- a/core/Players/PlayerActions.php +++ b/core/Players/PlayerActions.php @@ -211,9 +211,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma if ($teamName) { if ($calledByAdmin) { + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - '%s %s forced %s into the %s-Team!', - $admin->getAuthLevelName(), + "{$title} %s forced %s into the %s-Team!", $admin, $target, $teamName @@ -284,9 +284,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma // Announce force if ($displayAnnouncement) { if ($calledByAdmin) { + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - '%s %s forced %s to Play!', - $admin->getAuthLevelName(), + "{$title} %s forced %s to Play!", $admin, $target ); @@ -341,9 +341,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma } if ($calledByAdmin) { + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - '%s %s forced %s to Spectator!', - $admin->getAuthLevelName(), + "{$title} %s forced %s to Spectator!", $admin, $target ); @@ -397,16 +397,16 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma } catch (NotInListException $e) { $message = $this->maniaControl->getChat()->formatMessage( '%s is not muted!', - $player + $targetLogin ); $this->maniaControl->getChat()->sendError($message, $adminLogin); return false; } if ($calledByAdmin) { + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - '%s %s un-muted %s!', - $admin->getAuthLevelName(), + "{$title} %s un-muted %s!", $admin, $target ); @@ -451,16 +451,19 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma } catch (AlreadyInListException $e) { $message = $this->maniaControl->getChat()->formatMessage( '%s is already muted!', - $player + $targetLogin ); $this->maniaControl->getChat()->sendError($message, $adminLogin); return false; + } catch (UnknownPlayerException $e) { + $this->maniaControl->getChat()->sendException($e, $adminLogin); + return false; } if ($calledByAdmin) { + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - '%s %s muted %s!', - $admin->getAuthLevelName(), + "{$title} %s muted %s!", $admin, $target ); @@ -559,9 +562,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma $this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $target); if ($calledByAdmin) { + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - '%s %s warned %s!', - $admin->getAuthLevelName(), + "{$title} %s warned %s!", $admin, $target ); @@ -623,9 +626,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma } if ($calledByAdmin) { + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - '%s %s kicked %s!', - $admin->getAuthLevelName(), + "{$title} %s kicked %s!", $admin, $target ); @@ -676,9 +679,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma return; } + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - '%s %s banned %s!', - $admin->getAuthLevelName(), + "{$title} %s banned %s!", $admin, $target ); @@ -717,10 +720,10 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma $this->maniaControl->getChat()->sendError('This player is not Banned!', $admin); return; } - + + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - '%s %s unbanned %s!', - $admin->getAuthLevelName(), + "{$title} %s unbanned %s!", $admin, $target ); @@ -745,7 +748,6 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma * Grants the Player an Authorization Level * * @api - * @deprecated * @param string $adminLogin * @param string $targetLogin * @param int $authLevel @@ -774,9 +776,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma return; } + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - "%s %s added %s as {$authLevelName}!", - $admin->getAuthLevelName(), + "{$title} %s added %s as {$authLevelName}!", $admin, $target ); @@ -814,9 +816,9 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma return; } + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( - "%s %s revoked the Rights of %s!", - $admin->getAuthLevelName(), + "{$title} %s revoked the Rights of %s!", $admin, $target ); diff --git a/core/Players/PlayerManager.php b/core/Players/PlayerManager.php index 72b9bf22..e4f7032c 100644 --- a/core/Players/PlayerManager.php +++ b/core/Players/PlayerManager.php @@ -503,20 +503,21 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis $color = $this->maniaControl->getColorManager()->getColorByPlayer($player); } - $authName = $player->getAuthLeveName(); + $authName = $player->getAuthLevelName(); + $nation = $player->getCountry(); if (!$player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES) && !$player->isFakePlayer()) { $message = $this->maniaControl->getChat()->formatMessage( "{$color}{$authName} %s Nation: %s joined!", $player, - $player->getCountry() + $nation ); $this->maniaControl->getChat()->sendChat($message); } else if ($player->isSpectator && $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_JOIN_LEAVE_MESSAGES_SPECTATOR)) { $message = $this->maniaControl->getChat()->formatMessage( "{$color}{$authName} %s Nation: %s joined as Spectator!", $player, - $player->getCountry() + $nation ); $this->maniaControl->getChat()->sendChat($message); } diff --git a/plugins/MCTeam/LocalRecordsPlugin.php b/plugins/MCTeam/LocalRecordsPlugin.php index 5d8dafec..27d15f80 100644 --- a/plugins/MCTeam/LocalRecordsPlugin.php +++ b/plugins/MCTeam/LocalRecordsPlugin.php @@ -592,8 +592,8 @@ class LocalRecordsPlugin implements CallbackListener, CallQueueListener, Command $timeDiff = $oldRecord->time - $newRecord->time; $message .= $this->maniaControl->getChat()->formatMessage( ' (%s%s)', - ($improvedRank ? '$ff0'.$oldRecord->rank.'. ' : ''), - '-'.Formatter::formatTime($timeDiff) + ($improvedRank ? '$ff0' . $oldRecord->rank . '. ' : ''), + '-' . Formatter::formatTime($timeDiff) ); } From 2f57ee3d6c442f20c154d7c8e92796db8251e531 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Fri, 17 Jul 2020 14:26:03 +0200 Subject: [PATCH 96/98] distance and stuntsscore not available in CP-Callback of the new game --- .../Structures/TrackMania/OnWayPointEventStructure.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/Callbacks/Structures/TrackMania/OnWayPointEventStructure.php b/core/Callbacks/Structures/TrackMania/OnWayPointEventStructure.php index a946a8fa..358cbc6e 100644 --- a/core/Callbacks/Structures/TrackMania/OnWayPointEventStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnWayPointEventStructure.php @@ -39,14 +39,14 @@ class OnWayPointEventStructure extends BasePlayerTimeStructure { $this->raceTime = (int) $this->getPlainJsonObject()->racetime; $this->lapTime = (int) $this->getPlainJsonObject()->laptime; - $this->stuntsScore = $this->getPlainJsonObject()->stuntsscore; + $this->stuntsScore = isset($this->getPlainJsonObject()->stuntsscore) ? $this->getPlainJsonObject()->stuntsscore : null; $this->checkPointInRace = (int) $this->getPlainJsonObject()->checkpointinrace; $this->checkPointInLap = (int) $this->getPlainJsonObject()->checkpointinlap; $this->isEndRace = Formatter::parseBoolean($this->getPlainJsonObject()->isendrace); $this->isEndLap = Formatter::parseBoolean($this->getPlainJsonObject()->isendlap); $this->blockId = $this->getPlainJsonObject()->blockid; $this->speed = $this->getPlainJsonObject()->speed; - $this->distance = $this->getPlainJsonObject()->distance; + $this->distance = isset($this->getPlainJsonObject()->distance) ? $this->getPlainJsonObject()->distance : null; if ($this->checkPointInRace > 0) { $currentMap = $this->maniaControl->getMapManager()->getCurrentMap(); From 9711937a1e83108031ce1fbeabdac1c12d1bc0c5 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Fri, 17 Jul 2020 14:36:18 +0200 Subject: [PATCH 97/98] bestracerespawns and bestlaprespawns removed from Scores-Callback in the new game --- .../Structures/TrackMania/OnScoresStructure.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/Callbacks/Structures/TrackMania/OnScoresStructure.php b/core/Callbacks/Structures/TrackMania/OnScoresStructure.php index a15fd7ed..3918930f 100644 --- a/core/Callbacks/Structures/TrackMania/OnScoresStructure.php +++ b/core/Callbacks/Structures/TrackMania/OnScoresStructure.php @@ -38,10 +38,18 @@ class OnScoresStructure extends CommonScoresStructure { $playerScore->setBestRaceTime($jsonPlayer->bestracetime); $playerScore->setBestLapTime($jsonPlayer->bestlaptime); $playerScore->setStuntScore($jsonPlayer->stuntsscore); - $playerScore->setBestRaceRespawns($jsonPlayer->bestracerespawns); $playerScore->setBestRaceCheckpoints($jsonPlayer->bestracecheckpoints); - $playerScore->setBestLapRespawns($jsonPlayer->bestlaprespawns); $playerScore->setBestLapCheckpoints($jsonPlayer->bestlapcheckpoints); + + // removed in TM2020 + if (property_exists($jsonPlayer, 'bestracerespawns')) { + $playerScore->setBestRaceRespawns($jsonPlayer->bestracerespawns); + } + // removed in TM2020 + if (property_exists($jsonPlayer, 'bestlaprespawns')) { + $playerScore->setBestLapRespawns($jsonPlayer->bestlaprespawns); + } + //New attributes in 2.5.0 if (property_exists($jsonPlayer, 'prevracetime')) { $playerScore->setPrevRaceTime($jsonPlayer->prevracetime); From 24558b1982050ad9dc7544afbbfa53bfe79440e3 Mon Sep 17 00:00:00 2001 From: Alexander Nell Date: Sat, 18 Jul 2020 13:26:41 +0200 Subject: [PATCH 98/98] Version increase for deployment of quickfixes --- core/ManiaControl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ManiaControl.php b/core/ManiaControl.php index 6caf2345..106bee84 100644 --- a/core/ManiaControl.php +++ b/core/ManiaControl.php @@ -55,7 +55,7 @@ class ManiaControl implements CallbackListener, CommandListener, TimerListener, /* * Constants */ - const VERSION = '0.255'; + const VERSION = '0.256'; const API_VERSION = '2013-04-16'; const MIN_DEDIVERSION = '2017-05-03_21_00'; const SCRIPT_TIMEOUT = 40;