mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 09:59:49 -05:00
Implemented event listener to delete shops if they are outside a Grief Prevention claim when the claim is resized/shrinked.
This commit is contained in:
1 parent
fe5f99adc4
commit
d0a871cced
3 files changed
+31
-2
No files matched your search
@@ -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")) {
|
||||
|
||||
+23
@@ -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<Location, Shop> 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;
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user