ChestSort/HOW_TO_USE_API.md

28 lines
1.0 KiB
Markdown
Raw Normal View History

2018-11-07 23:59:42 +01:00
# API Usage
2018-11-08 00:33:30 +01:00
2018-11-08 16:41:02 +01:00
If you want to use ChestSort's advanced sorting features for your own plugin, you can use the ChestSort API. It provides two methods to sort any given inventory, following the rules you have specified in your ChestSort's plugin.yml and the corresponding category files.
2018-11-08 00:33:30 +01:00
To use ChestSort's sorting features in your Spigot/Bukkit plugin, you have to import ChestSort.jar into your BuildPath.
2018-11-07 23:59:42 +01:00
Then you can access it via the plugin manager:
```
2018-11-08 00:00:24 +01:00
JeffChestSortPlugin chestSort = (JeffChestSortPlugin) getServer().getPluginManager().getPlugin("ChestSort");
2018-11-07 23:59:42 +01:00
2018-11-08 00:00:24 +01:00
if(chestSort==null || !(chestSort instanceof JeffChestSortPlugin)) {
getLogger().warning("ChestSort plugin not found.");
}
2018-11-07 23:59:42 +01:00
```
Now, you can sort any Inventory! Just like this:
```
2018-11-08 16:41:02 +01:00
chestSort.sortInventory(Inventory inventory);
2018-11-08 00:00:24 +01:00
```
2018-11-08 16:41:02 +01:00
2019-01-12 15:51:21 +01:00
To sort only specific slots, you can pass slot numbers where to start and end sorting. ChestSort will not modify the inventory outside the given slot range.
2018-11-08 16:41:02 +01:00
```
chestSort.sortInventory(Inventory inventory, int startSlot, int endSlot);
2019-01-12 15:51:21 +01:00
```