From 806ca62485ec378ccb1c8b2676cf59e498ab2d2d Mon Sep 17 00:00:00 2001 From: ahdg <36436808+ahdg6@users.noreply.github.com> Date: Mon, 24 Jan 2022 01:29:01 +0800 Subject: [PATCH] fix: GriefDefender filter (#1546) * Fix: GriefDefender filter * Update libs.versions.toml * Now it only work with 2.1.0. --- gradle/libs.versions.toml | 6 ++---- worldedit-bukkit/build.gradle.kts | 8 ++++---- .../bukkit/regions/GriefDefenderFeature.java | 14 +++----------- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e1082a352..d8b9d3ad5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,7 +14,7 @@ dummypermscompat = "1.10" worldguard-bukkit = "7.0.6" mapmanager = "1.8.0-SNAPSHOT" griefprevention = "16.17.1" -griefdefender = "920a610" +griefdefender = "2.1.0-SNAPSHOT" mcore = "7.0.1" residence = "4.5._13.1" towny = "0.97.5.0" @@ -23,7 +23,6 @@ plotsquaredV6 = "6.3.0" redprotect = "1.9.6" # Third party -flow-math = "1.0.3" paperlib = "1.0.8-SNAPSHOT" bstats = "2.2.1" serverlib = "2.3.1" @@ -72,7 +71,7 @@ dummypermscompat = { group = "com.sk89q", name = "dummypermscompat", version.ref worldguard = { group = "com.sk89q.worldguard", name = "worldguard-bukkit", version.ref = "worldguard-bukkit" } mapmanager = { group = "com.github.InventivetalentDev", name = "MapManager", version.ref = "mapmanager" } griefprevention = { group = "com.github.TechFortress", name = "GriefPrevention", version.ref = "griefprevention" } -griefdefender = { group = "com.github.bloodmc", name = "GriefDefenderApi", version.ref = "griefdefender" } +griefdefender = { group = "com.griefdefender", name = "api", version.ref = "griefdefender" } mcore = { group = "com.massivecraft", name = "mcore", version.ref = "mcore" } residence = { group = "com.bekvon.bukkit.residence", name = "Residence", version.ref = "residence" } towny = { group = "com.github.TownyAdvanced", name = "Towny", version.ref = "towny" } @@ -82,7 +81,6 @@ plotsquaredV6Core = { group = "com.plotsquared", name = "PlotSquared-Core", vers redprotect = { group = "net.fabiozumbi12", name = "redprotect", version.ref = "redprotect" } # Third Party -flowmath = { group = "com.flowpowered", name = "flow-math", version.ref = "flow-math" } paperlib = { group = "io.papermc", name = "paperlib", version.ref = "paperlib" } bstatsBukkit = { group = "org.bstats", name = "bstats-bukkit", version.ref = "bstats" } bstatsBase = { group = "org.bstats", name = "bstats-base", version.ref = "bstats" } diff --git a/worldedit-bukkit/build.gradle.kts b/worldedit-bukkit/build.gradle.kts index 5233890d2..697c883f0 100644 --- a/worldedit-bukkit/build.gradle.kts +++ b/worldedit-bukkit/build.gradle.kts @@ -27,6 +27,10 @@ repositories { name = "ProtocolLib" url = uri("https://repo.dmulloy2.net/nexus/repository/public/") } + maven { + name = "GriefDefender" + url = uri("https://repo.glaremasters.me/repository/bloodshot/") + } maven { name = "OSS Sonatype Snapshots" url = uri("https://oss.sonatype.org/content/repositories/snapshots/") @@ -96,10 +100,6 @@ dependencies { compileOnly(libs.plotsquaredV6Core) { isTransitive = false } // Third party - compileOnly(libs.flowmath) { - because("This dependency is needed by GriefDefender but not exposed transitively.") - isTransitive = false - } implementation(libs.paperlib) implementation(libs.bstatsBukkit) { isTransitive = false } implementation(libs.bstatsBase) { isTransitive = false } diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/GriefDefenderFeature.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/GriefDefenderFeature.java index 1f9fc7233..9ac2fd68a 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/GriefDefenderFeature.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/GriefDefenderFeature.java @@ -1,7 +1,6 @@ package com.fastasyncworldedit.bukkit.regions; import com.fastasyncworldedit.core.regions.FaweMask; -import com.flowpowered.math.vector.Vector3i; import com.griefdefender.api.GriefDefender; import com.griefdefender.api.claim.Claim; import com.griefdefender.api.claim.TrustTypes; @@ -10,7 +9,6 @@ import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; import org.apache.logging.log4j.Logger; -import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; @@ -25,21 +23,15 @@ public class GriefDefenderFeature extends BukkitMaskManager implements Listener } public boolean isAllowed(Player player, Claim claim, MaskType type) { - return GriefDefender.getCore().isEnabled(player.getWorld().getUID()) && !claim.isWilderness() && (claim - .getOwnerName() - .equalsIgnoreCase(player.getName()) || claim.getOwnerUniqueId().equals(player.getUniqueId()) || - type == MaskType.MEMBER && claim.getUserTrusts(TrustTypes.BUILDER).contains(player.getUniqueId())); + return type == MaskType.MEMBER && claim.isUserTrusted(player.getUniqueId(), TrustTypes.BUILDER); } @Override public FaweMask getMask(final com.sk89q.worldedit.entity.Player wePlayer, MaskType type, boolean isWhitelist) { final Player player = BukkitAdapter.adapt(wePlayer); - final Location loc = player.getLocation(); - final Vector3i vector = Vector3i.from(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); - final Claim claim = GriefDefender.getCore().getClaimManager(loc.getWorld().getUID()).getClaimAt(vector); - if (!claim.isWilderness()) { + Claim claim = GriefDefender.getCore().getClaimAt(player.getLocation()); + if (claim != null && !claim.isWilderness()) { if (isAllowed(player, claim, type)) { - claim.getGreaterBoundaryCorner().getX(); final BlockVector3 pos1 = BlockVector3.at( claim.getLesserBoundaryCorner().getX(), claim.getLesserBoundaryCorner().getY(),