Revert switch to JUL for better colours

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad
2022-11-05 17:14:12 +00:00
parent 50d40257fe
commit f2ca9a6b31
7 changed files with 223 additions and 42 deletions

View File

@ -60,6 +60,8 @@ import net.minecraft.Launcher;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import org.prismlauncher.utils.logging.Log;
import java.applet.Applet;
import java.awt.Dimension;
import java.awt.event.WindowAdapter;
@ -72,12 +74,9 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
public final class LegacyFrame extends JFrame {
private static final Logger LOGGER = Logger.getLogger("LegacyFrame");
private static final long serialVersionUID = 1L;
private final Launcher launcher;
@ -92,7 +91,7 @@ public final class LegacyFrame extends JFrame {
try {
this.setIconImage(ImageIO.read(new File("icon.png")));
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Unable to read Minecraft icon", e);
Log.error("Unable to read Minecraft icon", e);
}
this.addWindowListener(new ForceExitHandler());
@ -116,7 +115,7 @@ public final class LegacyFrame extends JFrame {
if (lines.size() < 3) {
Files.move(mpticketFile, mpticketFileCorrupt, StandardCopyOption.REPLACE_EXISTING);
LOGGER.warning("Mpticket file is corrupted!");
Log.warning("Mpticket file is corrupted!");
} else {
// Assumes parameters are valid and in the correct order
this.launcher.setParameter("server", lines.get(0));
@ -124,7 +123,7 @@ public final class LegacyFrame extends JFrame {
this.launcher.setParameter("mppass", lines.get(2));
}
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Unable to read mpticket file!", e);
Log.error("Unable to read mpticket file", e);
}
}
@ -170,11 +169,10 @@ public final class LegacyFrame extends JFrame {
try {
Thread.sleep(30000L);
} catch (InterruptedException e) {
LOGGER.log(Level.SEVERE, "Thread interrupted", e);
Log.error("Thread interrupted", e);
}
LOGGER.info("Forcing exit!");
Log.warning("Forcing exit");
System.exit(0);
}
}).start();

View File

@ -59,22 +59,19 @@ package org.prismlauncher.launcher.impl.legacy;
import org.prismlauncher.launcher.impl.AbstractLauncher;
import org.prismlauncher.utils.Parameters;
import org.prismlauncher.utils.ReflectionUtils;
import org.prismlauncher.utils.logging.Log;
import java.io.File;
import java.lang.invoke.MethodHandle;
import java.lang.reflect.Field;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Used to launch old versions that support applets.
*/
public final class LegacyLauncher extends AbstractLauncher {
private static final Logger LOGGER = Logger.getLogger("LegacyLauncher");
private final String user, session;
private final String title;
private final String appletClass;
@ -101,24 +98,23 @@ public final class LegacyLauncher extends AbstractLauncher {
Field gameDirField = ReflectionUtils.getMinecraftGameDirField(main);
if (gameDirField == null)
LOGGER.warning("Could not find Minecraft path field");
Log.warning("Could not find Minecraft path field");
else {
gameDirField.setAccessible(true);
gameDirField.set(null /* field is static, so instance is null */, new File(this.cwd));
}
if (this.usesApplet) {
LOGGER.info("Launching legacy minecraft using applet wrapper...");
Log.launcher("Launching with applet wrapper...");
try {
LegacyFrame window = new LegacyFrame(this.title, ReflectionUtils.createAppletClass(this.appletClass));
window.start(this.user, this.session, this.width, this.height, this.maximize, this.serverAddress,
this.serverPort, this.mcParams.contains("--demo"));
return;
} catch (Throwable e) {
LOGGER.log(Level.SEVERE, "Running applet wrapper failed with exception; falling back to main class", e);
Log.error("Running applet wrapper failed with exception; falling back to main class", e);
}
}