Skip to content

Commit

Permalink
Double Click Jar Check
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyGalbreath committed Dec 7, 2019
1 parent daf6aa5 commit 8cb622f
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions patches/server/0088-Double-Click-Jar-Check.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
From 7037860af3e5c75edbb10461c821912432c69809 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Sat, 7 Dec 2019 14:35:43 -0600
Subject: [PATCH] Double Click Jar Check

---
src/main/java/org/bukkit/craftbukkit/Main.java | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index 31af710a07..f9e7577e1c 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -20,6 +20,12 @@ public class Main {
public static boolean useConsole = true;

public static void main(String[] args) {
+ // Purpur start
+ if (System.console() == null) {
+ javax.swing.JOptionPane.showMessageDialog(null, "Please do not run this server by double clicking the jar!");
+ return;
+ }
+ // Purpur end
// Todo: Installation script
OptionParser parser = new OptionParser() {
{
--
2.24.0.rc1

2 comments on commit 8cb622f

@mibby
Copy link

@mibby mibby commented on 8cb622f Dec 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BillyGalbreath This commit seems to prevent me from launching purpur via multicraft with CentOS. :(

11.12 00:37:20 [Server] INFO at org.bukkit.craftbukkit.Main.main(Main.java:25)
11.12 00:37:20 [Server] INFO at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:608)
11.12 00:37:20 [Server] INFO at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:637)
11.12 00:37:20 [Server] INFO at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:666)
11.12 00:37:20 [Server] INFO at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:863)
11.12 00:37:20 [Server] INFO at javax.swing.JOptionPane.getRootFrame(JOptionPane.java:1696)
11.12 00:37:20 [Server] INFO at javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1838)
11.12 00:37:20 [Server] INFO at javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1763)
11.12 00:37:20 [Server] INFO at java.awt.Frame.<init>(Frame.java:385)
11.12 00:37:20 [Server] INFO at java.awt.Frame.<init>(Frame.java:420)
11.12 00:37:20 [Server] INFO at java.awt.Window.<init>(Window.java:536)
11.12 00:37:20 [Server] INFO at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
11.12 00:37:20 [Server] INFO No X11 DISPLAY variable was set, but this program performed an operation which requires it.
11.12 00:37:20 [Server] INFO Exception in thread "main" java.awt.HeadlessException: 

Downgrading to purpur dev 333, all is well again.

@TheDGOfficial
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BillyGalbreath This commit seems to prevent me from launching purpur via multicraft with CentOS. :(

11.12 00:37:20 [Server] INFO at org.bukkit.craftbukkit.Main.main(Main.java:25)
11.12 00:37:20 [Server] INFO at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:608)
11.12 00:37:20 [Server] INFO at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:637)
11.12 00:37:20 [Server] INFO at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:666)
11.12 00:37:20 [Server] INFO at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:863)
11.12 00:37:20 [Server] INFO at javax.swing.JOptionPane.getRootFrame(JOptionPane.java:1696)
11.12 00:37:20 [Server] INFO at javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1838)
11.12 00:37:20 [Server] INFO at javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1763)
11.12 00:37:20 [Server] INFO at java.awt.Frame.<init>(Frame.java:385)
11.12 00:37:20 [Server] INFO at java.awt.Frame.<init>(Frame.java:420)
11.12 00:37:20 [Server] INFO at java.awt.Window.<init>(Window.java:536)
11.12 00:37:20 [Server] INFO at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
11.12 00:37:20 [Server] INFO No X11 DISPLAY variable was set, but this program performed an operation which requires it.
11.12 00:37:20 [Server] INFO Exception in thread "main" java.awt.HeadlessException: 

Downgrading to purpur dev 333, all is well again.

Might need a condition like GraphicsEnvironment#isHeadless() before trying to show message dialog. So changing if (System.console() == null) { to if (System.console() == null && !java.awt.GraphicsEnvironment.isHeadless()) { might fix the problem.

Please sign in to comment.