From c30af216086fc4fe8657b39a4bbe1958b2d81750 Mon Sep 17 00:00:00 2001
From: John <4679374+johnfriedrich@users.noreply.github.com>
Date: Sun, 22 May 2022 13:29:25 +0200
Subject: [PATCH] Use recent GD API (#51)
---
.../griefdefender/pom.xml | 10 +++++-----
.../hook/plugin/GriefDefenderHook.java | 16 +++++++++++++---
2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/randomteleport-plugin-hooks/griefdefender/pom.xml b/randomteleport-plugin-hooks/griefdefender/pom.xml
index 6988dfc..577aaba 100644
--- a/randomteleport-plugin-hooks/griefdefender/pom.xml
+++ b/randomteleport-plugin-hooks/griefdefender/pom.xml
@@ -12,15 +12,15 @@
griefdefender
- jitpack.io
- https://jitpack.io
+ gdapi
+ https://repo.glaremasters.me/repository/bloodshot
- com.github.bloodmc
- GriefDefenderAPI
- -dd5aa2224c-1
+ com.griefdefender
+ api
+ 2.1.0-20220122.032038-5
org.bukkit
diff --git a/randomteleport-plugin-hooks/griefdefender/src/main/java/de/themoep/randomteleport/hook/plugin/GriefDefenderHook.java b/randomteleport-plugin-hooks/griefdefender/src/main/java/de/themoep/randomteleport/hook/plugin/GriefDefenderHook.java
index 1fb9281..daef4d9 100644
--- a/randomteleport-plugin-hooks/griefdefender/src/main/java/de/themoep/randomteleport/hook/plugin/GriefDefenderHook.java
+++ b/randomteleport-plugin-hooks/griefdefender/src/main/java/de/themoep/randomteleport/hook/plugin/GriefDefenderHook.java
@@ -1,6 +1,7 @@
package de.themoep.randomteleport.hook.plugin;
import com.griefdefender.api.GriefDefender;
+import com.griefdefender.api.claim.ClaimManager;
import com.griefdefender.api.claim.ClaimTypes;
import de.themoep.randomteleport.hook.ProtectionHook;
import org.bukkit.Bukkit;
@@ -23,13 +24,22 @@ public class GriefDefenderHook implements ProtectionHook {
@Override
public boolean canBuild(Player player, Location location) {
- return GriefDefender.getCore().getClaimManager(location.getWorld().getUID()).getClaimAt(location.getBlockX(), location.getBlockY(), location.getBlockZ()).getType() == ClaimTypes.WILDERNESS;
+ return canBuild(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
@Override
public boolean canBuild(Player player, World world, int chunkX, int chunkZ) {
- if(GriefDefender.getCore().isEnabled(world.getUID())) {
- return GriefDefender.getCore().getClaimManager(world.getUID()).getClaimAt(chunkX,0,chunkZ).isTrusted(player.getUniqueId());
+ return canBuild(world, chunkX * 16, world.getSeaLevel(), chunkZ * 16);
+ }
+
+ private boolean canBuild(World world, int x, int y, int z) {
+ if (GriefDefender.getCore().isEnabled(world.getUID())) {
+ ClaimManager claimManager = GriefDefender.getCore().getClaimManager(world.getUID());
+ if (claimManager == null) {
+ return true;
+ } else {
+ return claimManager.getClaimAt(x, y, z).getType() == ClaimTypes.WILDERNESS;
+ }
}
return true;
}