diff --git a/examples/resourceexample/plugin.yml b/examples/resourceexample/plugin.yml index d0675e8..de05214 100644 --- a/examples/resourceexample/plugin.yml +++ b/examples/resourceexample/plugin.yml @@ -1,8 +1,11 @@ name: ResourceExample version: 1.0.0 main: pjz9n\resourceexample\Main -api: 3.0.0 +api: 4.0.0 commands: resourceexample: - aliases: - - re + description: Manage ResourcePack + permission: resourceexample.command.resourceexample +permissions: + resourceexample.command.resourceexample: + default: true diff --git a/examples/resourceexample/src/pjz9n/resourceexample/ExampleForm.php b/examples/resourceexample/src/pjz9n/resourceexample/ExampleForm.php index 3eacc4b..162f631 100644 --- a/examples/resourceexample/src/pjz9n/resourceexample/ExampleForm.php +++ b/examples/resourceexample/src/pjz9n/resourceexample/ExampleForm.php @@ -24,7 +24,7 @@ namespace pjz9n\resourceexample; use pocketmine\form\Form; -use pocketmine\Player; +use pocketmine\player\Player; class ExampleForm implements Form { diff --git a/examples/resourceexample/src/pjz9n/resourceexample/Main.php b/examples/resourceexample/src/pjz9n/resourceexample/Main.php index d4d9a83..9c22edc 100644 --- a/examples/resourceexample/src/pjz9n/resourceexample/Main.php +++ b/examples/resourceexample/src/pjz9n/resourceexample/Main.php @@ -28,7 +28,7 @@ use pjz9n\resourcepacktools\ResourcePack; use pocketmine\command\Command; use pocketmine\command\CommandSender; -use pocketmine\Player; +use pocketmine\player\Player; use pocketmine\plugin\PluginBase; use pocketmine\utils\TextFormat; diff --git a/resourcepacktools/plugin.yml b/resourcepacktools/plugin.yml index fcb9989..d0d1bbc 100644 --- a/resourcepacktools/plugin.yml +++ b/resourcepacktools/plugin.yml @@ -1,7 +1,7 @@ name: ResourcePackToolsPlugin version: 2.2.0 main: pjz9n\resourcepacktools\Main -api: 3.0.0 +api: 4.0.0 commands: resourcepack: description: Manage ResourcePack diff --git a/resourcepacktools/resources/locale/eng.ini b/resourcepacktools/resources/locale/eng.ini index d519ee1..a6cedc0 100644 --- a/resourcepacktools/resources/locale/eng.ini +++ b/resourcepacktools/resources/locale/eng.ini @@ -6,3 +6,4 @@ command.validate.onlynumeric = Only numeric can be used as arguments. resourcepack.notfound = ResourcePack does not exist. resourcepack.register.success = The ResourcePack ({%0}) was registered successfully. resourcepack.unregister.success = The ResourcePack ({%0}) was unregistered successfully. +resourcepack.unknown = "not supported." diff --git a/resourcepacktools/resources/locale/jpn.ini b/resourcepacktools/resources/locale/jpn.ini index 42fe283..7e51b2c 100644 --- a/resourcepacktools/resources/locale/jpn.ini +++ b/resourcepacktools/resources/locale/jpn.ini @@ -6,3 +6,4 @@ command.validate.onlynumeric = 引数には数字のみ使用できます。 resourcepack.notfound = リソースパックが存在しません。 resourcepack.register.success = リソースパック ({%0}) の登録に成功しました。 resourcepack.unregister.success = リソースパック ({%0}) の登録解除に成功しました。 +resourcepack.unknown = 非対応 diff --git a/resourcepacktools/src/pjz9n/resourcepacktools/Main.php b/resourcepacktools/src/pjz9n/resourcepacktools/Main.php index 5583c24..bc0ea75 100644 --- a/resourcepacktools/src/pjz9n/resourcepacktools/Main.php +++ b/resourcepacktools/src/pjz9n/resourcepacktools/Main.php @@ -1,5 +1,4 @@ saveDefaultConfig(); $configLang = (string)$this->getConfig()->get("lang", "def"); $lang = $configLang === "def" ? $this->getServer()->getLanguage()->getLang() : $configLang; $localePath = $this->getFile() . "resources/locale/"; - $this->lang = new BaseLang($lang, $localePath, "eng"); + $this->lang = new Language($lang, $localePath, "eng"); $this->getLogger()->info($this->lang->translateString("language.selected", [$this->lang->getName()])); } - public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool - { + public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool { switch ($command) {//$command->__toString() case "resourcepack": if (!isset($args[0])) return false; @@ -116,7 +113,12 @@ public function onCommand(CommandSender $sender, Command $command, string $label //pack mode $list = []; foreach (ResourcePack::getPackList() as $index => $pack) { + if($pack instanceof ZippedResourcePack){ $list[] = (string)$index . " => " . $pack->getPath(); + + }else{ + $list[] = (string)$index . " => " . $this->lang->translateString("resourcepack.unknown"); + } } if (count($list) < 1) { $sender->sendMessage( @@ -132,7 +134,11 @@ public function onCommand(CommandSender $sender, Command $command, string $label //uuid mode $list = []; foreach (ResourcePack::getUuidList() as $uuid => $pack) { - $list[] = (string)$uuid . " => " . $pack->getPath(); + if($pack instanceof ZippedResourcePack) { + $list[] = (string)$uuid . " => " . $pack->getPath(); + }else{ + $list[] = (string)$uuid . " => ". $this->lang->translateString("resourcepack.unknown"); + } } if (count($list) < 1) { $sender->sendMessage( diff --git a/resourcepacktools/src/pjz9n/resourcepacktools/generator/ResourcePackGenerator.php b/resourcepacktools/src/pjz9n/resourcepacktools/generator/ResourcePackGenerator.php index d944bb2..c8aaaea 100644 --- a/resourcepacktools/src/pjz9n/resourcepacktools/generator/ResourcePackGenerator.php +++ b/resourcepacktools/src/pjz9n/resourcepacktools/generator/ResourcePackGenerator.php @@ -25,27 +25,28 @@ use pjz9n\resourcepacktools\manifest\Manifest; use pocketmine\plugin\Plugin; +use pocketmine\plugin\PluginBase; use ZipArchive; class ResourcePackGenerator { - /** @var Plugin */ - private $plugin; + /** @var PluginBase */ + private PluginBase $plugin; /** @var Manifest */ - private $manifest; + private Manifest $manifest; /** @var string|null PluginResourceRelativePath */ - private $packIcon; + private ?string $packIcon; /** @var string[] ResourcePackPath => PluginResourceRelativePath */ - private $files; + private array $files; /** - * @param Plugin $plugin + * @param PluginBase $plugin * @param Manifest $manifest */ - public function __construct(Plugin $plugin, Manifest $manifest) + public function __construct(PluginBase $plugin, Manifest $manifest) { $this->plugin = $plugin; $this->manifest = $manifest; @@ -121,9 +122,9 @@ public function generate(string $generateFilePath, bool $overwrite = true): void } /** - * @return Plugin + * @return PluginBase */ - protected function getPlugin(): Plugin + protected function getPlugin(): PluginBase { return $this->plugin; } diff --git a/resourcepacktools/src/pjz9n/resourcepacktools/generator/SimpleResourcePack.php b/resourcepacktools/src/pjz9n/resourcepacktools/generator/SimpleResourcePack.php index 1564b15..4c03f6f 100644 --- a/resourcepacktools/src/pjz9n/resourcepacktools/generator/SimpleResourcePack.php +++ b/resourcepacktools/src/pjz9n/resourcepacktools/generator/SimpleResourcePack.php @@ -27,30 +27,30 @@ use pjz9n\resourcepacktools\manifest\Manifest; use pjz9n\resourcepacktools\manifest\Module; use pjz9n\resourcepacktools\manifest\Version; -use pocketmine\plugin\Plugin; -use pocketmine\utils\UUID; +use pocketmine\plugin\PluginBase; +use Ramsey\Uuid\Uuid; class SimpleResourcePack extends ResourcePackGenerator { /** - * @param Plugin $plugin + * @param PluginBase $plugin * @param Version $version */ - public function __construct(Plugin $plugin, Version $version) + public function __construct(PluginBase $plugin, Version $version) { //TODO: Can header and module versions be different? $manifest = new Manifest( new Header( "Auto generated by ResourcePackTools.", $plugin->getName() . " ResourcePack.", - UUID::fromData($plugin->getName(), "header")->toString(), + Uuid::fromBytes(md5($plugin->getName() . "header", true))->toString(), $version ), [ new Module( "Auto generated by ResourcePackTools.", Module::TYPE_RESOURCES, - UUID::fromData($plugin->getName(), "module")->toString(), + Uuid::fromBytes(md5($plugin->getName() . "module", true))->toString(), $version ), ] diff --git a/resourcepacktools/virion.yml b/resourcepacktools/virion.yml index b9491f6..62ba34c 100644 --- a/resourcepacktools/virion.yml +++ b/resourcepacktools/virion.yml @@ -1,4 +1,4 @@ name: ResourcePackTools version: 2.2.0 antigen: pjz9n\resourcepacktools -api: 3.0.0 +api: 4.0.0