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> <artifactId>griefdefender</artifactId>
<repositories> <repositories>
<repository> <repository>
<id>jitpack.io</id> <id>gdapi</id>
<url>https://jitpack.io</url> <url>https://repo.glaremasters.me/repository/bloodshot</url>
</repository> </repository>
</repositories> </repositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>com.github.bloodmc</groupId> <groupId>com.griefdefender</groupId>
<artifactId>GriefDefenderAPI</artifactId> <artifactId>api</artifactId>
<version>-dd5aa2224c-1</version> <version>2.1.0-20220122.032038-5</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>

View File

@ -1,6 +1,7 @@
package de.themoep.randomteleport.hook.plugin; package de.themoep.randomteleport.hook.plugin;
import com.griefdefender.api.GriefDefender; import com.griefdefender.api.GriefDefender;
import com.griefdefender.api.claim.ClaimManager;
import com.griefdefender.api.claim.ClaimTypes; import com.griefdefender.api.claim.ClaimTypes;
import de.themoep.randomteleport.hook.ProtectionHook; import de.themoep.randomteleport.hook.ProtectionHook;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -23,13 +24,22 @@ public class GriefDefenderHook implements ProtectionHook {
@Override @Override
public boolean canBuild(Player player, Location location) { 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 @Override
public boolean canBuild(Player player, World world, int chunkX, int chunkZ) { public boolean canBuild(Player player, World world, int chunkX, int chunkZ) {
if(GriefDefender.getCore().isEnabled(world.getUID())) { return canBuild(world, chunkX * 16, world.getSeaLevel(), chunkZ * 16);
return GriefDefender.getCore().getClaimManager(world.getUID()).getClaimAt(chunkX,0,chunkZ).isTrusted(player.getUniqueId()); }
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; return true;
} }