Does some much needed cleanup, adds the Paper server type and fixes broken downloads
Some checks failed
KnarCraft/Minecraft-Server-Launcher/pipeline/head There was a failure building this commit
Some checks failed
KnarCraft/Minecraft-Server-Launcher/pipeline/head There was a failure building this commit
This commit is contained in:
@ -0,0 +1,61 @@
|
||||
package net.knarcraft.minecraftserverlauncher.userinterface;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public abstract class MessageHandler implements GUI {
|
||||
|
||||
private final boolean silent;
|
||||
|
||||
/***
|
||||
* Initializes a new message handler
|
||||
*
|
||||
* @param silent <p>Whether to print to cli instead of showing a GUI element</p>
|
||||
*/
|
||||
public MessageHandler(boolean silent) {
|
||||
this.silent = silent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showError(String title, String message) {
|
||||
if (silent) {
|
||||
System.out.println(message);
|
||||
} else {
|
||||
showJOptionPane(title, message, JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showError(String message) {
|
||||
showError("Error", message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMessage(String title, String message) {
|
||||
if (silent) {
|
||||
System.out.println(message);
|
||||
} else {
|
||||
showJOptionPane(title, message, JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMessage(String message) {
|
||||
showMessage("Info", message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a JOptionPane
|
||||
*
|
||||
* @param title <p>The title of the pane</p>
|
||||
* @param message <p>The message of the pane</p>
|
||||
* @param paneType <p>The type of the pane</p>
|
||||
*/
|
||||
private void showJOptionPane(String title, String message, int paneType) {
|
||||
JOptionPane.showMessageDialog(
|
||||
null,
|
||||
message,
|
||||
title,
|
||||
paneType
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user