diff --git a/icon.png b/icon.png index 7a56a6e..6ab2e86 100644 Binary files a/icon.png and b/icon.png differ diff --git a/plugin.yml b/plugin.yml index 0020e21..072e872 100644 --- a/plugin.yml +++ b/plugin.yml @@ -2,7 +2,7 @@ name: MultiWorld author: CzechPMDevs authors: [VixikCZ, fuyutsuki, kaliiks] api: 4.0.0 -version: 2.0.0-dev +version: 2.0.0-beta1 main: czechpmdevs\multiworld\MultiWorld description: Plugin that manage with worlds website: https://github.com/CzechPMDevs/MultiWorld @@ -11,20 +11,20 @@ extensions: permissions: multiworld.command: - description: Permssion nested for /multiworld + description: Permission nested for /multiworld default: op multiworld.command.create: description: Permission for /multiworld create default: op + multiworld.command.debug: + description: Permission for /multiworld debug + default: op multiworld.command.delete: description: Permission for /multiworld delete default: op multiworld.command.duplicate: description: Permission for /multiworld duplicate default: op - multiworld.command.gamerule: - description: Permission for /multiworld gamerule - default: op multiworld.command.help: description: Permission for /multiworld help default: op @@ -49,6 +49,3 @@ permissions: multiworld.command.unload: description: Permission for /multiworld unload default: op - multiworld.command.update: - description: Permission for /multiworld update - default: op \ No newline at end of file diff --git a/src/czechpmdevs/multiworld/command/MultiWorldCommand.php b/src/czechpmdevs/multiworld/command/MultiWorldCommand.php index 72ac156..b5976e9 100644 --- a/src/czechpmdevs/multiworld/command/MultiWorldCommand.php +++ b/src/czechpmdevs/multiworld/command/MultiWorldCommand.php @@ -24,6 +24,7 @@ use CortexPE\Commando\BaseCommand; use czechpmdevs\multiworld\command\subcommand\CreateSubCommand; +use czechpmdevs\multiworld\command\subcommand\DebugSubCommand; use czechpmdevs\multiworld\command\subcommand\DeleteSubCommand; use czechpmdevs\multiworld\command\subcommand\DuplicateSubCommand; use czechpmdevs\multiworld\command\subcommand\HelpSubCommand; @@ -40,6 +41,7 @@ class MultiWorldCommand extends BaseCommand { protected function prepare(): void { $this->registerSubCommand(new CreateSubCommand("create", "Generate a new world", ["new", "c"])); + $this->registerSubCommand(new DebugSubCommand("debug", "Displays debug information")); $this->registerSubCommand(new DeleteSubCommand("delete", "Remove world", ["remove", "rm", "del"])); $this->registerSubCommand(new DuplicateSubCommand("duplicate", "Duplicate a world", ["dp"])); $this->registerSubCommand(new HelpSubCommand("help", "Display all the MultiWorld commands", ["?"])); diff --git a/src/czechpmdevs/multiworld/command/subcommand/DebugSubCommand.php b/src/czechpmdevs/multiworld/command/subcommand/DebugSubCommand.php new file mode 100644 index 0000000..b4c7bf0 --- /dev/null +++ b/src/czechpmdevs/multiworld/command/subcommand/DebugSubCommand.php @@ -0,0 +1,59 @@ +. + */ + +declare(strict_types=1); + +namespace czechpmdevs\multiworld\command\subcommand; + +use CortexPE\Commando\BaseSubCommand; +use CortexPE\Commando\constraint\InGameRequiredConstraint; +use pocketmine\command\CommandSender; +use pocketmine\player\Player; +use pocketmine\utils\AssumptionFailedError; +use pocketmine\world\biome\BiomeRegistry; + +class DebugSubCommand extends BaseSubCommand { + protected function prepare(): void { + $this->addConstraint(new InGameRequiredConstraint($this)); + } + + /** + * @param array $args + */ + public function onRun(CommandSender $sender, string $aliasUsed, array $args): void { + if(!$sender instanceof Player) { + throw new AssumptionFailedError("Sender is not a player"); + } + + $position = $sender->getPosition()->floor(); + $sender->sendMessage("Current position: {$position->getX()}, {$position->getY()}, {$position->getZ()}"); + + $chunkX = $position->getX() >> 4; + $chunkZ = $position->getZ() >> 4; + $sender->sendMessage("Current chunk position: $chunkX, $chunkZ"); + + $chunk = $sender->getPosition()->getWorld()->getChunk($chunkX, $chunkZ); + $x = $position->getX() & 0xf; + $z = $position->getZ() & 0xf; + $id = $chunk?->getBiomeId($x, $z) ?? 0; + $biome = BiomeRegistry::getInstance()->getBiome($id); + $sender->sendMessage("Current biome: [$id] {$biome->getName()}"); + } +} \ No newline at end of file diff --git a/src/czechpmdevs/multiworld/command/subcommand/InfoSubCommand.php b/src/czechpmdevs/multiworld/command/subcommand/InfoSubCommand.php index bd1112e..fbc4e5e 100644 --- a/src/czechpmdevs/multiworld/command/subcommand/InfoSubCommand.php +++ b/src/czechpmdevs/multiworld/command/subcommand/InfoSubCommand.php @@ -52,7 +52,6 @@ public function onRun(CommandSender $sender, string $aliasUsed, array $args): vo return; } - $world = null; if($worldName !== null) { if(!Server::getInstance()->getWorldManager()->isWorldGenerated($worldName)) { $sender->sendMessage(LanguageManager::translateMessage($sender, "info.levelnotexists", [$worldName]));