Package com.bergerkiller.bukkit.tc

Examples of com.bergerkiller.bukkit.tc.DirectionStatement


    final boolean facing = info.isFacing();
    if (facing) {
      final BlockFace cartDirection = info.getCartDirection();
      //find out what statements to parse
      List<DirectionStatement> statements = new ArrayList<DirectionStatement>();
      statements.add(new DirectionStatement(info.getLine(2), cartDirection, Direction.LEFT));
      statements.add(new DirectionStatement(info.getLine(3), cartDirection, Direction.RIGHT));
      //other signs below this sign we could parse?
      for (Sign sign : info.findSignsBelow()) {
        boolean valid = true;
        for (String line : sign.getLines()) {
          DirectionStatement stat = new DirectionStatement(line, cartDirection);
          if (stat.direction == Direction.NONE) {
            valid = false;
            break;
          } else {
            statements.add(stat);
          }
        }
        if (!valid) {
          break;
        }
      }
      Block signblock = info.getBlock();
      while (MaterialUtil.ISSIGN.get(signblock = signblock.getRelative(BlockFace.DOWN))) {
        Sign sign = BlockUtil.getSign(signblock);
        if (sign == null) break;
        boolean valid = true;
        for (String line : sign.getLines()) {
          DirectionStatement stat = new DirectionStatement(line, cartDirection);
          if (stat.direction == Direction.NONE) {
            valid = false;
            break;
          } else {
            statements.add(stat);
          }
        }
        if (!valid) break;
      }
      //parse all of the statements
      //are we going to use a counter?
      int maxcount = 0;
      int currentcount = 0;
      AtomicInteger signcounter = null;
      for (DirectionStatement stat : statements) {
        if (stat.hasNumber()) {
          maxcount += stat.number;
          if (signcounter == null) {
            signcounter = getSwitchedTimes(info.getBlock());
            if (info.isAction(SignActionType.MEMBER_ENTER, SignActionType.GROUP_ENTER)) {
              currentcount = signcounter.getAndIncrement();
            } else {
              currentcount = signcounter.get();
            }
          }
        }
      }
      if (signcounter != null && currentcount >= maxcount) {
        signcounter.set(1);
        currentcount = 0;
      }
     
      int counter = 0;
      Direction dir = Direction.NONE;
      for (DirectionStatement stat : statements) {
        if ((stat.hasNumber() && (counter += stat.number) > currentcount)
            || (doCart && stat.has(info, info.getMember()))
            || (doTrain && stat.has(info, info.getGroup()))) {

          dir = stat.direction;
          break;
        }
      }
View Full Code Here

TOP

Related Classes of com.bergerkiller.bukkit.tc.DirectionStatement

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.