refactored more stuff out of MoF and renamed it to ReflectionInfo
parent
469d40c513
commit
a335d9e788
|
@ -7,8 +7,6 @@ import amidst.map.MapMarkers;
|
|||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
|
@ -35,10 +33,10 @@ public class ChunkManager extends Thread
|
|||
public ChunkManager(long seed) {
|
||||
try {
|
||||
if (firstRun) {
|
||||
iBiome = ClassLoader.getSystemClassLoader().loadClass(MoF.chunkName);
|
||||
iCache = ClassLoader.getSystemClassLoader().loadClass(MoF.intCacheName);
|
||||
iBiome = ClassLoader.getSystemClassLoader().loadClass(ReflectionInfo.chunkName);
|
||||
iCache = ClassLoader.getSystemClassLoader().loadClass(ReflectionInfo.intCacheName);
|
||||
Type t = null;
|
||||
if (MoF.versionID >= 9) {
|
||||
if (ReflectionInfo.versionID >= 9) {
|
||||
Method cs[] = iBiome.getDeclaredMethods();
|
||||
for (int i = 0; i < cs.length; i++) {
|
||||
Class<?>[] types = cs[i].getParameterTypes();
|
||||
|
@ -57,7 +55,7 @@ public class ChunkManager extends Thread
|
|||
Object[] ret = null;
|
||||
Method init;
|
||||
clearCache = iCache.getDeclaredMethod("a");
|
||||
if (MoF.versionID >= 9) {
|
||||
if (ReflectionInfo.versionID >= 9) {
|
||||
init = iBiome.getDeclaredMethod("a", new Class[] {Long.TYPE, s12w03a});
|
||||
String genString = "b";
|
||||
if (SaveLoader.genType.equals("flat"))
|
||||
|
@ -135,7 +133,7 @@ public class ChunkManager extends Thread
|
|||
getSlimeData(frag);
|
||||
getPlayerData(frag);
|
||||
getNetherholdData(frag);
|
||||
if (MoF.versionID >= 21)
|
||||
if (ReflectionInfo.versionID >= 21)
|
||||
getPyramidData(frag);
|
||||
/*try {
|
||||
Thread.sleep(5L);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package MoF;
|
||||
|
||||
|
||||
import amidst.Amidst;
|
||||
import amidst.Options;
|
||||
import amidst.resources.ResourceLoader;
|
||||
|
||||
|
@ -8,7 +9,6 @@ import java.awt.BorderLayout;
|
|||
import java.awt.Container;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
@ -19,7 +19,6 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
|
@ -50,7 +49,7 @@ public class FinderWindow extends JFrame {
|
|||
private JFileChooser fc;
|
||||
public FinderWindow() throws IOException {
|
||||
//Initialize window
|
||||
super("Amidst v" + MoF.version());
|
||||
super("Amidst v" + Amidst.version());
|
||||
pref = Preferences.userRoot().node(this.getClass().getName());
|
||||
|
||||
boolean first = pref.getBoolean("firstRun", true);
|
||||
|
@ -196,7 +195,7 @@ public class FinderWindow extends JFrame {
|
|||
gotoChunkMenu.setEnabled(false);
|
||||
gotoSpawnMenu.setEnabled(false);
|
||||
layerIconMenu.setSelected(true);
|
||||
if (MoF.DISABLE_SAVE)
|
||||
if (!Options.instance.saveEnabled)
|
||||
saveMenu.setEnabled(false);
|
||||
captureMenu.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
|
@ -426,13 +425,7 @@ public class FinderWindow extends JFrame {
|
|||
e.printStackTrace();
|
||||
fc.addChoosableFileFilter(new FileFilter() {
|
||||
public boolean accept(File f) {
|
||||
|
||||
if (f.isDirectory()) {
|
||||
return true;
|
||||
}
|
||||
if (f.getName().toLowerCase().endsWith(".jar"))
|
||||
return true;
|
||||
return false;
|
||||
return f.isDirectory() || f.getName().toLowerCase().endsWith(".jar");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -463,16 +456,15 @@ public class FinderWindow extends JFrame {
|
|||
|
||||
String typeDump = "";
|
||||
Field fields[] = mc.getDeclaredFields();
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
String typeString = fields[i].getType().toString();
|
||||
for (Field field : fields) {
|
||||
String typeString = field.getType().toString();
|
||||
if (typeString.startsWith("class ") && !typeString.contains("."))
|
||||
typeDump += typeString.substring(6);
|
||||
}
|
||||
typeDump.replace("[", "-");
|
||||
System.out.println(typeDump);
|
||||
String worldName = "";
|
||||
Field f = null;
|
||||
java.lang.reflect.Type t = null;
|
||||
System.out.println(typeDump.replace("[", "-"));
|
||||
String worldName;
|
||||
Field f;
|
||||
java.lang.reflect.Type t;
|
||||
|
||||
boolean is25 = false;
|
||||
boolean is131 = false;
|
||||
|
@ -567,7 +559,7 @@ public class FinderWindow extends JFrame {
|
|||
t = m.getReturnType();
|
||||
System.out.println("Version 12w07a or newer found!");
|
||||
}
|
||||
if (t.equals("void")) {
|
||||
if (t.toString().equals("void")) {
|
||||
System.out.println("Version 1.4.2 or newer found.");
|
||||
|
||||
}
|
||||
|
@ -589,159 +581,159 @@ public class FinderWindow extends JFrame {
|
|||
t = f.getType();
|
||||
biomeName = t.toString().split(" ")[1];
|
||||
}
|
||||
MoF.chunkName = biomeName;
|
||||
ReflectionInfo.chunkName = biomeName;
|
||||
f = mc.getDeclaredField(is131?"d":"a");
|
||||
t = f.getType();
|
||||
MoF.biomeName = t.toString().split(" ")[1];
|
||||
String intCache = "";
|
||||
ReflectionInfo.biomeName = t.toString().split(" ")[1];
|
||||
String intCache;
|
||||
System.out.println(biomeName);
|
||||
if (biomeName.equals("ait")&&is131) {
|
||||
MoF.version = "1.5.1";
|
||||
MoF.versionID = 60;
|
||||
ReflectionInfo.version = "1.5.1";
|
||||
ReflectionInfo.versionID = 60;
|
||||
intCache = "air";
|
||||
} else if (biomeName.equals("ain")&&is131) {
|
||||
MoF.version = "1.5.0";
|
||||
MoF.versionID = 58;
|
||||
ReflectionInfo.version = "1.5.0";
|
||||
ReflectionInfo.versionID = 58;
|
||||
intCache = "ail";
|
||||
} else if (biomeName.equals("agw")&&is131) {
|
||||
MoF.version = "1.4.6";
|
||||
MoF.versionID = 54;
|
||||
ReflectionInfo.version = "1.4.6";
|
||||
ReflectionInfo.versionID = 54;
|
||||
intCache = "agu";
|
||||
} else if (biomeName.equals("agp")&&is131) {
|
||||
MoF.version = "1.4.5";
|
||||
MoF.versionID = 53;
|
||||
ReflectionInfo.version = "1.4.5";
|
||||
ReflectionInfo.versionID = 53;
|
||||
intCache = "agn";
|
||||
} else if (biomeName.equals("afu")&&is131) {
|
||||
MoF.version = "1.4.2";
|
||||
MoF.versionID = 50;
|
||||
ReflectionInfo.version = "1.4.2";
|
||||
ReflectionInfo.versionID = 50;
|
||||
intCache = "afs";
|
||||
} else if (biomeName.equals("adc")&&is131) {
|
||||
MoF.version = "1.3.2";
|
||||
MoF.versionID = 43;
|
||||
ReflectionInfo.version = "1.3.2";
|
||||
ReflectionInfo.versionID = 43;
|
||||
intCache = "ada";
|
||||
} else if (biomeName.equals("adb")&&is131) {
|
||||
MoF.version = "1.3.1";
|
||||
MoF.versionID = 42;
|
||||
ReflectionInfo.version = "1.3.1";
|
||||
ReflectionInfo.versionID = 42;
|
||||
intCache = "acz";
|
||||
} else if (biomeName.equals("acl")&&v13) {
|
||||
MoF.version = "1.3pre";
|
||||
MoF.versionID = 40;
|
||||
ReflectionInfo.version = "1.3pre";
|
||||
ReflectionInfo.versionID = 40;
|
||||
intCache = "acj";
|
||||
} else if (biomeName.equals("acs")) {
|
||||
MoF.version = "12w27a";
|
||||
MoF.versionID = 28;
|
||||
ReflectionInfo.version = "12w27a";
|
||||
ReflectionInfo.versionID = 28;
|
||||
intCache = "av";
|
||||
} else if (biomeName.equals("acl")) {
|
||||
MoF.version = "12w26a";
|
||||
MoF.versionID = 27;
|
||||
ReflectionInfo.version = "12w26a";
|
||||
ReflectionInfo.versionID = 27;
|
||||
intCache = "av";
|
||||
} else if (biomeName.equals("aca")) {
|
||||
MoF.version = "12w24a";
|
||||
MoF.versionID = 25;
|
||||
ReflectionInfo.version = "12w24a";
|
||||
ReflectionInfo.versionID = 25;
|
||||
intCache = "av";
|
||||
} else if (biomeName.equals("acg")) {
|
||||
if (is25) {
|
||||
MoF.version = "12w25a";
|
||||
MoF.versionID = 26;
|
||||
ReflectionInfo.version = "12w25a";
|
||||
ReflectionInfo.versionID = 26;
|
||||
intCache = "av";
|
||||
} else {
|
||||
MoF.version = "12w23b";
|
||||
MoF.versionID = 24;
|
||||
ReflectionInfo.version = "12w23b";
|
||||
ReflectionInfo.versionID = 24;
|
||||
intCache = "ay";
|
||||
}
|
||||
} else if (biomeName.equals("ace")) {
|
||||
MoF.version = "12w22a";
|
||||
MoF.versionID = 23;
|
||||
ReflectionInfo.version = "12w22a";
|
||||
ReflectionInfo.versionID = 23;
|
||||
intCache = "ay";
|
||||
MoF.DISABLE_SAVE = true;
|
||||
Options.instance.saveEnabled = false;
|
||||
} else if (biomeName.equals("aby")) {
|
||||
MoF.version = "12w21b";
|
||||
MoF.versionID = 22;
|
||||
ReflectionInfo.version = "12w21b";
|
||||
ReflectionInfo.versionID = 22;
|
||||
intCache = "ax";
|
||||
MoF.DISABLE_SAVE = true;
|
||||
Options.instance.saveEnabled = false;
|
||||
} else if (biomeName.equals("abm")) {
|
||||
MoF.version = "12w21a";
|
||||
MoF.versionID = 21;
|
||||
ReflectionInfo.version = "12w21a";
|
||||
ReflectionInfo.versionID = 21;
|
||||
intCache = "ar";
|
||||
MoF.DISABLE_SAVE = true;
|
||||
Options.instance.saveEnabled = false;
|
||||
} else if (biomeName.equals("aau")) {
|
||||
MoF.version = "12w19a";
|
||||
MoF.versionID = 19;
|
||||
ReflectionInfo.version = "12w19a";
|
||||
ReflectionInfo.versionID = 19;
|
||||
intCache = "ao";
|
||||
} else if (biomeName.equals("wp")) {
|
||||
MoF.version = "1.2.4";
|
||||
MoF.versionID = 17;
|
||||
ReflectionInfo.version = "1.2.4";
|
||||
ReflectionInfo.versionID = 17;
|
||||
intCache = "ad";
|
||||
} else if (biomeName.equals("wl")) {
|
||||
MoF.version = "1.2.2";
|
||||
MoF.versionID = 16;
|
||||
ReflectionInfo.version = "1.2.2";
|
||||
ReflectionInfo.versionID = 16;
|
||||
intCache = "ac";
|
||||
} else if (biomeName.equals("wj")) {
|
||||
MoF.version = "12w08a";
|
||||
MoF.versionID = 15;
|
||||
ReflectionInfo.version = "12w08a";
|
||||
ReflectionInfo.versionID = 15;
|
||||
intCache = "ac";
|
||||
} else if (biomeName.equals("wd")) {
|
||||
MoF.version = "12w07b";
|
||||
ReflectionInfo.version = "12w07b";
|
||||
intCache = "ab";
|
||||
MoF.versionID = 14;
|
||||
ReflectionInfo.versionID = 14;
|
||||
|
||||
//Skipping 12w07a
|
||||
} else if (biomeName.equals("wb")) {
|
||||
MoF.version = "12w06a";
|
||||
ReflectionInfo.version = "12w06a";
|
||||
intCache = "ab";
|
||||
MoF.versionID = 12;
|
||||
ReflectionInfo.versionID = 12;
|
||||
} else if (biomeName.equals("vy")) {
|
||||
MoF.version = "12w05a";
|
||||
ReflectionInfo.version = "12w05a";
|
||||
intCache = "ab";
|
||||
MoF.versionID = 11;
|
||||
ReflectionInfo.versionID = 11;
|
||||
} else if (biomeName.equals("vu")) {
|
||||
MoF.version = "12w04a";
|
||||
ReflectionInfo.version = "12w04a";
|
||||
intCache = "ab";
|
||||
MoF.versionID = 10;
|
||||
ReflectionInfo.versionID = 10;
|
||||
} else if (biomeName.equals("vj")) {
|
||||
intCache = "ab";
|
||||
MoF.version = "12w03a";
|
||||
MoF.versionID = 9;
|
||||
ReflectionInfo.version = "12w03a";
|
||||
ReflectionInfo.versionID = 9;
|
||||
} else if (biomeName.equals("vc")) {
|
||||
intCache = "ab";
|
||||
MoF.version = "1.1";
|
||||
MoF.versionID = 8;
|
||||
ReflectionInfo.version = "1.1";
|
||||
ReflectionInfo.versionID = 8;
|
||||
} else if (biomeName.equals("jx")) {
|
||||
intCache = "bm";
|
||||
MoF.version = "1.0";
|
||||
MoF.versionID = 7;
|
||||
ReflectionInfo.version = "1.0";
|
||||
ReflectionInfo.versionID = 7;
|
||||
} else if (biomeName.equals("uk")) {
|
||||
intCache = "z";
|
||||
MoF.version = "1.9-pre6";
|
||||
MoF.versionID = 6;
|
||||
ReflectionInfo.version = "1.9-pre6";
|
||||
ReflectionInfo.versionID = 6;
|
||||
} else if (biomeName.equals("ug")) {
|
||||
intCache = "y";
|
||||
MoF.version = "1.9-pre5";
|
||||
MoF.versionID = 5;
|
||||
ReflectionInfo.version = "1.9-pre5";
|
||||
ReflectionInfo.versionID = 5;
|
||||
} else if (biomeName.equals("uh")) {
|
||||
intCache = "y";
|
||||
MoF.version = "1.9-pre4";
|
||||
ReflectionInfo.version = "1.9-pre4";
|
||||
MapGenStronghold.reset0 = true;
|
||||
MoF.versionID = 4;
|
||||
ReflectionInfo.versionID = 4;
|
||||
} else if (biomeName.equals("to")) {
|
||||
intCache = "x";
|
||||
MoF.version = "1.9-pre3";
|
||||
MoF.versionID = 3;
|
||||
ReflectionInfo.version = "1.9-pre3";
|
||||
ReflectionInfo.versionID = 3;
|
||||
} else if (biomeName.equals("sv")) {
|
||||
intCache = "x";
|
||||
MoF.version = "1.9-pre2";
|
||||
MoF.versionID = 2;
|
||||
ReflectionInfo.version = "1.9-pre2";
|
||||
ReflectionInfo.versionID = 2;
|
||||
} else if (biomeName.equals("sq")) {
|
||||
intCache = "x";
|
||||
MoF.version = "1.9-pre1";
|
||||
MoF.versionID = 1;
|
||||
ReflectionInfo.version = "1.9-pre1";
|
||||
ReflectionInfo.versionID = 1;
|
||||
} else if (biomeName.equals("rj")) {
|
||||
intCache = "w";
|
||||
MoF.version = "1.8.1";
|
||||
MoF.versionID = 0;
|
||||
ReflectionInfo.version = "1.8.1";
|
||||
ReflectionInfo.versionID = 0;
|
||||
} else {
|
||||
MoF.version = "unknown";
|
||||
MoF.versionID = -1;
|
||||
ReflectionInfo.version = "unknown";
|
||||
ReflectionInfo.versionID = -1;
|
||||
intCache = "ab";
|
||||
String st = JOptionPane.showInputDialog(null, "Unsupported version of minecraft detected!\nEnter code to continue:\n(Name of the IntCache class)", "Error", 1);
|
||||
if (st==null) {
|
||||
|
@ -750,19 +742,18 @@ public class FinderWindow extends JFrame {
|
|||
intCache = st;
|
||||
}
|
||||
}
|
||||
System.out.println("Version " + MoF.version + " detected. " + (MoF.DISABLE_SAVE?"Saves disabled.":""));
|
||||
System.out.println("Version " + ReflectionInfo.version + " detected. " + (Options.instance.saveEnabled ? "" : "Saves disabled."));
|
||||
// pre5 - y, ug
|
||||
// pre4 - y, uh
|
||||
// pre3 - x, to
|
||||
// pre2 - x, sv
|
||||
// pre1 - x, sq
|
||||
// pre0 - w, rj
|
||||
MoF.intCacheName = intCache;
|
||||
ReflectionInfo.intCacheName = intCache;
|
||||
} catch (java.lang.NoClassDefFoundError e2) {
|
||||
JOptionPane.showMessageDialog(this, "AMIDST ran in JAR mode without -noverify!\nUse: java -noverify -jar AMIDST.jar");
|
||||
System.exit(0);
|
||||
} catch (Exception e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ package MoF;
|
|||
public class Google {
|
||||
//private static JGoogleAnalyticsTracker tracker;
|
||||
public static void startTracking() {
|
||||
//tracker = new JGoogleAnalyticsTracker("AMIDST",MoF.version(),"UA-27092717-1");
|
||||
//tracker = new JGoogleAnalyticsTracker("AMIDST", Amidst.version(), "UA-27092717-1");
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -32,9 +32,9 @@ public class MapGenPyramid {
|
|||
|
||||
if ((paramInt1 == n) && (paramInt2 == i1)) {
|
||||
boolean bool = false;
|
||||
if (MoF.versionID >= 50) //1.4.2
|
||||
if (ReflectionInfo.versionID >= 50) //1.4.2
|
||||
bool = x.a(paramInt1 * 16 + 8, paramInt2 * 16 + 8, 0, c);
|
||||
else if (MoF.versionID >= 23) //12w22a
|
||||
else if (ReflectionInfo.versionID >= 23) //12w22a
|
||||
bool = x.a(paramInt1 * 16 + 8, paramInt2 * 16 + 8, 0, b);
|
||||
else
|
||||
bool = x.a(paramInt1 * 16 + 8, paramInt2 * 16 + 8, 0, a);
|
||||
|
|
|
@ -25,11 +25,11 @@ public class MapGenStronghold
|
|||
int k = (int)Math.round(Math.cos(d1) * d2);
|
||||
int m = (int)Math.round(Math.sin(d1) * d2);
|
||||
Biome[] v = a;
|
||||
if (MoF.version.equals("1.9-pre6")||MoF.version.equals("1.0"))
|
||||
if (ReflectionInfo.version.equals("1.9-pre6")|| ReflectionInfo.version.equals("1.0"))
|
||||
v = b;
|
||||
if (MoF.version.equals("1.1"))
|
||||
if (ReflectionInfo.version.equals("1.1"))
|
||||
v = ab;
|
||||
if (MoF.versionID >= 9)
|
||||
if (ReflectionInfo.versionID >= 9)
|
||||
v = ac;
|
||||
ArrayList<Biome> localArrayList = new ArrayList<Biome>();
|
||||
for (Object localObject2 : v) {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package MoF;
|
||||
|
||||
|
||||
import amidst.Options;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
|
@ -399,7 +401,7 @@ public class MapViewer extends JComponent implements MouseListener, MouseWheelLi
|
|||
private int tempX, tempY;
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()&&!MoF.DISABLE_SAVE) {
|
||||
if (e.isPopupTrigger() && Options.instance.saveEnabled) {
|
||||
if (proj.saveLoaded) {
|
||||
tempX = e.getX();
|
||||
tempY = e.getY();
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
|
||||
package MoF;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
|
||||
public class MoF {
|
||||
public static double version_major = 2.0;
|
||||
public static int version_minor = 44;
|
||||
public static String biomeName;
|
||||
public static String intCacheName;
|
||||
public static String chunkName;
|
||||
public static String version;
|
||||
public static int versionID;
|
||||
|
||||
public static boolean NETHER = true;
|
||||
public static boolean DEBUG = true;
|
||||
public static boolean DISABLE_SAVE = false;
|
||||
|
||||
public static String stuff = "";
|
||||
|
||||
static {
|
||||
stuff += "Hey, if you actually bothered to decompile this code\n";
|
||||
stuff += "I just want to say sorry-- it's so messy and ugly :(\n";
|
||||
stuff += "I mean... really.. I'm sorry.\n";
|
||||
stuff += "....I cry a little bit every time I make an update...\n";
|
||||
}
|
||||
|
||||
public static String version() {
|
||||
return MoF.version_major + "." + MoF.version_minor;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package MoF;
|
||||
|
||||
public class ReflectionInfo {
|
||||
public static String biomeName;
|
||||
public static String intCacheName;
|
||||
public static String chunkName;
|
||||
public static String version;
|
||||
public static int versionID;
|
||||
}
|
|
@ -6,6 +6,8 @@ import java.net.URL;
|
|||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
import amidst.Amidst;
|
||||
import org.w3c.dom.*;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
@ -28,75 +30,58 @@ public class UpdateManager extends Thread {
|
|||
}
|
||||
public void run() {
|
||||
|
||||
URL url = null;
|
||||
try {
|
||||
url = new URL(updateURL);
|
||||
URL url = new URL(updateURL);
|
||||
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
|
||||
Document doc = docBuilder.parse(url.openStream());
|
||||
|
||||
doc.getDocumentElement().normalize();
|
||||
NodeList vlist = doc.getDocumentElement().getElementsByTagName("version");
|
||||
NodeList version = vlist.item(0).getChildNodes();
|
||||
|
||||
Node v = null;
|
||||
double major = 0;
|
||||
int minor = 0;
|
||||
String updateURL = doc.getFirstChild().getAttributes().item(0).getNodeValue();
|
||||
for (int i = 0; i < version.getLength(); i++) {
|
||||
v = version.item(i);
|
||||
if (v.getNodeType() == Node.ELEMENT_NODE) {
|
||||
if (v.getNodeName().toLowerCase().equals("major")) {
|
||||
major = Double.parseDouble(v.getAttributes().item(0).getNodeValue());
|
||||
} else if (v.getNodeName().toLowerCase().equals("minor")) {
|
||||
minor = Integer.parseInt(v.getAttributes().item(0).getNodeValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((major == MoF.version_major) && (minor == MoF.version_minor)) {
|
||||
if (!silent)
|
||||
JOptionPane.showMessageDialog(window, "There are no new updates.");
|
||||
} else if ((major == MoF.version_major) && (minor != MoF.version_minor)) {
|
||||
int n = JOptionPane.showConfirmDialog(
|
||||
window,
|
||||
"A minor revision was found. Update?",
|
||||
"Update Found",
|
||||
JOptionPane.YES_NO_OPTION);
|
||||
if (n==0) {
|
||||
if( !java.awt.Desktop.isDesktopSupported()) {
|
||||
JOptionPane.showMessageDialog(window, "Error unable to open browser.");
|
||||
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
|
||||
Document doc = docBuilder.parse(url.openStream());
|
||||
|
||||
doc.getDocumentElement().normalize();
|
||||
NodeList vlist = doc.getDocumentElement().getElementsByTagName("version");
|
||||
NodeList version = vlist.item(0).getChildNodes();
|
||||
|
||||
int major = 0;
|
||||
int minor = 0;
|
||||
String updateURL = doc.getFirstChild().getAttributes().item(0).getNodeValue();
|
||||
for (int i = 0; i < version.getLength(); i++) {
|
||||
Node v = version.item(i);
|
||||
if (v.getNodeType() == Node.ELEMENT_NODE) {
|
||||
if (v.getNodeName().toLowerCase().equals("major")) {
|
||||
major = Integer.parseInt(v.getAttributes().item(0).getNodeValue());
|
||||
} else if (v.getNodeName().toLowerCase().equals("minor")) {
|
||||
minor = Integer.parseInt(v.getAttributes().item(0).getNodeValue());
|
||||
}
|
||||
|
||||
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
|
||||
|
||||
if( !desktop.isSupported( java.awt.Desktop.Action.BROWSE ) ) {
|
||||
JOptionPane.showMessageDialog(window, "Error unable to open browser page.");
|
||||
}
|
||||
java.net.URI uri = new java.net.URI(updateURL);
|
||||
desktop.browse( uri );
|
||||
}
|
||||
|
||||
} else if (major != MoF.version_major) {
|
||||
int n = JOptionPane.showConfirmDialog(
|
||||
window,
|
||||
"A new version was found. Would you like to update?",
|
||||
"Update Found",
|
||||
JOptionPane.YES_NO_OPTION);
|
||||
if (n==0) {
|
||||
if( !java.awt.Desktop.isDesktopSupported()) {
|
||||
JOptionPane.showMessageDialog(window, "Error unable to open browser.");
|
||||
}
|
||||
|
||||
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
|
||||
|
||||
if( !desktop.isSupported( java.awt.Desktop.Action.BROWSE ) ) {
|
||||
|
||||
JOptionPane.showMessageDialog(window, "Error unable to open browser page.");
|
||||
}
|
||||
java.net.URI uri = new java.net.URI(updateURL);
|
||||
desktop.browse( uri );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int n = JOptionPane.NO_OPTION;
|
||||
if (major > Amidst.version_major) {
|
||||
n = JOptionPane.showConfirmDialog(
|
||||
window,
|
||||
"A new version was found. Would you like to update?",
|
||||
"Update Found",
|
||||
JOptionPane.YES_NO_OPTION);
|
||||
} else if ((major == Amidst.version_major) && (minor > Amidst.version_minor)) {
|
||||
n = JOptionPane.showConfirmDialog(
|
||||
window,
|
||||
"A minor revision was found. Update?",
|
||||
"Update Found",
|
||||
JOptionPane.YES_NO_OPTION);
|
||||
} else if (!silent)
|
||||
JOptionPane.showMessageDialog(window, "There are no new updates.");
|
||||
|
||||
if (n==0) {
|
||||
if( !java.awt.Desktop.isDesktopSupported()) {
|
||||
JOptionPane.showMessageDialog(window, "Error unable to open browser.");
|
||||
}
|
||||
|
||||
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
|
||||
|
||||
if( !desktop.isSupported( java.awt.Desktop.Action.BROWSE ) ) {
|
||||
JOptionPane.showMessageDialog(window, "Error unable to open browser page.");
|
||||
}
|
||||
java.net.URI uri = new java.net.URI(updateURL);
|
||||
desktop.browse(uri);
|
||||
}
|
||||
} catch (MalformedURLException e1) {
|
||||
if (!silent)
|
||||
JOptionPane.showMessageDialog(window, "Error connecting to update server: Malformed URL.");
|
||||
|
|
|
@ -6,7 +6,8 @@ import MoF.Google;
|
|||
import java.io.IOException;
|
||||
|
||||
public class Amidst {
|
||||
public static FinderWindow window;
|
||||
public final static int version_major = 3;
|
||||
public final static int version_minor = 0;
|
||||
|
||||
public static void main(String args[]) throws IOException {
|
||||
Google.startTracking();
|
||||
|
@ -14,4 +15,8 @@ public class Amidst {
|
|||
//TODO: load options
|
||||
new FinderWindow();
|
||||
}
|
||||
|
||||
public static String version() {
|
||||
return version_major + "." + version_minor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,11 @@ public enum Options {
|
|||
|
||||
public ToggleButtonModel showIcons;
|
||||
public ToggleButtonModel showNetherFortresses;
|
||||
public boolean saveEnabled;
|
||||
|
||||
private Options() {
|
||||
showIcons = new ToggleButtonModel();
|
||||
showNetherFortresses = new ToggleButtonModel();
|
||||
saveEnabled = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue