Java 类org.bukkit.event.vehicle.VehicleMoveEvent 实例源码

项目:beaconz    文件:BeaconProjectileDefenseListener.java   
/**
 * Check if player comes within range of a beacon
 * @param event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onVehicleMove(VehicleMoveEvent event) {
    // Remember that teleporting is not detected as player movement..
    // If we want to catch movement by teleportation, we have to keep track of the players to-from by ourselves
    // Only proceed if there's been a move, not just a head move
    if (event.getFrom().getBlockX() == event.getTo().getBlockX() && event.getFrom().getBlockY() == event.getTo().getBlockY()
            && event.getFrom().getBlockZ() == event.getTo().getBlockZ()) {
        return;
    }
    World world = event.getTo().getWorld();
    if (!world.equals(getBeaconzWorld())) {
        return;
    }
    if (event.getVehicle().getPassenger() == null) {
        return;
    }
    if (!(event.getVehicle().getPassenger() instanceof Player)) {
        return;
    }
    Player player = (Player)event.getVehicle().getPassenger();
    fireOnPlayer(player, event.getFrom(), event.getTo());
}
项目:Kineticraft    文件:Restrictions.java   
@EventHandler
public void onVehicleMove(VehicleMoveEvent evt) {
    String fly = evt.getVehicle().getPassengers().stream().filter(e -> e instanceof Player).map(Entity::getName)
            .collect(Collectors.joining(", "));

    if (evt.getVehicle().getType() == EntityType.BOAT && !Flight.checkNearby(evt.getFrom(), Material.WATER, Material.STATIONARY_WATER)
            && fly.length() > 0 && evt.getTo().getY() > evt.getFrom().getY() && evt.getVehicle().getVelocity().getY() <= 0)
        Core.alertStaff("[BoatFly] " + ChatColor.GRAY + fly + " may be using BoatFly.");
}
项目:beaconz    文件:PlayerMovementListener.java   
/**
 * Handles movement inside a vehicle (or on a vehicle)
 * @param event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onVehicleMove(final VehicleMoveEvent event) {
    if (!event.getVehicle().getWorld().equals(getBeaconzWorld())) {
        return;
    }
    // Check if a player is in it
    Entity passenger = event.getVehicle().getPassenger();
    if (passenger != null && passenger instanceof Player) {
        Player player = (Player)passenger;
        Location from = event.getFrom();
        Location to = event.getTo();
        /*
        if (checkMove(player, event.getVehicle().getWorld(), from, to)) {
            // Vehicle should stop moving
            Vector direction = event.getVehicle().getLocation().getDirection();
            event.getVehicle().teleport(event.getVehicle().getLocation().add(from.toVector().subtract(to.toVector()).normalize()));
            event.getVehicle().getLocation().setDirection(direction);
            event.getVehicle().setVelocity(new Vector(0,0,0));
        }*/
        // Check potion effects for boats etc.
        if ((!(event.getVehicle() instanceof LivingEntity))) {
            for (PotionEffect effect : getPml().getTriangleEffects(player.getUniqueId())) {
                if (effect.getType().equals(PotionEffectType.SLOW)) {
                    double delay = effect.getAmplifier();
                    event.getVehicle().setVelocity(event.getVehicle().getVelocity().divide(new Vector(delay,delay,delay)));
                    break;
                }
            }
        }
        // Check if there are any other passengers
        for (Player pl : getBeaconzWorld().getPlayers()) {
            if (!pl.equals(player) && pl.isInsideVehicle() && pl.getVehicle().getEntityId() == event.getVehicle().getEntityId()) {
                //getLogger().info(pl.getName() + " inside vehicle of id " + pl.getVehicle().getEntityId());
                //getLogger().info("Event id = " + event.getVehicle().getEntityId());
                checkMove(pl, event.getVehicle().getWorld(), from, to);
            }
        }
    }
}
项目:PexelCore    文件:EventProcessor.java   
@EventHandler
private void onVehicleMove(final VehicleMoveEvent event) {
    if (event.getVehicle() instanceof Minecart) {
        //ProtectedArea area = Areas.findArea(event.getVehicle().getLocation());

    }
}
项目:Bits    文件:ConfigurationManager.java   
private static HashMap<String, Class> getEventClassAssociations()
    {
        HashMap<String, Class> classHashMap = new HashMap<String, Class>();
        classHashMap.put("block-break", BlockBreakEvent.class);
        classHashMap.put("block-place", BlockPlaceEvent.class);

//      classHashMap.put("entity-leash", PlayerLeashEntityEvent.class);
        classHashMap.put("entity-kill", EntityDeathEvent.class);
        classHashMap.put("entity-shear", PlayerShearEntityEvent.class);

        classHashMap.put("item-brew", BrewEvent.class);
        classHashMap.put("item-enchant", EnchantItemEvent.class);
        classHashMap.put("item-furnace", FurnaceExtractEvent.class);

        classHashMap.put("painting-create", HangingPlaceEvent.class);

        classHashMap.put("player-regenerate", EntityRegainHealthEvent.class);
        classHashMap.put("player-shoot", EntityShootBowEvent.class);
        classHashMap.put("player-chat", AsyncPlayerChatEvent.class);
        classHashMap.put("player-death", PlayerDeathEvent.class);
        classHashMap.put("player-sleep", PlayerBedEnterEvent.class);
        classHashMap.put("player-author", PlayerEditBookEvent.class);
        classHashMap.put("player-egg", PlayerEggThrowEvent.class);
        classHashMap.put("player-fish", PlayerFishEvent.class);
        classHashMap.put("player-eat", PlayerItemConsumeEvent.class);
        classHashMap.put("player-join", PlayerJoinEvent.class);
        classHashMap.put("player-move", PlayerMoveEvent.class);

        classHashMap.put("portal-create", PortalCreateEvent.class);

        classHashMap.put("vehicle-move", VehicleMoveEvent.class);

        classHashMap.put("world-change", PlayerChangedWorldEvent.class);

        return classHashMap;
    }
