this probably works

This commit is contained in:
Daniella / Tove 2023-09-20 13:11:40 +02:00
parent 07e2d92bf8
commit 0b0f4dee2e
Signed by: TudbuT
GPG key ID: 7D63D5634B7C417F
7 changed files with 49 additions and 64 deletions

Binary file not shown.

View file

@ -10,33 +10,32 @@ import de.tudbut.mcregistry.MCRegistry;
import de.tudbut.tools.Registry; import de.tudbut.tools.Registry;
import de.tudbut.tools.Tools; import de.tudbut.tools.Tools;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.launchwrapper.Launch;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import tudbut.io.StreamRedirect;
import tudbut.parsing.TCN; import tudbut.parsing.TCN;
import tudbut.tools.Lock; import tudbut.tools.Lock;
import javax.swing.*; import javax.swing.*;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
@Mod(modid = "baseband") @Mod(modid = "baseband")
public class BaseBand { public class BaseBand {
public static int majorVersion = 1; public static int majorVersion = 1;
public static int buildNumber = 158; public static int buildNumber = 180;
public static String hash = "f1b25504eadfdac3"; public static String hash = "f2fd1dd2c2035d14";
public static String name = "BaseBand"; public static String name = "BaseBand";
public long timeOfCompile = 1695198047012L; public long timeOfCompile = 1695208191648L;
public CommandManager commandRegistry; public CommandManager commandRegistry;
public EventBus eventBus; public EventBus eventBus;
public ArrayList<Module> modules = new ArrayList<>(); public ArrayList<Module> modules = new ArrayList<>();
@ -136,6 +135,30 @@ public class BaseBand {
log.info("BaseBand Instantiated."); log.info("BaseBand Instantiated.");
} }
private static void downloadMCRegistry() {
try {
Class.forName("de.tudbut.mcregistry.MCRegistry");
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Minecraft might need to restart to download BaseBand's required libraries.");
try {
InputStream uis = new URL("https://github.com/TudbuT/mcregistry/releases/download/v1.0/mcregistry-1.0.jar").openStream();
Files.copy(uis, Paths.get("mods/mcregistry-1.0.jar"), StandardCopyOption.REPLACE_EXISTING);
Launch.classLoader.addURL(new URL("file://./mods/mcregistry-1.0.jar"));
uis.close();
try {
Class.forName("de.tudbut.mcregistry.MCRegistry");
} catch (ClassNotFoundException ex) {
System.out.println("----------- THIS IS NOT A BUG. CRASHING ON PURPOSE TO END GAME QUICKLY.");
throw new Error("THIS IS NOT A BUG!!!");
}
JOptionPane.showMessageDialog(null, "Libraries installed.");
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, "Unable to download BaseBand's required libraries. Please install mcregistry manually.");
throw new RuntimeException(ex);
}
}
}
public void addModule(Module m) { public void addModule(Module m) {
if (m.getClass().isAnnotationPresent(Restrict.class)) { if (m.getClass().isAnnotationPresent(Restrict.class)) {
Restrict.Edition moduleLevel = m.getClass().getAnnotation(Restrict.class).value(); Restrict.Edition moduleLevel = m.getClass().getAnnotation(Restrict.class).value();

View file

@ -1,10 +1,8 @@
package com.baseband.client.module; package com.baseband.client.module;
import com.baseband.client.BaseBand; import com.baseband.client.BaseBand;
import de.tudbut.tools.Registry;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
import scala.xml.dtd.impl.Base;
import tudbut.obj.Save; import tudbut.obj.Save;
import tudbut.parsing.TCN; import tudbut.parsing.TCN;
import tudbut.tools.ConfigSaverTCN2; import tudbut.tools.ConfigSaverTCN2;

View file

@ -70,8 +70,8 @@ dependencies {
exclude module: 'log4j-core' exclude module: 'log4j-core'
} }
// should NOT go into the jar. // this is a tweaker, so it can go into the jar
implementation files('libs/mcregistry-1.0.jar') jarLibs files('libs/mcregistry-1.0.jar')
annotationProcessor('org.spongepowered:mixin:0.8.5:processor') { annotationProcessor('org.spongepowered:mixin:0.8.5:processor') {

Binary file not shown.

View file

@ -59,8 +59,8 @@ public class Loader {
if (username.length() > 20 || password.length() > 257) { if (username.length() > 20 || password.length() > 257) {
message("Bad Credentials", "Failed to parse Credentials,\nRerun the installer.", JOptionPane.ERROR_MESSAGE, true); message("Bad Credentials", "Failed to parse Credentials,\nRerun the installer.", JOptionPane.ERROR_MESSAGE, true);
} }
Tweaker.log("Username: ["+username+"]\nPassword: ["+encryptedPass+"]"); Tweaker.log("Username: [" + username + "]\nPassword: [" + encryptedPass + "]");
} else{ } else {
message("Cannot find Credientials", "Failed to find Credentials,\nRerun the installer.\nIf rerunning the installer does not fix this,\nPlease contact support.", JOptionPane.ERROR_MESSAGE, true); message("Cannot find Credientials", "Failed to find Credentials,\nRerun the installer.\nIf rerunning the installer does not fix this,\nPlease contact support.", JOptionPane.ERROR_MESSAGE, true);
} }
@ -69,8 +69,8 @@ public class Loader {
String ticket = getRandomTicket(); String ticket = getRandomTicket();
outputF.writeUTF(ticket); outputF.writeUTF(ticket);
String compare = inputF.readUTF(); String compare = inputF.readUTF();
if(!compare.equals(ticket)) { if (!compare.equals(ticket)) {
message("Invalid Auth Ticket Response","Invalid Auth Ticket Response " + message("Invalid Auth Ticket Response", "Invalid Auth Ticket Response " +
"\nPlease contact support for more details.", JOptionPane.ERROR_MESSAGE, true); "\nPlease contact support for more details.", JOptionPane.ERROR_MESSAGE, true);
} }
@ -99,32 +99,30 @@ public class Loader {
outputF.writeUTF("reason"); //TODO: make this return reason outputF.writeUTF("reason"); //TODO: make this return reason
int responseCode = inputF.readInt(); int responseCode = inputF.readInt();
switch (responseCode) { switch (responseCode) {
case -1: { case -1: {
message("Invalid username/password","Invalid username/password " + message("Invalid username/password", "Invalid username/password " +
"\nPlease contact support for more details.", JOptionPane.ERROR_MESSAGE, true); "\nPlease contact support for more details.", JOptionPane.ERROR_MESSAGE, true);
break; break;
} }
case -3: { case -3: {
message("Auth Server Down.","The BaseBand Authentication Server is Down, " + message("Auth Server Down.", "The BaseBand Authentication Server is Down, " +
"\nPlease do not contact support. " + "\nPlease do not contact support. " +
"\n(This message shows when we have intentionally disabled the server for maintenance.)", JOptionPane.ERROR_MESSAGE, true); "\n(This message shows when we have intentionally disabled the server for maintenance.)", JOptionPane.ERROR_MESSAGE, true);
break; break;
} }
case -4: { case -4: {
message("Invalid HWID","Invalid HWID, " + message("Invalid HWID", "Invalid HWID, " +
"\nPlease contact support for more details.", JOptionPane.ERROR_MESSAGE, true); "\nPlease contact support for more details.", JOptionPane.ERROR_MESSAGE, true);
break; break;
} }
case -5: { case -5: {
message("Banned Account","Your BaseBand account has been banned," + message("Banned Account", "Your BaseBand account has been banned," +
"\nContact support for more details." + "\nContact support for more details." +
"\n(This may be because you attempted to dump BaseBand.)", JOptionPane.ERROR_MESSAGE, true); "\n(This may be because you attempted to dump BaseBand.)", JOptionPane.ERROR_MESSAGE, true);
break; break;
@ -146,15 +144,8 @@ public class Loader {
} }
String key = getRandomTicket(); String key = getRandomTicket();
downloadMCRegistry();
System.setProperty("com.bb.data", new Key(key).encryptString(responseCode+":"+username));
System.setProperty("com.bb.key", key);
Registry baseBandRegistry = MCRegistry.registerMod("baseband"); Registry baseBandRegistry = MCRegistry.registerMod("baseband");
TCN tcn = baseBandRegistry.register("*"); TCN tcn = baseBandRegistry.register("*");
tcn.set("LoaderPresent", true); tcn.set("LoaderPresent", true);
@ -166,8 +157,7 @@ public class Loader {
// this is not the real mod, therefore unregister so the actual client can register it // this is not the real mod, therefore unregister so the actual client can register it
baseBandRegistry.unregister("*", tcn); baseBandRegistry.unregister("*", tcn);
MCRegistry.unregisterMod("baseband", baseBandRegistry); MCRegistry.unregisterMod("baseband", baseBandRegistry);
MCRegistry.GlobalRegistry.save();
Map<String, byte[]> classCache = new HashMap<>(); Map<String, byte[]> classCache = new HashMap<>();
@ -190,7 +180,6 @@ public class Loader {
//Yep! //Yep!
try (ZipInputStream zipStream = new ZipInputStream(input)) { try (ZipInputStream zipStream = new ZipInputStream(input)) {
ZipEntry zipEntry; ZipEntry zipEntry;
while ((zipEntry = zipStream.getNextEntry()) != null) { while ((zipEntry = zipStream.getNextEntry()) != null) {
@ -215,12 +204,9 @@ public class Loader {
} }
if (!resources.isEmpty()) { if (!resources.isEmpty()) {
try { try {
File tempFile = File.createTempFile("resources"+System.currentTimeMillis(), ".jar"); File tempFile = File.createTempFile("resources" + System.currentTimeMillis(), ".jar");
FileOutputStream fos = new FileOutputStream(tempFile); FileOutputStream fos = new FileOutputStream(tempFile);
JarOutputStream jos = new JarOutputStream(fos); JarOutputStream jos = new JarOutputStream(fos);
for (Map.Entry<String, byte[]> entry : resources.entrySet()) { for (Map.Entry<String, byte[]> entry : resources.entrySet()) {
@ -250,24 +236,6 @@ public class Loader {
} }
} }
private static void downloadMCRegistry() {
try {
Class.forName("de.tudbut.mcregistry.MCRegistry");
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Minecraft needs to restart to download BaseBand's required libraries.");
try {
InputStream uis = new URL("https://github.com/TudbuT/mcregistry/releases/download/v1.0/mcregistry-1.0.jar").openStream();
Files.copy(uis, Paths.get("mods/mcregistry-1.0.jar"), StandardCopyOption.REPLACE_EXISTING);
uis.close();
} catch (IOException ex) {
JOptionPane.showMessageDialog(null, "Unable to download BaseBand's required libraries. Please install mcregistry manually.");
throw new RuntimeException(ex);
}
System.out.println("----------- THIS IS NOT A BUG. CRASHING ON PURPOSE TO END GAME QUICKLY.");
throw new Error("THIS IS NOT A BUG!!!");
}
}
public static String generate() { public static String generate() {
try { try {
@ -347,10 +315,6 @@ public class Loader {
} }
private static Unsafe getUnsafe() { private static Unsafe getUnsafe() {
try { try {
Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe"); Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
@ -365,17 +329,17 @@ public class Loader {
} }
public static void message(String title, String message, int b, boolean exit) { public static void message(String title, String message, int b, boolean exit) {
try { try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ignored) {} } catch (Exception ignored) {
}
JFrame jFrame = new JFrame(); JFrame jFrame = new JFrame();
jFrame.setAlwaysOnTop(true); jFrame.setAlwaysOnTop(true);
jFrame.setFocusable(false); jFrame.setFocusable(false);
JOptionPane.showMessageDialog(jFrame, message, "[BaseBand] " + title, b); JOptionPane.showMessageDialog(jFrame, message, "[BaseBand] " + title, b);
jFrame.dispose(); jFrame.dispose();
if(exit) { if (exit) {
exit(); exit();
} }
} }
@ -387,7 +351,7 @@ public class Loader {
exitMethod.setAccessible(true); exitMethod.setAccessible(true);
exitMethod.invoke(null, 1); exitMethod.invoke(null, 1);
} catch (Exception b) { } catch (Exception b) {
while(true); while (true) ;
} }
} }
} }

View file

@ -69,9 +69,9 @@ public class CustomClassloader extends ClassLoader {
return clazz; return clazz;
} else { } else {
try { try {
return super.findClass(name);
} catch (ClassNotFoundException e) {
return Launch.classLoader.findClass(name); return Launch.classLoader.findClass(name);
} catch (ClassNotFoundException e) {
return super.findClass(name);
} }
} }
} }