diff --git a/pom.xml b/pom.xml
index 09526d0..67ed5b3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
de.jeffclan
JeffChestSort
- 8.8.2
+ 8.8.3-pre1
jar
JeffChestSort
diff --git a/src/main/java/de/jeff_media/ChestSort/ChestSortEvent.java b/src/main/java/de/jeff_media/ChestSort/ChestSortEvent.java
new file mode 100644
index 0000000..94c06f5
--- /dev/null
+++ b/src/main/java/de/jeff_media/ChestSort/ChestSortEvent.java
@@ -0,0 +1,42 @@
+package de.jeff_media.ChestSort;
+
+import org.bukkit.Location;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+public class ChestSortEvent extends Event implements Cancellable {
+
+ boolean cancelled = false;
+ Location loc;
+
+ private static final HandlerList HANDLERS = new HandlerList();
+
+ public ChestSortEvent(Location loc) {
+ this.loc=loc;
+ }
+
+ public Location getLocation() {
+ return loc;
+ }
+
+ public HandlerList getHandlers() {
+ return HANDLERS;
+ }
+
+ public static HandlerList getHandlerList() {
+ return HANDLERS;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ cancelled = cancel;
+ }
+
+
+}
\ No newline at end of file
diff --git a/src/main/java/de/jeff_media/ChestSort/ChestSortListener.java b/src/main/java/de/jeff_media/ChestSort/ChestSortListener.java
index d6ee4dc..4ac712a 100644
--- a/src/main/java/de/jeff_media/ChestSort/ChestSortListener.java
+++ b/src/main/java/de/jeff_media/ChestSort/ChestSortListener.java
@@ -1,5 +1,6 @@
package de.jeff_media.ChestSort;
+import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.block.Chest;
@@ -397,6 +398,15 @@ public class ChestSortListener implements Listener {
@EventHandler
public void onAdditionalHotkeys(InventoryClickEvent e) {
+
+ if(e.getClickedInventory() != null && e.getClickedInventory().getLocation()!=null) {
+ ChestSortEvent chestSortEvent = new ChestSortEvent(e.getClickedInventory().getLocation());
+ Bukkit.getPluginManager().callEvent(chestSortEvent);
+ if (chestSortEvent.isCancelled()) {
+ return;
+ }
+ }
+
if(!plugin.getConfig().getBoolean("allow-hotkeys")) {
return;
}
diff --git a/src/main/java/de/jeff_media/ChestSort/ChestSortOrganizer.java b/src/main/java/de/jeff_media/ChestSort/ChestSortOrganizer.java
index 7ad8aa8..ad92fec 100644
--- a/src/main/java/de/jeff_media/ChestSort/ChestSortOrganizer.java
+++ b/src/main/java/de/jeff_media/ChestSort/ChestSortOrganizer.java
@@ -386,6 +386,14 @@ public class ChestSortOrganizer {
// Sort an inventory only between startSlot and endSlot
void sortInventory(Inventory inv, int startSlot, int endSlot) {
+
+ if(inv.getLocation() != null) {
+ ChestSortEvent chestSortEvent = new ChestSortEvent(inv.getLocation());
+ Bukkit.getPluginManager().callEvent(chestSortEvent);
+ if (chestSortEvent.isCancelled()) {
+ return;
+ }
+ }
if (plugin.debug) {
System.out.println(" ");
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index da5f8a7..7b22db5 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,6 +1,6 @@
main: de.jeff_media.ChestSort.ChestSortPlugin
name: ChestSort
-version: 8.8.2
+version: 8.8.3-pre1
api-version: 1.13
description: Allows automatic chest sorting
author: mfnalex