Skip to content

Commit 38f6e72

Browse files
author
FungY911
committed
auto run
1 parent 5c11f75 commit 38f6e72

4 files changed

Lines changed: 10 additions & 7 deletions

File tree

src/main/java/tk/fungy/wsformc/Command.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
public class Command implements CommandExecutor, TabCompleter {
1717
private static String secured;
18-
WebServer ws;
18+
public static WebServer ws;
1919

2020
@Override
2121
public boolean onCommand(CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {

src/main/java/tk/fungy/wsformc/Main.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package tk.fungy.wsformc;
22

3+
import com.sun.org.apache.xpath.internal.operations.Bool;
34
import org.bukkit.plugin.java.JavaPlugin;
45

56
import java.io.File;
@@ -34,6 +35,11 @@ public void onEnable() {
3435
instance.getCommand("wsm").setExecutor(new Command());
3536
instance.getCommand("webserver").setExecutor(new Command());
3637
Updater.startUpdater();
38+
if (WebServer.running) {
39+
if (Command.ws == null) Command.ws = new WebServer();
40+
getLogger().info("Starting Webserbver.");
41+
Command.ws.start();
42+
}
3743
}
3844

3945
@Override

src/main/java/tk/fungy/wsformc/WebServer.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public WebServer(int port) {
2020
public WebServer(String hostname, int port) {
2121
super(hostname, port);
2222
}
23-
public static boolean running = Boolean.parseBoolean(new FileManager().getStringFromConfig("WebServer.isRunning"));
23+
public static boolean running = new FileManager().getBooleanFromConfig("WebServer.isRunning");
2424
private File logFile;
2525
public WebServer() {
2626
super(port);
@@ -118,10 +118,7 @@ public Response serve(IHTTPSession session) {
118118
return newFixedLengthResponse(Response.Status.BAD_REQUEST, "text/plain", "DNS_PROBE_POSSIBLE");
119119
}
120120

121-
122-
if (uri.endsWith("/")) {
123-
uri = "/index.html";
124-
}
121+
if (uri.endsWith("/")) { uri = "/index.html"; }
125122

126123
Method method = session.getMethod();
127124
String mimeType = getMimeType(uri);

src/main/resources/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
########################################################################
2828
WebServer:
2929
port: 8080 # Set this to your open port
30-
isRunning: false #
30+
isRunning: false # Automatically run server on crash if was started
3131
domain: "CHANGE_ME" # Domain of your server, default is ip of your server.
3232
ssl: false # toggle: true/false, set this to true only if you have generated certificate and webserver pointed to domain
3333

0 commit comments

Comments
 (0)