Package org.rsbot.loader.script

Examples of org.rsbot.loader.script.ModScript


          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);
View Full Code Here

TOP

Related Classes of org.rsbot.loader.script.ModScript

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.