From 35349eae4405c51dcbfd4b57951e7efb9046d76a Mon Sep 17 00:00:00 2001 From: Ganom Date: Sun, 26 May 2019 16:44:30 -0400 Subject: [PATCH] Update client patch to latest version (#398) * Update client patch to latest version * Fix Client Loader for manual patching * Update TimersOverlay.java * Fix cox * defaults set --- runelite-client/pom.xml | 5 +- .../client/plugins/coxhelper/CoxPlugin.java | 20 +-- .../plugins/coxhelper/TimersOverlay.java | 17 +-- .../MenuEntrySwapperConfig.java | 14 +-- .../net/runelite/client/rs/ClientLoader.java | 117 +----------------- 5 files changed, 24 insertions(+), 149 deletions(-) diff --git a/runelite-client/pom.xml b/runelite-client/pom.xml index c3f795ac32..aa7438c45e 100644 --- a/runelite-client/pom.xml +++ b/runelite-client/pom.xml @@ -196,7 +196,7 @@ net.runelit client-patch - 1.5.25.1 + 1.5.25.2 runtime @@ -220,7 +220,6 @@ extended-mixins ${project.version} - junit junit @@ -334,7 +333,7 @@ - net.runelite:client-patch + net.runelit:client-patch ** diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxPlugin.java index 3da0246040..ce47a425a4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/CoxPlugin.java @@ -44,6 +44,7 @@ import net.runelite.api.GraphicID; import net.runelite.api.GraphicsObject; import net.runelite.api.NPC; import net.runelite.api.NpcID; +import net.runelite.api.Player; import net.runelite.api.Projectile; import net.runelite.api.ProjectileID; import net.runelite.api.Varbits; @@ -175,7 +176,7 @@ public class CoxPlugin extends Plugin private List burnTarget = new ArrayList<>(); @Getter(AccessLevel.PACKAGE) - private List teleportTarget = new ArrayList<>(); + private Actor teleportTarget; @Getter(AccessLevel.PACKAGE) private Actor acidTarget; @@ -234,7 +235,7 @@ public class CoxPlugin extends Plugin overlayManager.remove(timersOverlay); HandCripple = false; acidTarget = null; - teleportTarget.clear(); + teleportTarget = null; burnTarget.clear(); timer = 45; burnTicks = 40; @@ -248,7 +249,7 @@ public class CoxPlugin extends Plugin { final Matcher tpMatcher = TP_REGEX.matcher(chatMessage.getMessage()); String msg = chatMessage.getMessageNode().getValue(); - if (chatMessage.getType() == ChatMessageType.GAMEMESSAGE) + if (chatMessage.getType() == ChatMessageType.PUBLICCHAT) { if (msg.toLowerCase().contains("The Great Olm rises with the power of".toLowerCase())) { @@ -315,7 +316,7 @@ public class CoxPlugin extends Plugin { if (actor.getName().equals((tpMatcher.group(1)))) { - teleportTarget.add(actor); + teleportTarget = actor; } } } @@ -351,10 +352,6 @@ public class CoxPlugin extends Plugin { burnTarget.add(actor); } - if (actor.getGraphic() == GraphicID.OLM_TELEPORT) - { - teleportTarget.add(actor); - } } @Subscribe @@ -461,12 +458,15 @@ public class CoxPlugin extends Plugin acidTicks = 25; } } - if (teleportTarget.size() > 0) + if (teleportTarget != null) { + Player target = (Player) teleportTarget; + client.setHintArrow(target); teleportTicks--; if (teleportTicks <= 0) { - teleportTarget.clear(); + client.clearHintArrow(); + teleportTarget = null; teleportTicks = 10; } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/TimersOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/TimersOverlay.java index fb3d7bebda..f827615541 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/TimersOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/coxhelper/TimersOverlay.java @@ -33,7 +33,6 @@ import javax.inject.Inject; import net.runelite.api.Actor; import net.runelite.api.Client; import net.runelite.api.Perspective; -import net.runelite.api.Player; import net.runelite.api.Point; import net.runelite.api.coords.LocalPoint; import net.runelite.client.ui.overlay.Overlay; @@ -123,21 +122,9 @@ public class TimersOverlay extends Overlay if (config.tpOverlay()) { - if (plugin.getTeleportTarget().size() > 0) + if (plugin.getTeleportTarget() != null) { - for (Actor actor : plugin.getTeleportTarget()) - { - if (actor instanceof Player) - { - Player target = (Player) actor; - renderNpcOverlay(graphics, target, new Color(193, 255, 245, 255), 2, 100, 10); - client.setHintArrow(target); - } - else - { - renderNpcOverlay(graphics, actor, new Color(193, 255, 245, 255), 2, 100, 10); - } - } + renderNpcOverlay(graphics, plugin.getTeleportTarget(), new Color(193, 255, 245, 255), 2, 100, 10); } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java index 7fa9be0375..490d8a0d75 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/menuentryswapper/MenuEntrySwapperConfig.java @@ -1471,7 +1471,7 @@ public interface MenuEntrySwapperConfig extends Config ) default boolean hideExamine() { - return true; + return false; } @ConfigItem( @@ -1483,7 +1483,7 @@ public interface MenuEntrySwapperConfig extends Config ) default boolean hideTradeWith() { - return true; + return false; } @ConfigItem( @@ -1495,7 +1495,7 @@ public interface MenuEntrySwapperConfig extends Config ) default boolean hideReport() { - return true; + return false; } @ConfigItem( @@ -1507,7 +1507,7 @@ public interface MenuEntrySwapperConfig extends Config ) default boolean hideLookup() { - return true; + return false; } @ConfigItem( @@ -1519,7 +1519,7 @@ public interface MenuEntrySwapperConfig extends Config ) default boolean hideNet() { - return true; + return false; } @ConfigItem( @@ -1531,8 +1531,8 @@ public interface MenuEntrySwapperConfig extends Config ) default boolean hideBait() { - return true; + return false; } //------------------------------------------------------------// -} \ No newline at end of file +} diff --git a/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java b/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java index 127ef27b23..14a73594c7 100644 --- a/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java +++ b/runelite-client/src/main/java/net/runelite/client/rs/ClientLoader.java @@ -26,21 +26,13 @@ */ package net.runelite.client.rs; -import com.google.common.hash.Hashing; import com.google.common.io.ByteStreams; -import com.google.common.reflect.TypeToken; -import com.google.gson.Gson; import io.sigpipe.jbsdiff.InvalidHeaderException; import io.sigpipe.jbsdiff.Patch; import java.applet.Applet; import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; -import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.security.cert.Certificate; import java.security.cert.CertificateException; @@ -52,7 +44,6 @@ import java.util.Map; import java.util.jar.Attributes; import java.util.jar.JarEntry; import java.util.jar.JarInputStream; -import java.util.jar.JarOutputStream; import java.util.jar.Manifest; import javax.inject.Inject; import javax.inject.Named; @@ -61,8 +52,6 @@ import lombok.extern.slf4j.Slf4j; import net.runelite.api.Client; import static net.runelite.client.rs.ClientUpdateCheckMode.AUTO; import static net.runelite.client.rs.ClientUpdateCheckMode.NONE; -import static net.runelite.client.rs.ClientUpdateCheckMode.VANILLA; -import net.runelite.client.rs.mixins.MixinRunner; import net.runelite.http.api.RuneLiteAPI; import okhttp3.Request; import okhttp3.Response; @@ -152,44 +141,9 @@ public class ClientLoader } } - if (updateCheckMode == AUTO) - { - Map hashes; - try (InputStream is = ClientLoader.class.getResourceAsStream("/patch/hashes.json")) - { - hashes = new Gson().fromJson(new InputStreamReader(is), new TypeToken>() - { - }.getType()); - } - - for (Map.Entry file : hashes.entrySet()) - { - byte[] bytes = zipFile.get(file.getKey()); - - String ourHash = null; - if (bytes != null) - { - ourHash = Hashing.sha512().hashBytes(bytes).toString(); - } - - if (!file.getValue().equals(ourHash)) - { - log.info("{} had a hash mismatch; falling back to vanilla. {} != {}", file.getKey(), - file.getValue(), ourHash); - log.info("Client is outdated!"); - updateCheckMode = VANILLA; - break; - } - } - } if (updateCheckMode == AUTO) { - File injectedClientFile = new File("./InjectedClient.jar"); - Manifest manifest2 = new Manifest(); - manifest2.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); - JarOutputStream target = new JarOutputStream(new FileOutputStream(injectedClientFile), manifest2); - ByteArrayOutputStream patchOs = new ByteArrayOutputStream(756 * 1024); int patchCount = 0; @@ -211,68 +165,11 @@ public class ClientLoader file.setValue(patchOs.toByteArray()); ++patchCount; - if (!file.getKey().startsWith("META")) - { - add(file.getValue(), file.getKey(), target); - } } - target.close(); + log.info("Patched {} classes", patchCount); } - log.info("Patching for RuneLitePlus"); - - if (updateCheckMode == AUTO) - { - HashMap patches = new HashMap<>(); - - for (Map.Entry file : zipFile.entrySet()) - { - byte[] patchClass; - try (InputStream is = ClientLoader.class.getResourceAsStream("/extended-mixins/" + file.getKey())) - { - if (is == null) - { - continue; - } - - patchClass = ByteStreams.toByteArray(is); - } - - patches.put(file.getKey(), patchClass); - } - - new MixinRunner(zipFile, patches).run(); - - } - - Map injectedClient = new HashMap<>(); - JarInputStream jis = new JarInputStream(new FileInputStream("./injectedClient.jar")); - - byte[] tmp = new byte[4096]; - ByteArrayOutputStream buffer = new ByteArrayOutputStream(756 * 1024); - for (; ; ) - { - JarEntry metadata = jis.getNextJarEntry(); - if (metadata == null) - { - break; - } - - buffer.reset(); - for (; ; ) - { - int n = jis.read(tmp); - if (n <= -1) - { - break; - } - buffer.write(tmp, 0, n); - } - - injectedClient.put(metadata.getName(), buffer.toByteArray()); - } - String initialClass = config.getInitialClass(); ClassLoader rsClassLoader = new ClassLoader(ClientLoader.class.getClassLoader()) @@ -281,7 +178,7 @@ public class ClientLoader protected Class findClass(String name) throws ClassNotFoundException { String path = name.replace('.', '/').concat(".class"); - byte[] data = injectedClient.get(path); + byte[] data = zipFile.get(path); if (data == null) { throw new ClassNotFoundException(name); @@ -303,7 +200,7 @@ public class ClientLoader return rs; } - catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException | CompressorException | InvalidHeaderException | SecurityException | NoSuchMethodException | InvocationTargetException | CertificateException | VerificationException e) + catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException | SecurityException | VerificationException | CertificateException | CompressorException | InvalidHeaderException e) { if (e instanceof ClassNotFoundException) { @@ -323,12 +220,4 @@ public class ClientLoader Collection certificates = certificateFactory.generateCertificates(ClientLoader.class.getResourceAsStream("jagex.crt")); return certificates.toArray(new Certificate[0]); } - - private void add(byte[] bytes, String entryName, JarOutputStream target) throws IOException - { - JarEntry entry = new JarEntry(entryName); - target.putNextEntry(entry); - target.write(bytes); - target.closeEntry(); - } }