Merge pull request #2506 from mindw0rm/DenyTeleportBugfix

Bugfixes for deny-teleport
This commit is contained in:
Matt 2019-10-23 14:37:20 -04:00 committed by GitHub
commit 32654e1f25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 33 deletions

View File

@ -679,37 +679,34 @@ import java.util.regex.Pattern;
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTeleport(PlayerTeleportEvent event) { public void onTeleport(PlayerTeleportEvent event) {
if (event.getTo() == null || event.getFrom() == null || !event.getFrom().getWorld() final Object lastLoc =
.equals(event.getTo().getWorld())) { BukkitUtil.getPlayer(event.getPlayer()).deleteMeta(PlotPlayer.META_LOCATION);
final Object lastLoc = final Object lastPlot =
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta(PlotPlayer.META_LOCATION); BukkitUtil.getPlayer(event.getPlayer()).deleteMeta(PlotPlayer.META_LAST_PLOT);
final Object lastPlot = org.bukkit.Location to = event.getTo();
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta(PlotPlayer.META_LAST_PLOT); if (to != null) {
org.bukkit.Location to = event.getTo(); Player player = event.getPlayer();
if (to != null) { PlotPlayer plotPlayer = PlotPlayer.wrap(player);
Player player = event.getPlayer(); Location location = BukkitUtil.getLocation(to);
PlotPlayer plotPlayer = PlotPlayer.wrap(player); PlotArea area = location.getPlotArea();
Location location = BukkitUtil.getLocation(to); if (area == null) {
PlotArea area = location.getPlotArea(); return;
if (area == null) { }
return; Plot plot = area.getPlot(location);
} if (plot != null) {
Plot plot = area.getPlot(location); final boolean result = Flags.DENY_TELEPORT.allowsTeleport(plotPlayer, plot);
if (plot != null) { if (!result) {
final boolean result = Flags.DENY_TELEPORT.allowsTeleport(plotPlayer, plot); MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT,
if (!result) { Captions.PERMISSION_ADMIN_ENTRY_DENIED);
MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, event.setCancelled(true);
Captions.PERMISSION_ADMIN_ENTRY_DENIED); if (lastLoc != null) {
event.setCancelled(true); plotPlayer.setMeta(PlotPlayer.META_LOCATION, lastLoc);
if (lastLoc != null) {
plotPlayer.setMeta(PlotPlayer.META_LOCATION, lastLoc);
}
if (lastPlot != null) {
plotPlayer.setMeta(PlotPlayer.META_LAST_PLOT, lastPlot);
}
} else {
plotEntry(plotPlayer, plot);
} }
if (lastPlot != null) {
plotPlayer.setMeta(PlotPlayer.META_LAST_PLOT, lastPlot);
}
} else {
plotEntry(plotPlayer, plot);
} }
} }
} }

View File

@ -22,14 +22,14 @@ public class TeleportDenyFlag extends EnumFlag {
result = !plot.getMembers().contains(player.getUUID()); result = !plot.getMembers().contains(player.getUUID());
break; break;
case "nonmembers": case "nonmembers":
result = !plot.isAdded(player.getUUID()); result = plot.isAdded(player.getUUID());
break; break;
case "nontrusted": case "nontrusted":
result = !plot.getTrusted().contains(player.getUUID()) && !plot result = plot.getTrusted().contains(player.getUUID()) || plot
.isOwner(player.getUUID()); .isOwner(player.getUUID());
break; break;
case "nonowners": case "nonowners":
result = !plot.isOwner(player.getUUID()); result = plot.isOwner(player.getUUID());
break; break;
default: default:
return true; return true;