diff --git a/build.gradle.kts b/build.gradle.kts index 59b8a0b..0096a97 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -35,7 +35,7 @@ dependencies { exclude("org.spongepowered:configurate-hocon") exclude("com.mojang:brigadier") } - compileOnly("com.github.angeschossen:LandsAPI:7.0.2") + compileOnly("com.github.angeschossen:LandsAPI:7.10.13") implementation(platform("com.intellectualsites.bom:bom-1.18.x:1.20")) compileOnly("com.plotsquared:PlotSquared-Core") compileOnly("com.plotsquared:PlotSquared-Bukkit") diff --git a/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java b/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java index c3ca1f3..cb60283 100644 --- a/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java +++ b/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java @@ -4,8 +4,7 @@ import me.angeschossen.lands.api.LandsIntegration; import me.angeschossen.lands.api.flags.type.Flags; import me.angeschossen.lands.api.flags.type.RoleFlag; -import me.angeschossen.lands.api.land.Area; -import me.angeschossen.lands.api.land.Land; +import me.angeschossen.lands.api.land.LandWorld; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; @@ -27,8 +26,7 @@ public LandsCompat(JavaPlugin mainPlugin, Plugin plugin) { */ @Override public boolean canBuild(Player player, Location target) { - Land land = getLand(target); - return land == null || land.isTrusted(player.getUniqueId()) || hasFlag(target, player, Flags.BLOCK_PLACE); + return hasFlag(target, player, Flags.BLOCK_PLACE); } /** @@ -38,8 +36,7 @@ public boolean canBuild(Player player, Location target) { */ @Override public boolean canBreak(Player player, Location target) { - Land land = getLand(target); - return land == null || land.isTrusted(player.getUniqueId()) || hasFlag(target, player, Flags.BLOCK_BREAK); + return hasFlag(target, player, Flags.BLOCK_BREAK); } /** @@ -49,8 +46,7 @@ public boolean canBreak(Player player, Location target) { */ @Override public boolean canInteract(Player player, Location target) { - Land land = getLand(target); - return land == null || land.isTrusted(player.getUniqueId()) || hasFlag(target, player, Flags.INTERACT_GENERAL); + return hasFlag(target, player, Flags.INTERACT_GENERAL); } /** @@ -58,23 +54,22 @@ public boolean canInteract(Player player, Location target) { * @param target Place where the player seeks to use an item at a location * @return true if he can use the item at the location */ + @Override public boolean canUse(Player player, Location target) { - Land land = getLand(target); - return land == null || land.isTrusted(player.getUniqueId()) || hasFlag(target, player, Flags.INTERACT_GENERAL); - } - - private Land getLand(Location location) { - Area area = landsIntegration.getArea(location); - if (area == null) return null; - return area.getLand(); - } - - private Area getArea(Location location) { - return landsIntegration.getArea(location); + return hasFlag(target, player, Flags.INTERACT_GENERAL); } + /** + * Checks if a player's role has a flag at the given position. + * This does check bypass perms and wilderness flags (/lands admin menu) as well. + * + * @param location Location of interaction + * @param player Player that seeks to do stuff + * @param flag The Lands flag + * @return false if not allowed + */ private boolean hasFlag(Location location, Player player, RoleFlag flag) { - return getArea(location).hasRoleFlag(player.getUniqueId(), flag); + LandWorld landWorld = landsIntegration.getWorld(location.getWorld()); + return landWorld == null || landWorld.hasRoleFlag(landsIntegration.getLandPlayer(player.getUniqueId()), location, flag, null, true); } - }