aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gq/malwarefight/nosession/tweaks/initial
diff options
context:
space:
mode:
authorPandaNinjas <admin@malwarefight.gq>2023-02-08 09:25:37 -0800
committerPandaNinjas <admin@malwarefight.gq>2023-02-08 09:25:37 -0800
commit0579088389caf554624787fcfae910a1d7bede71 (patch)
tree230e14d815cc23b65cf8e265e4d76d1538437b9b /src/main/java/gq/malwarefight/nosession/tweaks/initial
parentfd51baf3f06141a151fde7ad1ecdd80b8093351f (diff)
downloadNoSession-0579088389caf554624787fcfae910a1d7bede71.tar.gz
NoSession-0579088389caf554624787fcfae910a1d7bede71.tar.bz2
NoSession-0579088389caf554624787fcfae910a1d7bede71.zip
More nightly trolling (it launches)
Diffstat (limited to 'src/main/java/gq/malwarefight/nosession/tweaks/initial')
-rw-r--r--src/main/java/gq/malwarefight/nosession/tweaks/initial/InitialTweaker.java97
-rw-r--r--src/main/java/gq/malwarefight/nosession/tweaks/initial/package-info.java5
2 files changed, 102 insertions, 0 deletions
diff --git a/src/main/java/gq/malwarefight/nosession/tweaks/initial/InitialTweaker.java b/src/main/java/gq/malwarefight/nosession/tweaks/initial/InitialTweaker.java
new file mode 100644
index 0000000..e2ca1ae
--- /dev/null
+++ b/src/main/java/gq/malwarefight/nosession/tweaks/initial/InitialTweaker.java
@@ -0,0 +1,97 @@
+package gq.malwarefight.nosession.tweaks.initial;
+
+import gq.malwarefight.nosession.relaunch.Relaunch;
+import gq.malwarefight.nosession.utils.Utils;
+import net.minecraft.launchwrapper.ITweaker;
+import net.minecraft.launchwrapper.LaunchClassLoader;
+import org.spongepowered.asm.launch.MixinBootstrap;
+import org.spongepowered.asm.mixin.MixinEnvironment;
+import org.spongepowered.asm.mixin.Mixins;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.Socket;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+
+public class InitialTweaker implements ITweaker {
+
+ public InitialTweaker() {
+ System.gc(); // try to garbage collect the earlier launch data
+ }
+
+ /**
+ * This handles the launch arguments passed towards minecraft
+ * @param args The launch arguments
+ * @param gameDir The game directory (ie: .minecraft)
+ * @param assetsDir The assets directory
+ * @param version The game version
+ */
+ @Override
+ public final void acceptOptions(List<String> args, File gameDir, File assetsDir, String version) {
+ ArrayList<String> argsCopy = new ArrayList<>(args);
+ for (int i = 0; i < argsCopy.size(); i++) {
+ if (argsCopy.get(i).equals("--accessToken")) {
+ if (argsCopy.get(i + 1).equals("<noSessionAccessToken>")) {
+ Runtime.getRuntime().addShutdownHook(
+ new Thread(() -> {
+ try {
+ Socket socket = Utils.getProperSocket();
+ socket.getOutputStream().write("fullquit\n".getBytes(StandardCharsets.UTF_8));
+ socket.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ })
+ );
+ return; // don't do anything, the change has already been made
+ }
+ try {
+ Utils.setToken(args.get(i + 1));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ argsCopy.set(i + 1, "<noSessionAccessToken>");
+ }
+ }
+ System.out.println("=======================");
+ System.out.println("NoSession: relaunching without the token");
+ System.out.println("=======================");
+ try {
+ Relaunch.relaunch(argsCopy, gameDir, assetsDir, version);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ /**
+ * Inject into the MC class loader
+ * @param classLoader The class loader
+ */
+ @Override
+ public final void injectIntoClassLoader(LaunchClassLoader classLoader) {
+ MixinBootstrap.init();
+ MixinEnvironment environment = MixinEnvironment.getDefaultEnvironment();
+ Mixins.addConfiguration("mixins.nosession.json");
+ // Check if the obfuscation context is null
+ if (environment.getObfuscationContext() == null) {
+ environment.setObfuscationContext("notch");
+ }
+ // This is a client side, client :)
+ environment.setSide(MixinEnvironment.Side.CLIENT);
+ }
+
+ @Override
+ public String getLaunchTarget() {
+ return MixinBootstrap.getPlatform().getLaunchTarget();
+ }
+
+ @Override
+ public String[] getLaunchArguments() {
+ return new String[0];
+ }
+
+}
diff --git a/src/main/java/gq/malwarefight/nosession/tweaks/initial/package-info.java b/src/main/java/gq/malwarefight/nosession/tweaks/initial/package-info.java
new file mode 100644
index 0000000..443e379
--- /dev/null
+++ b/src/main/java/gq/malwarefight/nosession/tweaks/initial/package-info.java
@@ -0,0 +1,5 @@
+/**
+ * Due to the launchwrapper using a launchclassloader exclusion on every tweaker's package, we separate the two tweakers
+ * so that the loader exclusion doesn't affect anything else
+ */
+package gq.malwarefight.nosession.tweaks.initial; \ No newline at end of file