Small fixes

This commit is contained in:
Norbi Peti 2017-06-16 23:46:10 +02:00 committed by NorbiPeti
parent 195a208f67
commit aaa1b8e3ba
3 changed files with 4 additions and 9 deletions

View file

@ -119,7 +119,7 @@ public class ButtonWebsiteModule extends JavaPlugin {
((Runnable) server::start).run(); // Totally normal way of calling a method
this.getLogger().info("Webserver started");
final Calendar calendar = Calendar.getInstance();
if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY) { // Only update every week
if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY && !TBMCCoreAPI.IsTestServer()) { // Only update every week
Thread t = new Thread(() -> AcmeClient.main("server.figytuna.com"));
t.setContextClassLoader(getClass().getClassLoader());
t.start();

View file

@ -72,14 +72,9 @@ public class IOHelper {
/**
* Sends login headers and sets the session id on the user
*
* @param exchange
* @param user
*/
public static void LoginUser(HttpExchange exchange, WebUser user) {
Bukkit.getLogger().fine("Logging in user: " + user);
// provider.SetValues(() ->
// user.setSessionid(UUID.randomUUID().toString()));
user.sessionID().set(UUID.randomUUID());
new Cookies(2).add(new Cookie("user_id", user.getUUID() + ""))
.add(new Cookie("session_id", user.sessionID().get().toString())).SendHeaders(exchange);
@ -97,9 +92,9 @@ public class IOHelper {
.SendHeaders(exchange);
}
public static void Redirect(String url, HttpExchange exchange) throws IOException {
public static Response Redirect(String url, HttpExchange exchange) throws IOException {
exchange.getResponseHeaders().add("Location", url);
IOHelper.SendResponse(303, "<a href=\"" + url + "\">If you can see this, click here to continue</a>", exchange);
return new Response(303, "<a href=\"" + url + "\">If you can see this, click here to continue</a>", exchange);
}
public static Cookies GetCookies(HttpExchange exchange) {

View file

@ -34,7 +34,7 @@ public abstract class Page implements HttpHandler {
str.print("</pre>");
IOHelper.SendResponse(500, baos.toString("UTF-8"), exchange);
} catch (Exception e1) {
e1.printStackTrace();
TBMCCoreAPI.SendException("Exception while sending Internal Server Error in ButtonWebsiteModule!", e1);
}
}
}