-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add static transformer directly to jma
- Loading branch information
1 parent
007ee1e
commit ffeec81
Showing
7 changed files
with
171 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
org.gradle.jvmargs=-Xmx1G | ||
version=0.1.2 | ||
version=0.1.3 | ||
maven_group=xyz.wagyourtail.unimined | ||
archives_base_name=jarmod-agent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...main/java/xyz/wagyourtail/unimined/jarmodagent/transformer/ClassProviderWithFallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package xyz.wagyourtail.unimined.jarmodagent.transformer; | ||
|
||
import net.lenni0451.classtransform.utils.tree.BasicClassProvider; | ||
import net.lenni0451.classtransform.utils.tree.IClassProvider; | ||
|
||
import java.io.InputStream; | ||
import java.util.Map; | ||
import java.util.function.Supplier; | ||
|
||
public class ClassProviderWithFallback implements IClassProvider { | ||
PriorityClasspath priorityClasspath; | ||
ClassLoader fallback; | ||
BasicClassProvider fallback2 = new BasicClassProvider(); | ||
|
||
|
||
public ClassProviderWithFallback(PriorityClasspath priorityClasspath, ClassLoader fallback) { | ||
this.priorityClasspath = priorityClasspath; | ||
this.fallback = fallback; | ||
} | ||
|
||
public void setFallback(ClassLoader fallback) { | ||
this.fallback = fallback; | ||
} | ||
|
||
@Override | ||
public byte[] getClass(String name) { | ||
InputStream is = priorityClasspath.getResourceAsStream(name.replace('.', '/') + ".class"); | ||
if (is == null && fallback != null) { | ||
is = fallback.getResourceAsStream(name.replace('.', '/') + ".class"); | ||
} | ||
if (is == null) { | ||
return fallback2.getClass(name); | ||
} | ||
return JarModder.readAllBytes(is); | ||
} | ||
|
||
public Map<String, Supplier<byte[]>> getAllClasses() { | ||
throw new UnsupportedOperationException("Cannot use wildcards yet"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters