From e6b05ff9829adbcf1ddde761a5a95b8485c4044a Mon Sep 17 00:00:00 2001 From: Rutger Kok Date: Sun, 28 Feb 2021 18:10:33 +0100 Subject: [PATCH] Add support for BlockLocker It's no longer possible to open shops on chests that were protected by someone else. --- pom.xml | 7 +++++ .../com/Acrobot/ChestShop/Dependencies.java | 4 +++ .../ChestShop/Plugins/BlockLocker.java | 29 +++++++++++++++++++ src/main/resources/plugin.yml | 2 +- 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/Acrobot/ChestShop/Plugins/BlockLocker.java diff --git a/pom.xml b/pom.xml index 63745f9..e82a806 100644 --- a/pom.xml +++ b/pom.xml @@ -295,6 +295,13 @@ + + nl.rutgerkok + blocklocker + 1.9 + provided + + com.bekvon.bukkit residence diff --git a/src/main/java/com/Acrobot/ChestShop/Dependencies.java b/src/main/java/com/Acrobot/ChestShop/Dependencies.java index 9e715d8..ad8b76e 100644 --- a/src/main/java/com/Acrobot/ChestShop/Dependencies.java +++ b/src/main/java/com/Acrobot/ChestShop/Dependencies.java @@ -118,6 +118,9 @@ public class Dependencies implements Listener { case SimpleChestLock: listener = SimpleChestLock.getSimpleChestLock(plugin); break; + case BlockLocker: + listener = new BlockLocker(); + break; case Residence: if (plugin.getDescription().getVersion().startsWith("2")) { ChestShop.getBukkitLogger().severe("You are using an old version of Residence! " + @@ -190,6 +193,7 @@ public class Dependencies implements Listener { LockettePro, Deadbolt, SimpleChestLock, + BlockLocker, Residence, WorldGuard, diff --git a/src/main/java/com/Acrobot/ChestShop/Plugins/BlockLocker.java b/src/main/java/com/Acrobot/ChestShop/Plugins/BlockLocker.java new file mode 100644 index 0000000..b87cf69 --- /dev/null +++ b/src/main/java/com/Acrobot/ChestShop/Plugins/BlockLocker.java @@ -0,0 +1,29 @@ +package com.Acrobot.ChestShop.Plugins; + +import org.bukkit.block.Block; +import org.bukkit.event.Event; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +import com.Acrobot.ChestShop.Events.Protection.ProtectionCheckEvent; + +import nl.rutgerkok.blocklocker.BlockLockerAPIv2; + +/** + * @author Acrobot + */ +public class BlockLocker implements Listener { + + + @EventHandler + public void onProtectionCheck(ProtectionCheckEvent event) { + if (event.getResult() == Event.Result.DENY) { + return; + } + + Block block = event.getBlock(); + if (BlockLockerAPIv2.isProtected(block) && !BlockLockerAPIv2.isOwner(event.getPlayer(), block)) { + event.setResult(Event.Result.DENY); + } + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index ed2921e..909f9d9 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -4,7 +4,7 @@ version: '${bukkit.plugin.version}' author: Acrobot authors: ['https://github.com/ChestShop-authors/ChestShop-3/contributors'] description: A chest shop for economy plugins. -softdepend: [Vault, Reserve, LWC, Lockette, LockettePro, Deadbolt, OddItem, WorldGuard, GriefPrevention, RedProtect, Heroes, SimpleChestLock, Residence, ShowItem] +softdepend: [Vault, Reserve, LWC, Lockette, LockettePro, Deadbolt, BlockLocker, OddItem, WorldGuard, GriefPrevention, RedProtect, Heroes, SimpleChestLock, Residence, ShowItem] api-version: '1.13' commands: