Search in sources :

Example 1 with PlayerBlockLocationEvent

use of io.github.wysohn.triggerreactor.bukkit.manager.event.PlayerBlockLocationEvent in project TriggerReactor by wysohn.

the class PlayerLocationManager method onMove.

@EventHandler(priority = EventPriority.HIGHEST)
public void onMove(PlayerMoveEvent e) {
    if (e.getTo() == e.getFrom())
        return;
    Player player = e.getPlayer();
    SimpleLocation from = getCurrentBlockLocation(player.getUniqueId());
    SimpleLocation to = LocationUtil.convertToSimpleLocation(e.getTo());
    PlayerBlockLocationEvent pble = new PlayerBlockLocationEvent(player, from, to);
    onMove(new BukkitPlayerBlockLocationEvent(pble));
    if (pble.isCancelled()) {
        Location loc = LocationUtil.convertToBukkitLocation(from);
        loc.setPitch(e.getPlayer().getLocation().getPitch());
        loc.setYaw(e.getPlayer().getLocation().getPitch());
        e.setFrom(loc);
        e.setTo(loc);
    }
}
Also used : BukkitPlayerBlockLocationEvent(io.github.wysohn.triggerreactor.bukkit.bridge.event.BukkitPlayerBlockLocationEvent) PlayerBlockLocationEvent(io.github.wysohn.triggerreactor.bukkit.manager.event.PlayerBlockLocationEvent) BukkitPlayerBlockLocationEvent(io.github.wysohn.triggerreactor.bukkit.bridge.event.BukkitPlayerBlockLocationEvent) Player(org.bukkit.entity.Player) SimpleLocation(io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation) SimpleLocation(io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Aggregations

BukkitPlayerBlockLocationEvent (io.github.wysohn.triggerreactor.bukkit.bridge.event.BukkitPlayerBlockLocationEvent)1 PlayerBlockLocationEvent (io.github.wysohn.triggerreactor.bukkit.manager.event.PlayerBlockLocationEvent)1 SimpleLocation (io.github.wysohn.triggerreactor.core.manager.location.SimpleLocation)1 Location (org.bukkit.Location)1 Player (org.bukkit.entity.Player)1 EventHandler (org.bukkit.event.EventHandler)1