diff --git a/CHANGELOG.md b/CHANGELOG.md index 5eeb9b5..d617ba6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # Changelog +## 8.14.1 +- Prevent players from using left-click and right-click hotkeys on inventories created by CrateReloaded or HeadDatabase + ## 8.14.0 - Updated Russian and Turkish translation - Separated ChestSort plugin and API. You can view the new API documentation [here](https://github.com/JEFF-Media-GbR/Spigot-ChestSort/blob/master/HOW_TO_USE_API.md). diff --git a/pom.xml b/pom.xml index 36ceae0..474e572 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ ChestSort https://www.chestsort.de Automatically sorts your chests! - 8.14.0 + 8.14.1 jar diff --git a/src/main/java/de/jeff_media/ChestSort/ChestSortListener.java b/src/main/java/de/jeff_media/ChestSort/ChestSortListener.java index 9ddfb41..1e177c3 100644 --- a/src/main/java/de/jeff_media/ChestSort/ChestSortListener.java +++ b/src/main/java/de/jeff_media/ChestSort/ChestSortListener.java @@ -1,5 +1,7 @@ package de.jeff_media.ChestSort; +import de.jeff_media.ChestSort.hooks.CrateReloadedHook; +import de.jeff_media.ChestSort.hooks.HeadDatabaseHook; import de.jeff_media.ChestSort.hooks.MinepacksHook; import de.jeff_media.ChestSort.utils.LlamaUtils; import org.bukkit.Bukkit; @@ -475,6 +477,19 @@ public class ChestSortListener implements Listener { return; } + // HeadDatabase hook + if(HeadDatabaseHook.isHeadDB(e.getClickedInventory()) + || HeadDatabaseHook.isHeadDB(e.getInventory())) { + return; + } + + // CrateReloaded hook + if(CrateReloadedHook.isCrate(e.getClickedInventory()) + || CrateReloadedHook.isCrate(e.getInventory())) { + //if(plugin.debug) plugin.getLogger().info("Aborting hotkey because this is a CrateReloaded crate"); + return; + } + // Don't sort inventories belonging to BossShopPro if (e.getInventory() != null && e.getInventory().getHolder() != null && e.getInventory().getHolder().getClass().getName().equalsIgnoreCase("org.black_ixx.bossshop.core.BSShopHolder")) { return; diff --git a/src/main/java/de/jeff_media/ChestSort/hooks/CrateReloadedHook.java b/src/main/java/de/jeff_media/ChestSort/hooks/CrateReloadedHook.java new file mode 100644 index 0000000..697e1b0 --- /dev/null +++ b/src/main/java/de/jeff_media/ChestSort/hooks/CrateReloadedHook.java @@ -0,0 +1,16 @@ +package de.jeff_media.ChestSort.hooks; + +import org.bukkit.inventory.Inventory; +import org.jetbrains.annotations.NotNull; + +public class CrateReloadedHook { + + // CrateReloaded inventories seem to have a holder called cratereloaded.bo + // Maybe this changes? We just check if the String starts with cratereloaded + public static boolean isCrate(Inventory inv) { + if(inv==null) return false; + if(inv.getHolder()==null) return false; + return inv.getHolder().getClass().getName().startsWith("cratereloaded"); + } + +} diff --git a/src/main/java/de/jeff_media/ChestSort/hooks/HeadDatabaseHook.java b/src/main/java/de/jeff_media/ChestSort/hooks/HeadDatabaseHook.java new file mode 100644 index 0000000..f7c6d3a --- /dev/null +++ b/src/main/java/de/jeff_media/ChestSort/hooks/HeadDatabaseHook.java @@ -0,0 +1,13 @@ +package de.jeff_media.ChestSort.hooks; + +import org.bukkit.inventory.Inventory; + +public class HeadDatabaseHook { + + public static boolean isHeadDB(Inventory inv) { + if(inv==null) return false; + if(inv.getHolder() == null) return false; + return inv.getHolder().getClass().getName().equals("me.arcaniax.hdb.object.HeadDatabaseHolder"); + } + +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 333f615..8a87d00 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.14.0 +version: 8.14.1 api-version: "1.13" description: Allows automatic chest sorting author: mfnalex