mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-23 19:16:40 +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.Listener;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
@ -58,6 +59,18 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
|
|||||||
session.testMoveTo(player, event.getRespawnLocation(), MoveType.RESPAWN, true);
|
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)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
public enum MoveType {
|
public enum MoveType {
|
||||||
|
|
||||||
RESPAWN(false),
|
RESPAWN(false),
|
||||||
|
EMBARK(true),
|
||||||
MOVE(true),
|
MOVE(true),
|
||||||
TELEPORT(true),
|
TELEPORT(true),
|
||||||
RIDE(true),
|
RIDE(true),
|
||||||
|
Loading…
Reference in New Issue
Block a user