mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-23 11:06:13 +01:00
Check movement with vehicle enter.
This commit is contained in:
parent
a3d2a1b127
commit
520f9e3fcf
@ -32,6 +32,7 @@
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@ -58,6 +59,18 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
session.testMoveTo(player, event.getRespawnLocation(), MoveType.RESPAWN, true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onVehicleEnter(VehicleEnterEvent event) {
|
||||
Entity entity = event.getEntered();
|
||||
if (entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
Session session = plugin.getSessionManager().get(player);
|
||||
if (null != session.testMoveTo(player, event.getVehicle().getLocation(), MoveType.EMBARK, true)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
|
@ -29,6 +29,7 @@
|
||||
public enum MoveType {
|
||||
|
||||
RESPAWN(false),
|
||||
EMBARK(true),
|
||||
MOVE(true),
|
||||
TELEPORT(true),
|
||||
RIDE(true),
|
||||
|
Loading…
Reference in New Issue
Block a user