Check movement with vehicle enter.

This commit is contained in:
sk89q 2015-01-17 19:25:15 -08:00
parent a3d2a1b127
commit 520f9e3fcf
2 changed files with 14 additions and 0 deletions

View File

@ -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();

View File

@ -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),