public void onMinecartClickedEvent(MinecartClickedEvent event) {
    if (event.isActionTaken()) {
      return;
    }
    MinecartManiaMinecart minecart = event.getMinecart();
    if (StationUtil.isInQueue(minecart)) {
      event.setActionTaken(true);
      return;
    }
    CompassDirection facingDir =
        DirectionUtils.getDirectionFromMinecartRotation(
            (minecart.minecart.getPassenger().getLocation().getYaw() - 90.0F) % 360.0F);

    Vector velocity = (Vector) minecart.getDataValue("preintersection velocity");
    if (velocity == null) {
      return;
    }

    velocity = StationUtil.alterMotionFromDirection(facingDir, velocity);

    // responding to chat direction prompt
    if (minecart.isAtIntersection() && minecart.hasPlayerPassenger()) {
      if (StationUtil.isValidDirection(facingDir, minecart)) {
        int data =
            DirectionUtils.getMinetrackRailDataForDirection(facingDir, minecart.getDirection());
        if (data != -1) {
          MinecartManiaWorld.setBlockData(
              minecart.minecart.getWorld(),
              minecart.getX(),
              minecart.getY(),
              minecart.getZ(),
              data);
        }
        minecart.minecart.setVelocity(velocity);
        minecart.setDataValue("preintersection velocity", null);
      }
      event.setActionTaken(true);
    }
  }
  public void onMinecartIntersectionEvent(MinecartIntersectionEvent event) {
    MinecartManiaMinecart minecart = event.getMinecart();

    if (event.isActionTaken()) {
      return;
    }

    if (ControlBlockList.isValidStationBlock(minecart)) {
      SignCommands.processStation(event);
    }

    if (event.isActionTaken()) {
      return;
    }

    if (StationUtil.shouldPromptUser(minecart)) {

      minecart.setDataValue("preintersection velocity", minecart.minecart.getVelocity().clone());
      minecart.stopCart();
      Player passenger = minecart.getPlayerPassenger();
      // set the track straight
      int data =
          DirectionUtils.getMinetrackRailDataForDirection(
              minecart.getDirection(), minecart.getDirection());
      Block oldBlock =
          MinecartManiaWorld.getBlockAt(
              minecart.minecart.getWorld(), minecart.getX(), minecart.getY(), minecart.getZ());
      ArrayList<Integer> blockData = new ArrayList<Integer>();
      blockData.add(new Integer(oldBlock.getX()));
      blockData.add(new Integer(oldBlock.getY()));
      blockData.add(new Integer(oldBlock.getZ()));
      blockData.add(new Integer(oldBlock.getData()));
      minecart.setDataValue("old rail data", blockData);
      if (data != -1) {
        MinecartManiaWorld.setBlockData(
            minecart.minecart.getWorld(), minecart.getX(), minecart.getY(), minecart.getZ(), data);
      }
      passenger.sendMessage(LocaleParser.getTextKey("StationsTapInDirection"));
    }
  }
 @Override
 public CompassDirection direction(MinecartManiaMinecart minecart, String str) {
   if (str.equals("R") || str.toLowerCase().contains("right"))
     return DirectionUtils.getRightDirection(minecart.getDirection());
   return CompassDirection.NO_DIRECTION;
 }
  public static void processStation(MinecartEvent event) {
    MinecartManiaMinecart minecart = event.getMinecart();

    ArrayList<Sign> signList = SignUtils.getAdjacentSignList(minecart, 2);
    for (Sign sign : signList) {
      convertCraftBookSorter(sign);
      for (int k = 0; k < 4; k++) {
        // Setup initial data
        String str = sign.getLine(k);
        String newLine = str;
        String val[] = str.split(":");
        if (val.length != 2) {
          continue;
        }
        // Strip header and ending characters
        val[0] = StringUtils.removeBrackets(val[0]);
        val[1] = StringUtils.removeBrackets(val[1]);
        // Strip whitespace
        val[0] = val[0].trim();
        val[1] = val[1].trim();
        boolean valid = false;
        // end of data setup

        for (StationCondition e : StationCondition.values()) {
          if (e.result(minecart, val[0])) {
            valid = true;
            break;
          }
        }

        if (valid) {
          CompassDirection direction = CompassDirection.NO_DIRECTION;

          for (StationDirection e : StationDirection.values()) {
            direction = e.direction(minecart, val[1]);
            if (direction != CompassDirection.NO_DIRECTION) {
              break;
            }
          }

          // Special case - if we are at a launcher, set the launch speed as well
          // mze 2012-08-29: Remove it because it makes more problems than it solves...
          /*if (event instanceof MinecartLaunchedEvent && direction != null && direction != CompassDirection.NO_DIRECTION) {
          	minecart.setMotion(direction, 0.6D);
          	((MinecartLaunchedEvent)event).setLaunchSpeed(minecart.minecart.getVelocity());
          }*/

          // setup sign formatting
          newLine = StringUtils.removeBrackets(newLine);
          char[] ch = {' ', ':'};
          newLine = WordUtils.capitalize(newLine, ch);
          newLine = StringUtils.addBrackets(newLine);

          boolean handled = false;
          // Handle minecart destruction
          if (direction == null) {
            // vanish sign, minecart is just gone ;)
            if (val[1].equals("V") || val[1].toLowerCase().contains("vanish")) {
              minecart.kill(false);
            }

            minecart.kill();
            handled = true;
          } else if (MinecartUtils.validMinecartTrack(
              minecart.minecart.getWorld(),
              minecart.getX(),
              minecart.getY(),
              minecart.getZ(),
              2,
              direction)) {
            int data =
                DirectionUtils.getMinetrackRailDataForDirection(direction, minecart.getDirection());
            if (data != -1) {
              handled = true;

              // Force the game to remember the old data of the rail we are on, and reset it once we
              // are done
              Block oldBlock =
                  MinecartManiaWorld.getBlockAt(
                      minecart.minecart.getWorld(),
                      minecart.getX(),
                      minecart.getY(),
                      minecart.getZ());
              ArrayList<Integer> blockData = new ArrayList<Integer>();
              blockData.add(new Integer(oldBlock.getX()));
              blockData.add(new Integer(oldBlock.getY()));
              blockData.add(new Integer(oldBlock.getZ()));
              blockData.add(new Integer(oldBlock.getData()));
              minecart.setDataValue("old rail data", blockData);

              // change the track dirtion
              MinecartManiaWorld.setBlockData(
                  minecart.minecart.getWorld(),
                  minecart.getX(),
                  minecart.getY(),
                  minecart.getZ(),
                  data);
            } else if (DirectionUtils.getOppositeDirection(direction)
                .equals(minecart.getDirection())) {
              // format the sign
              minecart.reverse();
              handled = true;
            }
          }

          if (handled) {
            event.setActionTaken(true);
            // format the sign
            sign.setLine(k, newLine);
            sign.update(true);
            return;
          }
        }
      }
    }
  }