mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-01-13 11:41:43 +01:00
Polish the fix from the last commit and straighten some other multiworld issues in the move handler.
This commit is contained in:
parent
714e75eb95
commit
60c3ed4f6b
@ -108,6 +108,11 @@ public void registerEvents() {
|
||||
}
|
||||
}
|
||||
|
||||
// unsure if anyone actually started using this yet, but just in case...
|
||||
public static boolean checkMove(WorldGuardPlugin plugin, Player player, World world, Location from, Location to) {
|
||||
return checkMove(plugin, player, from, to); // drop world since it used to be mishandled
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles movement related events, including changing gamemode, sending
|
||||
* greeting/farewell messages, etc.
|
||||
@ -115,7 +120,7 @@ public void registerEvents() {
|
||||
* although WGBukkit.getPlugin() may be used.
|
||||
* @return true if the movement should not be allowed
|
||||
*/
|
||||
public static boolean checkMove(WorldGuardPlugin plugin, Player player, World world, Location from, Location to) {
|
||||
public static boolean checkMove(WorldGuardPlugin plugin, Player player, Location from, Location to) {
|
||||
PlayerFlagState state = plugin.getFlagStateManager().getState(player);
|
||||
|
||||
//Flush states in multiworld scenario
|
||||
@ -124,10 +129,14 @@ public static boolean checkMove(WorldGuardPlugin plugin, Player player, World wo
|
||||
state = plugin.getFlagStateManager().getState(player);
|
||||
}
|
||||
|
||||
World world = from.getWorld();
|
||||
World toWorld = to.getWorld();
|
||||
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||
boolean hasBypass = plugin.getGlobalRegionManager().hasBypass(player, world);
|
||||
boolean hasRemoteBypass = plugin.getGlobalRegionManager().hasBypass(player, toWorld);
|
||||
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(world);
|
||||
RegionManager mgr = plugin.getGlobalRegionManager().get(toWorld);
|
||||
Vector pt = new Vector(to.getBlockX(), to.getBlockY(), to.getBlockZ());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||
|
||||
@ -170,7 +179,7 @@ public static boolean checkMove(WorldGuardPlugin plugin, Player player, World wo
|
||||
*/
|
||||
|
||||
boolean entryAllowed = set.allows(DefaultFlag.ENTRY, localPlayer);
|
||||
if (!hasBypass && (!entryAllowed /*|| regionFull*/)) {
|
||||
if (!hasRemoteBypass && (!entryAllowed /*|| regionFull*/)) {
|
||||
String message = /*maxPlayerMessage != null ? maxPlayerMessage :*/ "You are not permitted to enter this area.";
|
||||
|
||||
player.sendMessage(ChatColor.DARK_RED + message);
|
||||
@ -179,8 +188,9 @@ public static boolean checkMove(WorldGuardPlugin plugin, Player player, World wo
|
||||
|
||||
// Have to set this state
|
||||
if (state.lastExitAllowed == null) {
|
||||
state.lastExitAllowed = mgr.getApplicableRegions(toVector(from))
|
||||
.allows(DefaultFlag.EXIT, localPlayer);
|
||||
state.lastExitAllowed = plugin.getGlobalRegionManager().get(world)
|
||||
.getApplicableRegions(toVector(from))
|
||||
.allows(DefaultFlag.EXIT, localPlayer);
|
||||
}
|
||||
|
||||
boolean exitAllowed = set.allows(DefaultFlag.EXIT, localPlayer);
|
||||
@ -285,7 +295,7 @@ public void onPlayerMove(PlayerMoveEvent event) {
|
||||
if (event.getFrom().getBlockX() != event.getTo().getBlockX()
|
||||
|| event.getFrom().getBlockY() != event.getTo().getBlockY()
|
||||
|| event.getFrom().getBlockZ() != event.getTo().getBlockZ()) {
|
||||
boolean result = checkMove(plugin, player, world, event.getFrom(), event.getTo());
|
||||
boolean result = checkMove(plugin, player, event.getFrom(), event.getTo());
|
||||
if (result) {
|
||||
Location newLoc = event.getFrom();
|
||||
newLoc.setX(newLoc.getBlockX() + 0.5);
|
||||
@ -1377,7 +1387,7 @@ public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
LocalPlayer localPlayer = plugin.wrapPlayer(event.getPlayer());
|
||||
|
||||
if (cfg.usePlayerTeleports) {
|
||||
boolean result = checkMove(plugin, event.getPlayer(), event.getPlayer().getWorld(), event.getFrom(), event.getTo());
|
||||
boolean result = checkMove(plugin, event.getPlayer(), event.getFrom(), event.getTo());
|
||||
if (result) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
@ -87,7 +87,7 @@ public void onVehicleMove(VehicleMoveEvent event) {
|
||||
if (event.getFrom().getBlockX() != event.getTo().getBlockX()
|
||||
|| event.getFrom().getBlockY() != event.getTo().getBlockY()
|
||||
|| event.getFrom().getBlockZ() != event.getTo().getBlockZ()) {
|
||||
boolean result = WorldGuardPlayerListener.checkMove(plugin, player, world, event.getFrom(), event.getTo());
|
||||
boolean result = WorldGuardPlayerListener.checkMove(plugin, player, event.getFrom(), event.getTo());
|
||||
if (result) {
|
||||
vehicle.setVelocity(new org.bukkit.util.Vector(0,0,0));
|
||||
vehicle.teleport(event.getFrom());
|
||||
|
Loading…
Reference in New Issue
Block a user