/* */ 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.Galaxy; /* */ import NET.worlds.network.NetUpdate; /* */ import NET.worlds.network.URL; /* */ import java.io.PrintStream; /* */ import java.io.RandomAccessFile; /* */ import java.util.Vector; /* */ /* */ /* */ public class WorldValidator /* */ { /* 17 */ static Vector worldList = null; /* */ /* */ private static final boolean debug = true; /* */ /* */ public static boolean allow(String worldName) /* */ { /* 23 */ if (IniFile.gamma().getIniInt("FreeFreeFree", 1) == 1) { /* 24 */ return true; /* */ } /* 26 */ if (NetUpdate.isInternalVersion()) { /* 27 */ return true; /* */ } /* 29 */ Console c = Console.getActive(); /* 30 */ if ((c != null) && (!c.getGalaxy().getOnline())) { /* 31 */ return true; /* */ } /* 33 */ if (worldList == null) /* */ { /* */ try /* */ { /* 37 */ initializeList(); /* */ /* */ } /* */ catch (Exception e) /* */ { /* 42 */ return true; /* */ } /* */ } /* */ /* 46 */ if (worldList == null) { /* 47 */ return true; /* */ } /* 49 */ worldName = normalize(worldName); /* */ /* */ /* 52 */ System.out.println("Validating " + worldName); /* */ /* 54 */ boolean allow = worldList.contains(worldName); /* */ /* */ /* 57 */ System.out.println(allow); /* */ /* 59 */ return allow; /* */ } /* */ /* */ public static void initializeList() throws Exception /* */ { /* 64 */ String worldListFile = NetUpdate.getUpgradeServerURL() + /* 65 */ "tables/worlds.txt"; /* 66 */ URL worldListURL = URL.make(worldListFile); /* 67 */ CacheFile cf = Cache.getFile(worldListURL, true); /* 68 */ cf.waitUntilLoaded(); /* 69 */ if (!cf.error()) /* */ { /* */ /* */ /* */ /* */ /* 75 */ boolean foundAtLeastOneEntry = false; /* */ /* 77 */ worldList = new Vector(); /* */ /* 79 */ RandomAccessFile f = new RandomAccessFile( /* 80 */ cf.getLocalName(), "r"); /* 81 */ while (f.getFilePointer() < f.length()) /* */ { /* 83 */ String line = f.readLine(); /* */ /* 85 */ if (line.indexOf(".world") != -1) /* */ { /* 87 */ line = normalize(line); /* 88 */ foundAtLeastOneEntry = true; /* */ /* 90 */ System.out.println("Adding world " + line); /* 91 */ worldList.addElement(line); /* */ } /* */ } /* */ /* 95 */ f.close(); /* */ /* 97 */ if (!foundAtLeastOneEntry) { /* 98 */ throw new Exception(); /* */ } /* */ } /* */ else { /* 102 */ throw new Exception(); /* */ } /* */ } /* */ /* */ private static String normalize(String worldName) /* */ { /* 108 */ String out = URL.make(worldName).getAbsolute(); /* 109 */ if (out.startsWith("home:/")) /* 110 */ out = "home:" + out.substring(6); /* 111 */ return out.toLowerCase().trim(); /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\WorldValidator.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */