Compare commits

...

2 Commits

Author SHA1 Message Date
Beu
afe617b642 add callbacks for PlayerActions 2023-11-01 17:20:05 +01:00
Beu
4b9ea37217 convert value from database to int 2023-11-01 11:17:40 +01:00
2 changed files with 30 additions and 5 deletions

View File

@ -47,6 +47,17 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
const SPECTATOR_BUT_KEEP_SELECTABLE = 3; const SPECTATOR_BUT_KEEP_SELECTABLE = 3;
const ECHO_WARN_PLAYER = 'ManiaControl.PlayerManager.WarnPlayer'; 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 * Permission Setting Constants
*/ */
@ -201,6 +212,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
return false; return false;
} }
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYER_FORCED_TO_TEAM, $target, $teamId);
$message = false; $message = false;
$teamName = ''; $teamName = '';
if ($teamId === self::TEAM_BLUE) { if ($teamId === self::TEAM_BLUE) {
@ -229,7 +242,7 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
if ($message) { if ($message) {
$this->maniaControl->getChat()->sendInformation($message); $this->maniaControl->getChat()->sendInformation($message);
Logger::logInfo($chatMessage, true); Logger::logInfo($message, true);
} }
return 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 // Announce force
if ($displayAnnouncement) { if ($displayAnnouncement) {
if ($calledByAdmin) { if ($calledByAdmin) {
@ -340,6 +355,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
return false; return false;
} }
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYER_FORCED_TO_SPEC, $target);
if ($calledByAdmin) { if ($calledByAdmin) {
$title = $admin->getAuthLevelName(); $title = $admin->getAuthLevelName();
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
@ -460,6 +477,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
return false; return false;
} }
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYER_MUTED, $target);
if ($calledByAdmin) { if ($calledByAdmin) {
$title = $admin->getAuthLevelName(); $title = $admin->getAuthLevelName();
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
@ -561,6 +580,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
// Display manialink // Display manialink
$this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $target); $this->maniaControl->getManialinkManager()->displayWidget($maniaLink, $target);
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYER_WARNED, $target);
if ($calledByAdmin) { if ($calledByAdmin) {
$title = $admin->getAuthLevelName(); $title = $admin->getAuthLevelName();
$message = $this->maniaControl->getChat()->formatMessage( $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) { if ($calledByAdmin) {
$title = $admin->getAuthLevelName(); $title = $admin->getAuthLevelName();
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
@ -679,6 +702,8 @@ class PlayerActions implements EchoListener, CommunicationListener, UsageInforma
return; return;
} }
$this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PLAYER_BANNED, $target);
$title = $admin->getAuthLevelName(); $title = $admin->getAuthLevelName();
$message = $this->maniaControl->getChat()->formatMessage( $message = $this->maniaControl->getChat()->formatMessage(
"{$title} %s banned %s!", "{$title} %s banned %s!",

View File

@ -600,12 +600,12 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis
} }
$player = new Player($this->maniaControl, false); $player = new Player($this->maniaControl, false);
$player->index = $row->index; $player->index = intval($row->index);
$player->login = $row->login; $player->login = $row->login;
$player->rawNickname = $row->nickname; $player->rawNickname = $row->nickname;
$player->nickname = Formatter::stripDirtyCodes($player->rawNickname); $player->nickname = Formatter::stripDirtyCodes($player->rawNickname);
$player->path = $row->path; $player->path = $row->path;
$player->authLevel = $row->authLevel; $player->authLevel = intval($row->authLevel);
return $player; return $player;
} }
@ -715,12 +715,12 @@ class PlayerManager implements CallbackListener, TimerListener, CommunicationLis
} }
$player = new Player($this->maniaControl, false); $player = new Player($this->maniaControl, false);
$player->index = $playerIndex; $player->index = intval($playerIndex);
$player->login = $row->login; $player->login = $row->login;
$player->rawNickname = $row->nickname; $player->rawNickname = $row->nickname;
$player->nickname = Formatter::stripDirtyCodes($player->rawNickname); $player->nickname = Formatter::stripDirtyCodes($player->rawNickname);
$player->path = $row->path; $player->path = $row->path;
$player->authLevel = $row->authLevel; $player->authLevel = intval($row->authLevel);
return $player; return $player;
} }