diff options
| author | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 22:33:32 -0800 |
| commit | c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch) | |
| tree | df9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/WobLoader.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/scape/WobLoader.java')
| -rw-r--r-- | NET/worlds/scape/WobLoader.java | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/NET/worlds/scape/WobLoader.java b/NET/worlds/scape/WobLoader.java new file mode 100644 index 0000000..eb6d0e6 --- /dev/null +++ b/NET/worlds/scape/WobLoader.java @@ -0,0 +1,107 @@ +package NET.worlds.scape; + +import NET.worlds.console.Console; +import NET.worlds.network.URL; + +public class WobLoader implements BGLoaded { + private WobLoaded loaded; + private URL origURL; + SuperRoot value; + + public WobLoader(URL url, WobLoaded loaded) { + this(url, loaded, false); + } + + public WobLoader(URL url, WobLoaded loaded, boolean immediate) { + this.origURL = url; + this.loaded = loaded; + if (url.endsWith(".class")) { + String s = url.getAbsolute(); + if (s.startsWith("system:")) { + int len = s.length(); + + try { + Class c = Class.forName(s.substring(7, len - 6)); + SuperRoot sr = (SuperRoot)c.newInstance(); + sr.loadInit(); + this.gotIt(sr); + } catch (Exception var8) { + var8.printStackTrace(System.out); + Console.println("Can't make instance of class " + url); + this.gotIt(null); + } + + return; + } + } + + if (immediate) { + String s = url.unalias(); + if (s.indexOf(58) > 1) { + this.gotIt(null); + } else { + this.syncBackgroundLoad(this.asyncBackgroundLoad(s, url), url); + } + } else { + BackgroundLoader.get(this, url); + } + } + + public static SuperRoot immediateLoad(URL url) { + WobLoader w = new WobLoader(url, null, true); + return w.value; + } + + @Override + public Object asyncBackgroundLoad(String localName, URL remoteURL) { + return remoteURL.endsWith(".class") ? WobClassLoader.get(localName, remoteURL.getClassName()) : localName; + } + + @Override + public boolean syncBackgroundLoad(Object obj, URL remoteURL) { + SuperRoot sr = null; + if (obj != null) { + if (obj instanceof String) { + sr = SuperRoot.readFile((String)obj, remoteURL); + } else { + try { + sr = (SuperRoot)((Class)obj).newInstance(); + sr.loadInit(); + } catch (Exception var5) { + var5.printStackTrace(System.out); + } + } + } + + this.gotIt(sr); + return false; + } + + private void gotIt(SuperRoot s) { + if (s != null) { + s.setSourceURL(this.origURL); + } + + this.value = s; + if (this.loaded != null) { + this.loaded.wobLoaded(this, s); + } + } + + @Override + public Room getBackgroundLoadRoom() { + if (this.loaded instanceof SuperRoot) { + for (SuperRoot o = (SuperRoot)this.loaded; o != null; o = o.getOwner()) { + if (o instanceof WObject) { + return ((WObject)o).getRoom(); + } + } + } + + return null; + } + + public URL getWobName() { + return this.origURL; + } +} |