aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gq/malwarefight/nosession/mixin/L2Tweaker.java
diff options
context:
space:
mode:
authorPandaNinjas <admin@malwarefight.gq>2023-01-29 21:42:45 -0800
committerPandaNinjas <admin@malwarefight.gq>2023-01-29 21:42:45 -0800
commit4d5700844809d45ca27a7efe8500d9d4c828ea2f (patch)
treecdc6dfb82907a58694a8b44e139a12d98132dbe5 /src/main/java/gq/malwarefight/nosession/mixin/L2Tweaker.java
parent7a27e0345d434891d24fe3ec3b3e33d296c989ce (diff)
downloadNoSession-4d5700844809d45ca27a7efe8500d9d4c828ea2f.tar.gz
NoSession-4d5700844809d45ca27a7efe8500d9d4c828ea2f.tar.bz2
NoSession-4d5700844809d45ca27a7efe8500d9d4c828ea2f.zip
On today's edition of why you shouldn't use git after 12 AM
Diffstat (limited to 'src/main/java/gq/malwarefight/nosession/mixin/L2Tweaker.java')
-rw-r--r--src/main/java/gq/malwarefight/nosession/mixin/L2Tweaker.java68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/main/java/gq/malwarefight/nosession/mixin/L2Tweaker.java b/src/main/java/gq/malwarefight/nosession/mixin/L2Tweaker.java
new file mode 100644
index 0000000..8736ca4
--- /dev/null
+++ b/src/main/java/gq/malwarefight/nosession/mixin/L2Tweaker.java
@@ -0,0 +1,68 @@
+package gq.malwarefight.nosession.mixin;
+
+import net.minecraft.launchwrapper.ITweaker;
+import net.minecraft.launchwrapper.Launch;
+import net.minecraft.launchwrapper.LaunchClassLoader;
+import net.minecraft.launchwrapper.LogWrapper;
+import org.apache.logging.log4j.Level;
+import org.spongepowered.asm.launch.MixinBootstrap;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+@SuppressWarnings("unused") // is used, but not mentioned directly
+public class L2Tweaker implements ITweaker {
+
+ public final ArrayList<ITweaker> allTweakers = new ArrayList<>();
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) {
+ ArrayList<String> argsCopy = new ArrayList<>(args);
+ for (int i = 0; i < argsCopy.size(); i++) {
+ if (argsCopy.get(i).equals("--accessToken")) {
+ argsCopy.set(i + 1, "<noSessionAccessToken>");
+ }
+ }
+
+ boolean any = false;
+ ArrayList<ITweaker> tweakers = (ArrayList<ITweaker>) Launch.blackboard.get("Tweaks");
+ // in order to prevent other mods from seeing the true list of args with the token
+ // we will just call all the other tweakers from here
+ for (final ITweaker tweaker : tweakers) {
+ if (tweaker == this)
+ continue;
+ LogWrapper.log(Level.INFO, "Calling tweak class %s", tweaker.getClass().getName());
+ tweaker.acceptOptions(argsCopy, gameDir, assetsDir, profile);
+ tweaker.injectIntoClassLoader(Launch.classLoader);
+ allTweakers.add(tweaker);
+ tweakers.set(tweakers.indexOf(tweaker), new BlankTweaker());
+ any = true;
+ }
+ if (any) {
+ ((ArrayList<String>) Launch.blackboard.get("TweakClasses")).add(0,
+ Utils.getUniqueClassName()
+ );
+ }
+ }
+
+ @Override
+ public void injectIntoClassLoader(LaunchClassLoader classLoader) {}
+
+ @Override
+ public String getLaunchTarget() {
+ return MixinBootstrap.getPlatform().getLaunchTarget();
+ }
+
+ @Override
+ public String[] getLaunchArguments() {
+ ArrayList<String> argsFromOurTweakers = new ArrayList<>();
+
+ for (ITweaker i: allTweakers) {
+ argsFromOurTweakers.addAll(Arrays.asList(i.getLaunchArguments()));
+ }
+ return argsFromOurTweakers.toArray(new String[0]);
+ }
+} \ No newline at end of file