fix: GriefDefender filter (#1546)

* Fix: GriefDefender filter

* Update libs.versions.toml

* Now it only work with 2.1.0.
This commit is contained in:
ahdg 2022-01-24 01:29:01 +08:00 committed by GitHub
parent 016b4ba81d
commit 806ca62485
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 19 deletions

View File

@ -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" }

View File

@ -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 }

View File

@ -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(),