ChestSort/HOW_TO_USE_API.md

23 lines
825 B
Markdown
Raw Normal View History

2018-11-07 23:59:42 +01:00
# API Usage
2018-11-08 00:33:30 +01:00
If you want to use ChestSort's advanced sorting features for your own plugin, you can use the ChestSort API. It provides a method to sort any given inventory, following the rules you have specified in your ChestSort's plugin.yml and the corresponding category files.
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 00:00:24 +01:00
Inventory inv = ...
chestSort.sortInventory(inv);
```