项目:ProjectAres    文件:FreezeListener.java   
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onVehicleMove(final VehicleMoveEvent event) {
    if(!event.getVehicle().isEmpty() && freeze.isFrozen(event.getVehicle().getPassenger())) {
        event.getVehicle().setVelocity(new Vector(0, 0, 0));
    }
}
项目:Statz    文件:DistanceTravelledVehicleListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMove(final VehicleMoveEvent event) {

    final PlayerStat stat = PlayerStat.DISTANCE_TRAVELLED;

    Vehicle vehicle = event.getVehicle();

    if (vehicle.getPassenger() == null)
        return;

    // Get player
    final Player player;

    String movementType;

    if (vehicle.getPassenger() instanceof Player) {
        player = (Player) vehicle.getPassenger();

        movementType = StatzUtil.getMovementType(player);
    } else {
        // No passenger on the passenger
        if (vehicle.getPassenger().getPassenger() == null)
            return;

        // There is no player riding.
        if (!(vehicle.getPassenger().getPassenger() instanceof Player))
            return;

        player = (Player) vehicle.getPassenger().getPassenger();

        movementType = StatzUtil.getMovementType(player);
    }

    // No player found, no movementType found.
    if (player == null || movementType == null)
        return;

    // Do general check
    if (!plugin.doGeneralCheck(player, stat))
        return;

    final double distTravelled = event.getFrom().distance(event.getTo());

    if (distTravelled == 0) {
        return;
    }

    final String movement = movementType;

    // Update value to new stat.
    plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat,
            StatzUtil.makeQuery("uuid", player.getUniqueId().toString(), "value", distTravelled, "moveType",
                    movement, "world", player.getWorld().getName()));

}
项目:parchment    文件:GlobalListenerHeavy.java   
@EventHandler
public void onVehicleMove(VehicleMoveEvent event) {
    plugin.handleEvent(event);
}
项目:PlotSquared    文件:PlayerEvents.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void vehicleMove(VehicleMoveEvent event) throws IllegalAccessException {
    final org.bukkit.Location from = event.getFrom();
    final org.bukkit.Location to = event.getTo();

    int toX, toZ;
    if ((toX = MathMan.roundInt(to.getX())) != MathMan.roundInt(from.getX()) | (toZ = MathMan.roundInt(to.getZ())) != MathMan.roundInt(from.getZ())) {
        Vehicle vehicle = event.getVehicle();

        // Check allowed


        Entity passenger = vehicle.getPassenger();

        if (passenger instanceof Player) {
            final Player player = (Player) passenger;
            // reset
            if (moveTmp == null) moveTmp = new PlayerMoveEvent(null, from, to);
            moveTmp.setFrom(from);
            moveTmp.setTo(to);
            moveTmp.setCancelled(false);
            fieldPlayer.set(moveTmp, player);

            List<Entity> passengers;
            if (v112) passengers = vehicle.getPassengers();
            else passengers = null;

            this.playerMove(moveTmp);
            org.bukkit.Location dest;
            if (moveTmp.isCancelled()) {
                dest = from;
            } else if (MathMan.roundInt(moveTmp.getTo().getX()) != toX || MathMan.roundInt(moveTmp.getTo().getZ()) != toZ) {
                dest = to;
            } else {
                dest = null;
            }
            if (dest != null) {
                if (passengers != null) {
                    vehicle.eject();
                    vehicle.setVelocity(new Vector(0d, 0d, 0d));
                    vehicle.teleport(dest);
                    for (final Entity entity : passengers) vehicle.addPassenger(entity);
                } else {
                    vehicle.eject();
                    vehicle.setVelocity(new Vector(0d, 0d, 0d));
                    vehicle.teleport(dest);
                    vehicle.setPassenger(player);
                }
                return;
            }
        }
        if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
            switch (vehicle.getType()) {
                case MINECART:
                case MINECART_CHEST:
                case MINECART_COMMAND:
                case MINECART_FURNACE:
                case MINECART_HOPPER:
                case MINECART_MOB_SPAWNER:
                case ENDER_CRYSTAL:
                case MINECART_TNT:
                case BOAT: {
                    List<MetadataValue> meta = vehicle.getMetadata("plot");
                    Plot toPlot = BukkitUtil.getLocation(to).getPlot();
                    if (!meta.isEmpty()) {
                        Plot origin = (Plot) meta.get(0).value();
                        if (!origin.getBasePlot(false).equals(toPlot)) {
                            vehicle.remove();
                        }
                    } else if (toPlot != null) {
                        vehicle.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, toPlot));
                    }
                }
            }
        }
    }
}
项目:Abyss    文件:VehicleListener.java   
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onVehicleMove(final VehicleMoveEvent event) {
    // Do portal logic. We ignore the return value because we couldn't use it anyways.
    plugin.usePortal(event.getVehicle(), event.getFrom(), event.getTo());

}
项目:Demigods3    文件:MoveListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onBattleVehicleMove(VehicleMoveEvent event) {
    onBattleMoveEvent(event.getVehicle(), event.getTo(), event.getFrom());
    onFlagMoveEvent(event.getVehicle(), event.getTo(), event.getFrom());
}