mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-22 10:35:16 +01:00
Fix code stylings
This commit is contained in:
parent
961e65b3b3
commit
981a12e349
@ -127,11 +127,11 @@ public void load() throws IOException, ParseResourceException {
|
||||
}
|
||||
|
||||
webServer = new WebServer(
|
||||
webServerConfig.getWebserverPort(),
|
||||
webServerConfig.getWebserverMaxConnections(),
|
||||
webServerConfig.getWebserverBindAdress(),
|
||||
requestHandler,
|
||||
false
|
||||
webServerConfig.getWebserverPort(),
|
||||
webServerConfig.getWebserverMaxConnections(),
|
||||
webServerConfig.getWebserverBindAdress(),
|
||||
requestHandler,
|
||||
false
|
||||
);
|
||||
webServer.start();
|
||||
}
|
||||
|
@ -46,21 +46,21 @@ public class HttpConnection implements Runnable {
|
||||
private Socket connection;
|
||||
private InputStream in;
|
||||
private OutputStream out;
|
||||
|
||||
|
||||
private final boolean verbose;
|
||||
|
||||
|
||||
public HttpConnection(ServerSocket server, Socket connection, HttpRequestHandler handler, int timeout, TimeUnit timeoutUnit, boolean verbose) throws IOException {
|
||||
this.server = server;
|
||||
this.connection = connection;
|
||||
this.handler = handler;
|
||||
this.verbose = verbose;
|
||||
|
||||
|
||||
if (isClosed()){
|
||||
throw new IOException("Socket already closed!");
|
||||
}
|
||||
|
||||
|
||||
connection.setSoTimeout((int) timeoutUnit.toMillis(timeout));
|
||||
|
||||
|
||||
in = this.connection.getInputStream();
|
||||
out = this.connection.getOutputStream();
|
||||
}
|
||||
@ -91,42 +91,42 @@ public void run() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
close();
|
||||
} catch (IOException e){
|
||||
Logger.global.logError("Error while closing HttpConnection!", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void log(HttpRequest request, HttpResponse response) {
|
||||
|
||||
private void log(HttpRequest request, HttpResponse response) {
|
||||
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
||||
Date date = new Date();
|
||||
Logger.global.logInfo(
|
||||
connection.getInetAddress().toString()
|
||||
+ " [ "
|
||||
+ dateFormat.format(date)
|
||||
+ " ] \""
|
||||
+ request.getMethod()
|
||||
+ " " + request.getPath()
|
||||
+ " " + request.getVersion()
|
||||
+ "\" "
|
||||
+ response.getStatusCode().toString());
|
||||
}
|
||||
|
||||
connection.getInetAddress().toString()
|
||||
+ " [ "
|
||||
+ dateFormat.format(date)
|
||||
+ " ] \""
|
||||
+ request.getMethod()
|
||||
+ " " + request.getPath()
|
||||
+ " " + request.getVersion()
|
||||
+ "\" "
|
||||
+ response.getStatusCode().toString());
|
||||
}
|
||||
|
||||
private void sendResponse(HttpResponse response) throws IOException {
|
||||
response.write(out);
|
||||
out.flush();
|
||||
}
|
||||
|
||||
|
||||
private HttpRequest acceptRequest() throws ConnectionClosedException, InvalidRequestException, IOException {
|
||||
return HttpRequest.read(in);
|
||||
}
|
||||
|
||||
|
||||
public boolean isClosed(){
|
||||
return !connection.isBound() || connection.isClosed() || !connection.isConnected() || connection.isOutputShutdown() || connection.isInputShutdown();
|
||||
}
|
||||
|
||||
|
||||
public void close() throws IOException {
|
||||
try {
|
||||
in.close();
|
||||
@ -138,13 +138,13 @@ public void close() throws IOException {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class ConnectionClosedException extends IOException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
|
||||
public static class InvalidRequestException extends IOException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class WebServer extends Thread {
|
||||
private final int port;
|
||||
private final int maxConnections;
|
||||
private final InetAddress bindAdress;
|
||||
private final boolean verbose;
|
||||
private final boolean verbose;
|
||||
|
||||
private HttpRequestHandler handler;
|
||||
|
||||
|
@ -234,13 +234,13 @@ public void startWebserver(BlueMapService blueMap, boolean verbose) throws IOExc
|
||||
|
||||
WebServerConfig config = blueMap.getWebServerConfig();
|
||||
HttpRequestHandler requestHandler = new FileRequestHandler(config.getWebRoot().toPath(), "BlueMap v" + BlueMap.VERSION);
|
||||
|
||||
|
||||
WebServer webServer = new WebServer(
|
||||
config.getWebserverPort(),
|
||||
config.getWebserverMaxConnections(),
|
||||
config.getWebserverBindAdress(),
|
||||
requestHandler,
|
||||
verbose
|
||||
config.getWebserverPort(),
|
||||
config.getWebserverMaxConnections(),
|
||||
config.getWebserverBindAdress(),
|
||||
requestHandler,
|
||||
verbose
|
||||
);
|
||||
webServer.start();
|
||||
}
|
||||
@ -375,9 +375,9 @@ private static Options createOptions() {
|
||||
.desc("Sets the minecraft-version, used e.g. to load resource-packs correctly. Defaults to the latest compatible version.")
|
||||
.build()
|
||||
);
|
||||
|
||||
|
||||
options.addOption("w", "webserver", false, "Starts the web-server, configured in the 'webserver.conf' file");
|
||||
options.addOption("b", "verbose", false, "Causes the web-server to log requests to the console");
|
||||
options.addOption("b", "verbose", false, "Causes the web-server to log requests to the console");
|
||||
|
||||
options.addOption("g", "generate-webapp", false, "Generates the files for the web-app to the folder, configured in the 'render.conf' file (this is done automatically when rendering if the 'index.html' file in the webroot can't be found)");
|
||||
options.addOption("s", "generate-websettings", false, "Generates the settings for the web-app, using the settings from the 'render.conf' file (this is done automatically when rendering)");
|
||||
|
Loading…
Reference in New Issue
Block a user