Пример #1
0
  public void cycleDestination(Player player, int dir) {
    Boolean activate = false;
    if (!isActive() || getActivePlayer() != player) {
      activate(player);
      Stargate.debug(
          "cycleDestination", "Network Size: " + allPortalsNet.get(network.toLowerCase()).size());
      Stargate.debug("cycleDestination", "Player has access to: " + destinations.size());
      activate = true;
    }

    if (destinations.size() == 0) {
      Stargate.sendMessage(player, Stargate.getString("destEmpty"));
      return;
    }

    if (!Stargate.destMemory || !activate || lastDest.isEmpty()) {
      int index = destinations.indexOf(destination);
      index += dir;
      if (index >= destinations.size()) index = 0;
      else if (index < 0) index = destinations.size() - 1;
      destination = destinations.get(index);
      lastDest = destination;
    }
    openTime = System.currentTimeMillis() / 1000;
    drawSign();
  }
Пример #2
0
  private void register() {
    if (!lookupNamesNet.containsKey(getNetwork().toLowerCase())) {
      Stargate.debug("register", "Network not in lookupNamesNet, adding");
      lookupNamesNet.put(getNetwork().toLowerCase(), new HashMap<String, Portal>());
    }
    lookupNamesNet.get(getNetwork().toLowerCase()).put(getName().toLowerCase(), this);

    for (Blox block : getFrame()) {
      lookupBlocks.put(block, this);
    }
    // Include the sign and button
    lookupBlocks.put(new Blox(id.getBlock()), this);
    if (button != null) {
      lookupBlocks.put(button, this);
    }

    for (Blox entrance : getEntrances()) {
      lookupEntrances.put(entrance, this);
    }

    allPortals.add(this);
    // Check if this network exists
    if (!allPortalsNet.containsKey(getNetwork().toLowerCase())) {
      Stargate.debug("register", "Network not in allPortalsNet, adding");
      allPortalsNet.put(getNetwork().toLowerCase(), new ArrayList<String>());
    }
    allPortalsNet.get(getNetwork().toLowerCase()).add(getName().toLowerCase());
  }
Пример #3
0
  public CostHandler(String cost) {
    method = PaymentMethod.Blocks;

    ArrayList<Item> array = new ArrayList<Item>();
    Matcher matcher = regex.matcher(cost);

    while (matcher.find()) {
      int amount = 1;
      int itemid = etc.getDataSource().getItem(matcher.group(2));

      if (itemid == 0) {
        try {
          itemid = Integer.parseInt(matcher.group(2));
        } catch (NumberFormatException ex) {
          Stargate.log(
              Level.WARNING,
              ex.getMessage() + " while parsing block payment string - no such block exists?");
          continue;
        }
      }

      if ((matcher.group(1) != null) && (!matcher.group(1).isEmpty())) {
        try {
          amount = Integer.parseInt(matcher.group(1));
        } catch (NumberFormatException ex) {
          amount = 1;
          Stargate.log(Level.WARNING, ex.getMessage() + " while parsing block payment string");
        }
      }

      array.add(new Item(itemid, amount));
    }

    items = array.toArray(items);
  }
Пример #4
0
  public void activate(Player player) {
    StargateActivateEvent event = new StargateActivateEvent(this, player);
    Stargate.server.getPluginManager().callEvent(event);
    if (event.isCancelled()) return;

    destinations.clear();
    destination = "";
    Stargate.activeList.add(this);
    activePlayer = player;
    String network = getNetwork();
    for (String dest : allPortalsNet.get(network.toLowerCase())) {
      Portal portal = getByName(dest, network);
      // Check if dest is always open (Don't show if so)
      if (portal.isAlwaysOn() && !portal.isShown()) continue;
      // Check if this player can access the dest world
      if (!Stargate.canAccessWorld(player, portal.getWorld().getName())) continue;
      // Check if dest is this portal
      if (dest.equalsIgnoreCase(getName())) continue;
      // Check if dest is a fixed gate not pointing to this gate
      if (portal.isFixed() && !portal.getDestinationName().equalsIgnoreCase(getName())) continue;
      // Visible to this player.
      if (Stargate.canSee(player, portal)) {
        destinations.add(portal.getName());
      }
    }
    if (Stargate.destMemory && !lastDest.isEmpty() && destinations.contains(lastDest)) {
      destination = lastDest;
    }
    drawSign();
  }
