Skip to content

Commit

Permalink
Version Increment
Browse files Browse the repository at this point in the history
  • Loading branch information
PeachesMLG committed Jan 15, 2024
1 parent 00e2714 commit 17a4771
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 24 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "com.iridium"
version = "1.8.4"
version = "1.8.5"
description = "IridiumCore"

allprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import de.tr7zw.changeme.nbtapi.NBTCompound;
import de.tr7zw.changeme.nbtapi.NBTItem;
import de.tr7zw.changeme.nbtapi.NBTListCompound;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.inventory.ItemFlag;
Expand All @@ -21,8 +20,6 @@
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* Class which creates {@link ItemStack}'s.
Expand Down Expand Up @@ -138,15 +135,11 @@ private static ItemStack setHeadData(String headData, ItemStack itemStack) {
if (IridiumCore.getInstance().isTesting()) return itemStack;
if (headData == null) return itemStack;

IridiumCore.getInstance().getLogger().info("Setting "+headData + " as HeadData for ItemStack");

NBTItem nbtItem = new NBTItem(itemStack);
NBTCompound skull = nbtItem.addCompound("SkullOwner");
if (supports) {
IridiumCore.getInstance().getLogger().info("Setting as uuid");
skull.setUUID("Id", UUID.randomUUID());
} else {
IridiumCore.getInstance().getLogger().info("Setting as String");
skull.setString("Id", UUID.randomUUID().toString());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.iridium.iridiumcore.IridiumCore;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;

Expand All @@ -17,8 +15,6 @@
import java.util.HashMap;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;
import java.util.logging.Logger;

public class SkinUtils {

Expand All @@ -31,30 +27,24 @@ public class SkinUtils {
private static final String steveSkin = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZWI3YWY5ZTQ0MTEyMTdjN2RlOWM2MGFjYmQzYzNmZDY1MTk3ODMzMzJhMWIzYmM1NmZiZmNlOTA3MjFlZjM1In19fQ==";

public static UUID getUUID(String username) {
IridiumCore.getInstance().getLogger().info("Getting UUID for "+username);
if (!isValidUsername(username)) {
OfflinePlayer player = Bukkit.getOfflinePlayer(username);
return player.getUniqueId();
}
if (!uuidCache.containsKey(username)) {
IridiumCore.getInstance().getLogger().info("UUID is not in cache");
uuidCache.put(username, loadingUUID);
CompletableFuture.runAsync(() -> {
try {
String signature = getURLContent("https://api.mojang.com/users/profiles/minecraft/" + username);

IridiumCore.getInstance().getLogger().info("Retrieved "+signature+" for "+ username);
if (!signature.isEmpty()) {
JsonObject profileJsonObject = gson.fromJson(signature, JsonObject.class);
String value = profileJsonObject.get("id").getAsString();
IridiumCore.getInstance().getLogger().info("Retrieved "+value+" for "+ username);
if (value != null) {
uuidCache.put(username,
UUID.fromString(value.replaceFirst(
"(\\p{XDigit}{8})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}{4})(\\p{XDigit}+)",
"$1-$2-$3-$4-$5"
)));
IridiumCore.getInstance().getLogger().info("put "+uuidCache.get(username)+" into cache for "+ username);
}
}
} catch (UnknownHostException ignored) {
Expand All @@ -65,15 +55,12 @@ public static UUID getUUID(String username) {
}

public static String getHeadData(UUID uuid) {
IridiumCore.getInstance().getLogger().info("Getting Head Data for "+uuid);
if (uuid.equals(loadingUUID) || isBedrockPlayer(uuid)) return steveSkin;
if (!cache.containsKey(uuid)) {
IridiumCore.getInstance().getLogger().info("Head Data for "+uuid +" is not in cache");
cache.put(uuid, steveSkin);
CompletableFuture.runAsync(() -> {
try {
String signature = getURLContent("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid);
IridiumCore.getInstance().getLogger().info("Returned "+signature +" for "+uuid);
String signature = getURLContent("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid.toString());
if (!signature.isEmpty()) {
JsonObject profileJsonObject = gson.fromJson(signature, JsonObject.class);
if (profileJsonObject.has("properties")) {
Expand All @@ -84,15 +71,13 @@ public static String getHeadData(UUID uuid) {
String skinURL = textureJsonObject.getAsJsonObject("textures").getAsJsonObject("SKIN").get("url").getAsString();
byte[] skinByte = ("{\"textures\":{\"SKIN\":{\"url\":\"" + skinURL + "\"}}}").getBytes();
String data = new String(Base64.getEncoder().encode(skinByte));
IridiumCore.getInstance().getLogger().info("Returned "+data +" for "+uuid);
cache.put(uuid, data);
}
}
} catch (UnknownHostException ignored) {
}
});
}
IridiumCore.getInstance().getLogger().info("returned "+cache.get(uuid) +" for "+uuid);
return cache.get(uuid);
}

Expand Down

0 comments on commit 17a4771

Please sign in to comment.