From 1670c77672c9f8de5d2c0dda68cab29fce745942 Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Wed, 4 Mar 2020 20:44:42 -0600 Subject: [PATCH] Only allow console to shut down Geyser with a command --- .../geysermc/platform/standalone/console/GeyserLogger.java | 5 +++++ .../java/org/geysermc/connector/command/CommandSender.java | 2 ++ .../org/geysermc/connector/command/defaults/StopCommand.java | 3 +++ .../geysermc/connector/network/session/GeyserSession.java | 5 +++++ 4 files changed, 15 insertions(+) diff --git a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/console/GeyserLogger.java b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/console/GeyserLogger.java index cac40b563..7df8a4efb 100644 --- a/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/console/GeyserLogger.java +++ b/bootstrap/standalone/src/main/java/org/geysermc/platform/standalone/console/GeyserLogger.java @@ -108,4 +108,9 @@ public class GeyserLogger extends SimpleTerminalConsole implements IGeyserLogger public void sendMessage(String message) { info(message); } + + @Override + public boolean isConsole() { + return true; + } } diff --git a/connector/src/main/java/org/geysermc/connector/command/CommandSender.java b/connector/src/main/java/org/geysermc/connector/command/CommandSender.java index eb69010d1..9e4f020bd 100644 --- a/connector/src/main/java/org/geysermc/connector/command/CommandSender.java +++ b/connector/src/main/java/org/geysermc/connector/command/CommandSender.java @@ -11,4 +11,6 @@ public interface CommandSender { } void sendMessage(String message); + + boolean isConsole(); } diff --git a/connector/src/main/java/org/geysermc/connector/command/defaults/StopCommand.java b/connector/src/main/java/org/geysermc/connector/command/defaults/StopCommand.java index c54d48c5c..25034f1ad 100644 --- a/connector/src/main/java/org/geysermc/connector/command/defaults/StopCommand.java +++ b/connector/src/main/java/org/geysermc/connector/command/defaults/StopCommand.java @@ -44,6 +44,9 @@ public class StopCommand extends GeyserCommand { @Override public void execute(CommandSender sender, String[] args) { + if (!sender.isConsole()) + return; + connector.shutdown(); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index 330ef0ac5..a2d8a7263 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -324,6 +324,11 @@ public class GeyserSession implements CommandSender { upstream.sendPacket(textPacket); } + @Override + public boolean isConsole() { + return false; + } + public void sendForm(FormWindow window, int id) { windowCache.showWindow(window, id); }