Пример #5
0
  public static void saveAllGates(World world) {
    String loc = Stargate.getSaveLocation() + "/" + world.getName() + ".db";

    try {
      BufferedWriter bw = new BufferedWriter(new FileWriter(loc, false));

      for (Portal portal : allPortals) {
        String wName = portal.world.getName();
        if (!wName.equalsIgnoreCase(world.getName())) continue;
        StringBuilder builder = new StringBuilder();
        Blox sign = new Blox(portal.id.getBlock());
        Blox button = portal.button;

        builder.append(portal.name);
        builder.append(':');
        builder.append(sign.toString());
        builder.append(':');
        builder.append((button != null) ? button.toString() : "");
        builder.append(':');
        builder.append(portal.modX);
        builder.append(':');
        builder.append(portal.modZ);
        builder.append(':');
        builder.append(portal.rotX);
        builder.append(':');
        builder.append(portal.topLeft.toString());
        builder.append(':');
        builder.append(portal.gate.getFilename());
        builder.append(':');
        builder.append(portal.isFixed() ? portal.getDestinationName() : "");
        builder.append(':');
        builder.append(portal.getNetwork());
        builder.append(':');
        builder.append(portal.getOwner());
        builder.append(':');
        builder.append(portal.isHidden());
        builder.append(':');
        builder.append(portal.isAlwaysOn());
        builder.append(':');
        builder.append(portal.isPrivate());
        builder.append(':');
        builder.append(portal.world.getName());
        builder.append(':');
        builder.append(portal.isFree());
        builder.append(':');
        builder.append(portal.isBackwards());
        builder.append(':');
        builder.append(portal.isShown());

        bw.append(builder.toString());
        bw.newLine();
      }

      bw.close();
    } catch (Exception e) {
      Stargate.log.log(Level.SEVERE, "Exception while writing stargates to " + loc + ": " + e);
    }
  }
Пример #6
0
  public CostHandler(String cost, String moneyDest) {
    method = PaymentMethod.iConomy;
    destination = moneyDest;

    try {
      money = Integer.parseInt(cost);
    } catch (NumberFormatException ex) {
      money = 0;
      Stargate.log(Level.WARNING, ex.getMessage() + " while parsing iConomy payment");
    }
  }
Пример #7
0
  private boolean deductIConomy(Player player) {
    if (!iData.iExist()) {
      Stargate.log(Level.WARNING, "iConomy payment selected but iConomy does not exist");
      return true;
    }

    if (money > 0) {
      iData icon = new iData();
      int balance = icon.getBalance(player.getName());
      String deducted = icon.settings.getString("money-deducted", "");
      String coin = icon.settings.getString("money-name", "");
      String receive = icon.settings.getString("money-receive", "");

      if (balance >= money) {
        String[] recipient = destination.split(" ", 2);
        icon.setBalance(player.getName(), balance - money);
        if (!deducted.isEmpty()) player.sendMessage(String.format(deducted, money + coin));

        if ((recipient.length > 0) && (recipient[0].equalsIgnoreCase("player"))) {
          if ((recipient.length > 1) && (icon.hasBalance(recipient[1]))) {
            balance = icon.getBalance(recipient[1]);
            icon.setBalance(recipient[1], balance + money);

            if (!receive.isEmpty()) player.sendMessage(String.format(receive, money + coin));
          } else {
            Stargate.log(
                Level.WARNING,
                "cost-destination set to player but specified player does not exist or was not defined");
          }
        }

        return true;
      } else {
        return false;
      }
    }

    return true;
  }
