Skip to content

Commit

Permalink
fix: don't catch runelite patching errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Z-Kris committed Jan 29, 2025
1 parent f48917a commit d8a993f
Showing 1 changed file with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,31 +290,27 @@ public class RuneLitePatcher : Patcher<Unit> {
originalResource: String,
replacementResource: String,
) {
try {
val replacementResourceFile =
RuneLitePatcher::class.java
.getResourceAsStream(replacementResource)
?.readAllBytes()
?: throw IllegalStateException("$replacementResource resource not available")

val originalResourceFile =
RuneLitePatcher::class.java
.getResourceAsStream(originalResource)
?.readAllBytes()
?: throw IllegalStateException("$originalResource resource not available.")

val originalBytes = classFile.readBytes()
if (!originalBytes.contentEquals(originalResourceFile)) {
throw IllegalStateException("Unable to patch RuneLite $replacementResource - out of date.")
}
val replacementResourceFile =
RuneLitePatcher::class.java
.getResourceAsStream(replacementResource)
?.readAllBytes()
?: throw IllegalStateException("$replacementResource resource not available")

// Overwrite the WorldClient.class file to read worlds from our proxied-list
// This ensures that the world switcher still goes through the proxy tool,
// instead of just connecting to RuneLite's own world list API.
classFile.writeBytes(replacementResourceFile)
} catch (t: Throwable) {
t.printStackTrace()
val originalResourceFile =
RuneLitePatcher::class.java
.getResourceAsStream(originalResource)
?.readAllBytes()
?: throw IllegalStateException("$originalResource resource not available.")

val originalBytes = classFile.readBytes()
if (!originalBytes.contentEquals(originalResourceFile)) {
throw IllegalStateException("Unable to patch RuneLite $replacementResource - out of date.")
}

// Overwrite the WorldClient.class file to read worlds from our proxied-list
// This ensures that the world switcher still goes through the proxy tool,
// instead of just connecting to RuneLite's own world list API.
classFile.writeBytes(replacementResourceFile)
}

private fun patchPort(
Expand Down

0 comments on commit d8a993f

Please sign in to comment.