Do not allow teleport inside of regions with the chorus-fruit-teleport deny flag set

This commit is contained in:
Max Lee 2016-05-30 17:35:40 +02:00 committed by wizjany
parent 5c9ba2e22e
commit e38d98da00

View File

@ -380,11 +380,15 @@ public void onPlayerTeleport(PlayerTeleportEvent event) {
}
try {
if (event.getCause() == TeleportCause.CHORUS_FRUIT) {
if (!plugin.getGlobalRegionManager().hasBypass(localPlayer, world)
&& !(setFrom.allows(DefaultFlag.CHORUS_TELEPORT, localPlayer))) {
player.sendMessage(ChatColor.DARK_RED + "You're not allowed to teleport from here.");
event.setCancelled(true);
return;
if (!plugin.getGlobalRegionManager().hasBypass(localPlayer, world)) {
boolean allowFrom = setFrom.allows(DefaultFlag.CHORUS_TELEPORT, localPlayer);
boolean allowTo = set.allows(DefaultFlag.CHORUS_TELEPORT, localPlayer);
if (!allowFrom || !allowTo) {
player.sendMessage(ChatColor.DARK_RED + "You're not allowed to teleport " +
(!allowFrom ? "from here." : "there."));
event.setCancelled(true);
return;
}
}
}
} catch (NoSuchFieldError ignored) {}