EpicKnarvik97 26cc5370e2
Some checks failed
KnarCraft/Minecraft-Server-Launcher/pipeline/head There was a failure building this commit
Does some much needed cleanup, adds the Paper server type and fixes broken downloads
2020-08-06 19:55:27 +02:00

62 lines
1.5 KiB
Java

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
);
}
}