Add GriefPreventionListener to listen to GriefPreventionEvents
This commit is contained in:
parent
fa2d5689fb
commit
7553df9c12
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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<PlayerShop> playerShops = shopHandler.getShops(uuid);
|
||||
for(PlayerShop shop : playerShops) {
|
||||
shop.expireSign();
|
||||
shopHandler.removeShop(shop);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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<PlayerShop> playerShops = shopHandler.getShops(uuid);
|
||||
for(PlayerShop shop : playerShops) {
|
||||
shop.expireSign();
|
||||
shopHandler.removeShop(shop);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user