diff --git a/pom.xml b/pom.xml index cd9c8c0..a7b703e 100644 --- a/pom.xml +++ b/pom.xml @@ -167,9 +167,26 @@ - com.griefcraft.lwc + com.griefcraft lwc - 4.3.1 + 4.7.0-SNAPSHOT + provided + + + org.bukkit + bukkit + + + org.bukkit + craftbukkit + + + + + + com.griefcraft.lwc + LWCX + 2.2.0 provided diff --git a/src/main/java/com/Acrobot/ChestShop/Plugins/LightweightChestProtection.java b/src/main/java/com/Acrobot/ChestShop/Plugins/LightweightChestProtection.java index f7d1e42..15e5279 100644 --- a/src/main/java/com/Acrobot/ChestShop/Plugins/LightweightChestProtection.java +++ b/src/main/java/com/Acrobot/ChestShop/Plugins/LightweightChestProtection.java @@ -1,5 +1,6 @@ package com.Acrobot.ChestShop.Plugins; +import com.Acrobot.ChestShop.ChestShop; import com.Acrobot.ChestShop.Configuration.Messages; import com.Acrobot.ChestShop.Configuration.Properties; import com.Acrobot.ChestShop.Events.Protection.ProtectBlockEvent; @@ -11,7 +12,6 @@ import com.griefcraft.lwc.LWC; import com.griefcraft.model.Protection; import com.griefcraft.scripting.event.LWCProtectionRegisterEvent; import org.bukkit.block.Block; -import org.bukkit.block.Chest; import org.bukkit.block.Container; import org.bukkit.block.Sign; import org.bukkit.entity.Player; @@ -99,8 +99,24 @@ public class LightweightChestProtection implements Listener { return; } - // TODO: Update to new API once LWC is updated - Protection protection = lwc.getPhysicalDatabase().registerProtection(block.getType().getId(), Protection.Type.PRIVATE, worldName, player.getUniqueId().toString(), "", x, y, z); + Protection protection = null; + try { + protection = lwc.getPhysicalDatabase().registerProtection(block.getType(), Protection.Type.PRIVATE, worldName, player.getUniqueId().toString(), "", x, y, z); + } catch (LinkageError e) { + try { + int blockId = com.griefcraft.cache.BlockCache.getInstance().getBlockId(block); + if (blockId < 0) { + return; + } + protection = lwc.getPhysicalDatabase().registerProtection(blockId, Protection.Type.PRIVATE, worldName, player.getUniqueId().toString(), "", x, y, z); + } catch (LinkageError e2) { + ChestShop.getBukkitLogger().warning( + "Incompatible LWC version installed! (" + lwc.getPlugin().getName() + " v" + lwc.getVersion() + ") \n" + + "Material method error: " + e.getMessage() + "\n" + + "Block cache/type id error: " + e2.getMessage() + ); + } + } if (protection != null) { event.setProtected(true);