classes.put(name, IOHelper.read(jar.getInputStream(entry)));
}
}
jar.close();
} else {
final ModScript script;
if (localms.exists() && !Configuration.RUNNING_FROM_JAR) {
log.info("Loading game client against local patch");
script = new ModScript(IOHelper.ungzip(IOHelper.read(localms)));
} else {
log.info("Downloading new game client");
script = new ModScript(HttpClient.downloadBinary(new URL(Configuration.Paths.URLs.CLIENTPATCH)));
}
version[0] = script.getVersion();
if (version[2] > version[0]) {
throw new ParseException("Patch outdated (" + version[2] + " > " + version[0] + ")");
}
final JarFile loader = getJar(true), client = getJar(false);
final List<String> replace = Arrays.asList(script.getAttribute("replace").split(" "));
for (final JarFile jar : new JarFile[]{loader, client}) {
final Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
final JarEntry entry = entries.nextElement();
String name = entry.getName();
if (name.endsWith(".class")) {
name = name.substring(0, name.length() - 6).replace('/', '.');
if (jar == client || replace.contains(name)) {
classes.put(name, IOHelper.read(jar.getInputStream(entry)));
}
}
}
jar.close();
}
for (final Map.Entry<String, byte[]> entry : classes.entrySet()) {
entry.setValue(script.process(entry.getKey(), entry.getValue()));
}
final ClassReader reader = new ClassReader(new ByteArrayInputStream(classes.get("client")));
final VersionVisitor vv = new VersionVisitor();
reader.accept(vv, ClassReader.SKIP_FRAMES);