Exemple #1
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")));
                }
              }
            }
          }
        }
      }
    }
  }