Package org.bukkit.entity

Examples of org.bukkit.entity.Vehicle


    getRailTracker().setLiveRailLogic();

    // Perform some (CraftBukkit) events
    Location from = entity.getLastLocation();
    Location to = entity.getLocation();
    Vehicle vehicle = entity.getEntity();
    CommonUtil.callEvent(new VehicleUpdateEvent(vehicle));
    if (!from.equals(to)) {
      // Execute move events
      CommonUtil.callEvent(new VehicleMoveEvent(vehicle, from, to));
      for (org.bukkit.block.Block sign : this.getBlockTracker().getActiveSigns()) {
View Full Code Here


     *            the event
     */
    @EventHandler(
            ignoreCancelled = true, priority = EventPriority.MONITOR)
    public void onVehicleMove(final VehicleMoveEvent event) {
        final Vehicle vehicle = event.getVehicle();
        final EntityType entityType = vehicle.getType();
        if (!normalVehicles.contains(entityType)) {
            // A little extra sweep to check for debug flags.
            normalVehicles.add(entityType);
            if (MovingConfig.getConfig(vehicle.getWorld().getName()).debug) {
                System.out.println("[NoCheatPlus] VehicleMoveEvent fired for: " + entityType);
            }
        }
        // TODO: Might account for the case of a player letting the vehicle move but not themself (do mind latency).
        // Mind that players could be riding horses inside of minecarts etc.
        if (vehicle.getVehicle() != null) {
            // Do ignore events for vehicles inside of other vehicles.
            return;
        }
        onVehicleMove(vehicle, event.getFrom(), event.getTo(), false);
    }
View Full Code Here

  }

  public @Override void onVehicleMove(VehicleMoveEvent event)
  {

    Vehicle vehicle = event.getVehicle();
    Entity passenger = vehicle.getPassenger();

    if(passenger != null)
    {
      EpicZonePlayer ezp = General.getPlayer(passenger.getEntityId());

      if(ezp != null)
      {
        int playerHeight = event.getTo().getBlockY();
        Point playerPoint = new Point(event.getTo().getBlockX(), event.getTo().getBlockZ());

        if(General.ShouldCheckPlayer(ezp))
        {
          if(!ezp.isTeleporting())
          {
            if(ezp.getCurrentLocation() == null){ezp.setCurrentLocation(event.getFrom());}
            if(!VehicleWithinZoneLogic((Player)passenger, ezp, playerHeight, playerPoint))
            {
              ezp.setIsTeleporting(true);
              vehicle.teleportTo(ezp.getCurrentLocation());
              vehicle.setVelocity(zero);
              ezp.setIsTeleporting(false);
              //event.setTo(ezp.getCurrentLocation());
              //event.setCancelled(true);
            }
            else
View Full Code Here

    public
    @Override
    void onVehicleMove(VehicleMoveEvent event)
    {
        Vehicle vehicle = event.getVehicle();
        Entity passenger = vehicle.getPassenger();
        if (passenger != null)
        {
            if (passenger instanceof Player)
            {
                Player player = (Player) passenger;
                if (!General.PlayerMovementLogic(player, event.getFrom(), event.getTo()))
                {
                    Location loc = General.getPlayer(player.getName()).getCurrentLocation();
                    loc.setY(loc.getY() + 1);
                    vehicle.teleport(loc);
                    vehicle.setVelocity(zero);
                }
            }
        }
    }
View Full Code Here

  }

  public @Override void onVehicleMove(VehicleMoveEvent event)
  {

    Vehicle vehicle = event.getVehicle();
    Entity passenger = vehicle.getPassenger();

    if(passenger != null)
    {
      EpicZonePlayer ezp = General.getPlayer(passenger.getEntityId());

      if(ezp != null)
      {
        int playerHeight = event.getTo().getBlockY();
        Point playerPoint = new Point(event.getTo().getBlockX(), event.getTo().getBlockZ());

        if(General.ShouldCheckPlayer(ezp))
        {
          if(!ezp.isTeleporting())
          {
            if(ezp.getCurrentLocation() == null){ezp.setCurrentLocation(event.getFrom());}
            if(!VehicleWithinZoneLogic((Player)passenger, ezp, playerHeight, playerPoint))
            {
              ezp.setIsTeleporting(true);
              vehicle.teleportTo(ezp.getCurrentLocation());
              vehicle.setVelocity(zero);
              ezp.setIsTeleporting(false);
              //event.setTo(ezp.getCurrentLocation());
              //event.setCancelled(true);
            }
            else
View Full Code Here

        if(!EventUtil.passesFilter(event)) return;

        if(!event.getVehicle().getWorld().isChunkLoaded(event.getVehicle().getLocation().getBlockX() >> 4, event.getVehicle().getLocation().getBlockZ() >> 4))
            return;

        Vehicle vehicle = event.getVehicle();

        if (!(vehicle instanceof Minecart)) return;

        if(!(event.getEntered() instanceof Player))
            event.setCancelled(true);
View Full Code Here

    @EventHandler(priority = EventPriority.HIGH)
    public void onVehicleExit(VehicleExitEvent event) {

        if(!EventUtil.passesFilter(event)) return;

        Vehicle vehicle = event.getVehicle();

        if (!(vehicle instanceof Boat)) return;

        CraftBookPlugin.inst().getServer().getScheduler().runTaskLater(CraftBookPlugin.inst(), new Decay((Boat) vehicle), delay);
    }
View Full Code Here

    @EventHandler(priority = EventPriority.HIGH)
    public void onVehicleExit(VehicleExitEvent event) {

        if(!EventUtil.passesFilter(event)) return;

        Vehicle vehicle = event.getVehicle();

        if (!(vehicle instanceof RideableMinecart)) return;

        CraftBookPlugin.inst().getServer().getScheduler().runTaskLater(CraftBookPlugin.inst(), new Decay((RideableMinecart) vehicle), delay);
    }
View Full Code Here

    }

    @EventHandler
    public void vehicleMove(VehicleMoveEvent event) {
        if (event.getVehicle().getPassenger() instanceof Player) {
            Vehicle v = event.getVehicle();
            Player p = (Player) v.getPassenger();
            PortalPlayerSession ps = this.plugin.getPortalSession(p);
            ps.setStaleLocation(v.getLocation(), MoveType.VEHICLE_MOVE);

            if (ps.isStaleLocation()) {
                return;
            }

            // Teleport the Player
            teleportVehicle(p, v, event.getTo());
        } else {
            MVPortal portal = this.plugin.getPortalManager().getPortal(event.getFrom());
            if ((portal != null) && (portal.getTeleportNonPlayers())) {
                MVDestination dest = portal.getDestination();
                if (dest == null || dest instanceof InvalidDestination)
                    return;

                // Check the portal's frame.
                if (!portal.isFrameValid(event.getVehicle().getLocation())) {
                    return;
                }

                Vector vehicleVec = event.getVehicle().getVelocity();
                Location target = dest.getLocation(event.getVehicle());
                if (dest instanceof PortalDestination) {
                    PortalDestination pd = (PortalDestination) dest;
                    // Translate the direction of travel.
                    vehicleVec = this.locationManipulation.getTranslatedVector(vehicleVec, pd.getOrientationString());
                }

                this.setVehicleVelocity(vehicleVec, dest, event.getVehicle());

                Entity formerPassenger = event.getVehicle().getPassenger();
                event.getVehicle().eject();

                Vehicle newVehicle = target.getWorld().spawn(target, event.getVehicle().getClass());

                if (formerPassenger != null) {
                    formerPassenger.teleport(target);
                    newVehicle.setPassenger(formerPassenger);
                }

                this.setVehicleVelocity(vehicleVec, dest, newVehicle);

                // remove the old one
View Full Code Here

            v.setPassenger(p);
            return false;
        }

        // Now create a new vehicle:
        Vehicle newVehicle = toLocation.getWorld().spawn(toLocation, v.getClass());

        // Set the vehicle's velocity to ours.
        this.setVehicleVelocity(v.getVelocity(), to, newVehicle);

        // Set the new player
        newVehicle.setPassenger(p);

        // They did teleport. Let's delete the old vehicle.
        v.remove();

        return true;
View Full Code Here

TOP

Related Classes of org.bukkit.entity.Vehicle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.