Fix deny-teleport flag: Fixes #2128

This commit is contained in:
Sauilitired 2019-01-22 10:43:29 +01:00
parent 7e56e47046
commit 8733dc6dab
No known key found for this signature in database
GPG Key ID: C0207FF7EA146678

View File

@ -619,8 +619,8 @@ import java.util.regex.Pattern;
public void onTeleport(PlayerTeleportEvent event) { public void onTeleport(PlayerTeleportEvent event) {
if (event.getTo() == null || event.getFrom() == null || !event.getFrom().getWorld() if (event.getTo() == null || event.getFrom() == null || !event.getFrom().getWorld()
.equals(event.getTo().getWorld())) { .equals(event.getTo().getWorld())) {
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta(PlotPlayer.META_LOCATION); final Object lastLoc = BukkitUtil.getPlayer(event.getPlayer()).deleteMeta(PlotPlayer.META_LOCATION);
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta(PlotPlayer.META_LAST_PLOT); final Object lastPlot = BukkitUtil.getPlayer(event.getPlayer()).deleteMeta(PlotPlayer.META_LAST_PLOT);
org.bukkit.Location to = event.getTo(); org.bukkit.Location to = event.getTo();
if (to != null) { if (to != null) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -632,9 +632,21 @@ import java.util.regex.Pattern;
} }
Plot plot = area.getPlot(loc); Plot plot = area.getPlot(loc);
if (plot != null) { if (plot != null) {
final boolean result = Flags.DENY_TELEPORT.allowsTeleport(pp, plot);
if (!result) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
event.setCancelled(true);
if (lastLoc != null) {
pp.setMeta(PlotPlayer.META_LOCATION, lastLoc);
}
if (lastPlot != null) {
pp.setMeta(PlotPlayer.META_LAST_PLOT, lastPlot);
}
} else {
plotEntry(pp, plot); plotEntry(pp, plot);
} }
} }
}
return; return;
} }
playerMove(event); playerMove(event);