From b922865fda674dfb7e0cac594046a1ba6e66c572 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Jul 2021 10:12:22 +0000 Subject: [PATCH 1/7] Bump commons-compress from 1.20 to 1.21 Bumps commons-compress from 1.20 to 1.21. --- updated-dependencies: - dependency-name: org.apache.commons:commons-compress dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c8b43e786..062338c39 100644 --- a/pom.xml +++ b/pom.xml @@ -418,7 +418,7 @@ org.apache.commons commons-compress - 1.20 + 1.21 com.griefcraft.lwc From 62e9cc6c765028ae4f0ae20cf70502b86437aa0e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Jul 2021 10:15:27 +0000 Subject: [PATCH 2/7] Bump spigot-api from 1.17-R0.1-SNAPSHOT to 1.17.1-R0.1-SNAPSHOT Bumps spigot-api from 1.17-R0.1-SNAPSHOT to 1.17.1-R0.1-SNAPSHOT. --- updated-dependencies: - dependency-name: org.spigotmc:spigot-api dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c8b43e786..b68dc02bd 100644 --- a/pom.xml +++ b/pom.xml @@ -609,7 +609,7 @@ org.spigotmc spigot-api - 1.17-R0.1-SNAPSHOT + 1.17.1-R0.1-SNAPSHOT provided From dd00fcce73b7c16cdd2b9cb1deacb3e9d285fa19 Mon Sep 17 00:00:00 2001 From: 1171066 <1171066@isep.ipp.pt> Date: Tue, 13 Jul 2021 16:52:53 +0100 Subject: [PATCH 3/7] Eliminated duplicated Code. Changed variables names. Fixed problem with the Grief Prevention untrust handler (it would remove shops that were not related to the claim that someone untrusted other person). Reverted changes made by Ghost_chu that wouldn't make sense in the context of GriefPrevention (now when a claim is unclaimed or expired all shops inside it will me deleted as well). --- .../GriefPreventionIntegration.java | 55 +++++++------------ 1 file changed, 21 insertions(+), 34 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 19f47723d..d4b7f12e8 100644 --- a/src/main/java/org/maxgamer/quickshop/integration/griefprevention/GriefPreventionIntegration.java +++ b/src/main/java/org/maxgamer/quickshop/integration/griefprevention/GriefPreventionIntegration.java @@ -36,7 +36,6 @@ import org.maxgamer.quickshop.integration.IntegrateStage; import org.maxgamer.quickshop.integration.IntegrationStage; import org.maxgamer.quickshop.integration.QSIntegratedPlugin; import org.maxgamer.quickshop.shop.Shop; - import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -48,7 +47,7 @@ public class GriefPreventionIntegration extends QSIntegratedPlugin { private final List tradeLimits = new ArrayList<>(3); private final boolean whiteList; private final boolean deleteOnUntrusted; - private final boolean deleteOnUnClaim; + private final boolean deleteOnUnclaim; private final boolean deleteOnClaimExpired; public GriefPreventionIntegration(QuickShop plugin) { @@ -56,7 +55,7 @@ public class GriefPreventionIntegration extends QSIntegratedPlugin { ConfigurationSection configurationSection = plugin.getConfig(); this.whiteList = configurationSection.getBoolean("integration.griefprevention.whitelist-mode"); deleteOnUntrusted = configurationSection.getBoolean("integration.griefprevention.delete-on-untrusted"); - deleteOnUnClaim = configurationSection.getBoolean("integration.griefprevention.delete-on-unclaim"); + deleteOnUnclaim = configurationSection.getBoolean("integration.griefprevention.delete-on-unclaim"); deleteOnClaimExpired = configurationSection.getBoolean("integration.griefprevention.delete-on-claim-expired"); createLimits.addAll(toFlags(configurationSection.getStringList("integration.griefprevention.create"))); tradeLimits.addAll(toFlags(configurationSection.getStringList("integration.griefprevention.trade"))); @@ -105,7 +104,7 @@ public class GriefPreventionIntegration extends QSIntegratedPlugin { return true; } - @EventHandler(ignoreCancelled = true) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onUntrusted(me.ryanhamshire.GriefPrevention.events.TrustChangedEvent event) { if (!deleteOnUntrusted) { return; @@ -122,6 +121,12 @@ public class GriefPreventionIntegration extends QSIntegratedPlugin { if (shop.getOwner().equals(claim.getOwnerID())) { return; } + + Claim shopClaim = griefPrevention.dataStore.getClaimAt(shop.getLocation(), true, true, null); + if(shopClaim == null || shopClaim.getID() != claim.getID()) { + return; + } + //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()); @@ -134,6 +139,7 @@ public class GriefPreventionIntegration extends QSIntegratedPlugin { 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(); @@ -146,45 +152,26 @@ public class GriefPreventionIntegration extends QSIntegratedPlugin { } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onUnclaimed(ClaimDeletedEvent event) { - if (!deleteOnUnClaim) { - return; - } - Claim claim = event.getClaim(); - if (event.getClaim().getOwnerID() == null) { - return; - } - for (Chunk chunk : claim.getChunks()) { - Map shops = plugin.getShopManager().getShops(chunk); - if (shops != null && !shops.isEmpty()) { - for (Shop shop : shops.values()) { - if (griefPrevention.dataStore.getClaimAt(shop.getLocation(), true, true, null) == null) { - if (event.getClaim().getOwnerID().equals(shop.getOwner())) { - shop.delete(); - } - } - } - } - } + public void onClaimUnclaimed(ClaimDeletedEvent event) { + onUnclaimOrExpiredHelper(event.getClaim(), deleteOnUnclaim); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onUnclaimed(ClaimExpirationEvent event) { - if (!deleteOnClaimExpired) { + public void onClaimExpired(ClaimExpirationEvent event) { + onUnclaimOrExpiredHelper(event.getClaim(), deleteOnClaimExpired); + } + + private void onUnclaimOrExpiredHelper(Claim claim, boolean configSectionBoolean) { + if (!configSectionBoolean) { return; } - if (event.getClaim().getOwnerID() == null) { - return; - } - Claim claim = event.getClaim(); for (Chunk chunk : claim.getChunks()) { Map shops = plugin.getShopManager().getShops(chunk); - if (shops != null && !shops.isEmpty()) { + if (shops != null) { for (Shop shop : shops.values()) { if (griefPrevention.dataStore.getClaimAt(shop.getLocation(), true, true, null) == null) { - if (event.getClaim().getOwnerID().equals(shop.getOwner())) { - shop.delete(); - } + plugin.log("[SHOP DELETE] GP Integration: Single delete (Unclaimed/Expired) #" + shop.getOwner()); + shop.delete(); } } } From a24e8fccd5f4375624d8ea602e5f156e6bb98ebf Mon Sep 17 00:00:00 2001 From: Ghost_chu <30802565+Ghost-chu@users.noreply.github.com> Date: Wed, 14 Jul 2021 00:11:14 +0800 Subject: [PATCH 4/7] Delete semgrep.yml --- .github/workflows/semgrep.yml | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 .github/workflows/semgrep.yml diff --git a/.github/workflows/semgrep.yml b/.github/workflows/semgrep.yml deleted file mode 100644 index f271ad83b..000000000 --- a/.github/workflows/semgrep.yml +++ /dev/null @@ -1,18 +0,0 @@ -on: - pull_request: {} - push: - branches: - - main - - master -name: Semgrep -jobs: - semgrep: - name: Scan - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: returntocorp/semgrep-action@v1 - with: - auditOn: push - publishToken: ${{ secrets.SEMGREP_APP_TOKEN }} - publishDeployment: 1559 From 28b3e4f3bf89e657ab2f70ff7756c6299e1bd0fa Mon Sep 17 00:00:00 2001 From: Ghost_chu <30802565+Ghost-chu@users.noreply.github.com> Date: Wed, 14 Jul 2021 02:41:57 +0800 Subject: [PATCH 5/7] New translations messages.json (Danish) --- src/main/resources/lang/da-DK/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/lang/da-DK/messages.json b/src/main/resources/lang/da-DK/messages.json index 6ebfa2997..d0e0b61fd 100644 --- a/src/main/resources/lang/da-DK/messages.json +++ b/src/main/resources/lang/da-DK/messages.json @@ -1,5 +1,5 @@ { - "_comment": "Hi translator! If you editing this from Github or from code sources, you should go https://crowdin.com/project/quickshop-reremake", + "_comment": "Hej oversætter! Hvis du redigerer dette fra Github eller fra kodekilder, bør du gå https://crowdin.com/project/quickshop-reremake", "file-test": "This is a test textfile. We use it to test if the messages.json is broken. You can fill it with any easter eggs you like here :)", "translation-author": "Oversættere: Ghost_chu, Andre_601, notashelf", "translation-version": "Supportversion: Reremake", 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 6/7] 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(); } From d0a871cced129aca60de553659919450a8ea761f Mon Sep 17 00:00:00 2001 From: 1171066 <1171066@isep.ipp.pt> Date: Tue, 13 Jul 2021 23:51:01 +0100 Subject: [PATCH 7/7] Implemented event listener to delete shops if they are outside a Grief Prevention claim when the claim is resized/shrinked. --- .../org/maxgamer/quickshop/QuickShop.java | 4 ++++ .../GriefPreventionIntegration.java | 23 +++++++++++++++++++ src/main/resources/config.yml | 6 +++-- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/maxgamer/quickshop/QuickShop.java b/src/main/java/org/maxgamer/quickshop/QuickShop.java index a992b5ad4..fe6f4542b 100644 --- a/src/main/java/org/maxgamer/quickshop/QuickShop.java +++ b/src/main/java/org/maxgamer/quickshop/QuickShop.java @@ -1864,6 +1864,10 @@ public class QuickShop extends JavaPlugin { getConfig().set("integration.griefprevention.delete-on-claim-expired", false); getConfig().set("config-version", ++selectedVersion); } + if (selectedVersion == 134) { + getConfig().set("integration.griefprevention.delete-on-claim-resized", false); + getConfig().set("config-version", ++selectedVersion); + } if (getConfig().getInt("matcher.work-type") != 0 && GameVersion.get(ReflectFactory.getServerVersion()).name().contains("1_16")) { 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 6b3995d70..ee34782e6 100644 --- a/src/main/java/org/maxgamer/quickshop/integration/griefprevention/GriefPreventionIntegration.java +++ b/src/main/java/org/maxgamer/quickshop/integration/griefprevention/GriefPreventionIntegration.java @@ -23,6 +23,7 @@ import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.GriefPrevention; import me.ryanhamshire.GriefPrevention.events.ClaimDeletedEvent; import me.ryanhamshire.GriefPrevention.events.ClaimExpirationEvent; +import me.ryanhamshire.GriefPrevention.events.ClaimModifiedEvent; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.Material; @@ -49,6 +50,7 @@ public class GriefPreventionIntegration extends QSIntegratedPlugin { private final boolean deleteOnUntrusted; private final boolean deleteOnUnclaim; private final boolean deleteOnClaimExpired; + private final boolean deleteOnClaimResized; public GriefPreventionIntegration(QuickShop plugin) { super(plugin); @@ -57,6 +59,7 @@ public class GriefPreventionIntegration extends QSIntegratedPlugin { deleteOnUntrusted = configurationSection.getBoolean("integration.griefprevention.delete-on-untrusted"); deleteOnUnclaim = configurationSection.getBoolean("integration.griefprevention.delete-on-unclaim"); deleteOnClaimExpired = configurationSection.getBoolean("integration.griefprevention.delete-on-claim-expired"); + deleteOnClaimResized = configurationSection.getBoolean("integration.griefprevention.delete-on-claim-resized"); createLimits.addAll(toFlags(configurationSection.getStringList("integration.griefprevention.create"))); tradeLimits.addAll(toFlags(configurationSection.getStringList("integration.griefprevention.trade"))); } @@ -147,6 +150,26 @@ public class GriefPreventionIntegration extends QSIntegratedPlugin { onUnclaimOrExpiredHelper(event.getClaim(), deleteOnClaimExpired); } + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onClaimResized(ClaimModifiedEvent event) { + if (!deleteOnClaimResized) { + return; + } + Claim oldClaim = event.getFrom(); + Claim newClaim = event.getTo(); + for (Chunk chunk : oldClaim.getChunks()) { + Map shops = plugin.getShopManager().getShops(chunk); + if (shops != null) { + for (Shop shop : shops.values()) { + if (oldClaim.contains(shop.getLocation(), true, false) && !newClaim.contains(shop.getLocation(), true, false)) { + plugin.log("[SHOP DELETE] GP Integration: Single delete (Resized) #" + shop.getOwner()); + shop.delete(); + } + } + } + } + } + private void onUnclaimOrExpiredHelper(Claim claim, boolean configSectionBoolean) { if (!configSectionBoolean) { return; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 57849258e..b0dca484d 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -22,7 +22,7 @@ # TO EDIT QUICKSHOP'S CONFIGURATION, USE THE "config.yml" FILE! #Do not touch this if you don't know what you're doing! -config-version: 134 +config-version: 135 #Select the language you want to use, (e.g de), use only supported language codes from the list below. #If you use a not existant/not supported language, then QuickShop will use en_US. @@ -694,9 +694,11 @@ integration: #Should QuickShop delete shops if the shop owner has been untrusted on the claim? delete-on-untrusted: true #Should QuickShop delete shops if claim has been deleted? - delete-on-unclaim: false + delete-on-unclaim: true #Should QuickShop delete shops if claim has been expired? delete-on-claim-expired: true + #Should QuickShop delete shops if claim has been resized (claim has become smaller and the shop is now outside claim)? + delete-on-claim-resized: true #Residence Integration residence: enable: false