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
This commit is contained in:
Ganom
2019-05-26 16:44:30 -04:00
committed by GitHub
parent 6234515eea
commit 35349eae44
5 changed files with 24 additions and 149 deletions

View File

@@ -196,7 +196,7 @@
<dependency>
<groupId>net.runelit</groupId>
<artifactId>client-patch</artifactId>
<version>1.5.25.1</version>
<version>1.5.25.2</version>
<scope>runtime</scope>
</dependency>
<dependency>
@@ -220,7 +220,6 @@
<artifactId>extended-mixins</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -334,7 +333,7 @@
</filter>
<filter>
<!-- net.runelit:client-patch -->
<artifact>net.runelite:client-patch</artifact>
<artifact>net.runelit:client-patch</artifact>
<includes>
<include>**</include>
</includes>

View File

@@ -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<Actor> burnTarget = new ArrayList<>();
@Getter(AccessLevel.PACKAGE)
private List<Actor> 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;
}
}

View File

@@ -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);
}
}

View File

@@ -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;
}
//------------------------------------------------------------//
}
}

View File

@@ -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<String, String> hashes;
try (InputStream is = ClientLoader.class.getResourceAsStream("/patch/hashes.json"))
{
hashes = new Gson().fromJson(new InputStreamReader(is), new TypeToken<HashMap<String, String>>()
{
}.getType());
}
for (Map.Entry<String, String> 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<String, byte[]> patches = new HashMap<>();
for (Map.Entry<String, byte[]> 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<String, byte[]> 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<? extends Certificate> 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();
}
}