Fix potential issues when java.awt.headless is true
This commit is contained in:
@@ -37,7 +37,9 @@ import com.seibel.distanthorizons.coreapi.util.StringUtil;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -1423,10 +1425,20 @@ public class Config
|
||||
.set(new HashMap<String, String>())
|
||||
.build();
|
||||
|
||||
public static ConfigUIButton uiButtonTest = new ConfigUIButton(() -> { new Thread(() -> {
|
||||
System.setProperty("java.awt.headless", "false"); // Required to make it work
|
||||
JOptionPane.showMessageDialog(null, "Button pressed!", "UITester dialog", JOptionPane.INFORMATION_MESSAGE);
|
||||
});});
|
||||
public static ConfigUIButton uiButtonTest = new ConfigUIButton(() ->
|
||||
{
|
||||
new Thread(() ->
|
||||
{
|
||||
if (!GraphicsEnvironment.isHeadless())
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "Button pressed!", "UITester dialog", JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info("button pressed!");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
public static ConfigCategory categoryTest = new ConfigCategory.Builder().set(CategoryTest.class).build();
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.seibel.distanthorizons.coreapi.util.jar.DeleteOnUnlock;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.file.Files;
|
||||
@@ -222,9 +223,17 @@ public class SelfUpdater
|
||||
deleteOldJarOnJvmShutdown = true;
|
||||
|
||||
LOGGER.info(ModInfo.READABLE_NAME + " successfully updated. It will apply on game's relaunch");
|
||||
new Thread(() -> {
|
||||
System.setProperty("java.awt.headless", "false"); // Required to make it work
|
||||
JOptionPane.showMessageDialog(null, ModInfo.READABLE_NAME + " updated, this will be applied on game restart.", ModInfo.READABLE_NAME, JOptionPane.INFORMATION_MESSAGE);
|
||||
new Thread(() ->
|
||||
{
|
||||
String message = ModInfo.READABLE_NAME + " updated, this will be applied on game restart.";
|
||||
if (!GraphicsEnvironment.isHeadless())
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, message, ModInfo.READABLE_NAME, JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(message);
|
||||
}
|
||||
}).start();
|
||||
return true;
|
||||
}
|
||||
@@ -270,9 +279,17 @@ public class SelfUpdater
|
||||
deleteOldJarOnJvmShutdown = true;
|
||||
|
||||
LOGGER.info(ModInfo.READABLE_NAME + " successfully updated. It will apply on game's relaunch");
|
||||
new Thread(() -> {
|
||||
System.setProperty("java.awt.headless", "false"); // Required to make it work
|
||||
JOptionPane.showMessageDialog(null, ModInfo.READABLE_NAME + " updated, this will be applied on game restart.", ModInfo.READABLE_NAME, JOptionPane.INFORMATION_MESSAGE);
|
||||
new Thread(() ->
|
||||
{
|
||||
String message = ModInfo.READABLE_NAME + " updated, this will be applied on game restart.";
|
||||
if (!GraphicsEnvironment.isHeadless())
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, message, ModInfo.READABLE_NAME, JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(message);
|
||||
}
|
||||
}).start();
|
||||
|
||||
zis.close();
|
||||
|
||||
Reference in New Issue
Block a user