Merge pull request #107 from utarwyn/feature-endercontainers
Add EnderContainers support
This commit is contained in:
commit
fe559304b5
|
@ -158,7 +158,10 @@ public class ChestSortListener implements Listener {
|
|||
Player p = (Player) event.getPlayer();
|
||||
Inventory inventory = event.getInventory();
|
||||
|
||||
if (!isAPICall(inventory) && !belongsToChestLikeBlock(inventory) && !LlamaUtils.belongsToLlama(inventory)) {
|
||||
if (!isAPICall(inventory)
|
||||
&& !belongsToChestLikeBlock(inventory)
|
||||
&& !plugin.enderContainersHook.isEnderchest(inventory)
|
||||
&& !LlamaUtils.belongsToLlama(inventory)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -205,7 +208,10 @@ public class ChestSortListener implements Listener {
|
|||
Player p = (Player) event.getPlayer();
|
||||
Inventory inventory = event.getInventory();
|
||||
|
||||
if (!isAPICall(inventory) && !belongsToChestLikeBlock(inventory) && !LlamaUtils.belongsToLlama(inventory)) {
|
||||
if (!isAPICall(inventory)
|
||||
&& !belongsToChestLikeBlock(inventory)
|
||||
&& !plugin.enderContainersHook.isEnderchest(inventory)
|
||||
&& !LlamaUtils.belongsToLlama(inventory)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -487,7 +493,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")) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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.2.1+ is installed, ChestSort can detect your
|
||||
# enderchests and sort them like regular chests.
|
||||
hook-endercontainers: true
|
||||
|
||||
##### CrateReloaded #####
|
||||
# Prevents the player from using hotkeys on a crate
|
||||
hook-cratereloaded: true
|
||||
|
@ -658,4 +663,4 @@ log: false
|
|||
|
||||
# Please DO NOT change the following line manually!
|
||||
# It is used by the automatic config updater.
|
||||
config-version: 46
|
||||
config-version: 46
|
||||
|
|
Loading…
Reference in New Issue