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 diff --git a/pom.xml b/pom.xml index c8b43e786..c21768b8e 100644 --- a/pom.xml +++ b/pom.xml @@ -418,7 +418,7 @@ org.apache.commons commons-compress - 1.20 + 1.21 com.griefcraft.lwc @@ -609,7 +609,7 @@ org.spigotmc spigot-api - 1.17-R0.1-SNAPSHOT + 1.17.1-R0.1-SNAPSHOT provided 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 19f47723d..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; @@ -36,7 +37,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,16 +48,18 @@ 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; + private final boolean deleteOnClaimResized; public GriefPreventionIntegration(QuickShop plugin) { super(plugin); 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"); + 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"))); } @@ -105,39 +107,32 @@ 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; } - 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; - } - //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 (!shop.getOwner().equals(claim.getOwnerID())) { - 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; + Claim shopClaim = griefPrevention.dataStore.getClaimAt(shop.getLocation(), true, false, null); + if(shopClaim != null && shopClaim.getID() == claim.getID()) { + + 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(); + } + } } } } @@ -146,45 +141,46 @@ public class GriefPreventionIntegration extends QSIntegratedPlugin { } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onUnclaimed(ClaimDeletedEvent event) { - if (!deleteOnUnClaim) { + public void onClaimUnclaimed(ClaimDeletedEvent event) { + onUnclaimOrExpiredHelper(event.getClaim(), deleteOnUnclaim); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onClaimExpired(ClaimExpirationEvent event) { + onUnclaimOrExpiredHelper(event.getClaim(), deleteOnClaimExpired); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onClaimResized(ClaimModifiedEvent event) { + if (!deleteOnClaimResized) { return; } - Claim claim = event.getClaim(); - if (event.getClaim().getOwnerID() == null) { - return; - } - for (Chunk chunk : claim.getChunks()) { + Claim oldClaim = event.getFrom(); + Claim newClaim = event.getTo(); + for (Chunk chunk : oldClaim.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(); - } + 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(); } } } } } - @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) - public void onUnclaimed(ClaimExpirationEvent event) { - if (!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(); - } + if (claim.contains(shop.getLocation(), true, false)) { + plugin.log("[SHOP DELETE] GP Integration: Single delete (Unclaimed/Expired) #" + shop.getOwner()); + shop.delete(); } } } 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 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",