{"id":16377198,"url":"https://github.com/mrmicky-fr/fastinv","last_synced_at":"2025-04-05T07:01:56.027Z","repository":{"id":115034064,"uuid":"118676776","full_name":"MrMicky-FR/FastInv","owner":"MrMicky-FR","description":"Lightweight and easy-to-use inventory API for Bukkit plugins.","archived":false,"fork":false,"pushed_at":"2025-01-27T07:36:00.000Z","size":113,"stargazers_count":122,"open_issues_count":1,"forks_count":21,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T06:01:43.800Z","etag":null,"topics":["api","bukkit","gui","inventory","menu","minecraft","spigot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MrMicky-FR.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-23T22:10:19.000Z","updated_at":"2025-03-17T22:51:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"44da4d1f-9528-43c5-8511-8e25d10d207c","html_url":"https://github.com/MrMicky-FR/FastInv","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrMicky-FR%2FFastInv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrMicky-FR%2FFastInv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrMicky-FR%2FFastInv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrMicky-FR%2FFastInv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrMicky-FR","download_url":"https://codeload.github.com/MrMicky-FR/FastInv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247299829,"owners_count":20916190,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","bukkit","gui","inventory","menu","minecraft","spigot"],"created_at":"2024-10-11T03:42:35.494Z","updated_at":"2025-04-05T07:01:55.991Z","avatar_url":"https://github.com/MrMicky-FR.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FastInv\n\n[![JitPack](https://jitpack.io/v/fr.mrmicky/FastInv.svg)](https://jitpack.io/#fr.mrmicky/FastInv)\n\nLightweight and easy-to-use inventory API for Bukkit plugins.\n\n## Features\n\n* Lightweight (around 500 lines of code with the JavaDoc) and no dependencies\n* Compatible with all Minecraft versions starting with 1.7.10\n* [Adventure components support](#adventure-components-support)\n* Supports custom inventories (size, title and type)\n* Built-in support for [paginated inventories](#paginated-inventory)\n* Easy to use\n* Option to prevent a player from closing the inventory\n* The Bukkit inventory can still be directly used\n\n## Installation\n\n### Maven\n\n```xml\n\u003cbuild\u003e\n    \u003cplugins\u003e\n        \u003cplugin\u003e\n            \u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n            \u003cartifactId\u003emaven-shade-plugin\u003c/artifactId\u003e\n            \u003cversion\u003e3.3.0\u003c/version\u003e\n            \u003cexecutions\u003e\n                \u003cexecution\u003e\n                    \u003cphase\u003epackage\u003c/phase\u003e\n                    \u003cgoals\u003e\n                        \u003cgoal\u003eshade\u003c/goal\u003e\n                    \u003c/goals\u003e\n                \u003c/execution\u003e\n            \u003c/executions\u003e\n            \u003cconfiguration\u003e\n                \u003crelocations\u003e\n                    \u003crelocation\u003e\n                        \u003cpattern\u003efr.mrmicky.fastinv\u003c/pattern\u003e\n                        \u003c!-- Replace 'com.yourpackae' with the package of your plugin ! --\u003e\n                        \u003cshadedPattern\u003ecom.yourpackage.fastinv\u003c/shadedPattern\u003e\n                    \u003c/relocation\u003e\n                \u003c/relocations\u003e\n            \u003c/configuration\u003e\n        \u003c/plugin\u003e\n    \u003c/plugins\u003e\n\u003c/build\u003e\n\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ejitpack.io\u003c/id\u003e\n        \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003efr.mrmicky\u003c/groupId\u003e\n        \u003cartifactId\u003eFastInv\u003c/artifactId\u003e\n        \u003cversion\u003e3.1.1\u003c/version\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n### Gradle\n\n```groovy\nplugins {\n    id 'com.gradleup.shadow' version '8.3.0'\n}\n\nrepositories {\n    maven { url 'https://jitpack.io' }\n}\n\ndependencies {\n    implementation 'fr.mrmicky:FastInv:3.1.1'\n}\n\nshadowJar {\n    // Replace 'com.yourpackage' with the package of your plugin \n    relocate 'fr.mrmicky.fastinv', 'com.yourpackage.fastinv'\n}\n```\n\n### Manual\n\nSimply copy `FastInv.java` and `FastInvManager.java` in your plugin.\nYou can also add `ItemBuilder.java` if you need.\n\n## Usage\n\n### Register FastInv\n\nBefore creating inventories, you just need to register your plugin by adding `FastInvManager.register(this);` in the `onEnable()` method of your plugin:\n```java\n@Override\npublic void onEnable() {\n    FastInvManager.register(this);\n}\n```\n\n### Creating an inventory class\n\nNow you can create an inventory by creating a class that extends `FastInv`, and adding items in the constructor. \nYou can also override `onClick`, `onClose` and `onOpen` if you need.\n\nBasic example inventory:\n\n```java\npackage fr.mrmicky.fastinv.test;\n\nimport fr.mrmicky.fastinv.FastInv;\nimport fr.mrmicky.fastinv.ItemBuilder;\nimport org.bukkit.ChatColor;\nimport org.bukkit.Material;\nimport org.bukkit.event.inventory.InventoryClickEvent;\nimport org.bukkit.event.inventory.InventoryCloseEvent;\nimport org.bukkit.event.inventory.InventoryOpenEvent;\nimport org.bukkit.inventory.ItemStack;\n\npublic class ExampleInventory extends FastInv {\n\n    private boolean preventClose = false;\n\n    public ExampleInventory() {\n        super(45, ChatColor.GOLD + \"Example inventory\");\n\n        // Just add a random item\n        setItem(22, new ItemStack(Material.IRON_SWORD), e -\u003e e.getWhoClicked().sendMessage(\"You clicked on the sword\"));\n\n        // Add some blocks to the borders\n        setItems(getBorders(), new ItemBuilder(Material.LAPIS_BLOCK).name(\" \").build());\n\n        // Add a simple item to prevent closing the inventory\n        setItem(34, new ItemBuilder(Material.BARRIER).name(ChatColor.RED + \"Prevent close\").build(), e -\u003e {\n            this.preventClose = !this.preventClose;\n        });\n\n        // Prevent from closing when preventClose is to true\n        setCloseFilter(p -\u003e this.preventClose);\n    }\n\n    @Override\n    public void onOpen(InventoryOpenEvent event) {\n        event.getPlayer().sendMessage(ChatColor.GOLD + \"You opened the inventory\");\n    }\n\n    @Override\n    public void onClose(InventoryCloseEvent event) {\n        event.getPlayer().sendMessage(ChatColor.GOLD + \"You closed the inventory\");\n    }\n\n    @Override\n    public void onClick(InventoryClickEvent event) {\n        // do something\n    }\n}\n```\n\nThe inventory can be opened with the `open(player)` method:\n```java\nnew ExampleInventory().open(player);\n```\n\n### Paginated inventory\n\nFastInv also supports paginated inventories, which can be created by using `PaginatedFastInv` instead of `FastInv`.\n\nContent can be added to the inventory using `addContent` or `setContent`, and pagination items can be added with `previousPageItem` and `nextPageItem`.\n\nYou can also use `onPageChange` to execute code when the page changes, and the `#currentPage()`, `#lastPage()`, `#isFirstPage()` and `#isLastPage()` methods to get information about the current page.\n```java\nimport org.bukkit.Material;\nimport org.bukkit.inventory.ItemStack;\n\npublic class ExamplePaginatedInventory extends PaginatedFastInv {\n\n    private static final InventoryScheme SCHEME = new InventoryScheme()\n            .mask(\" 1111111 \")\n            .mask(\" 1111111 \")\n            .bindPagination('1');\n\n    public ExamplePaginatedInventory() {\n        super(27, \"Example paginated inventory\");\n\n        // Add pagination items to the inventory\n        // These items are automatically updated when the page changes and displayed only if needed\n        previousPageItem(20, p -\u003e new ItemBuilder(Material.ARROW).name(\"Page \" + p + \"/\" + lastPage()).build());\n        nextPageItem(24, p -\u003e new ItemBuilder(Material.ARROW).name(\"Page \" + p + \"/\" + lastPage()).build());\n\n        // Add some paginated content to the inventory\n        for (int i = 1; i \u003c 64; i++) {\n            addContent(new ItemStack(Material.GOLDEN_APPLE, i),\n                    e -\u003e e.getWhoClicked().sendMessage(\"You clicked on paginated item\"));\n        }\n\n        // The setContent method can also be used to set the index of a specific item of the paginated content\n        setContent(42, new ItemStack(Material.APPLE, 42));\n\n        // Non-paginated items can also still be added to the inventory if needed\n        setItem(26, new ItemBuilder(Material.BARRIER).name(\"Close\").build(),\n                e -\u003e e.getWhoClicked().closeInventory());\n\n        // The pagination layout can also be customized with a mask instead of the default one\n        SCHEME.apply(this);\n    }\n\n    @Override // Optional method to handle the page change event if needed\n    protected void onPageChange(int page) {\n        // Called after the page change\n        setItem(18, new ItemBuilder(Material.PAPER).name(\"Current page \" + page).build());\n    }\n}\n```\n\nLike a normal inventory, you can open the paginated inventory with `open(player)`:\n```java\nnew ExamplePaginatedInventory().open(player);\n```\n\n### Creating a 'compact' inventory\n\nInstead of creating a new class for each inventory, a 'compact' inventory can be created directly:\n\n```java\nFastInv inv = new FastInv(InventoryType.DISPENSER, \"Example compact inventory\");\n\ninv.setItem(4, new ItemStack(Material.NAME_TAG), e -\u003e e.getWhoClicked().sendMessage(\"You clicked on the name tag\"));\ninv.addClickHandler(e -\u003e player.sendMessage(\"You clicked on slot \" + e.getSlot()));\ninv.addCloseHandler(e -\u003e player.sendMessage(ChatColor.YELLOW + \"Inventory closed\"));\ninv.open(player);\n```\n\nIn the same way, you can also create a 'compact' paginated inventory.\n\n### Get the FastInv instance\nYou can easily get the FastInv instance from a Bukkit inventory with the holder:\n```java\nif (inventory.getHolder() instanceof FastInv) {\n    FastInv fastInv = (FastInv) inventory.getHolder();\n}\n```\n\n### Adventure components support\n\nFastInv supports [Adventure components](https://github.com/KyoriPowered/adventure) for inventory titles on [PaperMC](https://papermc.io/) servers:\n```java\nComponent title = Component.text(\"Hello World\");\n\nFastInv inv = new FastInv(owner -\u003e Bukkit.createInventory(owner, 27, title));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrmicky-fr%2Ffastinv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrmicky-fr%2Ffastinv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrmicky-fr%2Ffastinv/lists"}