diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java index a80aa6b73..611303552 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/PlayerEvents.java @@ -695,7 +695,11 @@ import java.util.regex.Pattern; Plot plot = area.getPlot(location); if (plot != null) { final boolean result = Flags.DENY_TELEPORT.allowsTeleport(plotPlayer, plot); - if (!result) { + // there is one possibility to still allow teleportation: + // to is identical to the plot's home location, and untrusted-visit is true + // i.e. untrusted-visit can override deny-teleport + // this is acceptable, because otherwise it wouldn't make sense to have both flags set + if (!result && !(Flags.UNTRUSTED_VISIT.isTrue(plot) && plot.getHome().equals(BukkitUtil.getLocationFull(to)))) { MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_ENTRY_DENIED); event.setCancelled(true); diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java index ebf67e075..a6f49ca66 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/BukkitUtil.java @@ -215,6 +215,12 @@ import java.util.Set; MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ())); } + public static Location getLocationFull(@NonNull final org.bukkit.Location location) { + return new Location(location.getWorld().getName(), MathMan.roundInt(location.getX()), + MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), + location.getYaw(), location.getPitch()); + } + public static org.bukkit.Location getLocation(@NonNull final Location location) { return new org.bukkit.Location(getWorld(location.getWorld()), location.getX(), location.getY(), location.getZ()); diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Visit.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Visit.java index ea5647b66..5c38ea63f 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Visit.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Visit.java @@ -5,6 +5,7 @@ import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Settings; +import com.github.intellectualsites.plotsquared.plot.flag.Flags; import com.github.intellectualsites.plotsquared.plot.object.*; import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MathMan; @@ -129,7 +130,8 @@ import java.util.concurrent.CompletableFuture; return CompletableFuture.completedFuture(false); } } else { - if (!Permissions.hasPermission(player, Captions.PERMISSION_VISIT_OTHER)) { + if (!Permissions.hasPermission(player, Captions.PERMISSION_VISIT_OTHER) && + !Flags.UNTRUSTED_VISIT.isTrue(plot)) { Captions.NO_PERMISSION.send(player, Captions.PERMISSION_VISIT_OTHER); return CompletableFuture.completedFuture(false); } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java index 1da139665..b21d6fb25 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java @@ -119,6 +119,7 @@ public final class Flags { }; public static final TeleportDenyFlag DENY_TELEPORT = new TeleportDenyFlag("deny-teleport"); public static final BooleanFlag DENY_EXIT = new BooleanFlag("deny-exit"); + public static final BooleanFlag UNTRUSTED_VISIT = new BooleanFlag("untrusted-visit"); private static final HashMap> flags;