mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2024-11-18 00:46:55 +01:00
covered up string's size insecurities with a fat bufferedreader
This commit is contained in:
parent
66758b1992
commit
35738f59d9
@ -164,10 +164,13 @@ public class ExpansionCloudManager {
|
||||
plugin.getLogger().info("Fetching available expansion information...");
|
||||
|
||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
final Map<String, CloudExpansion> data;
|
||||
|
||||
final String readJson = URLReader.read(API_URL);
|
||||
final Map<String, CloudExpansion> data = GSON.fromJson(readJson, new TypeToken<Map<String, CloudExpansion>>() {
|
||||
}.getType());
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(API_URL).openStream()))) {
|
||||
data = GSON.fromJson(reader, new TypeToken<Map<String, CloudExpansion>>() {}.getType());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
final List<CloudExpansion> unsorted = new ArrayList<>();
|
||||
|
||||
@ -309,24 +312,4 @@ public class ExpansionCloudManager {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private static class URLReader {
|
||||
static String read(String url) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(url).openStream()))) {
|
||||
String inputLine;
|
||||
while ((inputLine = reader.readLine()) != null) {
|
||||
builder.append(inputLine);
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
builder.setLength(0);
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user