Skip to content

Commit

Permalink
Merge branch 'dev-j8' of ssh://github.com:22/NyanGuyMF/VoidWhitelist …
Browse files Browse the repository at this point in the history
…into dev-j8
  • Loading branch information
voidpointer0x00 committed Apr 3, 2023
2 parents 62cb44c + a9fede2 commit 3d08709
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public final class CachedProfileFetcher {
.expireAfterAccess(30, TimeUnit.MINUTES)
.build();
@AutowiredLocale private static LocaleLog log;
private static JsonParser jsonParser;

public static ConcurrentLinkedQueue<Profile> fetchProfiles(final Iterable<Whitelistable> whitelistables) {
ConcurrentLinkedQueue<Profile> profiles = new ConcurrentLinkedQueue<>();
Expand All @@ -60,7 +61,8 @@ public static CompletableFuture<String> fetchName(final UUID uniqueId) {
return completedFuture(profilesCache.asMap().get(uniqueId).getName());
return supplyAsync(() -> {
try {
JsonElement jsonElement = JsonParser.parseReader(newConnectionReader(uniqueId));
//noinspection deprecation
JsonElement jsonElement = getJsonParser().parse(newConnectionReader(uniqueId));
if (!jsonElement.isJsonObject()) {
log.warn("Profile with name for UUID {0} not found.", uniqueId);
return null;
Expand Down Expand Up @@ -104,11 +106,19 @@ private static Profile requestApi(final Whitelistable whitelistable) {

private static Profile requestApi0(final Whitelistable whitelistable) throws IOException {
Profile profile = new Profile(whitelistable);
profile.fromJson(JsonParser.parseReader(newConnectionReader(whitelistable.getUniqueId())));
//noinspection deprecation
profile.fromJson(getJsonParser().parse(newConnectionReader(whitelistable.getUniqueId())));
return profile;
}

private static InputStreamReader newConnectionReader(final UUID uuid) throws IOException {
return new InputStreamReader(new URL(API_URL + uuid.toString()).openStream());
}

private static JsonParser getJsonParser() {
if (jsonParser == null)
//noinspection deprecation
jsonParser = new JsonParser();
return jsonParser;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: VoidWhitelist
version: ${project.version}b${buildNumber}-${version.stability}
main: voidpointer.spigot.voidwhitelist.VoidWhitelistPlugin
api-version: 1.18
api-version: 1.13
authors: [ _voidpointer ]
description: Mixed UUID based whitelist with the possibility of temporary addition.
website: github.com/voidpointer0x00/VoidWhitelist
Expand Down

0 comments on commit 3d08709

Please sign in to comment.