Skip to content
Snippets Groups Projects
Commit c77828fe authored by Spotlight Deveaux's avatar Spotlight Deveaux :fox:
Browse files

Redo startup method

parent 52938e17
Branches master
No related tags found
No related merge requests found
......@@ -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);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment