mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-23 01:27:42 +01:00
Fix deprecation smells
This commit is contained in:
parent
630247d884
commit
f67a02775f
@ -114,7 +114,7 @@ public class PlanSystem implements SubSystem {
|
||||
SchedulerSvc schedulerService,
|
||||
PluginLogger logger,
|
||||
ErrorLogger errorLogger,
|
||||
PlanAPI.PlanAPIHolder apiHolder
|
||||
@SuppressWarnings("deprecation") PlanAPI.PlanAPIHolder apiHolder // Deprecated PlanAPI, backwards compatibility
|
||||
) {
|
||||
this.files = files;
|
||||
this.configSystem = configSystem;
|
||||
@ -149,14 +149,6 @@ public class PlanSystem implements SubSystem {
|
||||
logger.info("§2");
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link com.djrapitops.plan.delivery.webserver.Addresses} instead.
|
||||
*/
|
||||
@Deprecated(since = "Addresses.java")
|
||||
public String getMainAddress() {
|
||||
return webServerSystem.getAddresses().getMainAddress().orElse(webServerSystem.getAddresses().getFallbackLocalhostAddress());
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables only the systems that are required for {@link com.djrapitops.plan.commands.PlanCommand}.
|
||||
*
|
||||
|
@ -115,7 +115,12 @@ public class PlayersTableJSONCreator {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
/**
|
||||
* This method is kept for /v1/players backwards compatibility.
|
||||
*
|
||||
* @deprecated Use {@link PlayersTableJSONCreator#toPlayerList()}.
|
||||
*/
|
||||
@Deprecated(since = "5.6")
|
||||
public Map<String, Object> toJSONMap() {
|
||||
return Maps.builder(String.class, Object.class)
|
||||
.put("columns", createColumnHeaders())
|
||||
|
@ -101,6 +101,7 @@ public class ResourceSvc implements ResourceService {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@SuppressWarnings("deprecation") // Legacy method, backwards compatibility
|
||||
private static String applyLegacy(Map<Position, StringBuilder> byPosition, String html) {
|
||||
StringBuilder toHead = byPosition.get(Position.PRE_CONTENT);
|
||||
if (toHead != null) {
|
||||
|
@ -107,6 +107,7 @@ public class PlayersJSONResolver extends JSONResolver {
|
||||
return getCachedOrNewResponse(request, storedJSON);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation") // /v1/players is deprecated but kept for backwards compatibility.
|
||||
private JSONStorage.StoredJSON getStoredJSON(@Untrusted Request request) {
|
||||
Optional<Long> timestamp = Identifiers.getTimestamp(request);
|
||||
JSONStorage.StoredJSON storedJSON;
|
||||
|
@ -22,11 +22,11 @@ import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -79,7 +79,7 @@ public class OreVersionInfoLoader {
|
||||
connection.setRequestProperty("User-Agent", "Player Analytics Update Checker");
|
||||
connection.connect();
|
||||
try (InputStream in = connection.getInputStream()) {
|
||||
JsonArray versions = new JsonParser().parse(readInputFully(in)).getAsJsonObject().get("result").getAsJsonArray();
|
||||
JsonArray versions = JsonParser.parseString(readInputFully(in)).getAsJsonObject().get("result").getAsJsonArray();
|
||||
|
||||
return new Gson().getAdapter(new TypeToken<List<OreVersionDto>>() {}).fromJsonTree(versions);
|
||||
}
|
||||
@ -98,21 +98,14 @@ public class OreVersionInfoLoader {
|
||||
connection.setRequestProperty("User-Agent", "Player Analytics Update Checker");
|
||||
connection.connect();
|
||||
try (InputStream in = connection.getInputStream()) {
|
||||
return new JsonParser().parse(readInputFully(in)).getAsJsonObject().get("session").getAsString();
|
||||
return JsonParser.parseString(readInputFully(in)).getAsJsonObject().get("session").getAsString();
|
||||
}
|
||||
} finally {
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
// I want Java 9 already...
|
||||
private static String readInputFully(InputStream in) throws IOException {
|
||||
try (ByteArrayOutputStream buf = new ByteArrayOutputStream(512)) {
|
||||
int b;
|
||||
while ((b = in.read()) != -1) {
|
||||
buf.write((byte) b);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
return new String(in.readAllBytes(), StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user