Skip to content

Commit 2d696d3

Browse files
committed
1.1 - Only setup transformer once
1 parent 9f9e09a commit 2d696d3

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
group 'io.github.impactdevelopment'
6-
version '1.0'
6+
version '1.1'
77

88
sourceCompatibility = targetCompatibility = 1.8
99
compileJava {

src/main/java/io/github/impactdevelopment/simpletweaker/SimpleTweaker.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public class SimpleTweaker implements ITweaker {
3737

3838
public static final Logger LOGGER = LogManager.getLogger("SimpleTweaker");
3939

40+
private static boolean setupTransformer = false;
41+
4042
/**
4143
* The raw game launch arguments that are provided in {@link SimpleTweaker#acceptOptions(List, File, File, String)}
4244
*/
@@ -52,8 +54,7 @@ public void acceptOptions(List<String> args, File gameDir, File assetsDir, Strin
5254

5355
@Override
5456
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
55-
classLoader.addClassLoaderExclusion("io.github.impactdevelopment.simpletweaker.");
56-
classLoader.registerTransformer(SimpleTransformer.class.getName());
57+
doInitialSetup(classLoader);
5758
}
5859

5960
@Override
@@ -88,4 +89,12 @@ private void addArg(String label, String value) {
8889
this.args.add(value);
8990
}
9091
}
92+
93+
private static void doInitialSetup(LaunchClassLoader classLoader) {
94+
if (!setupTransformer) {
95+
classLoader.addClassLoaderExclusion("io.github.impactdevelopment.simpletweaker.");
96+
classLoader.registerTransformer(SimpleTransformer.class.getName());
97+
setupTransformer = true;
98+
}
99+
}
91100
}

0 commit comments

Comments
 (0)