Пример #8
0
  private Portal(
      Blox topLeft,
      int modX,
      int modZ,
      float rotX,
      SignPost id,
      Blox button,
      String dest,
      String name,
      boolean verified,
      String network,
      Gate gate,
      String owner,
      boolean hidden,
      boolean alwaysOn,
      boolean priv,
      boolean free,
      boolean backwards,
      boolean show) {
    this.topLeft = topLeft;
    this.modX = modX;
    this.modZ = modZ;
    this.rotX = rotX;
    this.id = id;
    this.destination = dest;
    this.button = button;
    this.verified = verified;
    this.network = network;
    this.name = name;
    this.gate = gate;
    this.owner = owner;
    this.hidden = hidden;
    this.alwaysOn = alwaysOn;
    this.priv = priv;
    this.free = free;
    this.backwards = backwards;
    this.show = show;
    this.world = topLeft.getWorld();
    this.fixed = dest.length() > 0;

    if (this.isAlwaysOn() && !this.isFixed()) {
      this.alwaysOn = false;
      Stargate.debug(
          "Portal", "Can not create a non-fixed always-on gate. Setting AlwaysOn = false");
    }

    this.register();
    if (verified) {
      this.drawSign();
    }
  }
  @Override
  protected void initialize() {
    window.requestFocusInWindow();

    // Replace the default keyboard input with DyehardKeyboard
    window.removeKeyListener(keyboard);
    keyboard = new DyehardKeyboard();
    window.addKeyListener(keyboard);

    window.addMouseListener(mouse);

    resources.setClassInJar(this);

    state = State.BEGIN;
    GameState.TargetDistance = Configuration.worldMapLength;
    world = new GameWorld();

    // preload sound/music, and play bg music
    DyeHardSound.playBgMusic();

    hero = new Hero();

    // move mouse to where center of hero is
    try {
      Robot robot = new Robot();

      robot.mouseMove(
          window.getLocationOnScreen().x
              + (int) (hero.center.getX() * window.getWidth() / BaseCode.world.getWidth()),
          window.getLocationOnScreen().y
              + window.getHeight()
              - (int) (hero.center.getX() * window.getWidth() / BaseCode.world.getWidth()));
    } catch (AWTException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    //
    // hero.registerWeapon(new SpreadFireWeapon(hero));
    // hero.registerWeapon(new OverHeatWeapon(hero));
    // hero.registerWeapon(new LimitedAmmoWeapon(hero));

    world.initialize(hero);

    new DeveloperControls(hero);

    Stargate.addColor(Colors.Yellow);

    timer = new Timer(2000);
  }
Пример #10
0
  public void unregister(boolean removeAll) {
    Stargate.debug("Unregister", "Unregistering gate " + getName());
    close(true);
    lookupNamesNet.get(getNetwork().toLowerCase()).remove(getName().toLowerCase());

    for (Blox block : getFrame()) {
      lookupBlocks.remove(block);
    }
    // Include the sign and button
    lookupBlocks.remove(new Blox(id.getBlock()));
    if (button != null) {
      lookupBlocks.remove(button);
    }

    for (Blox entrance : getEntrances()) {
      lookupEntrances.remove(entrance);
    }

    if (removeAll) allPortals.remove(this);

    allPortalsNet.get(getNetwork().toLowerCase()).remove(getName().toLowerCase());

    if (id.getBlock().getType() == Material.WALL_SIGN) {
      id.setText(0, getName());
      id.setText(1, "");
      id.setText(2, "");
      id.setText(3, "");
      id.update();
    }

    for (String originName : allPortalsNet.get(getNetwork().toLowerCase())) {
      Portal origin = Portal.getByName(originName, getNetwork());
      if (origin == null) continue;
      if (!origin.getDestinationName().equalsIgnoreCase(getName())) continue;
      if (!origin.isVerified()) continue;
      if (origin.isFixed()) origin.drawSign();
      if (origin.isAlwaysOn()) origin.close(true);
    }

    saveAllGates(getWorld());
  }
Пример #11
0
  public static Portal createPortal(SignChangeEvent event, Player player) {
    SignPost id = new SignPost(new Blox(event.getBlock()));
    Block idParent = id.getParent();
    if (idParent == null) {
      return null;
    }

    if (Gate.getGatesByControlBlock(idParent).length == 0) return null;

    if (Portal.getByBlock(idParent) != null) {
      Stargate.debug("createPortal", "idParent belongs to existing gate");
      return null;
    }

    Blox parent = new Blox(player.getWorld(), idParent.getX(), idParent.getY(), idParent.getZ());
    Blox topleft = null;
    String name = filterName(event.getLine(0));
    String destName = filterName(event.getLine(1));
    String network = filterName(event.getLine(2));
    String options = filterName(event.getLine(3));
    boolean hidden = (options.indexOf('h') != -1 || options.indexOf('H') != -1);
    boolean alwaysOn = (options.indexOf('a') != -1 || options.indexOf('A') != -1);
    boolean priv = (options.indexOf('p') != -1 || options.indexOf('P') != -1);
    boolean free = (options.indexOf('f') != -1 || options.indexOf('F') != -1);
    boolean backwards = (options.indexOf('b') != -1 || options.indexOf('B') != -1);
    boolean show = (options.indexOf('s') != -1 || options.indexOf('S') != -1);

    // Check permissions for options.
    if (hidden && !Stargate.canOption(player, "hidden")) hidden = false;
    if (alwaysOn && !Stargate.canOption(player, "alwayson")) alwaysOn = false;
    if (priv && !Stargate.canOption(player, "private")) priv = false;
    if (free && !Stargate.canOption(player, "free")) free = false;
    if (backwards && !Stargate.canOption(player, "backwards")) backwards = false;
    if (show && !Stargate.canOption(player, "show")) show = false;

    // Can not create a non-fixed always-on gate.
    if (alwaysOn && destName.length() == 0) {
      alwaysOn = false;
    }

    // Show isn't useful if A is false
    if (show && !alwaysOn) {
      show = false;
    }

    // Moved the layout check so as to avoid invalid messages when not making a gate
    int modX = 0;
    int modZ = 0;
    float rotX = 0f;
    int facing = 0;

    if (idParent.getX() > id.getBlock().getX()) {
      modZ -= 1;
      rotX = 90f;
      facing = 2;
    } else if (idParent.getX() < id.getBlock().getX()) {
      modZ += 1;
      rotX = 270f;
      facing = 1;
    } else if (idParent.getZ() > id.getBlock().getZ()) {
      modX += 1;
      rotX = 180f;
      facing = 4;
    } else if (idParent.getZ() < id.getBlock().getZ()) {
      modX -= 1;
      rotX = 0f;
      facing = 3;
    }

    Gate[] possibleGates = Gate.getGatesByControlBlock(idParent);
    Gate gate = null;
    RelativeBlockVector buttonVector = null;

    for (Gate possibility : possibleGates) {
      if ((gate == null) && (buttonVector == null)) {
        RelativeBlockVector[] vectors = possibility.getControls();
        RelativeBlockVector otherControl = null;

        for (RelativeBlockVector vector : vectors) {
          Blox tl =
              parent.modRelative(
                  -vector.getRight(), -vector.getDepth(), -vector.getDistance(), modX, 1, modZ);

          if (gate == null) {
            if (possibility.matches(tl, modX, modZ, true)) {
              gate = possibility;
              topleft = tl;

              if (otherControl != null) {
                buttonVector = otherControl;
              }
            }
          } else if (otherControl != null) {
            buttonVector = vector;
          }

          otherControl = vector;
        }
      }
    }

    if ((gate == null) || (buttonVector == null)) {
      Stargate.debug("createPortal", "Could not find matching gate layout");
      return null;
    }

    // Debug
    Stargate.debug(
        "createPortal",
        "h = " + hidden + " a = " + alwaysOn + " p = " + priv + " f = " + free + " b = " + backwards
            + " s = " + show);

    if ((network.length() < 1) || (network.length() > 11)) {
      network = Stargate.getDefaultNetwork();
    }

    // Check if the player can create gates on this network
    if (!Stargate.canCreate(player, network)) {
      Stargate.debug(
          "createPortal", "Player doesn't have create permissions on network. Trying personal");
      if (Stargate.canCreatePersonal(player)) {
        network = player.getName();
        if (network.length() > 11) network = network.substring(0, 11);
        Stargate.debug("createPortal", "Creating personal portal");
        Stargate.sendMessage(player, Stargate.getString("createPersonal"));
      } else {
        Stargate.debug("createPortal", "Player does not have access to network");
        Stargate.sendMessage(player, Stargate.getString("createNetDeny"));
        return null;
      }
    }

    // Check if the player can create this gate layout
    String gateName = gate.getFilename();
    gateName = gateName.substring(0, gateName.indexOf('.'));
    if (!Stargate.canCreateGate(player, gateName)) {
      Stargate.debug("createPortal", "Player does not have access to gate layout");
      Stargate.sendMessage(player, Stargate.getString("createGateDeny"));
      return null;
    }

    if (name.length() < 1 || name.length() > 11) {
      Stargate.debug("createPortal", "Name length error");
      Stargate.sendMessage(player, Stargate.getString("createNameLength"));
      return null;
    }

    if (getByName(name, network) != null) {
      Stargate.debug("createPortal", "Name Error");
      Stargate.sendMessage(player, Stargate.getString("createExists"));
      return null;
    }

    // Check if there are too many gates in this network
    ArrayList<String> netList = allPortalsNet.get(network.toLowerCase());
    if (Stargate.maxGates > 0 && netList != null && netList.size() >= Stargate.maxGates) {
      Stargate.sendMessage(player, Stargate.getString("createFull"));
      return null;
    }

    // Check if the user can create gates to this world.
    if (destName.length() > 0) {
      Portal p = Portal.getByName(destName, network);
      if (p != null) {
        String world = p.getWorld().getName();
        if (!Stargate.canAccessWorld(player, world)) {
          Stargate.debug("canCreate", "Player does not have access to destination world");
          Stargate.sendMessage(player, Stargate.getString("createWorldDeny"));
          return null;
        }
      }
    }

    // Bleh, gotta check to make sure none of this gate belongs to another gate. Boo slow.
    for (RelativeBlockVector v : gate.getBorder()) {
      Blox b = topleft.modRelative(v.getRight(), v.getDepth(), v.getDistance(), modX, 1, modZ);
      if (Portal.getByBlock(b.getBlock()) != null) {
        Stargate.debug("createPortal", "Gate conflicts with existing gate");
        Stargate.sendMessage(player, Stargate.getString("createConflict"));
        return null;
      }
    }

    int cost = Stargate.getCreateCost(player, gate);
    if (cost > 0) {
      if (!Stargate.chargePlayer(player, null, gate.getCreateCost())) {
        String inFundMsg = Stargate.getString("ecoInFunds");
        inFundMsg =
            Stargate.replaceVars(
                inFundMsg,
                new String[] {"%cost%", "%portal%"},
                new String[] {iConomyHandler.format(cost), name});
        Stargate.sendMessage(player, inFundMsg);
        Stargate.debug("createPortal", "Insufficient Funds");
        return null;
      }
      String deductMsg = Stargate.getString("ecoDeduct");
      deductMsg =
          Stargate.replaceVars(
              deductMsg,
              new String[] {"%cost%", "%portal%"},
              new String[] {iConomyHandler.format(cost), name});
      Stargate.sendMessage(player, deductMsg, false);
    }

    Portal portal = null;

    Blox button = null;
    // No button on an always-open gate.
    if (!alwaysOn) {
      button =
          topleft.modRelative(
              buttonVector.getRight(),
              buttonVector.getDepth(),
              buttonVector.getDistance() + 1,
              modX,
              1,
              modZ);
      button.setType(Material.STONE_BUTTON.getId());
      button.setData(facing);
    }
    portal =
        new Portal(
            topleft,
            modX,
            modZ,
            rotX,
            id,
            button,
            destName,
            name,
            true,
            network,
            gate,
            player.getName(),
            hidden,
            alwaysOn,
            priv,
            free,
            backwards,
            show);

    // Open always on gate
    if (portal.isAlwaysOn()) {
      Portal dest = Portal.getByName(destName, portal.getNetwork());
      if (dest != null) {
        portal.open(true);
        dest.drawSign();
      }
      // Set the inside of the gate to its closed material
    } else {
      for (Blox inside : portal.getEntrances()) {
        inside.setType(portal.getGate().getPortalBlockClosed());
      }
    }

    // Open any always on gate pointing at this gate
    for (String originName : allPortalsNet.get(portal.getNetwork().toLowerCase())) {
      Portal origin = Portal.getByName(originName, portal.getNetwork());
      if (origin == null) continue;
      if (!origin.getDestinationName().equalsIgnoreCase(portal.getName())) continue;
      if (!origin.isVerified()) continue;
      if (origin.isFixed()) origin.drawSign();
      if (origin.isAlwaysOn()) origin.open(true);
    }

    saveAllGates(portal.getWorld());

    return portal;
  }
Пример #12
0
  public final void drawSign() {
    id.setText(0, "--" + name + "--");
    int max = destinations.size() - 1;
    int done = 0;

    if (!isActive()) {
      id.setText(++done, "Right click to");
      id.setText(++done, "use the gate");
      id.setText(++done, " (" + network + ") ");
    } else {
      if (isFixed()) {
        id.setText(++done, "To: " + destination);
        id.setText(++done, " (" + network + ") ");
        Portal dest = Portal.getByName(destination, network);
        if (dest == null) {
          id.setText(++done, "(Not Connected)");
        } else {
          id.setText(++done, "");
        }
      } else {
        int index = destinations.indexOf(destination);

        if ((index == max) && (max > 1) && (++done <= 3)) {
          if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
            Portal dest = Portal.getByName(destinations.get(index - 2), network);
            boolean green = Stargate.isFree(activePlayer, this, dest);
            id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index - 2));
          } else {
            id.setText(done, destinations.get(index - 2));
          }
        }
        if ((index > 0) && (++done <= 3)) {
          if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
            Portal dest = Portal.getByName(destinations.get(index - 1), network);
            boolean green = Stargate.isFree(activePlayer, this, dest);
            id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index - 1));
          } else {
            id.setText(done, destinations.get(index - 1));
          }
        }
        if (++done <= 3) {
          if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
            Portal dest = Portal.getByName(destination, network);
            boolean green = Stargate.isFree(activePlayer, this, dest);
            id.setText(done, (green ? ChatColor.DARK_GREEN : "") + " >" + destination + "< ");
          } else {
            id.setText(done, " >" + destination + "< ");
          }
        }
        if ((max >= index + 1) && (++done <= 3)) {
          if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
            Portal dest = Portal.getByName(destinations.get(index + 1), network);
            boolean green = Stargate.isFree(activePlayer, this, dest);
            id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index + 1));
          } else {
            id.setText(done, destinations.get(index + 1));
          }
        }
        if ((max >= index + 2) && (++done <= 3)) {
          if (iConomyHandler.useiConomy() && iConomyHandler.freeGatesGreen) {
            Portal dest = Portal.getByName(destinations.get(index + 2), network);
            boolean green = Stargate.isFree(activePlayer, this, dest);
            id.setText(done, (green ? ChatColor.DARK_GREEN : "") + destinations.get(index + 2));
          } else {
            id.setText(done, destinations.get(index + 2));
          }
        }
      }
    }

    for (done++; done <= 3; done++) {
      id.setText(done, "");
    }

    id.update();
  }
