It's getting late here
This commit is contained in:
parent
4099a54ce8
commit
3377290dfa
2 changed files with 23 additions and 7 deletions
|
@ -269,6 +269,11 @@ public class AcmeClient {
|
|||
* LOG.info("Press any key to continue..."); if (ButtonWebsiteModule.PORT != 443) try { System.in.read(); } catch (IOException e) { e.printStackTrace(); }
|
||||
*/
|
||||
ButtonWebsiteModule.addHttpPage(new AcmeChallengePage(challenge.getToken(), challenge.getAuthorization()));
|
||||
ButtonWebsiteModule.startHttp();
|
||||
try {
|
||||
Thread.sleep(1000); // Just to make sure
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
return challenge;
|
||||
}
|
||||
|
||||
|
|
|
@ -130,23 +130,34 @@ public class ButtonWebsiteModule extends JavaPlugin {
|
|||
this.getLogger().info("Starting webserver...");
|
||||
server.setExecutor(
|
||||
new ThreadPoolExecutor(4, 8, 30, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(100)));
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY && !TBMCCoreAPI.IsTestServer()) { // Only update every week
|
||||
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
|
||||
AcmeClient.main("server.figytuna.com"); // Task is running async so we don't need an extra thread
|
||||
}
|
||||
((Runnable) server::start).run(); // Totally normal way of calling a method
|
||||
httpserver.createContext("/", new HttpHandler() {
|
||||
@Override
|
||||
public void handle(HttpExchange exchange) throws IOException {
|
||||
IOHelper.SendResponse(IOHelper.Redirect("https://server.figytuna.com/", exchange));
|
||||
}
|
||||
});
|
||||
httpserver.start();
|
||||
final Calendar calendar = Calendar.getInstance();
|
||||
if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY && !TBMCCoreAPI.IsTestServer()) { // Only update every week
|
||||
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
|
||||
AcmeClient.main("server.figytuna.com"); // Task is running async so we don't need an extra thread
|
||||
}
|
||||
((Runnable) server::start).run(); // Totally normal way of calling a method
|
||||
if (!httpstarted)
|
||||
httpserver.start();
|
||||
this.getLogger().info("Webserver started");
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean httpstarted = false;
|
||||
|
||||
/**
|
||||
* Used to start the server when the ACME client needs it
|
||||
*/
|
||||
static void startHttp() {
|
||||
httpserver.start();
|
||||
httpstarted = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new page/endpoint to the website. This method needs to be called before the server finishes loading (onEnable).
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue