From 01d1926104b9578d3a62b47cd93d904855366543 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Elias=20M=C3=BCller?= <elias@elias-mueller.com>
Date: Tue, 5 Nov 2024 21:23:43 +0100
Subject: [PATCH 1/2] removed webserver shutdown

---
 src/main/java/eu/mhsl/craftattack/spawn/Main.java           | 5 ++---
 src/main/java/eu/mhsl/craftattack/spawn/api/HttpServer.java | 4 ----
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/main/java/eu/mhsl/craftattack/spawn/Main.java b/src/main/java/eu/mhsl/craftattack/spawn/Main.java
index 56d8198..00f837d 100644
--- a/src/main/java/eu/mhsl/craftattack/spawn/Main.java
+++ b/src/main/java/eu/mhsl/craftattack/spawn/Main.java
@@ -19,7 +19,6 @@ public final class Main extends JavaPlugin {
     private static Logger logger;
 
     private List<Appliance> appliances;
-    private HttpServer httpApi;
 
     @Override
     public void onEnable() {
@@ -62,7 +61,7 @@ public final class Main extends JavaPlugin {
         Main.logger().info(String.format("Initialized %d appliances!", appliances.size()));
 
         Main.logger().info("Starting HTTP API...");
-        this.httpApi = new HttpServer();
+        new HttpServer();
 
         getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
         Main.logger().info("Startup complete!");
@@ -76,7 +75,7 @@ public final class Main extends JavaPlugin {
             appliance.onDisable();
             appliance.destruct(this);
         });
-        this.httpApi.stop();
+
         HandlerList.unregisterAll(this);
         Bukkit.getScheduler().cancelTasks(this);
         Main.logger().info("Disabled " + appliances.size() + " appliances!");
diff --git a/src/main/java/eu/mhsl/craftattack/spawn/api/HttpServer.java b/src/main/java/eu/mhsl/craftattack/spawn/api/HttpServer.java
index 4961f1d..412d95b 100644
--- a/src/main/java/eu/mhsl/craftattack/spawn/api/HttpServer.java
+++ b/src/main/java/eu/mhsl/craftattack/spawn/api/HttpServer.java
@@ -24,10 +24,6 @@ public class HttpServer {
         Main.instance().getAppliances().forEach(appliance -> appliance.httpApi(new ApiBuilder(appliance)));
     }
 
-    public void stop() {
-        Spark.stop();
-    }
-
     public record Response(Status status, Object error, Object response) {
         public enum Status {
             FAILURE,

From 3abf5a95e8c64a43ae6b86bbde446cea5c35c6dd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Elias=20M=C3=BCller?= <elias@elias-mueller.com>
Date: Tue, 5 Nov 2024 21:24:06 +0100
Subject: [PATCH 2/2] updated maintenance command feedback

---
 .../appliances/maintenance/MaintenanceCommand.java  | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/main/java/eu/mhsl/craftattack/spawn/appliances/maintenance/MaintenanceCommand.java b/src/main/java/eu/mhsl/craftattack/spawn/appliances/maintenance/MaintenanceCommand.java
index 9372b17..d23e3e2 100644
--- a/src/main/java/eu/mhsl/craftattack/spawn/appliances/maintenance/MaintenanceCommand.java
+++ b/src/main/java/eu/mhsl/craftattack/spawn/appliances/maintenance/MaintenanceCommand.java
@@ -1,6 +1,8 @@
 package eu.mhsl.craftattack.spawn.appliances.maintenance;
 
 import eu.mhsl.craftattack.spawn.appliance.ApplianceCommand;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.format.NamedTextColor;
 import org.bukkit.command.Command;
 import org.bukkit.command.CommandSender;
 import org.jetbrains.annotations.NotNull;
@@ -18,9 +20,14 @@ public class MaintenanceCommand extends ApplianceCommand<Maintenance> {
 
     @Override
     protected void execute(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) throws Exception {
-        if(args.length != 1 || !arguments.containsKey(args[0])) throw new Error("Argument 'enable' oder 'disable' gefordert!");
-        getAppliance().setState(arguments.get(args[0]));
-        sender.sendMessage(String.format("Maintanance: %b", getAppliance().isInMaintenance()));
+        if(args.length == 1 && arguments.containsKey(args[0])) {
+            getAppliance().setState(arguments.get(args[0]));
+            sender.sendMessage(Component.text("Maintanance mode updated!", NamedTextColor.GREEN));
+        }
+        sender.sendMessage(Component.text(
+            String.format("Maintanance mode is %b", getAppliance().isInMaintenance()),
+            NamedTextColor.GOLD
+        ));
     }
 
     @Override