diff --git a/.poggit.yml b/.poggit.yml index ef23ea8..f311442 100644 --- a/.poggit.yml +++ b/.poggit.yml @@ -1,15 +1,14 @@ ---- # Poggit-CI Manifest. Open the CI at https://poggit.pmmp.io/ci/adeynes/cucumber +--- # Poggit-CI Manifest. Open the CI at https://poggit.pmmp.io/ci/BlackD14/cucumber branches: - master -- stable projects: cucumber: libs: - src: poggit/libasynql/libasynql version: ^3.3.0 - - src: adeynes/parsecmd/parsecmd + - src: BlackD14/parsecmd/parsecmd version: ^5.0.0 - - src: adeynes/asyncio/asyncio + - src: BlackD14/asyncio/asyncio version: ^0.1.0 ... diff --git a/plugin.yml b/plugin.yml index 2474cba..ff39e25 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,7 +1,7 @@ name: cucumber main: adeynes\cucumber\Cucumber version: 3.0.0 -api: 4.0.0 +api: 5.0.0 author: adeynes description: Advanced, flexible moderation plugin website: https://github.com/adeynes/cucumber @@ -87,4 +87,4 @@ permissions: cucumber.command.history: description: "Allows for the user of /history" - default: op \ No newline at end of file + default: op diff --git a/src/adeynes/cucumber/CucumberListener.php b/src/adeynes/cucumber/CucumberListener.php index 7397ff7..2ddae55 100644 --- a/src/adeynes/cucumber/CucumberListener.php +++ b/src/adeynes/cucumber/CucumberListener.php @@ -16,11 +16,12 @@ use adeynes\cucumber\utils\Queries; use pocketmine\event\Listener; use pocketmine\event\player\PlayerChatEvent; -use pocketmine\event\player\PlayerCommandPreprocessEvent; +use pocketmine\event\server\CommandEvent as PlayerCommandEvent; use pocketmine\event\player\PlayerJoinEvent; use pocketmine\event\player\PlayerLoginEvent; use pocketmine\event\player\PlayerPreLoginEvent; use pocketmine\event\player\PlayerQuitEvent; +use pocketmine\player\Player; final class CucumberListener implements Listener { @@ -66,10 +67,11 @@ public function onChat(PlayerChatEvent $ev) } } - public function onCommandPreprocess(PlayerCommandPreprocessEvent $ev) + public function onPlayerCommand(PlayerCommandEvent $ev) { - if (str_starts_with(($command = $ev->getMessage()), '/') && $this->log_command) { - (new CommandEvent($ev->getPlayer(), $command))->call(); + $sender = $ev->getSender(); + if ($sender instanceof Player && $this->log_command) { + (new CommandEvent($sender, $ev->getCommand()))->call(); } } @@ -124,4 +126,4 @@ public function onCucumberEvent(CucumberEvent $ev) $log_dispatcher->log($log_dispatcher->formatEventMessage($ev), $ev->getSeverity()); } -} \ No newline at end of file +} diff --git a/src/adeynes/cucumber/event/CommandEvent.php b/src/adeynes/cucumber/event/CommandEvent.php index 70d260d..97157f2 100644 --- a/src/adeynes/cucumber/event/CommandEvent.php +++ b/src/adeynes/cucumber/event/CommandEvent.php @@ -39,7 +39,7 @@ public function getCommand(): string public function getFormatData(): array { - return parent::getFormatData() + ['command' => $this->getCommand()]; + return parent::getFormatData() + ['command' => '/' . $this->getCommand()]; } public function getMessagesPath(): string @@ -47,4 +47,4 @@ public function getMessagesPath(): string return 'log.command'; } -} \ No newline at end of file +} diff --git a/src/adeynes/cucumber/utils/ds/Enum.php b/src/adeynes/cucumber/utils/ds/Enum.php index 182545d..fa680e3 100644 --- a/src/adeynes/cucumber/utils/ds/Enum.php +++ b/src/adeynes/cucumber/utils/ds/Enum.php @@ -114,8 +114,8 @@ public static function __callStatic(string $name, mixed $arguments) throw new BadMethodCallException("No static method or enum constant '$name' in class " . get_called_class()); } - public function jsonSerialize() + public function jsonSerialize(): array { return $this->getValue(); } -} \ No newline at end of file +} diff --git a/src/adeynes/cucumber/utils/ds/Stack.php b/src/adeynes/cucumber/utils/ds/Stack.php index 79219c5..655bab9 100644 --- a/src/adeynes/cucumber/utils/ds/Stack.php +++ b/src/adeynes/cucumber/utils/ds/Stack.php @@ -20,7 +20,7 @@ public function rewind(): void $this->position = 0; } - public function current() + public function current(): mixed { return $this->peek($this->position); } @@ -74,4 +74,4 @@ public function peek(int $index = 0): mixed return $this->stack[$index] ?? null; } -} \ No newline at end of file +}