summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/WorldValidator.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/WorldValidator.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/WorldValidator.java')
-rw-r--r--NET/worlds/scape/WorldValidator.java84
1 files changed, 84 insertions, 0 deletions
diff --git a/NET/worlds/scape/WorldValidator.java b/NET/worlds/scape/WorldValidator.java
new file mode 100644
index 0000000..dbfd629
--- /dev/null
+++ b/NET/worlds/scape/WorldValidator.java
@@ -0,0 +1,84 @@
+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();
+ }
+}