better synchronous call warning
This commit is contained in:
parent
ddedcea8ea
commit
9004609c1b
@ -74,7 +74,7 @@ public abstract class HttpRepository extends Repository {
|
||||
|
||||
private ReqResp<String> sendHttp(HttpRequest request) {
|
||||
try(HttpClient client = HttpClient.newHttpClient()) {
|
||||
this.validateThread();
|
||||
this.validateThread(request.uri().getPath());
|
||||
HttpResponse<String> httpResponse = client.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
return new ReqResp<>(httpResponse.statusCode(), httpResponse.body());
|
||||
} catch(IOException | InterruptedException e) {
|
||||
|
@ -15,7 +15,13 @@ public abstract class Repository {
|
||||
this.gson = new Gson();
|
||||
}
|
||||
|
||||
protected void validateThread() {
|
||||
if(Bukkit.isPrimaryThread()) Main.logger().warning("Repository was called synchronously!");
|
||||
protected void validateThread(String commandName) {
|
||||
if(!Bukkit.isPrimaryThread()) return;
|
||||
|
||||
Main.logger().warning(String.format(
|
||||
"Repository '%s' was called synchronously with command '%s'!",
|
||||
this.getClass().getSimpleName(),
|
||||
commandName
|
||||
));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user