Пример #13
0
  public static void loadAllGates(World world) {
    String location = Stargate.getSaveLocation();

    File db = new File(location, world.getName() + ".db");

    if (db.exists()) {
      int l = 0;
      int portalCount = 0;
      try {
        Scanner scanner = new Scanner(db);
        while (scanner.hasNextLine()) {
          l++;
          String line = scanner.nextLine().trim();
          if (line.startsWith("#") || line.isEmpty()) {
            continue;
          }
          String[] split = line.split(":");
          if (split.length < 8) {
            Stargate.log.info("[Stargate] Invalid line - " + l);
            continue;
          }
          String name = split[0];
          Blox s = new Blox(world, split[1]);
          if (!(s.getBlock().getState() instanceof Sign)) {
            Stargate.log.info(
                "[Stargate] Sign on line "
                    + l
                    + " doesn't exist. BlockType = "
                    + s.getBlock().getType());
            continue;
          }
          SignPost sign = new SignPost(s);
          Blox button = (split[2].length() > 0) ? new Blox(world, split[2]) : null;
          int modX = Integer.parseInt(split[3]);
          int modZ = Integer.parseInt(split[4]);
          float rotX = Float.parseFloat(split[5]);
          Blox topLeft = new Blox(world, split[6]);
          Gate gate =
              (split[7].contains(";"))
                  ? Gate.getGateByName("nethergate.gate")
                  : Gate.getGateByName(split[7]);
          if (gate == null) {
            Stargate.log.info(
                "[Stargate] Gate layout on line " + l + " does not exist [" + split[7] + "]");
            continue;
          }

          String dest = (split.length > 8) ? split[8] : "";
          String network = (split.length > 9) ? split[9] : Stargate.getDefaultNetwork();
          if (network.isEmpty()) network = Stargate.getDefaultNetwork();
          String owner = (split.length > 10) ? split[10] : "";
          boolean hidden = (split.length > 11) ? split[11].equalsIgnoreCase("true") : false;
          boolean alwaysOn = (split.length > 12) ? split[12].equalsIgnoreCase("true") : false;
          boolean priv = (split.length > 13) ? split[13].equalsIgnoreCase("true") : false;
          boolean free = (split.length > 15) ? split[15].equalsIgnoreCase("true") : false;
          boolean backwards = (split.length > 16) ? split[16].equalsIgnoreCase("true") : false;
          boolean show = (split.length > 17) ? split[17].equalsIgnoreCase("true") : false;

          Portal portal =
              new Portal(
                  topLeft, modX, modZ, rotX, sign, button, dest, name, false, network, gate, owner,
                  hidden, alwaysOn, priv, free, backwards, show);
          portal.close(true);
        }
        scanner.close();

        // Open any always-on gates. Do this here as it should be more efficient than in the loop.
        int OpenCount = 0;
        for (Iterator<Portal> iter = allPortals.iterator(); iter.hasNext(); ) {
          Portal portal = iter.next();
          if (portal == null) continue;

          // Verify portal integrity/register portal
          if (!portal.wasVerified()) {
            if (!portal.isVerified() || !portal.checkIntegrity()) {
              // DEBUG
              for (RelativeBlockVector control : portal.getGate().getControls()) {
                if (portal.getBlockAt(control).getBlock().getTypeId()
                    != portal.getGate().getControlBlock()) {
                  Stargate.debug(
                      "loadAllGates",
                      "Control Block Type == " + portal.getBlockAt(control).getBlock().getTypeId());
                }
              }
              portal.unregister(false);
              iter.remove();
              Stargate.log.info("[Stargate] Destroying stargate at " + portal.toString());
              continue;
            } else {
              portal.drawSign();
              portalCount++;
            }
          }

          if (!portal.isFixed()) continue;
          Portal dest = portal.getDestination();
          if (dest != null) {
            if (portal.isAlwaysOn()) {
              portal.open(true);
              OpenCount++;
            }
            portal.drawSign();
            dest.drawSign();
          }
        }
        Stargate.log.info(
            "[Stargate] {"
                + world.getName()
                + "} Loaded "
                + portalCount
                + " stargates with "
                + OpenCount
                + " set as always-on");
      } catch (Exception e) {
        Stargate.log.log(
            Level.SEVERE, "Exception while reading stargates from " + db.getName() + ": " + l);
        e.printStackTrace();
      }
    } else {
      Stargate.log.info("[Stargate] {" + world.getName() + "} No stargates for world ");
    }
  }