diff options
| author | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
| commit | e1e781bb2135ef78592226f1a3eaba4925702f1f (patch) | |
| tree | 8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/scape/WorldValidator.java | |
| download | worlds.jar-main.tar.xz worlds.jar-main.zip | |
Diffstat (limited to 'NET/worlds/scape/WorldValidator.java')
| -rw-r--r-- | NET/worlds/scape/WorldValidator.java | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/NET/worlds/scape/WorldValidator.java b/NET/worlds/scape/WorldValidator.java new file mode 100644 index 0000000..fb0e6bf --- /dev/null +++ b/NET/worlds/scape/WorldValidator.java @@ -0,0 +1,119 @@ +/* */ 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<String> 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 + */
\ No newline at end of file |