mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-11 19:02:16 +01:00
More smell cleans
This commit is contained in:
parent
db47e51e45
commit
fa8b1d2b35
@ -68,9 +68,9 @@ public class ConnectionIn {
|
||||
|
||||
private Map<String, String> readVariables(Request request) throws WebException {
|
||||
String requestBody = readRequestBody(request.getRequestBody());
|
||||
String[] variables = requestBody.split(";&variable;");
|
||||
String[] bodyVariables = requestBody.split(";&variable;");
|
||||
|
||||
return Arrays.stream(variables)
|
||||
return Arrays.stream(bodyVariables)
|
||||
.map(variable -> variable.split("=", 2))
|
||||
.filter(splitVariables -> splitVariables.length == 2)
|
||||
.collect(Collectors.toMap(splitVariables -> splitVariables[0], splitVariables -> splitVariables[1], (a, b) -> b));
|
||||
|
@ -11,6 +11,7 @@ import com.djrapitops.plugin.api.utility.log.Log;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Class responsible for logging what ConnectionOut objects get in return.
|
||||
@ -90,6 +91,20 @@ public class ConnectionLog {
|
||||
public int compareTo(Entry o) {
|
||||
return Long.compare(o.date, this.date);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Entry)) return false;
|
||||
Entry entry = (Entry) o;
|
||||
return responseCode == entry.responseCode &&
|
||||
date == entry.date;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(responseCode, date);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -116,9 +116,4 @@ public class ServerConnectionSystem extends ConnectionSystem {
|
||||
Log.info(locale.get().getString(PluginLang.ENABLE_NOTIFY_ADDRESS_CONFIRMATION, webServerAddress));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -63,4 +63,7 @@ public class WebExceptionLogger {
|
||||
return null;
|
||||
}
|
||||
|
||||
private WebExceptionLogger() {
|
||||
// Static method class.
|
||||
}
|
||||
}
|
||||
|
@ -50,13 +50,13 @@ public class CacheAnalysisPageRequest extends InfoRequestWithVariables implement
|
||||
public Response handleRequest(Map<String, String> variables) throws WebException {
|
||||
// Available variables: sender, html (Base64)
|
||||
|
||||
UUID serverUUID = UUID.fromString(variables.get("sender"));
|
||||
UUID sender = UUID.fromString(variables.get("sender"));
|
||||
|
||||
String html = variables.get("html");
|
||||
Verify.nullCheck(html, () -> new BadRequestException("HTML 'html' variable not supplied in the request"));
|
||||
String sentHtml = variables.get("html");
|
||||
Verify.nullCheck(sentHtml, () -> new BadRequestException("HTML 'html' variable not supplied in the request"));
|
||||
|
||||
boolean export = Settings.ANALYSIS_EXPORT.isTrue();
|
||||
cache(export, serverUUID, Base64Util.decode(html));
|
||||
cache(export, sender, Base64Util.decode(sentHtml));
|
||||
return DefaultResponses.SUCCESS.get();
|
||||
}
|
||||
|
||||
|
@ -32,13 +32,7 @@ public class PlanErrorManager implements ErrorManager {
|
||||
} else {
|
||||
Log.warn("It has been logged to ErrorLog.txt");
|
||||
}
|
||||
try {
|
||||
if ((Check.isBukkitAvailable() && Check.isBungeeAvailable()) || Settings.DEV_MODE.isTrue()) {
|
||||
Logger.getGlobal().log(Level.WARNING, source, e);
|
||||
}
|
||||
} catch (IllegalStateException ignored) {
|
||||
/* Config system not initialized */
|
||||
}
|
||||
logGlobally(source, e);
|
||||
ErrorLogger.logThrowable(e, logsFolder);
|
||||
} catch (Exception exception) {
|
||||
System.out.println("Failed to log error to file because of " + exception);
|
||||
@ -48,4 +42,14 @@ public class PlanErrorManager implements ErrorManager {
|
||||
Logger.getGlobal().log(Level.WARNING, source, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void logGlobally(String source, Throwable e) {
|
||||
try {
|
||||
if ((Check.isBukkitAvailable() && Check.isBungeeAvailable()) || Settings.DEV_MODE.isTrue()) {
|
||||
Logger.getGlobal().log(Level.WARNING, source, e);
|
||||
}
|
||||
} catch (IllegalStateException ignored) {
|
||||
/* Config system not initialized */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user