Merge pull request #103 from xmssss/master

Compatiblity with GoldenCrates plugin
This commit is contained in:
mfnalex 2021-02-17 14:39:14 +01:00 committed by GitHub
commit 88ba548215
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 0 deletions

View File

@ -1,6 +1,7 @@
package de.jeff_media.ChestSort;
import de.jeff_media.ChestSort.hooks.CrateReloadedHook;
import de.jeff_media.ChestSort.hooks.GoldenCratesHook;
import de.jeff_media.ChestSort.hooks.HeadDatabaseHook;
import de.jeff_media.ChestSort.hooks.MinepacksHook;
import de.jeff_media.ChestSort.utils.LlamaUtils;
@ -36,12 +37,14 @@ public class ChestSortListener implements Listener {
final MinepacksHook minepacksHook;
final HeadDatabaseHook headDatabaseHook;
final CrateReloadedHook crateReloadedHook;
final GoldenCratesHook goldenCratesHook;
ChestSortListener(ChestSortPlugin plugin) {
this.plugin = plugin;
this.minepacksHook = new MinepacksHook(plugin);
this.headDatabaseHook = new HeadDatabaseHook(plugin);
this.crateReloadedHook = new CrateReloadedHook(plugin);
this.goldenCratesHook = new GoldenCratesHook(plugin);
}
@EventHandler
@ -545,6 +548,13 @@ public class ChestSortListener implements Listener {
return;
}
// GoldenCrates hook
if(goldenCratesHook.isCrate(e.getClickedInventory())
|| goldenCratesHook.isCrate(e.getInventory())) {
//if(plugin.debug) plugin.getLogger().info("Aborting hotkey because this is a CrateReloaded crate");
return;
}
// Detect generic GUIs
if(!isAPICall(e.getInventory()) && !isAPICall(e.getClickedInventory()) &&
(plugin.genericHook.isPluginGUI(e.getInventory())

View File

@ -0,0 +1,23 @@
package de.jeff_media.ChestSort.hooks;
import de.jeff_media.ChestSort.ChestSortPlugin;
import org.bukkit.inventory.Inventory;
import sun.awt.Win32GraphicsConfig;
public class GoldenCratesHook {
ChestSortPlugin main;
public GoldenCratesHook(ChestSortPlugin main) {
this.main=main;
}
public boolean isCrate(Inventory inv) {
if(inv==null) return false;
if(inv.getHolder()==null) return false;
if(!main.getConfig().getBoolean("hook-goldencrates",true)) return false;
return inv.getHolder().getClass().getName().contains("crate") || inv.getHolder().getClass().getName().contains("crates") || inv.getHolder().getClass().getName().contains("preview") || inv.getHolder().getClass().getName().contains("golden");
}
}

View File

@ -229,6 +229,10 @@ hook-minepacks: true
# Prevents the player from using hotkeys on a crate
hook-cratereloaded: true
##### GoldenCrates #####
# Prevents the player from using hotkeys on a crate
hook-goldencrates: true
##### HeadDatabase #####
# Prevents the player from using hotkeys on the HeadDatabase GUI
hook-headdatabase: true