Skip to content

Commit

Permalink
First 2.0 pre-release
Browse files Browse the repository at this point in the history
  • Loading branch information
VixikHD committed Aug 5, 2022
1 parent 88a31ff commit 4b70692
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 9 deletions.
Binary file modified icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 5 additions & 8 deletions plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
2 changes: 2 additions & 0 deletions src/czechpmdevs/multiworld/command/MultiWorldCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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", ["?"]));
Expand Down
59 changes: 59 additions & 0 deletions src/czechpmdevs/multiworld/command/subcommand/DebugSubCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

/**
* MultiWorld - PocketMine plugin that manages worlds.
* Copyright (C) 2018 - 2022 CzechPMDevs
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

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<string, mixed> $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()}");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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]));
Expand Down

0 comments on commit 4b70692

Please sign in to comment.