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/console/PersonalInfoDownload.java | |
| download | worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip | |
Initial commit
Diffstat (limited to 'NET/worlds/console/PersonalInfoDownload.java')
| -rw-r--r-- | NET/worlds/console/PersonalInfoDownload.java | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/NET/worlds/console/PersonalInfoDownload.java b/NET/worlds/console/PersonalInfoDownload.java new file mode 100644 index 0000000..4e4e890 --- /dev/null +++ b/NET/worlds/console/PersonalInfoDownload.java @@ -0,0 +1,99 @@ +package NET.worlds.console; + +import NET.worlds.network.Cache; +import NET.worlds.network.CacheFile; +import NET.worlds.network.URL; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.Label; +import java.io.DataInputStream; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.text.MessageFormat; +import java.util.Vector; + +class PersonalInfoDownload extends OkCancelDialog implements Runnable { + private static final long serialVersionUID = -198244581766521022L; + private String name; + private CacheFile cf; + private static Font font = new Font(Console.message("MenuFont"), 0, 12); + + public PersonalInfoDownload(String name, Console console) { + super(Console.getFrame(), null, Console.message("Downloading2"), Console.message("Cancel"), null, false); + this.name = name; + String cfS = console.getScriptServer() + "profile" + Console.message(".pl") + "?" + name; + this.cf = Cache.getFile(URL.make(cfS)); + if (Console.wasHttpNoSuchFile(cfS)) { + this.cf = Cache.getFile(URL.make(console.getScriptServer() + "profile.pl?" + name)); + } + + this.setFont(new Font(Console.message("FriendsFont"), 0, 12)); + Thread t = new Thread(this); + t.setDaemon(true); + t.start(); + } + + @Override + protected void build() { + GridBagConstraints c = new GridBagConstraints(); + c.weightx = 1.0; + c.weighty = 1.0; + c.gridwidth = 0; + Object[] arguments = new Object[]{new String(this.name)}; + Label lDown = new Label(MessageFormat.format(Console.message("Downloading"), arguments)); + lDown.setFont(font); + this.add(this.gbag, lDown, c); + Label lWait = new Label(Console.message("Please-wait")); + lWait.setFont(font); + this.add(this.gbag, lWait, c); + super.build(); + } + + @Override + public void run() { + this.readySetGo(); + this.cf.waitUntilLoaded(); + if (this.cf.isActive()) { + this.done(true); + if (this.cf.error()) { + Object[] arguments = new Object[]{new String(this.name)}; + new OkCancelDialog( + Console.getFrame(), + null, + Console.message("Error"), + null, + Console.message("OK"), + MessageFormat.format(Console.message("Error-down"), arguments), + false + ); + System.out.println("Error downloading personal info for " + this.name); + } else { + Vector<String> data = new Vector<String>(); + DataInputStream in = null; + + try { + in = new DataInputStream(new FileInputStream(this.cf.getLocalName())); + + String line; + while ((line = in.readLine()) != null) { + data.addElement(line); + } + + new PersonalInfoDialog(this.name, data); + } catch (FileNotFoundException var14) { + } catch (IOException var15) { + } finally { + try { + if (in != null) { + in.close(); + } + } catch (IOException var13) { + } + } + } + + this.cf.close(); + } + } +} |