From afe617b6422fab5f1589ec18d4d33946c3accd76 Mon Sep 17 00:00:00 2001 From: Beu Date: Wed, 1 Nov 2023 17:20:05 +0100 Subject: [PATCH] add callbacks for PlayerActions --- core/Players/PlayerActions.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/core/Players/PlayerActions.php b/core/Players/PlayerActions.php index b1a75683..4c63ee37 100644 --- a/core/Players/PlayerActions.php +++ b/core/Players/PlayerActions.php @@ -47,6 +47,17 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma const SPECTATOR_BUT_KEEP_SELECTABLE = 3; const ECHO_WARN_PLAYER = 'ManiaControl.PlayerManager.WarnPlayer'; + /* + * Callback Constants + */ + const CB_PLAYER_FORCED_TO_PLAY = 'PlayerActions.PlayerForcedToPlay'; + const CB_PLAYER_FORCED_TO_TEAM = 'PlayerActions.PlayerForcedToTeam'; + const CB_PLAYER_FORCED_TO_SPEC = 'PlayerActions.PlayerForcedToSpec'; + const CB_PLAYER_MUTED = 'PlayerActions.PlayerMuted'; + const CB_PLAYER_WARNED = 'PlayerActions.PlayerWarned'; + const CB_PLAYER_KICKED = 'PlayerActions.PlayerKicked'; + const CB_PLAYER_BANNED = 'PlayerActions.PlayerBanned'; + /* * Permission Setting Constants */ @@ -201,6 +212,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma return false; } + $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYER_FORCED_TO_TEAM, $target, $teamId); + $message = false; $teamName = ''; if ($teamId === self::TEAM_BLUE) { @@ -229,7 +242,7 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma if ($message) { $this->maniaControl->getChat()->sendInformation($message); - Logger::logInfo($chatMessage, true); + Logger::logInfo($message, true); } return true; @@ -281,6 +294,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma } } + $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYER_FORCED_TO_PLAY, $target); + // Announce force if ($displayAnnouncement) { if ($calledByAdmin) { @@ -340,6 +355,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma return false; } + $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYER_FORCED_TO_SPEC, $target); + if ($calledByAdmin) { $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( @@ -460,6 +477,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma return false; } + $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYER_MUTED, $target); + if ($calledByAdmin) { $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( @@ -561,6 +580,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma // Display manialink $this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $target); + $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYER_WARNED, $target); + if ($calledByAdmin) { $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( @@ -625,6 +646,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma } } + $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYER_KICKED, $target); + if ($calledByAdmin) { $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( @@ -679,6 +702,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma return; } + $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYER_BANNED, $target); + $title = $admin->getAuthLevelName(); $message = $this->maniaControl->getChat()->formatMessage( "{$title} %s banned %s!",