Use recent GD API (#51)

This commit is contained in:
John 2022-05-22 13:29:25 +02:00 committed by GitHub
parent 61c32c5995
commit c30af21608
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 8 deletions

View File

@ -12,15 +12,15 @@
<artifactId>griefdefender</artifactId>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
<id>gdapi</id>
<url>https://repo.glaremasters.me/repository/bloodshot</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.bloodmc</groupId>
<artifactId>GriefDefenderAPI</artifactId>
<version>-dd5aa2224c-1</version>
<groupId>com.griefdefender</groupId>
<artifactId>api</artifactId>
<version>2.1.0-20220122.032038-5</version>
<exclusions>
<exclusion>
<groupId>org.bukkit</groupId>

View File

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