diff --git a/build.gradle.kts b/build.gradle.kts index 9a45649..8d71ca7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -19,24 +19,27 @@ repositories { maven("https://maven.enginehub.org/repo/") maven("https://repo.papermc.io/repository/maven-public/") maven("https://jitpack.io") + maven("https://repo.william278.net/releases") } dependencies { - compileOnly("org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT") + compileOnly("org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT") compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.1.0-SNAPSHOT") - compileOnly("com.palmergames.bukkit.towny:towny:0.99.2.0") + compileOnly("com.palmergames.bukkit.towny:towny:0.100.1.0") compileOnly("com.massivecraft:Factions:1.6.9.5-U0.6.11") { exclude("org.kitteh:paste-gg-api") exclude("com.darkblade12:particleeffect") exclude("org.spongepowered:configurate-hocon") exclude("com.mojang:brigadier") } - compileOnly("com.github.angeschossen:LandsAPI:6.29.12") + compileOnly("com.github.angeschossen:LandsAPI:6.44.0") compileOnly("com.github.WhipDevelopment:CrashClaim:75abe3b665") implementation(platform("com.intellectualsites.bom:bom-1.18.x:1.20")) compileOnly("com.plotsquared:PlotSquared-Core") compileOnly("com.plotsquared:PlotSquared-Bukkit") compileOnly("com.github.TechFortress:GriefPrevention:16.18") + compileOnly("net.william278.huskclaims:huskclaims-common:1.0.1") + compileOnly("net.william278.huskclaims:huskclaims-bukkit:1.0.1") } java { diff --git a/gradle.properties b/gradle.properties index 463a255..b8c1d62 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -pluginVersion=1.3.6 +pluginVersion=1.4.0 diff --git a/src/main/java/io/th0rgal/protectionlib/ProtectionLib.java b/src/main/java/io/th0rgal/protectionlib/ProtectionLib.java index 9b54724..2c2d2d3 100644 --- a/src/main/java/io/th0rgal/protectionlib/ProtectionLib.java +++ b/src/main/java/io/th0rgal/protectionlib/ProtectionLib.java @@ -23,6 +23,7 @@ public static void init(JavaPlugin plugin) { handleCompatibility("PlotSquared", plugin, (m, p) -> new PlotSquaredCompat(m, p)); handleCompatibility("CrashClaim", plugin, (m, p) -> new CrashClaimCompat(m, p)); handleCompatibility("GriefPrevention", plugin, (m, p) -> new GriefPreventionCompat(m, p)); + handleCompatibility("HuskClaims", plugin, (m, p) -> new HuskClaimCompat(m, p)); } public static boolean canBuild(Player player, Location target) { diff --git a/src/main/java/io/th0rgal/protectionlib/compatibilities/HuskClaimCompat.java b/src/main/java/io/th0rgal/protectionlib/compatibilities/HuskClaimCompat.java new file mode 100644 index 0000000..60abc8c --- /dev/null +++ b/src/main/java/io/th0rgal/protectionlib/compatibilities/HuskClaimCompat.java @@ -0,0 +1,64 @@ +package io.th0rgal.protectionlib.compatibilities; + +import io.th0rgal.protectionlib.ProtectionCompatibility; +import net.william278.cloplib.operation.OperationType; +import net.william278.huskclaims.api.BukkitHuskClaimsAPI; +import net.william278.huskclaims.api.HuskClaimsAPI; +import net.william278.huskclaims.position.Position; +import net.william278.huskclaims.trust.TrustLevel; +import net.william278.huskclaims.user.OnlineUser; +import org.bukkit.Location; +import org.bukkit.entity.Player; +import org.bukkit.plugin.Plugin; +import org.bukkit.plugin.java.JavaPlugin; + +import java.util.Optional; + +public class HuskClaimCompat extends ProtectionCompatibility { + + private final HuskClaimsAPI huskClaimsCommon; + private final BukkitHuskClaimsAPI huskClaimsBukkit; + + public HuskClaimCompat(JavaPlugin mainPlugin, Plugin plugin) { + super(mainPlugin, plugin); + huskClaimsCommon = HuskClaimsAPI.getInstance(); + huskClaimsBukkit = BukkitHuskClaimsAPI.getInstance(); + } + + @Override + public boolean canBuild(Player player, Location target) { + OnlineUser onlineUser = huskClaimsCommon.getOnlineUser(player.getUniqueId()); + Position position = huskClaimsBukkit.getPosition(target); + + Optional trustLevel = huskClaimsBukkit.getTrustLevelAt(position, onlineUser); + return trustLevel.isPresent() && trustLevel.get().getFlags().contains(OperationType.BLOCK_PLACE); + } + + @Override + public boolean canBreak(Player player, Location target) { + OnlineUser onlineUser = huskClaimsCommon.getOnlineUser(player.getUniqueId()); + Position position = huskClaimsBukkit.getPosition(target); + + Optional trustLevel = huskClaimsBukkit.getTrustLevelAt(position, onlineUser); + return trustLevel.isPresent() && trustLevel.get().getFlags().contains(OperationType.BLOCK_BREAK); + } + + @Override + public boolean canInteract(Player player, Location target) { + OnlineUser onlineUser = huskClaimsCommon.getOnlineUser(player.getUniqueId()); + Position position = huskClaimsBukkit.getPosition(target); + + OperationType operationType = target.getBlock().getType().isBlock() ? OperationType.BLOCK_INTERACT : OperationType.ENTITY_INTERACT; + Optional trustLevel = huskClaimsBukkit.getTrustLevelAt(position, onlineUser); + return trustLevel.isPresent() && trustLevel.get().getFlags().contains(operationType); + } + + @Override + public boolean canUse(Player player, Location target) { + OnlineUser onlineUser = huskClaimsCommon.getOnlineUser(player.getUniqueId()); + Position position = huskClaimsBukkit.getPosition(target); + + Optional trustLevel = huskClaimsBukkit.getTrustLevelAt(position, onlineUser); + return trustLevel.isPresent() && trustLevel.get().getFlags().contains(OperationType.BLOCK_INTERACT); + } +}