package NET.worlds.scape; import NET.worlds.console.Console; import NET.worlds.core.IniFile; import NET.worlds.network.Cache; import NET.worlds.network.CacheFile; import NET.worlds.network.NetUpdate; import NET.worlds.network.URL; import java.io.RandomAccessFile; import java.util.Vector; public class WorldValidator { static Vector worldList = null; private static final boolean debug = true; public static boolean allow(String worldName) { if (IniFile.gamma().getIniInt("FreeFreeFree", 1) == 1) { return true; } else if (NetUpdate.isInternalVersion()) { return true; } else { Console c = Console.getActive(); if (c != null && !c.getGalaxy().getOnline()) { return true; } else { if (worldList == null) { try { initializeList(); } catch (Exception var3) { return true; } } if (worldList == null) { return true; } else { worldName = normalize(worldName); System.out.println("Validating " + worldName); boolean allow = worldList.contains(worldName); System.out.println(allow); return allow; } } } } public static void initializeList() throws Exception { String worldListFile = NetUpdate.getUpgradeServerURL() + "tables/worlds.txt"; URL worldListURL = URL.make(worldListFile); CacheFile cf = Cache.getFile(worldListURL, true); cf.waitUntilLoaded(); if (!cf.error()) { boolean foundAtLeastOneEntry = false; worldList = new Vector(); RandomAccessFile f = new RandomAccessFile(cf.getLocalName(), "r"); while (f.getFilePointer() < f.length()) { String line = f.readLine(); if (line.indexOf(".world") != -1) { line = normalize(line); foundAtLeastOneEntry = true; System.out.println("Adding world " + line); worldList.addElement(line); } } f.close(); if (!foundAtLeastOneEntry) { throw new Exception(); } } else { throw new Exception(); } } private static String normalize(String worldName) { String out = URL.make(worldName).getAbsolute(); if (out.startsWith("home:/")) { out = "home:" + out.substring(6); } return out.toLowerCase().trim(); } }