mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-15 15:16:06 +01:00
Ignore session reset if player doesn't move a block.
So technically we do this block check in Session#testMoveTo, but the /wg flushstates command can force a session re-initialization even if the player hasn't moved a full block yet. The amount of logic going on between the event call and the point where we test that force boolean is rather lengthy though, so ignoring it for the time being may be worth it. TL;DR: Don't want WG in timings for PlayerMoveEvent needlessly.
This commit is contained in:
parent
d37f015f0c
commit
789405d116
@ -77,6 +77,14 @@ public void onVehicleEnter(VehicleEnterEvent event) {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
|
Location from = event.getFrom();
|
||||||
|
Location to = event.getTo();
|
||||||
|
if (from.getBlockX() == to.getBlockX()
|
||||||
|
&& from.getBlockY() == to.getBlockY()
|
||||||
|
&& from.getBlockZ() == to.getBlockZ()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
LocalPlayer localPlayer = plugin.wrapPlayer(player);
|
||||||
|
|
||||||
@ -89,15 +97,15 @@ public void onPlayerMove(PlayerMoveEvent event) {
|
|||||||
} else if (event.getPlayer().getVehicle() != null && event.getPlayer().getVehicle() instanceof Horse) {
|
} else if (event.getPlayer().getVehicle() != null && event.getPlayer().getVehicle() instanceof Horse) {
|
||||||
moveType = MoveType.RIDE;
|
moveType = MoveType.RIDE;
|
||||||
}
|
}
|
||||||
com.sk89q.worldedit.util.Location weLocation = session.testMoveTo(localPlayer, BukkitAdapter.adapt(event.getTo()), moveType);
|
com.sk89q.worldedit.util.Location weLocation = session.testMoveTo(localPlayer, BukkitAdapter.adapt(to), moveType);
|
||||||
|
|
||||||
if (weLocation != null) {
|
if (weLocation != null) {
|
||||||
final Location override = BukkitAdapter.adapt(weLocation);
|
final Location override = BukkitAdapter.adapt(weLocation);
|
||||||
override.setX(override.getBlockX() + 0.5);
|
override.setX(override.getBlockX() + 0.5);
|
||||||
override.setY(override.getBlockY());
|
override.setY(override.getBlockY());
|
||||||
override.setZ(override.getBlockZ() + 0.5);
|
override.setZ(override.getBlockZ() + 0.5);
|
||||||
override.setPitch(event.getTo().getPitch());
|
override.setPitch(to.getPitch());
|
||||||
override.setYaw(event.getTo().getYaw());
|
override.setYaw(to.getYaw());
|
||||||
|
|
||||||
event.setTo(override.clone());
|
event.setTo(override.clone());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user