From f48d1cf9b5991530b51335ed4058a391eaa097b2 Mon Sep 17 00:00:00 2001 From: Angeschossen <24841122+Angeschossen@users.noreply.github.com> Date: Fri, 13 Dec 2024 18:09:28 +0100 Subject: [PATCH 1/5] new version lands --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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") From 0d6e4063e41f2e3ddb38089af27dad2775ff6b8e Mon Sep 17 00:00:00 2001 From: Angeschossen <24841122+Angeschossen@users.noreply.github.com> Date: Fri, 13 Dec 2024 18:09:39 +0100 Subject: [PATCH 2/5] check bypass perms and minimize --- .../compatibilities/LandsCompat.java | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java b/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java index c3ca1f3..a6cbc5b 100644 --- a/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java +++ b/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java @@ -6,6 +6,7 @@ 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 +28,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 +38,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 +48,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 +56,13 @@ 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); } 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, false); } - } From a1e45ad7af93d8da9198d8599891fbc2e83e011c Mon Sep 17 00:00:00 2001 From: Angeschossen <24841122+Angeschossen@users.noreply.github.com> Date: Fri, 13 Dec 2024 18:13:28 +0100 Subject: [PATCH 3/5] send msg --- .../io/th0rgal/protectionlib/compatibilities/LandsCompat.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java b/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java index a6cbc5b..8aad249 100644 --- a/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java +++ b/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java @@ -63,6 +63,6 @@ public boolean canUse(Player player, Location target) { private boolean hasFlag(Location location, Player player, RoleFlag flag) { LandWorld landWorld = landsIntegration.getWorld(location.getWorld()); - return landWorld == null || landWorld.hasRoleFlag(landsIntegration.getLandPlayer(player.getUniqueId()), location, flag, null, false); + return landWorld == null || landWorld.hasRoleFlag(landsIntegration.getLandPlayer(player.getUniqueId()), location, flag, null, true); } } From dcb9e2dffbe9a51d5726f4a6566c12b0faffc52f Mon Sep 17 00:00:00 2001 From: Angeschossen <24841122+Angeschossen@users.noreply.github.com> Date: Fri, 13 Dec 2024 18:20:24 +0100 Subject: [PATCH 4/5] doc --- .../protectionlib/compatibilities/LandsCompat.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java b/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java index 8aad249..4583c3b 100644 --- a/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java +++ b/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java @@ -4,8 +4,6 @@ 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; @@ -61,6 +59,15 @@ public boolean canUse(Player player, Location target) { return hasFlag(target, player, Flags.INTERACT_GENERAL); } + /** + * Checks if a player's role has a flag at the given position. + * This does check 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) { LandWorld landWorld = landsIntegration.getWorld(location.getWorld()); return landWorld == null || landWorld.hasRoleFlag(landsIntegration.getLandPlayer(player.getUniqueId()), location, flag, null, true); From ea730e2a823f69494adf1c61d9b28063227c2dfd Mon Sep 17 00:00:00 2001 From: Angeschossen <24841122+Angeschossen@users.noreply.github.com> Date: Fri, 13 Dec 2024 18:22:13 +0100 Subject: [PATCH 5/5] doc bypass perms --- .../io/th0rgal/protectionlib/compatibilities/LandsCompat.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java b/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java index 4583c3b..cb60283 100644 --- a/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java +++ b/src/main/java/io/th0rgal/protectionlib/compatibilities/LandsCompat.java @@ -61,7 +61,7 @@ public boolean canUse(Player player, Location target) { /** * Checks if a player's role has a flag at the given position. - * This does check wilderness flags (/lands admin menu) as well. + * 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