From c77828fe48272445bfeb322fb970732a7faf5d64 Mon Sep 17 00:00:00 2001
From: Spotlight <spotlight@joscomputing.space>
Date: Fri, 3 Jun 2016 09:46:19 -0500
Subject: [PATCH] Redo startup method

---
 src/io/github/packserver/RegPlug/Main.java | 42 ++++++++++++++++++----
 1 file changed, 35 insertions(+), 7 deletions(-)

diff --git a/src/io/github/packserver/RegPlug/Main.java b/src/io/github/packserver/RegPlug/Main.java
index e223341..e8e7ca0 100644
--- a/src/io/github/packserver/RegPlug/Main.java
+++ b/src/io/github/packserver/RegPlug/Main.java
@@ -9,28 +9,56 @@
 package io.github.packserver.RegPlug;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+
+import org.bukkit.configuration.file.FileConfiguration;
+import org.bukkit.configuration.file.YamlConfiguration;
 import org.bukkit.event.Listener;
 import org.bukkit.plugin.java.JavaPlugin;
 
 public class Main extends JavaPlugin implements Listener {
 
-    // Fired when plugin is disabled
-    @Override
-    public void onDisable() {
+    /**
+     * Global debug mode
+     */
+    static Boolean DEBUG;
 
-    }
+    /**
+     * Plugin instance
+     */
+    static Main plugin;
 
-    // Fired when plugin is first enabled
+    /**
+     * Fired when plugin is first enabled
+     */
     @Override
     public void onEnable() {
+        // Create plugin instance and hand it to plugin
+        plugin = this;
+        // Try to run websocket server
         try {
-            WebServer.runServer();
             WebsocketServer.runServer();
         } catch (InterruptedException | IOException ex) {
             Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
         }
-        this.getCommand("reg").setExecutor(new RegistrationExecutorThingy(this));
+        // Debug mode
+        // Find if we are in debug mode or not
+        InputStream in = getClass().getResourceAsStream("/config.yml");
+        FileConfiguration config = YamlConfiguration.loadConfiguration(in);
+        DEBUG = config.getBoolean("debug");
+    }
+
+    /**
+     * Fired when plugin is disabled
+     */
+    @Override
+    public void onDisable() {
+        try {
+            WebsocketServer.server.stop();
+        } catch (IOException | InterruptedException ex) {
+            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
+        }
     }
 }
-- 
GitLab