Skip to content

Commit

Permalink
Test 2
Browse files Browse the repository at this point in the history
  • Loading branch information
matcracker committed Apr 11, 2020
1 parent 3d1703f commit 346ad03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/matcracker/BedcoreProtect/commands/BCPCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ static function (): void {
return true;
case 'lookup':
if (array_key_exists(1, $args)) {
$parser = new CommandParser($sender->getName(), $this->plugin->getParsedConfig(), $args, ['time'], true);
$parser = new CommandParser($lang, $sender->getName(), $this->plugin->getParsedConfig(), $args, ['time'], true);
if ($parser->parse()) {
$this->queryManager->getPluginQueries()->requestLookup($sender, $parser);
} else {
Expand Down Expand Up @@ -162,7 +162,7 @@ static function (): void {
return true;
case 'purge':
if (array_key_exists(1, $args)) {
$parser = new CommandParser($sender->getName(), $this->plugin->getParsedConfig(), $args, ['time'], true);
$parser = new CommandParser($lang, $sender->getName(), $this->plugin->getParsedConfig(), $args, ['time'], true);
if ($parser->parse()) {
$sender->sendMessage(TextFormat::colorize(Main::MESSAGE_PREFIX . $lang->translateString('command.purge.started')));
$sender->sendMessage(TextFormat::colorize(Main::MESSAGE_PREFIX . $lang->translateString('command.purge.no-restart')));
Expand Down Expand Up @@ -226,7 +226,7 @@ static function (): void {
return true;
case 'rollback':
if (array_key_exists(1, $args)) {
$parser = new CommandParser($sender->getName(), $this->plugin->getParsedConfig(), $args, ['time', 'radius'], true);
$parser = new CommandParser($lang, $sender->getName(), $this->plugin->getParsedConfig(), $args, ['time', 'radius'], true);
if ($parser->parse()) {
$sender->sendMessage(TextFormat::colorize(Main::MESSAGE_PREFIX . $lang->translateString('command.rollback.started', [$sender->getLevel()->getName()])));

Expand All @@ -242,7 +242,7 @@ static function (): void {
return true;
case 'restore':
if (array_key_exists(1, $args)) {
$parser = new CommandParser($sender->getName(), $this->plugin->getParsedConfig(), $args, ['time', 'radius'], true);
$parser = new CommandParser($lang, $sender->getName(), $this->plugin->getParsedConfig(), $args, ['time', 'radius'], true);
if ($parser->parse()) {
$sender->sendMessage(TextFormat::colorize(Main::MESSAGE_PREFIX . $lang->translateString('command.restore.started', [$sender->getLevel()->getName()])));

Expand Down
11 changes: 5 additions & 6 deletions src/matcracker/BedcoreProtect/commands/CommandParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use BadMethodCallException;
use InvalidArgumentException;
use matcracker\BedcoreProtect\enums\Action;
use matcracker\BedcoreProtect\Main;
use matcracker\BedcoreProtect\math\MathUtils;
use matcracker\BedcoreProtect\utils\ConfigParser;
use matcracker\BedcoreProtect\utils\Utils;
Expand Down Expand Up @@ -65,6 +64,8 @@ final class CommandParser
/** @var Action[][] */
public static $ACTIONS;

/** @var BaseLang */
private $lang;
/** @var string */
private $senderName;
/** @var ConfigParser */
Expand All @@ -76,8 +77,6 @@ final class CommandParser
/** @var bool */
private $parsed = false;

/** @var BaseLang */
private $lang;
/** @var string */
private $errorMessage;

Expand All @@ -94,14 +93,16 @@ final class CommandParser

/**
* CommandParser constructor.
* @param BaseLang $lang
* @param string $senderName
* @param ConfigParser $configParser
* @param string[] $arguments
* @param string[] $requiredParams
* @param bool $shift It shift the first element of array used internally for command arguments. Default false.
*/
public function __construct(string $senderName, ConfigParser $configParser, array $arguments, array $requiredParams = [], bool $shift = false)
public function __construct(BaseLang $lang, string $senderName, ConfigParser $configParser, array $arguments, array $requiredParams = [], bool $shift = false)
{
$this->lang = $lang;
$this->senderName = $senderName;
$this->configParser = $configParser;
$this->arguments = $arguments;
Expand All @@ -113,8 +114,6 @@ public function __construct(string $senderName, ConfigParser $configParser, arra
if (($dr = $this->configParser->getDefaultRadius()) !== 0) {
$this->data['radius'] = $dr;
}

$this->lang = Main::getInstance()->getLanguage();
}

/**
Expand Down

0 comments on commit 346ad03

Please sign in to comment.