Skip to content

Commit

Permalink
Fix class NotFoundException on Paper-443 (1.8.8) (#159)
Browse files Browse the repository at this point in the history
Java couldn't find the class WorldType because it wasn't using the
correct classpath. The ByteArrayClassPath will only load the class
we're patching, and not any dependent classes. I'm pretty sure we
don't need both the ByteArrayClassPath and the new LoaderClassPath,
but I only tested with 1.8.8 on Spigot/Paper.

Fixes #158

Co-authored-by: Grinderwolf <[email protected]>
  • Loading branch information
brandonwamboldt and cijaaimee authored Sep 9, 2020
1 parent 59443d6 commit 0196209
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 15 additions & 1 deletion slimeworldmanager-classmodifier/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,29 @@

<artifactId>slimeworldmanager-classmodifier</artifactId>

<repositories>
<repository>
<id>minecraft-libraries</id>
<name>Minecraft Libraries</name>
<url>https://libraries.minecraft.net</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.25.0-GA</version>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>datafixerupper</artifactId>
<version>1.0.20</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<artifactId>spigot-api</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.grinderwolf.swm.clsm;

import javassist.ByteArrayClassPath;
import javassist.LoaderClassPath;
import javassist.CannotCompileException;
import javassist.ClassPool;
import javassist.CtClass;
Expand Down Expand Up @@ -145,7 +145,7 @@ public byte[] transform(ClassLoader classLoader, String className, Class<?> clas

try {
ClassPool pool = ClassPool.getDefault();
pool.appendClassPath(new ByteArrayClassPath(fixedClassName, bytes));
pool.appendClassPath(new LoaderClassPath(classLoader));
CtClass ctClass = pool.get(fixedClassName);

for (Change change : changes.get(className)) {
Expand Down

0 comments on commit 0196209

Please sign in to comment.