Add integration with EnderContainers

This commit is contained in:
utarwyn 2021-03-11 10:22:21 +01:00
parent 036c4fd68a
commit f9cdebb243
No known key found for this signature in database
GPG Key ID: 620A888ED7D70468
4 changed files with 34 additions and 2 deletions

View File

@ -487,7 +487,8 @@ public class ChestSortListener implements Listener {
|| belongsToChestLikeBlock(event.getClickedInventory())
|| LlamaUtils.belongsToLlama(event.getClickedInventory())
|| minepacksHook.isMinepacksBackpack(event.getClickedInventory())
|| plugin.playerVaultsHook.isPlayerVault(event.getClickedInventory())) {
|| plugin.playerVaultsHook.isPlayerVault(event.getClickedInventory())
|| plugin.enderContainersHook.isEnderchest(event.getClickedInventory())) {
if (!p.hasPermission("chestsort.use")) {

View File

@ -42,6 +42,7 @@ import java.util.Map;
import java.util.UUID;
import de.jeff_media.ChestSort.config.Config;
import de.jeff_media.ChestSort.hooks.EnderContainersHook;
import de.jeff_media.ChestSort.hooks.GenericGUIHook;
import de.jeff_media.ChestSort.hooks.PlayerVaultsHook;
import de.jeff_media.ChestSort.placeholders.ChestSortPlaceholders;
@ -86,7 +87,8 @@ public class ChestSortPlugin extends JavaPlugin implements de.jeff_media.ChestSo
public GenericGUIHook genericHook;
public PlayerVaultsHook playerVaultsHook;
public EnderContainersHook enderContainersHook;
private static long updateCheckInterval = 4*60*60; // in seconds. We check on startup and every 4 hours
String mcVersion; // 1.13.2 = 1_13_R2
@ -519,6 +521,7 @@ public class ChestSortPlugin extends JavaPlugin implements de.jeff_media.ChestSo
updateCheckInterval = (int) (getConfig().getDouble("check-interval")*60*60);
sortingMethod = getConfig().getString("sorting-method");
playerVaultsHook = new PlayerVaultsHook(this);
enderContainersHook = new EnderContainersHook(this);
getServer().getPluginManager().registerEvents(listener, this);
getServer().getPluginManager().registerEvents(settingsGUI, this);
ChestSortChestSortCommand chestsortCommandExecutor = new ChestSortChestSortCommand(this);

View File

@ -0,0 +1,23 @@
package de.jeff_media.ChestSort.hooks;
import de.jeff_media.ChestSort.ChestSortPlugin;
import org.bukkit.inventory.Inventory;
public class EnderContainersHook {
private static final String CLASS_NAME = "fr.utarwyn.endercontainers.inventory.EnderChestInventory";
private final ChestSortPlugin main;
public EnderContainersHook(ChestSortPlugin main) {
this.main = main;
}
public boolean isEnderchest(Inventory inv) {
if (inv == null) return false;
if (inv.getHolder() == null) return false;
if (!main.getConfig().getBoolean("hook-endercontainers", true)) return false;
return inv.getHolder().getClass().getName().equals(CLASS_NAME);
}
}

View File

@ -234,6 +234,11 @@ hook-minepacks: true
# player vaults just like regular chests.
hook-playervaults: true
##### EnderContainers ##### -> https://www.spigotmc.org/resources/endercontainers.4750/
# When EnderContainers version 2+ is installed, ChestSort can detect your
# enderchests and sort them like a regular chest.
hook-endercontainers: true
##### CrateReloaded #####
# Prevents the player from using hotkeys on a crate
hook-cratereloaded: true