Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/minuskube/smartinvsdocs
Documentation for the SmartInvs API, https://minuskube.gitbooks.io/smartinvs
https://github.com/minuskube/smartinvsdocs
Last synced: 10 days ago
JSON representation
Documentation for the SmartInvs API, https://minuskube.gitbooks.io/smartinvs
- Host: GitHub
- URL: https://github.com/minuskube/smartinvsdocs
- Owner: MinusKube
- Created: 2017-06-23T19:18:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-08-15T21:02:28.000Z (over 4 years ago)
- Last Synced: 2024-11-08T15:53:29.730Z (2 months ago)
- Size: 385 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Introduction
![](.gitbook/assets/smart_invs.png)
## SmartInvs
SmartInvs is a modern API for easily using inventories with Bukkit to make awesome GUIs. This book contains a guide on how to use this API to create your own amazing GUIs!
_This API requires Java 8 to work._
### Features
* Inventories of any type \(workbench, chest, furnace, ...\)
* Customizable size when possible \(chest, ...\)
* Custom titles
* Allows to prevent the player from closing its inventory
* Custom listeners for the event related to the inventory
* Iterator for inventory slots
* Page system
* Util methods to fill an inventory's row/column/borders/...
* Actions when player clicks on an item
* Update methods to edit the content of the inventory every tick### Usage
To use the SmartInvs API, either:
* Put it in the `plugins` folder of your server, add it to your dependencies in your plugin.yml \(e.g. `depend: [SmartInvs]`\) and add it to the dependencies in your IDE.
* Put it inside your plugin jar, initialize an `InventoryManager` in your plugin \(don't forget to call the `init()` method\), and add a `.manager(invManager)` to your SmartInventory Builders.You can download the latest version on the [Releases page](https://github.com/MinusKube/SmartInvs/releases) on Github.
You can also use a build system:
#### Gradle
```text
repositories {
mavenCentral()
}dependencies {
compile 'fr.minuskube.inv:smart-invs:1.2.7'
}
```#### Maven
```markup
fr.minuskube.inv
smart-invs
1.2.7```
### Preview
Here is a simple preview of an inventory.
```java
public class SimpleInventory implements InventoryProvider {public static final SmartInventory INVENTORY = SmartInventory.builder()
.id("myInventory")
.provider(new SimpleInventory())
.size(3, 9)
.title(ChatColor.BLUE + "My Awesome Inventory!")
.build();private final Random random = new Random();
@Override
public void init(Player player, InventoryContents contents) {
contents.fillBorders(ClickableItem.empty(new ItemStack(Material.STAINED_GLASS_PANE)));contents.set(1, 1, ClickableItem.of(new ItemStack(Material.CARROT_ITEM),
e -> player.sendMessage(ChatColor.GOLD + "You clicked on a potato.")));contents.set(1, 7, ClickableItem.of(new ItemStack(Material.BARRIER),
e -> player.closeInventory()));
}@Override
public void update(Player player, InventoryContents contents) {
int state = contents.property("state", 0);
contents.setProperty("state", state + 1);if(state % 5 != 0)
return;short durability = (short) random.nextInt(15);
ItemStack glass = new ItemStack(Material.STAINED_GLASS_PANE, 1, durability);
contents.fillBorders(ClickableItem.empty(glass));
}}
```And there is the result:
![](.gitbook/assets/444ecfe1e103b.gif)
If we click on the carrot, we receive the message `You clicked on a potato`, and if we click on the barrier, the inventory is closed.
### Useful links
The source code is available on [Github](https://github.com/MinusKube/SmartInvs)! If you have some issues with the API, please [open an issue](https://github.com/MinusKube/SmartInvs/issues) on Github.