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