@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
  public void onVehicleMove(VehicleMoveEvent event) {

    if (((event.getTo().getBlockX() != event.getFrom().getBlockX())
        || (event.getTo().getBlockY() != event.getFrom().getBlockY())
        || (event.getTo().getBlockZ() != event.getFrom().getBlockZ()))) {

      Location from, to;
      Player player =
          (event.getVehicle().getPassenger() instanceof Player
              ? (Player) event.getVehicle().getPassenger()
              : null);
      if (player == null) {
        return;
      }

      if (!shouldTrackPlayer(player, Refs.TRACK_PLAYER_MOVE)) {
        return;
      }

      from = event.getFrom();
      to = event.getTo();
      if (from.getWorld().equals(to.getWorld())) {
        if (from.distance(to) < 10) {
          StatUtils.instance.modifyStatEntity(
              player, "vehicle", event.getVehicle(), (int) Math.ceil(from.distance(to)));
        }
      }
    }
  }
  /** @param event */
  @EventHandler(priority = EventPriority.HIGH)
  public void onVehicleMove(VehicleMoveEvent event) {
    Vehicle v = event.getVehicle();
    Entity entity = v.getPassenger();

    if (plugin.getSettingsManager().isBlacklistedWorld(v.getLocation().getWorld())) {
      return;
    }

    if (!(entity instanceof Player)) {
      return;
    }

    plugin
        .getPlayerListener()
        .onPlayerMove(new PlayerMoveEvent((Player) entity, event.getFrom(), event.getTo()));
  }
  @Override
  public void onVehicleMove(VehicleMoveEvent event) {
    if (event.getVehicle().getPassenger() != null
        && event.getVehicle().getPassenger() instanceof Player) {
      if (event.getFrom().getBlock() != event.getTo().getBlock()) {
        DCPortal dcportal = Misc.getPortal(event.getTo());

        if (dcportal != null
            && dcportal.getTarget((Player) event.getVehicle().getPassenger()) != null) {
          event
              .getVehicle()
              .teleport(dcportal.getTarget((Player) event.getVehicle().getPassenger()));
        }
      }
    }
  }
Exemplo n.º 4
0
  public void main(Event e) {

    if (Util.config("bumpintherail", null).getBoolean("active")) {

      if (e.getEventName().equalsIgnoreCase("VehicleMoveEvent")) {
        VehicleMoveEvent event = (VehicleMoveEvent) e;

        if (event.getVehicle().getPassenger() instanceof Player) {
          Player player = (Player) event.getVehicle().getPassenger();

          if (!Util.config("bumpintherail", null)
              .getList("skipworld")
              .contains(player.getWorld().getName())) {
            if (event.getTo().getBlock().getType().equals(Material.RAILS)
                && event.getVehicle().getType().equals(EntityType.MINECART)) {
              if (!player.hasPermission("ijmh.immunity.rail")) {
                Rails rail = (Rails) event.getTo().getBlock().getState().getData();
                if (rail.isCurve()
                    && Util.pctChance(
                        Util.config("bumpintherail", null).getInt("chance"),
                        Util.config("bumpintherail", null).getInt("chancemod"))) {
                  event.getVehicle().eject();
                  Vector vector =
                      event.getTo().getDirection().midpoint(event.getFrom().getDirection());
                  player.setVelocity(
                      new Vector(
                          vector.getX() + Util.config("bumpintherail", null).getInt("distance"),
                          Util.config("bumpintherail", null).getInt("angle"),
                          vector.getZ() + Util.config("bumpintherail", null).getInt("distance")));
                  if (Util.config("bumpintherail", null).getBoolean("message"))
                    player.sendMessage(
                        ChatColor.GOLD + Util.chatColorText(Util.language.getString("lan_18")));
                }
              }
            }
          }
        }
      }
    }
  }
Exemplo n.º 5
0
  /**
   * Called on vehicle movement.
   *
   * @param event Relevant event details
   */
  @EventHandler
  public void onVehicleMove(VehicleMoveEvent event) {
    Vehicle vehicle = event.getVehicle();
    if (vehicle.getPassenger() == null || !(vehicle.getPassenger() instanceof Player)) return;
    Player player = (Player) vehicle.getPassenger();

    if (event.getFrom().getBlockX() != event.getTo().getBlockX()
        || event.getFrom().getBlockY() != event.getTo().getBlockY()
        || event.getFrom().getBlockZ() != event.getTo().getBlockZ()) {

      if (sessions.getAdminSession(player).isFrozen()) {

        player.sendMessage(ChatColor.RED + "You are frozen.");

        vehicle.setVelocity(new org.bukkit.util.Vector(0, 0, 0));
        vehicle.teleport(event.getFrom());
      }
    }
  }