updated API

This commit is contained in:
mfnalex 2018-11-08 16:41:02 +01:00
parent 8f40373df6
commit fc52c42b92
5 changed files with 29 additions and 14 deletions

View File

@ -1,6 +1,6 @@
# API Usage
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.
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.
To use ChestSort's sorting features in your Spigot/Bukkit plugin, you have to import ChestSort.jar into your BuildPath.
@ -17,6 +17,11 @@ if(chestSort==null || !(chestSort instanceof JeffChestSortPlugin)) {
Now, you can sort any Inventory! Just like this:
```
Inventory inv = ...
chestSort.sortInventory(inv);
chestSort.sortInventory(Inventory inventory);
```
To sort only specific slots, you can pass slot numbers where to start and end sorting.
```
chestSort.sortInventory(Inventory inventory, int startSlot, int endSlot);
```

View File

@ -1,9 +0,0 @@
changes since 2.0.1:
- updated spigot api to version 1.13.2
- players in adventure mode will no longer have their chests sorted (maybe make this toggleable?)
changes since 2.0.0:
- added re-initialization of the PerPlayerSettings object to avoid problems with /reload
- updated spigot api to version 1.13.1
- added ChestSort version to user agent for auto update
- added show-message-when-using-chest-and-sorting-is-enabled to Metrics

View File

@ -1,6 +1,6 @@
main: de.jeffclan.JeffChestSort.JeffChestSortPlugin
name: ChestSort
version: 3.0
version: 3.1
api-version: 1.13
description: Allows automatic chest sorting
author: mfnalex

View File

@ -192,12 +192,27 @@ public class JeffChestSortOrganizer {
}
void sortInventory(Inventory inv) {
sortInventory(inv,0,inv.getSize()-1);
}
void sortInventory(Inventory inv,int startSlot, int endSlot) {
if(plugin.debug) {
System.out.println(" ");
System.out.println(" ");
}
ItemStack[] items = inv.getContents();
inv.clear();
for(int i = 0; i<startSlot;i++) {
items[i] = null;
}
for(int i=endSlot;i<inv.getSize();i++) {
items[i] = null;
}
//inv.clear();
for(int i = startSlot; i<endSlot;i++) {
inv.clear(i);
}
String[] itemList = new String[inv.getSize()];
int i = 0;

View File

@ -35,6 +35,10 @@ public class JeffChestSortPlugin extends JavaPlugin {
this.organizer.sortInventory(inv);
}
public void sortInventory(Inventory inv, int startSlot, int endSlot) {
this.organizer.sortInventory(inv,startSlot,endSlot);
}
void createConfig() {
this.saveDefaultConfig();