forked from MLG-Fortress/AutomaticInventory
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathLWCHook.java
More file actions
33 lines (27 loc) · 1.01 KB
/
Copy pathLWCHook.java
File metadata and controls
33 lines (27 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package dev.chaws.automaticinventory.hooks;
import com.griefcraft.lwc.LWC;
import org.bukkit.Location;
import org.bukkit.block.DoubleChest;
import org.bukkit.entity.Player;
import org.bukkit.inventory.BlockInventoryHolder;
import org.bukkit.inventory.Inventory;
public class LWCHook {
private static boolean enabled = false;
public static void enable() {
enabled = true;
}
public static boolean canUseContainer(Inventory inventory, Player player) {
if (inventory.getHolder() instanceof BlockInventoryHolder || inventory.getHolder() instanceof DoubleChest) {
Location location = inventory.getLocation();
return canUseContainer(location, player);
}
return false;
}
public static boolean canUseContainer(Location location, Player player) {
if (enabled) {
var protection = LWC.getInstance().findProtection(location);
return protection != null && protection.isRealOwner(player);
}
return true;
}
}