From 9690817f40ba2c70e487145d75ab3bf41231ae23 Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 2 Jun 2016 20:36:48 +0200 Subject: [PATCH] Add LWC magnet pull listener Currently only working with 'LWC Unofficial - Entity locking' by 'Me_Goes_RAWR' v1.7.3 or later. --- src/de/epiceric/shopchest/ShopChest.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/de/epiceric/shopchest/ShopChest.java b/src/de/epiceric/shopchest/ShopChest.java index efad496..98cee02 100644 --- a/src/de/epiceric/shopchest/ShopChest.java +++ b/src/de/epiceric/shopchest/ShopChest.java @@ -2,6 +2,8 @@ package de.epiceric.shopchest; import com.griefcraft.lwc.LWC; import com.griefcraft.lwc.LWCPlugin; +import com.griefcraft.scripting.JavaModule; +import com.griefcraft.scripting.event.LWCMagnetPullEvent; import de.epiceric.shopchest.config.Config; import de.epiceric.shopchest.event.*; import de.epiceric.shopchest.interfaces.JsonBuilder; @@ -253,6 +255,27 @@ public class ShopChest extends JavaPlugin { if (getServer().getPluginManager().getPlugin("ClearLag") != null) getServer().getPluginManager().registerEvents(new RegenerateShopItemAfterRemove(), this); + + if (getServer().getPluginManager().getPlugin("LWC") != null){ + try { + Class.forName("com.griefcraft.scripting.event.LWCMagnetPullEvent"); + + LWC.getInstance().getModuleLoader().registerModule(this, new JavaModule() { + + @Override + public void onMagnetPull(LWCMagnetPullEvent event) { + if (event.getItem().hasMetadata("shopItem")) { + event.setCancelled(true); + } + } + + }); + + } catch (ClassNotFoundException ex) { + getLogger().warning("Shop items can be sucked up by the magnet flag of a protected chest of LWC."); + getLogger().warning("Use 'LWC Unofficial - Entity locking' v1.7.3 or later by 'Me_Goes_RAWR' to prevent this."); + }; + } } @Override