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