Add back shop expiration when claims expire
This commit is contained in:
parent
72fd7efc86
commit
057df73513
|
|
@ -104,7 +104,7 @@ bukkit {
|
|||
version = "${rootProject.version}-${gitCommit()}"
|
||||
apiVersion = "1.19"
|
||||
authors = listOf("destro174")
|
||||
depend = listOf("Vault")
|
||||
depend = listOf("Vault", "GriefPrevention")
|
||||
|
||||
commands {
|
||||
register("playershop") {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.alttd.playershops.handler.ShopHandler;
|
|||
import com.alttd.playershops.shop.PlayerShop;
|
||||
import com.alttd.playershops.utils.EconomyUtils;
|
||||
import com.destroystokyo.paper.MaterialSetTag;
|
||||
import me.ryanhamshire.GriefPrevention.events.ClaimExpirationEvent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
|
|
@ -34,6 +35,8 @@ import org.bukkit.inventory.InventoryHolder;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Dedicated class to listen to events related to shops.
|
||||
|
|
@ -239,4 +242,21 @@ public class ShopListener extends EventListener {
|
|||
if (material == Material.INK_SAC || material == Material.GLOW_INK_SAC || material.name().endsWith("_DYE")) // TODO create a cache for these?
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,6 +141,10 @@ public class PlayerShop {
|
|||
}
|
||||
}
|
||||
|
||||
public void expireSign() {
|
||||
setSignLines(type.getShopTypeConfig().expiredSignLines);
|
||||
}
|
||||
|
||||
public void removeSignLines() {
|
||||
setSignLines(type.getShopTypeConfig().activeSignLines);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user