From 7d14d1d7e2d29dc88f1c033afb5916fb2be6974e Mon Sep 17 00:00:00 2001 From: OmerBenGera Date: Fri, 3 Jun 2022 11:17:38 +0300 Subject: [PATCH] Added support for Lands --- Hook_Lands/build.gradle | 13 +++++++++ .../hooks/ClaimsProvider_Lands.java | 27 +++++++++++++++++++ settings.gradle | 1 + .../handlers/ProvidersHandler.java | 4 +++ 4 files changed, 45 insertions(+) create mode 100644 Hook_Lands/build.gradle create mode 100644 Hook_Lands/src/main/java/com/bgsoftware/wildloaders/hooks/ClaimsProvider_Lands.java diff --git a/Hook_Lands/build.gradle b/Hook_Lands/build.gradle new file mode 100644 index 0000000..d0829b0 --- /dev/null +++ b/Hook_Lands/build.gradle @@ -0,0 +1,13 @@ +group 'Hook_Lands' + +dependencies { + compileOnly 'me.angeschossen:Lands:latest' + compileOnly "org.spigotmc:v1_8_R3-Taco:latest" + compileOnly project(":API") + compileOnly parent +} + +if (project.hasProperty('hook.compile_lands') && + !Boolean.valueOf(project.findProperty("hook.compile_lands").toString())) { + project.tasks.all { task -> task.enabled = false } +} \ No newline at end of file diff --git a/Hook_Lands/src/main/java/com/bgsoftware/wildloaders/hooks/ClaimsProvider_Lands.java b/Hook_Lands/src/main/java/com/bgsoftware/wildloaders/hooks/ClaimsProvider_Lands.java new file mode 100644 index 0000000..c1088f5 --- /dev/null +++ b/Hook_Lands/src/main/java/com/bgsoftware/wildloaders/hooks/ClaimsProvider_Lands.java @@ -0,0 +1,27 @@ +package com.bgsoftware.wildloaders.hooks; + +import com.bgsoftware.wildloaders.WildLoadersPlugin; +import com.bgsoftware.wildloaders.api.hooks.ClaimsProvider; +import me.angeschossen.lands.api.integration.LandsIntegration; +import me.angeschossen.lands.api.land.Land; +import me.angeschossen.lands.api.role.enums.RoleSetting; +import org.bukkit.Chunk; + +import java.util.UUID; + +public final class ClaimsProvider_Lands implements ClaimsProvider { + + private final LandsIntegration landsIntegration; + + public ClaimsProvider_Lands(WildLoadersPlugin plugin) { + landsIntegration = new LandsIntegration(plugin, false); + landsIntegration.initialize(); + } + + @Override + public boolean hasClaimAccess(UUID player, Chunk chunk) { + Land land = landsIntegration.getLand(chunk.getWorld(), chunk.getX(), chunk.getZ()); + return land == null || land.canSetting(player, RoleSetting.BLOCK_PLACE); + } + +} diff --git a/settings.gradle b/settings.gradle index 78b2e40..6f50bf3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -14,4 +14,5 @@ include 'v1_17_R1' include 'v1_18_R1' include 'Hook_EpicSpawners7' include 'v1_18_R2' +include 'Hook_Lands' diff --git a/src/main/java/com/bgsoftware/wildloaders/handlers/ProvidersHandler.java b/src/main/java/com/bgsoftware/wildloaders/handlers/ProvidersHandler.java index b5956ca..04d688f 100644 --- a/src/main/java/com/bgsoftware/wildloaders/handlers/ProvidersHandler.java +++ b/src/main/java/com/bgsoftware/wildloaders/handlers/ProvidersHandler.java @@ -50,6 +50,10 @@ public final class ProvidersHandler implements ProvidersManager { Optional claimsProvider = createInstance("ClaimsProvider_SuperiorSkyblock"); claimsProvider.ifPresent(this::addClaimsProvider); } + if (Bukkit.getPluginManager().isPluginEnabled("Lands")) { + Optional claimsProvider = createInstance("ClaimsProvider_Lands"); + claimsProvider.ifPresent(this::addClaimsProvider); + } } private void loadTickableProviders() {