diff --git a/.poggit.yml b/.poggit.yml index a7618ef..6f94ad9 100644 --- a/.poggit.yml +++ b/.poggit.yml @@ -1,4 +1,4 @@ ---- # Poggit-CI Manifest. Open the CI at https://poggit.pmmp.io/ci/Muqsit/CustomSizedInvMenu +--- # Poggit-CI Manifest. Open the CI at https://poggit.pmmp.io/ci/ClickedTran/CustomSizedInvMenu build-by-default: true branches: - master @@ -6,7 +6,7 @@ projects: CustomSizedInvMenu: path: "" libs: - - src: muqsit/InvMenu/InvMenu - branch: pm5 - version: ^4.6.4 + - src: muqsit/InvMenu/InvMenu + branch: pm5 + version: ^4.6.5 ... diff --git a/README.md b/README.md index 33051e5..4db9577 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # CustomSizedInvMenu -To be able to build custom-sized `InvMenu` instances, you must install the [tedo0627/InventoryUIResourcePack](https://github.com/tedo0627/InventoryUIResourcePack) resource pack on your server. +Now to be able to build custom-sized [`InvMenu`](https://github.com/muqsit/InvMenu) instances, you no longer need to install the [`tedo0627/InventoryUIResourcePack`](https://github.com/tedo0627/InventoryUIResourcePack) resource pack on your server as new version has it built into the plugin. However, you need to install the virion [`libBedrock`](https://github.com/NhanAZ/libBedrock) to your server so that errors do not occur during use A custom-sized InvMenu provides several advantages over traditional ways of displaying menus (`InvMenu::TYPE_CHEST`, `InvMenu::TYPE_DOUBLE_CHEST`): 1. **Dynamic:** To create a menu that can hold `n` items, you need not know the size of a chest or a double chest inventory. Instead, simply create a menu of the preferred size: `CustomSizedInvMenu::create(n)`. @@ -25,8 +25,3 @@ Run `/cinvmenu [title]` to open an InvMenu of `numSlots` number of sl - `/cinvmenu 59 "59-slot Inventory"` ![image](https://github.com/Muqsit/CustomSizedInvMenu/assets/15074389/602e2fdc-b675-4b7f-9e2e-b76c700c64a3) - - -### Resources -- [tedo0627/InventoryUI](https://github.com/tedo0627/InventoryUI) -- [tedo0627/InventoryUIResourcePack](https://github.com/tedo0627/InventoryUIResourcePack) diff --git a/plugin.yml b/plugin.yml index ba56618..cf5db17 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,15 +1,5 @@ name: CustomSizedInvMenu main: muqsit\customsizedinvmenu\CustomSizedInvMenu api: 5.0.0 -version: 0.0.2 - -commands: - cinvmenu: - usage: /cinvmenu [title] - description: Opens a custom-sized inventory menu - permission: customsizedinvmenu.command - -permissions: - customsizedinvmenu.command: - description: Allows using the /cinvmenu command - default: true +version: 0.0.3 +virion: ["InvMenu", "libBedrock"] diff --git a/resources/CustomSizedInvMenu Pack/manifest.json b/resources/CustomSizedInvMenu Pack/manifest.json new file mode 100644 index 0000000..cc38b55 --- /dev/null +++ b/resources/CustomSizedInvMenu Pack/manifest.json @@ -0,0 +1,18 @@ +{ + "format_version": 2, + "header": { + "name": "CustomSizedInvMenu Resource Pack", + "description": "CustomSizedInvMenu Resource Pack", + "uuid": "7ca75eab-549d-45e4-b5b8-56d44209abf1", + "version": [1, 1, 0], + "min_engine_version": [1, 18, 0] + }, + "modules": [ + { + "type": "resources", + "description": "CustomSizedInvMenu Resource Pack", + "uuid": "dce102e8-6112-4190-a363-d6ee18bac0d2", + "version": [1, 1, 0] + } + ] +} \ No newline at end of file diff --git a/resources/CustomSizedInvMenu Pack/pack_icon.png b/resources/CustomSizedInvMenu Pack/pack_icon.png new file mode 100644 index 0000000..cf325f0 Binary files /dev/null and b/resources/CustomSizedInvMenu Pack/pack_icon.png differ diff --git a/resources/CustomSizedInvMenu Pack/ui/_ui_defs.json b/resources/CustomSizedInvMenu Pack/ui/_ui_defs.json new file mode 100644 index 0000000..2fd5d7d --- /dev/null +++ b/resources/CustomSizedInvMenu Pack/ui/_ui_defs.json @@ -0,0 +1,6 @@ +{ + "ui_defs": [ + "ui/custom_pocket_containers.json", + "ui/custom_scroll_screen.json" + ] +} \ No newline at end of file diff --git a/resources/CustomSizedInvMenu Pack/ui/chest_screen.json b/resources/CustomSizedInvMenu Pack/ui/chest_screen.json new file mode 100644 index 0000000..b3b67c1 --- /dev/null +++ b/resources/CustomSizedInvMenu Pack/ui/chest_screen.json @@ -0,0 +1,136 @@ +{ + "namespace": "chest", + + "small_chest_screen@common.inventory_screen_common": { + "$close_on_player_hurt|default": true, + "close_on_player_hurt": "$close_on_player_hurt", + + "$keyword1": "§1§0§r§r§r§r§r§r§r§r§r", + "$keyword2": "§2§0§r§r§r§r§r§r§r§r§r", + "$keyword3": "§3§0§r§r§r§r§r§r§r§r§r", + "$keyword4": "§4§0§r§r§r§r§r§r§r§r§r", + "$keyword5": "§5§0§r§r§r§r§r§r§r§r§r", + "$keyword6": "§6§0§r§r§r§r§r§r§r§r§r", + + "$keyword_scroll1": "§1§1§r§r§r§r§r§r§r§r§r", + "$keyword_scroll2": "§2§1§r§r§r§r§r§r§r§r§r", + "$keyword_scroll3": "§3§1§r§r§r§r§r§r§r§r§r", + "$keyword_scroll4": "§4§1§r§r§r§r§r§r§r§r§r", + "$keyword_scroll5": "§5§1§r§r§r§r§r§r§r§r§r", + "$keyword_scroll6": "§6§1§r§r§r§r§r§r§r§r§r", + + "$keyword_pocket": "§r§r§r§r§r§r§r§r§r", + + "$container_title_copy": "$container_title", + + "variables": [ + { + "requires": "$desktop_screen", + "$screen_content": "chest.small_chest_panel", + "$screen_bg_content": "common.screen_background" + }, + { + "requires": "$pocket_screen", + "$screen_content": "pocket_containers.small_chest_panel" + }, + + // desktop not scroll + + { // 9 * 1 + "requires": "(not (($container_title_copy - $keyword1) = $container_title_copy)) and $desktop_screen", + "$root_panel_size": [ 176, 130 ], + "$panel_top_half_size": [ "100%", 42 ], + "$scrolling_panel_size": [ 162, 18 ], + "$screen_content": "custom_scroll_screen.custom_scroll_panel" + }, + { // 9 * 2 + "requires": "(not (($container_title_copy - $keyword2) = $container_title_copy)) and $desktop_screen", + "$root_panel_size": [ 176, 148 ], + "$panel_top_half_size": [ "100%", 60 ], + "$scrolling_panel_size": [ 162, 36 ], + "$screen_content": "custom_scroll_screen.custom_scroll_panel" + }, + { // 9 * 3 + "requires": "(not (($container_title_copy - $keyword3) = $container_title_copy)) and $desktop_screen", + "$root_panel_size": [ 176, 166 ], + "$panel_top_half_size": [ "100%", 78 ], + "$scrolling_panel_size": [ 162, 54 ], + "$screen_content": "custom_scroll_screen.custom_scroll_panel" + }, + { // 9 * 4 + "requires": "(not (($container_title_copy - $keyword4) = $container_title_copy)) and $desktop_screen", + "$root_panel_size": [ 176, 184 ], + "$panel_top_half_size": [ "100%", 96 ], + "$scrolling_panel_size": [ 162, 72 ], + "$screen_content": "custom_scroll_screen.custom_scroll_panel" + }, + { // 9 * 5 + "requires": "(not (($container_title_copy - $keyword5) = $container_title_copy)) and $desktop_screen", + "$root_panel_size": [ 176, 202 ], + "$panel_top_half_size": [ "100%", 114 ], + "$scrolling_panel_size": [ 162, 90 ], + "$screen_content": "custom_scroll_screen.custom_scroll_panel" + }, + { // 9 * 6 + "requires": "(not (($container_title_copy - $keyword6) = $container_title_copy)) and $desktop_screen", + "$root_panel_size": [ 176, 220 ], + "$panel_top_half_size": [ "100%", 132 ], + "$scrolling_panel_size": [ 162, 108 ], + "$screen_content": "custom_scroll_screen.custom_scroll_panel" + }, + + // desktop scroll + + { // 9 * 1 + "requires": "(not (($container_title_copy - $keyword_scroll1) = $container_title_copy)) and $desktop_screen", + "$root_panel_size": [ 184, 130 ], + "$panel_top_half_size": [ "100%", 42 ], + "$scrolling_panel_size": [ 168, 18 ], + "$screen_content": "custom_scroll_screen.custom_scroll_panel" + }, + { // 9 * 2 + "requires": "(not (($container_title_copy - $keyword_scroll2) = $container_title_copy)) and $desktop_screen", + "$root_panel_size": [ 184, 148 ], + "$panel_top_half_size": [ "100%", 60 ], + "$scrolling_panel_size": [ 168, 36 ], + "$screen_content": "custom_scroll_screen.custom_scroll_panel" + }, + { // 9 * 3 + "requires": "(not (($container_title_copy - $keyword_scroll3) = $container_title_copy)) and $desktop_screen", + "$root_panel_size": [ 184, 166 ], + "$panel_top_half_size": [ "100%", 78 ], + "$scrolling_panel_size": [ 168, 54 ], + "$screen_content": "custom_scroll_screen.custom_scroll_panel" + }, + { // 9 * 4 + "requires": "(not (($container_title_copy - $keyword_scroll4) = $container_title_copy)) and $desktop_screen", + "$root_panel_size": [ 184, 184 ], + "$panel_top_half_size": [ "100%", 96 ], + "$scrolling_panel_size": [ 168, 72 ], + "$screen_content": "custom_scroll_screen.custom_scroll_panel" + }, + { // 9 * 5 + "requires": "(not (($container_title_copy - $keyword_scroll5) = $container_title_copy)) and $desktop_screen", + "$root_panel_size": [ 184, 202 ], + "$panel_top_half_size": [ "100%", 114 ], + "$scrolling_panel_size": [ 168, 90 ], + "$screen_content": "custom_scroll_screen.custom_scroll_panel" + }, + { // 9 * 6 + "requires": "(not (($container_title_copy - $keyword_scroll6) = $container_title_copy)) and $desktop_screen", + "$root_panel_size": [ 184, 220 ], + "$panel_top_half_size": [ "100%", 132 ], + "$scrolling_panel_size": [ 168, 108 ], + "$screen_content": "custom_scroll_screen.custom_scroll_panel" + }, + + // pocket + + { + "requires": "(not (($container_title_copy - $keyword_pocket) = $container_title_copy)) and $pocket_screen", + "$screen_content": "custom_pocket_containers.panel" + + } + ] + } +} diff --git a/resources/CustomSizedInvMenu Pack/ui/custom_pocket_containers.json b/resources/CustomSizedInvMenu Pack/ui/custom_pocket_containers.json new file mode 100644 index 0000000..d1336e1 --- /dev/null +++ b/resources/CustomSizedInvMenu Pack/ui/custom_pocket_containers.json @@ -0,0 +1,75 @@ +{ + "namespace" : "custom_pocket_containers", + + "custom_pocket_container_grid@common.container_grid": { + "layer": 3, + "$item_collection_name": "container_items", + "grid_item_template": "common.pocket_ui_container_item" + }, + + "inventory_panel": { + "type": "panel", + //"size": [ "80%", "95%" ], + "size": [ "84%", "95%" ], // change + "anchor_to": "center", + "anchor_from": "center", + "controls": [ + { + "scrolling_panel@common.scrolling_panel": { + "$allow_scrolling_even_when_content_fits": false, + "layer": 1, + "$scrolling_pane_size": [ "100%", "100%-2px" ], + //"$scrolling_content": "pocket_containers.inventory_grid", + "$scrolling_content": "custom_pocket_containers.custom_pocket_container_grid", // change + "$scroll_box_mouse_image_control": "common-classic.button_state_default", + "$scroll_size": [ "8px", "100%" ] + } + } + ] + }, + + "half_screen": { + "type": "panel", + "size": [ "50%", "100%-27px" ], + "offset": [ 0, 27 ], + "anchor_from": "top_left", + "anchor_to": "top_left", + "controls": [ + { "inventory_panel@inventory_panel": {} } + ] + }, + + "panel": { + "type": "panel", + "controls": [ + { "container_gamepad_helpers@common.container_gamepad_helpers": { "layer": 3 } }, + //{ "header@header_area": { "layer": 2 } }, + { "header@pocket_containers.header_area": { "layer": 2 } }, // change + //{ "bg@background_panel": { "layer": 0 } }, + { "bg@pocket_containers.background_panel": { "layer": 0 } }, // change + { + //"inventory@half_screen": { + "inventory@pocket_containers.half_screen": { // change + "$container_size": 36, + "$pane_collection": "combined_hotbar_and_inventory_items" + } + }, + { + "container@half_screen": { + "anchor_from": "top_middle", + "$pane_collection": "container_items" + } + }, + { "selected_item_details_factory@common.selected_item_details_factory": {} }, + { + "item_lock_notification_factory@common.item_lock_notification_factory": { + "$offset": [ 0, "85%" ] + } + }, + { "gamepad_cursor@common.gamepad_cursor_button": {} }, + { "inventory_selected_icon_button@common.inventory_selected_icon_button": {} }, + { "hold_icon@common.inventory_take_progress_icon_button": {} }, + { "flying_item_renderer@common.flying_item_renderer": {} } + ] + } +} \ No newline at end of file diff --git a/resources/CustomSizedInvMenu Pack/ui/custom_scroll_screen.json b/resources/CustomSizedInvMenu Pack/ui/custom_scroll_screen.json new file mode 100644 index 0000000..4efb811 --- /dev/null +++ b/resources/CustomSizedInvMenu Pack/ui/custom_scroll_screen.json @@ -0,0 +1,71 @@ +{ + "namespace": "custom_scroll_screen", + + "custom_container_grid@common.container_grid": { + "layer": 3, + "$item_collection_name": "container_items" + }, + + "custom_scroll_panel_top_half": { + "type": "panel", + "$panel_top_half_size|default": [ "100%", 132 ], // large_chest_panel_top_half + "size": "$panel_top_half_size", + "offset": [ 0, 11 ], + "anchor_from": "top_left", + "anchor_to": "top_left", + "controls": [ + { "chest_label@chest.chest_label": {} }, + { + "scrolling_panel@common.container_scroll_panel": { + "$scroll_view_port_size": [ "100%", "100%" ], + "$scroll_view_port_size_touch": [ "100%", "100%" ], + "$scroll_view_port_offset": [ 0, 0 ], + "$scroll_view_port_offset_touch": [ 0, 0 ], + "$scroll_bar_left_padding_size": [ 0, 0 ], + "$scroll_bar_right_padding_size": [ 0, 0 ], + "$scrolling_panel_size|default": [ 162, 108 ], // large_chest_grid + "size": "$scrolling_panel_size", + "$scrolling_content": "custom_scroll_screen.custom_container_grid" + } + } + ] + }, + + "custom_scroll_panel": { + "type": "panel", + "controls": [ + { "container_gamepad_helpers@common.container_gamepad_helpers": {} }, + { + "flying_item_renderer@common.flying_item_renderer": { + "layer": 14 + } + }, + { "selected_item_details_factory@common.selected_item_details_factory": {} }, + { "item_lock_notification_factory@common.item_lock_notification_factory": {} }, + { + "root_panel@common.root_panel": { + "$root_panel_size|default": [ 176, 220 ], // large_chest_panel + "size": "$root_panel_size", + "layer": 1, + "controls": [ + { "common_panel@common.common_panel": {} }, + { + "chest_panel": { + "type": "panel", + "layer": 5, + "controls": [ + { "small_chest_panel_top_half@custom_scroll_screen.custom_scroll_panel_top_half": {} }, + { "inventory_panel_bottom_half_with_label@common.inventory_panel_bottom_half_with_label": {} }, + { "hotbar_grid@common.hotbar_grid_template": {} }, + { "inventory_take_progress_icon_button@common.inventory_take_progress_icon_button": {} } + ] + } + }, + { "inventory_selected_icon_button@common.inventory_selected_icon_button": {} }, + { "gamepad_cursor@common.gamepad_cursor_button": {} } + ] + } + } + ] + } +} \ No newline at end of file diff --git a/src/muqsit/customsizedinvmenu/CustomSizedInvMenu.php b/src/muqsit/customsizedinvmenu/CustomSizedInvMenu.php index 40ccf39..4252357 100644 --- a/src/muqsit/customsizedinvmenu/CustomSizedInvMenu.php +++ b/src/muqsit/customsizedinvmenu/CustomSizedInvMenu.php @@ -6,14 +6,12 @@ use muqsit\invmenu\InvMenu; use muqsit\invmenu\InvMenuHandler; -use pocketmine\command\Command; -use pocketmine\command\CommandSender; -use pocketmine\item\VanillaItems; +use muqsit\customsizedinvmenu\type\CustomSizedInvMenuType; +use muqsit\customsizedinvmenu\manager\ResourcePackManager as RSP; use pocketmine\nbt\tag\CompoundTag; use pocketmine\network\mcpe\cache\StaticPacketCache; -use pocketmine\player\Player; use pocketmine\plugin\PluginBase; -use pocketmine\utils\TextFormat; + use RuntimeException; use function array_rand; use function assert; @@ -21,7 +19,6 @@ final class CustomSizedInvMenu extends PluginBase{ - private const RESOURCE_PACK_ID = "21f0427f-572a-416d-a90e-c5d9becb0fa3"; private const TYPE_DYNAMIC_PREFIX = "muqsit:customsizedinvmenu_"; public static function create(int $size) : InvMenu{ @@ -35,11 +32,8 @@ public static function create(int $size) : InvMenu{ } protected function onEnable() : void{ - if($this->getServer()->getResourcePackManager()->getPackById(self::RESOURCE_PACK_ID) === null){ - $this->getLogger()->warning("Resource pack 'Inventory UI Resource Pack' could not be found."); - $this->getLogger()->warning("This plugin cannot be loaded. Please download the resource pack from: https://github.com/tedo0627/InventoryUIResourcePack"); - throw new RuntimeException("Resource pack 'Inventory UI Resource Pack' has not been loaded"); - } + $this->saveDefaultConfig(); + RSP::register($this); if(!InvMenuHandler::isRegistered()){ InvMenuHandler::register($this); @@ -57,27 +51,8 @@ protected function onEnable() : void{ ->setByte("summonable", 0) ); } - - public function onCommand(CommandSender $sender, Command $command, string $label, array $args) : bool{ - if(!($sender instanceof Player)){ - $sender->sendMessage(TextFormat::RED . "Please use this command in-game."); - return true; - } - - if(!isset($args[0]) || !is_numeric($args[0]) || (int) $args[0] <= 0){ - $sender->sendMessage(TextFormat::RED . "/" . $command . " [title : string]"); - return true; - } - - $menu = CustomSizedInvMenu::create((int) $args[0]); - $menu->setName($args[1] ?? null); - - $items = VanillaItems::getAll(); - for($i = 0, $max = $menu->getInventory()->getSize(); $i < $max; $i++){ - $menu->getInventory()->setItem($i, $items[array_rand($items)]); - } - - $menu->send($sender); - return true; + + protected function onDisable() : void{ + RSP::unRegister($this); } -} \ No newline at end of file +} diff --git a/src/muqsit/customsizedinvmenu/exception/UnexpectedValueException.php b/src/muqsit/customsizedinvmenu/exception/UnexpectedValueException.php new file mode 100644 index 0000000..9a158b2 --- /dev/null +++ b/src/muqsit/customsizedinvmenu/exception/UnexpectedValueException.php @@ -0,0 +1,13 @@ +scrollbar; $this->size_data = "§{$this->length}§{$scroll}§r§r§r§r§r§r§r§r§r§r"; @@ -42,4 +42,4 @@ public function getNetworkTranslator() : ?InvMenuGraphicNetworkTranslator{ public function getAnimationDuration() : int{ return $this->inner->getAnimationDuration(); } -} \ No newline at end of file +} diff --git a/src/muqsit/customsizedinvmenu/manager/ResourcePackManager.php b/src/muqsit/customsizedinvmenu/manager/ResourcePackManager.php new file mode 100644 index 0000000..8179dd0 --- /dev/null +++ b/src/muqsit/customsizedinvmenu/manager/ResourcePackManager.php @@ -0,0 +1,117 @@ +getLogger()->debug('Compiling resource pack'); + $zip = new \ZipArchive(); + $zip->open(Path::join($plugin->getDataFolder(), $plugin->getName() . '.mcpack'), \ZipArchive::CREATE | \ZipArchive::OVERWRITE); + + foreach ($plugin->getResources() as $resource) { + if ($resource->isFile() && str_contains($resource->getPathname(), $plugin->getName() . ' Pack')) { + $path = preg_replace("/.*[\/\\\\]{$plugin->getName()}\hPack[\/\\\\].*/U", '', $resource->getPathname()); + if (!is_string($path)) { + throw new UnexpectedValueException(); + } + $relativePath = Path::normalize($path); + $plugin->saveResource(Path::join($plugin->getName() . ' Pack', $relativePath), false); + $zip->addFile(Path::join($plugin->getDataFolder(), $plugin->getName() . ' Pack', $relativePath), $relativePath); + } + } + + $zip->close(); + Filesystem::recursiveUnlink(Path::join($plugin->getDataFolder() . $plugin->getName() . ' Pack')); + $plugin->getLogger()->debug('Resource pack compiled'); + + $plugin->getLogger()->debug('Registering resource pack'); + $plugin->getLogger()->debug('Resource pack compiled'); + self::$pack = $pack = new ZippedResourcePack(Path::join($plugin->getDataFolder(), $plugin->getName() . '.mcpack')); + $packId = $pack->getPackId(); + $manager = $plugin->getServer()->getResourcePackManager(); + + $reflection = new \ReflectionClass($manager); + + $property = $reflection->getProperty("resourcePacks"); + $currentResourcePacks = $property->getValue($manager); + if (!is_array($currentResourcePacks)) { + throw new UnexpectedValueException(); + } + $currentResourcePacks[] = $pack; + $property->setValue($manager, $currentResourcePacks); + + $property = $reflection->getProperty("uuidList"); + $currentUUIDPacks = $property->getValue($manager); + if (!is_array($currentUUIDPacks)) { + throw new UnexpectedValueException(); + } + $currentUUIDPacks[mb_strtolower($pack->getPackId())] = $pack; + $property->setValue($manager, $currentUUIDPacks); + + $property = $reflection->getProperty("serverForceResources"); + $property->setValue($manager, true); + + if ($encryptKey !== "") { + $manager->setPackEncryptionKey($packId, $encryptKey); + } + + $plugin->getLogger()->debug('Resource pack registered'); + } + + public static function unRegister(PluginBase $plugin) : void { + $manager = $plugin->getServer()->getResourcePackManager(); + $pack = self::$pack; + + $reflection = new \ReflectionClass($manager); + + $property = $reflection->getProperty("resourcePacks"); + $currentResourcePacks = $property->getValue($manager); + if (!is_array($currentResourcePacks)) { + throw new UnexpectedValueException(); + } + $key = array_search($pack, $currentResourcePacks, true); + + if ($key !== false) { + unset($currentResourcePacks[$key]); + $property->setValue($manager, $currentResourcePacks); + } + + $property = $reflection->getProperty("uuidList"); + $currentUUIDPacks = $property->getValue($manager); + + if (is_null($pack)) { + throw new UnexpectedValueException(); + } + if (isset($currentResourcePacks[mb_strtolower($pack->getPackId())])) { + if (!is_array($currentUUIDPacks)) { + throw new UnexpectedValueException(); + } + unset($currentUUIDPacks[mb_strtolower($pack->getPackId())]); + $property->setValue($manager, $currentUUIDPacks); + } + $plugin->getLogger()->debug('Resource pack unregistered'); + + unlink(Path::join($plugin->getDataFolder(), $plugin->getName() . '.mcpack')); + $plugin->getLogger()->debug('Resource pack file deleted'); + } +} diff --git a/src/muqsit/customsizedinvmenu/CustomSizedInvMenuType.php b/src/muqsit/customsizedinvmenu/type/CustomSizedInvMenuType.php similarity index 88% rename from src/muqsit/customsizedinvmenu/CustomSizedInvMenuType.php rename to src/muqsit/customsizedinvmenu/type/CustomSizedInvMenuType.php index 605ae4b..b76b51b 100644 --- a/src/muqsit/customsizedinvmenu/CustomSizedInvMenuType.php +++ b/src/muqsit/customsizedinvmenu/type/CustomSizedInvMenuType.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace muqsit\customsizedinvmenu; +namespace muqsit\customsizedinvmenu\type; use muqsit\invmenu\inventory\InvMenuInventory; use muqsit\invmenu\InvMenu; @@ -10,6 +10,7 @@ use muqsit\invmenu\type\graphic\InvMenuGraphic; use muqsit\invmenu\type\graphic\network\ActorInvMenuGraphicNetworkTranslator; use muqsit\invmenu\type\InvMenuType; +use muqsit\customsizedinvmenu\graphic\CustomSizedActorInvMenuGraphic; use pocketmine\entity\Entity; use pocketmine\inventory\Inventory; use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection; @@ -29,12 +30,12 @@ public static function ofSize(int $size) : self{ return new self($size, $length, $length * 9 < $size); } - readonly private ActorInvMenuGraphic $inner_graphic; + private ActorInvMenuGraphic $inner_graphic; public function __construct( - readonly private int $size, - readonly private int $length, - readonly private bool $scrollbar + private int $size, + private int $length, + private bool $scrollbar ){ $actor_runtime_identifier = Entity::nextRuntimeId(); @@ -57,4 +58,4 @@ public function createGraphic(InvMenu $menu, Player $player) : ?InvMenuGraphic{ public function createInventory() : Inventory{ return new InvMenuInventory($this->size); } -} \ No newline at end of file +}