From 761f4c14f02ef8244fb88b4df2690e786d738def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20N=C3=A4gele?= Date: Sun, 14 Jan 2024 20:37:33 +0100 Subject: [PATCH] fix error in gameprofilebuilder --- missilewars-plugin/pom.xml | 2 +- .../missilewars/commands/StatsCommands.java | 2 +- .../util/stats/GameProfileBuilder.java | 25 +++++++++++++------ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/missilewars-plugin/pom.xml b/missilewars-plugin/pom.xml index 91321199..47919b8f 100644 --- a/missilewars-plugin/pom.xml +++ b/missilewars-plugin/pom.xml @@ -117,7 +117,7 @@ com.mojang authlib - 1.5.25 + 4.0.43 provided diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/commands/StatsCommands.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/commands/StatsCommands.java index 40949964..78e7e4b8 100644 --- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/commands/StatsCommands.java +++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/commands/StatsCommands.java @@ -140,7 +140,7 @@ public void onRecommendations(CommandSender sender, String[] args) { } // TODO implement more features - if (recommendations.size() == 0) { + if (recommendations.isEmpty()) { player.sendMessage(Messages.getPrefix() + "§aThere are currently no recommendations, everything seems fine :)"); } else { player.sendMessage(Messages.getPrefix() + "§7=====[ §eMissileWars recommendations §7]====="); diff --git a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/stats/GameProfileBuilder.java b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/stats/GameProfileBuilder.java index bd0ab35a..a92eee1b 100644 --- a/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/stats/GameProfileBuilder.java +++ b/missilewars-plugin/src/main/java/de/butzlabben/missilewars/util/stats/GameProfileBuilder.java @@ -18,21 +18,32 @@ package de.butzlabben.missilewars.util.stats; -import com.google.gson.*; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.JsonSerializationContext; +import com.google.gson.JsonSerializer; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.PropertyMap; import com.mojang.util.UUIDTypeAdapter; -import lombok.Getter; -import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; - import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.net.URL; import java.net.URLConnection; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import lombok.Getter; +import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder; /** * @author Butzlabben @@ -59,7 +70,7 @@ public static GameProfile fetch(UUID uuid, boolean forceNew) throws IOException } String json = getText(String.format("https://sessionserver.mojang.com/session/minecraft/profile/%s?unsigned=false", - UUIDTypeAdapter.fromUUID(uuid))); + uuid.toString().replace("-", ""))); try { GameProfile result = gson.fromJson(json, GameProfile.class); @@ -80,7 +91,7 @@ public static GameProfile getProfile(UUID uuid, String name, String skinUrl, Str List args = new ArrayList<>(); args.add(System.currentTimeMillis()); - args.add(UUIDTypeAdapter.fromUUID(uuid)); + args.add(uuid.toString().replaceAll("-", "")); args.add(name); args.add(skinUrl); if (cape) {