diff --git a/src/main/java/com/alttd/playershops/PlayerShops.java b/src/main/java/com/alttd/playershops/PlayerShops.java index e65c256..badc757 100644 --- a/src/main/java/com/alttd/playershops/PlayerShops.java +++ b/src/main/java/com/alttd/playershops/PlayerShops.java @@ -32,6 +32,7 @@ public class PlayerShops extends JavaPlugin { private PlayerListener playerListener; private TransactionListener transactionListener; private InventoryListener inventoryListener; + private GriefPreventionListener griefPreventionListener; public void onEnable() { instance = this; @@ -92,6 +93,7 @@ public class PlayerShops extends JavaPlugin { playerListener = new PlayerListener(this); transactionListener = new TransactionListener(this); inventoryListener = new InventoryListener(this); + griefPreventionListener = new GriefPreventionListener(this); // TODO hook into GP } private void unRegisterListeners() { diff --git a/src/main/java/com/alttd/playershops/listener/GriefPreventionListener.java b/src/main/java/com/alttd/playershops/listener/GriefPreventionListener.java new file mode 100644 index 0000000..8374b42 --- /dev/null +++ b/src/main/java/com/alttd/playershops/listener/GriefPreventionListener.java @@ -0,0 +1,40 @@ +package com.alttd.playershops.listener; + +import com.alttd.playershops.PlayerShops; +import com.alttd.playershops.handler.ShopHandler; +import com.alttd.playershops.shop.PlayerShop; +import me.ryanhamshire.GriefPrevention.events.ClaimExpirationEvent; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import java.util.List; +import java.util.UUID; + +public class GriefPreventionListener extends EventListener { + + private final PlayerShops plugin; + ShopHandler shopHandler; + + public GriefPreventionListener(PlayerShops plugin) { + this.plugin = plugin; + this.register(this.plugin); + shopHandler = plugin.getShopHandler(); + } + + @EventHandler(priority = EventPriority.HIGHEST) + public void onClaimExpiration(ClaimExpirationEvent event) { + if(!this.isRegistered) + return; + + UUID uuid = event.getClaim().ownerID; + if(uuid == null) + return; + + List playerShops = shopHandler.getShops(uuid); + for(PlayerShop shop : playerShops) { + shop.expireSign(); + shopHandler.removeShop(shop); + } + } + +} diff --git a/src/main/java/com/alttd/playershops/listener/ShopListener.java b/src/main/java/com/alttd/playershops/listener/ShopListener.java index 7d5eb63..5875a1a 100644 --- a/src/main/java/com/alttd/playershops/listener/ShopListener.java +++ b/src/main/java/com/alttd/playershops/listener/ShopListener.java @@ -243,20 +243,4 @@ public class ShopListener extends EventListener { event.setCancelled(true); } - @EventHandler(priority = EventPriority.HIGHEST) - public void onClaimExpiration(ClaimExpirationEvent event) { - if(!this.isRegistered) - return; - - UUID uuid = event.getClaim().ownerID; - if(uuid == null) - return; - - List playerShops = shopHandler.getShops(uuid); - for(PlayerShop shop : playerShops) { - shop.expireSign(); - shopHandler.removeShop(shop); - } - } - }