diff --git a/src/matcracker/BedcoreProtect/Inspector.php b/src/matcracker/BedcoreProtect/Inspector.php index c06c9f2a..affeda52 100644 --- a/src/matcracker/BedcoreProtect/Inspector.php +++ b/src/matcracker/BedcoreProtect/Inspector.php @@ -90,7 +90,7 @@ public static function isInspector(CommandSender $inspector): bool return self::$inspectors[self::getSenderUUID($inspector)]['enabled'] ?? false; } - public static function cacheLogs(CommandSender $inspector, array $logs = []): void + public static function saveLogs(CommandSender $inspector, array $logs = []): void { self::$inspectors[self::getSenderUUID($inspector)]['logs'] = $logs; } @@ -100,12 +100,12 @@ public static function cacheLogs(CommandSender $inspector, array $logs = []): vo * * @return array */ - public static function getCachedLogs(CommandSender $inspector): array + public static function getSavedLogs(CommandSender $inspector): array { return self::$inspectors[self::getSenderUUID($inspector)]['logs'] ?? []; } - public static function clearCache(): void + public static function removeAll(): void { self::$inspectors = []; } diff --git a/src/matcracker/BedcoreProtect/Main.php b/src/matcracker/BedcoreProtect/Main.php index 3ca2adc6..4d4058f9 100644 --- a/src/matcracker/BedcoreProtect/Main.php +++ b/src/matcracker/BedcoreProtect/Main.php @@ -206,7 +206,7 @@ public function onDisable(): void $this->getScheduler()->cancelAllTasks(); $this->database->disconnect(); - Inspector::clearCache(); + Inspector::removeAll(); $this->bsHooked = false; unset($this->database, $this->baseLang, $this->configParser, $this->oldConfigParser); } diff --git a/src/matcracker/BedcoreProtect/commands/BCPCommand.php b/src/matcracker/BedcoreProtect/commands/BCPCommand.php index 464c1b7e..09a7f327 100644 --- a/src/matcracker/BedcoreProtect/commands/BCPCommand.php +++ b/src/matcracker/BedcoreProtect/commands/BCPCommand.php @@ -104,9 +104,9 @@ public function execute(CommandSender $sender, string $commandLabel, array $args Await::f2c( function () use ($sender, $lang) : Generator { $description = $this->plugin->getDescription(); - - $pluginVersion = $this->plugin->getVersion(); + $pluginVersion = $description->getVersion(); $dbVersion = (string)(yield $this->plugin->getDatabase()->getStatus())[0]["version"]; + if (version_compare($pluginVersion, $dbVersion) > 0) { //Database version could be minor respect the plugin, in this case I apply a BC suffix (Backward Compatibility) $dbVersion .= ' (' . $lang->translateString("command.status.bc") . ')'; @@ -130,7 +130,7 @@ static function (): void { if ($parser->parse()) { $this->queryManager->getPluginQueries()->requestLookup($sender, $parser); } else { - if (count($logs = Inspector::getCachedLogs($sender)) > 0) { + if (count($logs = Inspector::getSavedLogs($sender)) > 0) { $page = 0; $lines = 4; $split = explode(":", $args[1]); @@ -169,7 +169,6 @@ static function (): void { $sender->sendMessage(TextFormat::colorize(Main::MESSAGE_PREFIX . $lang->translateString('command.purge.deleted-rows', [$affectedRows]))); }); - return true; } else { $sender->sendMessage(TextFormat::colorize(Main::MESSAGE_PREFIX . "&c{$parser->getErrorMessage()}")); } diff --git a/src/matcracker/BedcoreProtect/storage/queries/PluginQueries.php b/src/matcracker/BedcoreProtect/storage/queries/PluginQueries.php index f6b0cf99..4f823cc8 100644 --- a/src/matcracker/BedcoreProtect/storage/queries/PluginQueries.php +++ b/src/matcracker/BedcoreProtect/storage/queries/PluginQueries.php @@ -76,7 +76,7 @@ private function requestLog(string $queryName, Player $inspector, Position $posi 'max_z' => $maxV->getZ(), 'world_name' => $position->getLevel()->getName() ], static function (array $rows) use ($inspector): void { - Inspector::cacheLogs($inspector, $rows); + Inspector::saveLogs($inspector, $rows); Inspector::parseLogs($inspector, $rows); }); } @@ -87,7 +87,7 @@ public function requestLookup(CommandSender $sender, CommandParser $parser): voi $parser->buildLookupQuery(), [], static function (array $rows) use ($sender): void { - Inspector::cacheLogs($sender, $rows); + Inspector::saveLogs($sender, $rows); Inspector::parseLogs($sender, $rows); } );