Add "chorus-fruit-teleport" flag to prevent teleporting with chorus fruits.

Fixes WORLDGUARD-3645.
This commit is contained in:
wizjany 2016-05-20 15:03:45 -04:00
parent 38dcdff0b6
commit a8591e536a
2 changed files with 13 additions and 1 deletions

View File

@ -53,6 +53,7 @@
import org.bukkit.plugin.PluginManager;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.Set;
import java.util.logging.Logger;
import java.util.regex.Pattern;
@ -367,6 +368,16 @@ public void onPlayerTeleport(PlayerTeleportEvent event) {
return;
}
}
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;
}
}
} catch (NoSuchElementException ignored) {}
}
}

View File

@ -100,6 +100,7 @@ public final class DefaultFlag {
public static final StateFlag ENTRY = new StateFlag("entry", true, RegionGroup.NON_MEMBERS);
public static final StateFlag EXIT = new StateFlag("exit", true, RegionGroup.NON_MEMBERS);
public static final StateFlag ENDERPEARL = new StateFlag("enderpearl", true);
public static final StateFlag CHORUS_TELEPORT = new StateFlag("chorus-fruit-teleport", true);
public static final StateFlag ENTITY_PAINTING_DESTROY = new StateFlag("entity-painting-destroy", true);
public static final StateFlag ENTITY_ITEM_FRAME_DESTROY = new StateFlag("entity-item-frame-destroy", true);
public static final StateFlag FALL_DAMAGE = new StateFlag("fall-damage", true);
@ -146,7 +147,7 @@ public final class DefaultFlag {
CREEPER_EXPLOSION, OTHER_EXPLOSION, ENDERDRAGON_BLOCK_DAMAGE, GHAST_FIREBALL, ENDER_BUILD,
DENY_MESSAGE, ENTRY_DENY_MESSAGE, EXIT_DENY_MESSAGE, EXIT_OVERRIDE, EXIT_VIA_TELEPORT,
GREET_MESSAGE, FAREWELL_MESSAGE, NOTIFY_ENTER, NOTIFY_LEAVE,
EXIT, ENTRY, LIGHTNING, ENTITY_PAINTING_DESTROY, ENDERPEARL,
EXIT, ENTRY, LIGHTNING, ENTITY_PAINTING_DESTROY, ENDERPEARL, CHORUS_TELEPORT,
ENTITY_ITEM_FRAME_DESTROY, FALL_DAMAGE, ITEM_PICKUP, ITEM_DROP, /*MAX_PLAYERS, MAX_PLAYERS_MESSAGE,*/
HEAL_AMOUNT, HEAL_DELAY, MIN_HEAL, MAX_HEAL,
FEED_DELAY, FEED_AMOUNT, MIN_FOOD, MAX_FOOD,