From fc52c42b92a62eb86da870bc211b30ed11c2910b Mon Sep 17 00:00:00 2001 From: mfnalex <1122571+mfnalex@users.noreply.github.com> Date: Thu, 8 Nov 2018 16:41:02 +0100 Subject: [PATCH] updated API --- HOW_TO_USE_API.md | 11 ++++++++--- changes.txt | 9 --------- plugin.yml | 2 +- .../JeffChestSort/JeffChestSortOrganizer.java | 17 ++++++++++++++++- .../JeffChestSort/JeffChestSortPlugin.java | 4 ++++ 5 files changed, 29 insertions(+), 14 deletions(-) delete mode 100644 changes.txt diff --git a/HOW_TO_USE_API.md b/HOW_TO_USE_API.md index 106b224..96284c0 100644 --- a/HOW_TO_USE_API.md +++ b/HOW_TO_USE_API.md @@ -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); +``` \ No newline at end of file diff --git a/changes.txt b/changes.txt deleted file mode 100644 index f9c947e..0000000 --- a/changes.txt +++ /dev/null @@ -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 \ No newline at end of file diff --git a/plugin.yml b/plugin.yml index b886790..3aae3ac 100644 --- a/plugin.yml +++ b/plugin.yml @@ -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 diff --git a/src/de/jeffclan/JeffChestSort/JeffChestSortOrganizer.java b/src/de/jeffclan/JeffChestSort/JeffChestSortOrganizer.java index 994b1f8..7dce112 100644 --- a/src/de/jeffclan/JeffChestSort/JeffChestSortOrganizer.java +++ b/src/de/jeffclan/JeffChestSort/JeffChestSortOrganizer.java @@ -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