From fe5f99adc456244a1c41c082cbb36419a8f74bdf Mon Sep 17 00:00:00 2001 From: 1171066 <1171066@isep.ipp.pt> Date: Tue, 13 Jul 2021 21:18:53 +0100 Subject: [PATCH] Changed code in the event handler of unclaimed/expired claim to consider subclaims. Fixed more problems in the event handler of untrusted claim to consider subclaims. Also removed the code event.isGiven() because if the player changes the trust permission from one greater level to another lower level, it does not consider as untrust, so it happens problems. Refactored the previous event because of the problems of the return statements inside loops. --- .../GriefPreventionIntegration.java | 44 +++++++------------ 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/integration/griefprevention/GriefPreventionIntegration.java b/src/main/java/org/maxgamer/quickshop/integration/griefprevention/GriefPreventionIntegration.java index d4b7f12e8..6b3995d70 100644 --- a/src/main/java/org/maxgamer/quickshop/integration/griefprevention/GriefPreventionIntegration.java +++ b/src/main/java/org/maxgamer/quickshop/integration/griefprevention/GriefPreventionIntegration.java @@ -109,41 +109,27 @@ public class GriefPreventionIntegration extends QSIntegratedPlugin { if (!deleteOnUntrusted) { return; } - if (event.isGiven()) { - return; - } - for (Claim claim : event.getClaims()) { for (Chunk chunk : claim.getChunks()) { Map shops = plugin.getShopManager().getShops(chunk); if (shops != null) { for (Shop shop : shops.values()) { - if (shop.getOwner().equals(claim.getOwnerID())) { - return; - } + if (!shop.getOwner().equals(claim.getOwnerID())) { - Claim shopClaim = griefPrevention.dataStore.getClaimAt(shop.getLocation(), true, true, null); - if(shopClaim == null || shopClaim.getID() != claim.getID()) { - return; - } + Claim shopClaim = griefPrevention.dataStore.getClaimAt(shop.getLocation(), true, false, null); + if(shopClaim != null && shopClaim.getID() == claim.getID()) { - //https://github.com/TechFortress/GriefPrevention/blob/e63d1d9e513f48aa0aaa81f154de01626248b7fe/src/main/java/me/ryanhamshire/GriefPrevention/events/TrustChangedEvent.java#L104 - if (event.getIdentifier().equals(shop.getOwner().toString())) { //Single - plugin.log("[SHOP DELETE] GP Integration: Single delete #" + event.getIdentifier()); - shop.delete(); - return; - } - - if (event.getIdentifier().contains(shop.getOwner().toString())) { //Group - plugin.log("[SHOP DELETE] GP Integration: Group delete #" + event.getIdentifier()); - shop.delete(); - return; - } - - if ("all".equals(event.getIdentifier()) || "public".equals(event.getIdentifier())) { //All - plugin.log("[SHOP DELETE] GP Integration: All/Public delete #" + event.getIdentifier()); - shop.delete(); - return; + if(event.getIdentifier().equals(shop.getOwner().toString())) { + plugin.log("[SHOP DELETE] GP Integration: Single delete #" + event.getIdentifier()); + shop.delete(); + } else if(event.getIdentifier().contains(shop.getOwner().toString())) { + plugin.log("[SHOP DELETE] GP Integration: Group delete #" + event.getIdentifier()); + shop.delete(); + } else if("all".equals(event.getIdentifier()) || "public".equals(event.getIdentifier())) { + plugin.log("[SHOP DELETE] GP Integration: All/Public delete #" + event.getIdentifier()); + shop.delete(); + } + } } } } @@ -169,7 +155,7 @@ public class GriefPreventionIntegration extends QSIntegratedPlugin { Map shops = plugin.getShopManager().getShops(chunk); if (shops != null) { for (Shop shop : shops.values()) { - if (griefPrevention.dataStore.getClaimAt(shop.getLocation(), true, true, null) == null) { + if (claim.contains(shop.getLocation(), true, false)) { plugin.log("[SHOP DELETE] GP Integration: Single delete (Unclaimed/Expired) #" + shop.getOwner()); shop.delete(); }