use Chat::formatMessage in Commands-namespace

This commit is contained in:
Alexander Nell 2020-05-26 21:56:00 +02:00
parent a311dcdbd9
commit 1d0215df52
2 changed files with 36 additions and 23 deletions

View File

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

View File

@ -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
*