Improves writing speed when not using a GUI
All checks were successful
KnarCraft/Minecraft-Server-Launcher/pipeline/head This commit looks good
All checks were successful
KnarCraft/Minecraft-Server-Launcher/pipeline/head This commit looks good
Uses buffered writers instead of System.out Uses a GUI for writing JarBuilder messages Adds some missing comments to the jar builder
This commit is contained in:
@ -1,6 +1,9 @@
|
||||
package net.knarcraft.minecraftserverlauncher.userinterface;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
||||
/**
|
||||
* This class handles displaying messages to the user
|
||||
@ -8,6 +11,7 @@ import javax.swing.*;
|
||||
public abstract class MessageHandler implements GUI {
|
||||
|
||||
private final boolean silent;
|
||||
private final BufferedWriter writer;
|
||||
|
||||
/***
|
||||
* Initializes a new message handler
|
||||
@ -16,12 +20,18 @@ public abstract class MessageHandler implements GUI {
|
||||
*/
|
||||
public MessageHandler(boolean silent) {
|
||||
this.silent = silent;
|
||||
this.writer = new BufferedWriter(new OutputStreamWriter(System.out));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showError(String title, String message) {
|
||||
if (silent) {
|
||||
System.out.println(message);
|
||||
try {
|
||||
writer.write(message);
|
||||
writer.flush();
|
||||
} catch (IOException e) {
|
||||
System.out.println(message);
|
||||
}
|
||||
} else {
|
||||
showJOptionPane(title, message, JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
@ -35,7 +45,12 @@ public abstract class MessageHandler implements GUI {
|
||||
@Override
|
||||
public void showMessage(String title, String message) {
|
||||
if (silent) {
|
||||
System.out.println(message);
|
||||
try {
|
||||
writer.write(message);
|
||||
writer.flush();
|
||||
} catch (IOException e) {
|
||||
System.out.println(message);
|
||||
}
|
||||
} else {
|
||||
showJOptionPane(title, message, JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
|
Reference in New Issue
Block a user