diff --git a/pom.xml b/pom.xml
index 9d21007..fea478d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,7 +9,7 @@
ChestSort
https://www.chestsort.de
Allows automatic chest sorting!
- 13.5.1
+ 13.5.2
jar
@@ -186,6 +186,11 @@
https://jitpack.io
+
+ CoreProtect
+ https://maven.playpro.com/
+
+
@@ -273,6 +278,13 @@
provided
+
+ net.coreprotect
+ coreprotect
+ 21.3
+ provided
+
+
diff --git a/src/main/java/de/jeff_media/chestsort/hooks/CoreProtectHook.java b/src/main/java/de/jeff_media/chestsort/hooks/CoreProtectHook.java
new file mode 100644
index 0000000..0f4c9cf
--- /dev/null
+++ b/src/main/java/de/jeff_media/chestsort/hooks/CoreProtectHook.java
@@ -0,0 +1,40 @@
+package de.jeff_media.chestsort.hooks;
+
+import net.coreprotect.CoreProtect;
+import net.coreprotect.CoreProtectAPI;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.plugin.Plugin;
+
+public class CoreProtectHook {
+
+ public static void logContainerTransaction(String user, Location location) {
+ CoreProtectAPI api = getCoreProtect();
+ if (api == null) {
+ return;
+ }
+ api.logContainerTransaction(user, location);
+ }
+
+ private static CoreProtectAPI getCoreProtect() {
+ Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("CoreProtect");
+
+ // Check that CoreProtect is loaded
+ if (!(plugin instanceof CoreProtect)) {
+ return null;
+ }
+
+ // Check that the API is enabled
+ CoreProtectAPI api = ((CoreProtect) plugin).getAPI();
+ if (!api.isEnabled()) {
+ return null;
+ }
+
+ // Check that a compatible version of the API is loaded
+ if (api.APIVersion() < 9) {
+ return null;
+ }
+ return api;
+ }
+
+}
diff --git a/src/main/java/de/jeff_media/chestsort/listeners/ChestSortListener.java b/src/main/java/de/jeff_media/chestsort/listeners/ChestSortListener.java
index b788260..71baed8 100644
--- a/src/main/java/de/jeff_media/chestsort/listeners/ChestSortListener.java
+++ b/src/main/java/de/jeff_media/chestsort/listeners/ChestSortListener.java
@@ -31,10 +31,7 @@ import org.bukkit.event.inventory.InventoryType.SlotType;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
-import org.bukkit.inventory.EquipmentSlot;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryHolder;
-import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.*;
import java.util.HashMap;
@@ -734,6 +731,12 @@ public class ChestSortListener implements org.bukkit.event.Listener {
return;
}
+ // CoreProtect hook
+ if (e.getInventory().getHolder() instanceof BlockInventoryHolder) {
+ Block block = ((BlockInventoryHolder) e.getInventory().getHolder()).getBlock();
+ CoreProtectHook.logContainerTransaction(p.getName(), block.getLocation());
+ }
+
if (e.isLeftClick() && setting.leftClick && p.hasPermission(Hotkey.getPermission(Hotkey.LEFT_CLICK))) {
plugin.getLgr().logSort(p, Logger.SortCause.H_LEFT);
if (setting.getCurrentDoubleClick(plugin, PlayerSetting.DoubleClickType.LEFT_CLICK)
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index daca3c8..e19d9c4 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -10,7 +10,7 @@ website: ${project.url}
prefix: ${spigot.prefix}
database: false
loadbefore: [InvUnload]
-softdepend: [CrackShot,InventoryPages,Minepacks,PlaceholderAPI,AdvancedChests,ShulkerPacks]
+softdepend: [CrackShot,InventoryPages,Minepacks,PlaceholderAPI,AdvancedChests,ShulkerPacks,CoreProtect]
commands:
sort:
description: Toggle automatic chest sorting or change your hotkey settings