BUMP Minecraft version to 1.19.2 #16
2 changed files with 15 additions and 14 deletions
|
@ -46,9 +46,8 @@ public class CheckFunction {
|
||||||
|
|
||||||
TagFunction.loadPlayer(playerUUID, true);
|
TagFunction.loadPlayer(playerUUID, true);
|
||||||
|
|
||||||
List<String> names = PlayerInfo.playerUUIDToNames(playerUUID);
|
String name = PlayerInfo.playerUUIDToName(playerUUID);
|
||||||
for (int i = 1; i <= names.size(); i++)
|
source.sendFeedback(Text.of(name));
|
||||||
source.sendFeedback(Text.of(i + ". " + names.get(i-1)));
|
|
||||||
|
|
||||||
List<DB_Tag> tags = DB_Tag.getTagsFromPlayer(DB_Player.getPlayer(playerUUID));
|
List<DB_Tag> tags = DB_Tag.getTagsFromPlayer(DB_Player.getPlayer(playerUUID));
|
||||||
if (tags.size() > 0) {
|
if (tags.size() > 0) {
|
||||||
|
|
|
@ -57,6 +57,8 @@ public class PlayerInfo {
|
||||||
if (responseJSON.containsKey("name") && ! ((String)responseJSON.get("name")).equalsIgnoreCase(playerName))
|
if (responseJSON.containsKey("name") && ! ((String)responseJSON.get("name")).equalsIgnoreCase(playerName))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
LOGGER.info("player: " + playerName + " is: " + responseJSON.get("id"));
|
||||||
|
|
||||||
return (String) responseJSON.get("id");
|
return (String) responseJSON.get("id");
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -65,20 +67,22 @@ public class PlayerInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<String> playerUUIDToNames(String playerUUID) throws MojangUtilException {
|
//changed due to API changes ...
|
||||||
|
public static String playerUUIDToName(String playerUUID) throws MojangUtilException {
|
||||||
try {
|
try {
|
||||||
HttpClient httpClient = HttpClientBuilder.create().build();
|
HttpClient httpClient = HttpClientBuilder.create().build();
|
||||||
HttpGet request = new HttpGet("https://api.mojang.com/user/profiles/" + playerUUID.replaceAll("-", "") + "/names");
|
HttpGet request = new HttpGet("https://api.mojang.com/user/profile/" + playerUUID.replaceAll("-", ""));
|
||||||
HttpResponse response = httpClient.execute(request);
|
HttpResponse response = httpClient.execute(request);
|
||||||
|
|
||||||
List<String> ret = new ArrayList<>();
|
|
||||||
|
|
||||||
// take the response body as a json formatted string
|
// take the response body as a json formatted string
|
||||||
for (Object responseJSON : (JSONArray) new JSONParser().parse(EntityUtils.toString(response.getEntity()))) {
|
JSONObject responseJSON = (JSONObject) new JSONParser().parse(EntityUtils.toString(response.getEntity()));
|
||||||
ret.add((String) ((JSONObject)responseJSON).get("name"));
|
//doublecheck correct name
|
||||||
}
|
if (responseJSON.containsKey("id") && ! ((String)responseJSON.get("id")).equalsIgnoreCase(playerUUID.replaceAll("-", "")))
|
||||||
|
return null;
|
||||||
|
|
||||||
return ret;
|
LOGGER.info("player: " + playerUUID + " is: " + responseJSON.get("name"));
|
||||||
|
|
||||||
|
return (String) responseJSON.get("name");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Could not parse UUID to username!", e);
|
LOGGER.error("Could not parse UUID to username!", e);
|
||||||
|
@ -87,8 +91,6 @@ public class PlayerInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String playerUUIDToCurrentName(String playerUUID) throws MojangUtilException {
|
public static String playerUUIDToCurrentName(String playerUUID) throws MojangUtilException {
|
||||||
List<String> playernames = playerUUIDToNames(playerUUID);
|
return playerUUIDToName(playerUUID);
|
||||||
|
|
||||||
return playernames.get(playernames.size() - 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue