diff --git a/Core/src/main/java/com/craftaro/core/utils/SkullItemCreator.java b/Core/src/main/java/com/craftaro/core/utils/SkullItemCreator.java index 98db7e6a..b674b194 100644 --- a/Core/src/main/java/com/craftaro/core/utils/SkullItemCreator.java +++ b/Core/src/main/java/com/craftaro/core/utils/SkullItemCreator.java @@ -1,58 +1,104 @@ package com.craftaro.core.utils; import com.craftaro.core.nms.Nms; -import com.cryptomorin.xseries.profiles.builder.XSkull; -import com.cryptomorin.xseries.profiles.objects.ProfileInputType; -import com.cryptomorin.xseries.profiles.objects.Profileable; -import org.bukkit.Bukkit; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.cryptomorin.xseries.XMaterial; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Objects; import java.util.UUID; public final class SkullItemCreator { private static final String STEVE_TEXTURE = "ewogICJ0aW1lc3RhbXAiIDogMTYyMTcxNTMxMjI5MCwKICAicHJvZmlsZUlkIiA6ICJiNTM5NTkyMjMwY2I0MmE0OWY5YTRlYmYxNmRlOTYwYiIsCiAgInByb2ZpbGVOYW1lIiA6ICJtYXJpYW5hZmFnIiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzFhNGFmNzE4NDU1ZDRhYWI1MjhlN2E2MWY4NmZhMjVlNmEzNjlkMTc2OGRjYjEzZjdkZjMxOWE3MTNlYjgxMGIiCiAgICB9CiAgfQp9"; private static final String ALEX_TEXTURE = "rZvLQoZsgLYaoKqEuASopYAs7IAlZlsGkwagoM8ZX38cP9kalseZrWY5OHZVfoiftdQJ+lGOzkiFfyx6kNJDTZniLrnRa8sd3X6D65ZihT1sOm/RInCwxpS1K0zGCM2h9ErkWswfwaviIf7hJtrwk8/zL0bfzDk2IgX/IBvIZpVoYTfmQsVY9jgSwORrS9ObePGIfFgmThMoZnCYWQMVpS2+yTFA2wnw9hmisQK9UWBU+iBZv55bMmkMcyEuXw1w14DaEu+/M0UGD91LU4GmJLPA9T4GCuIV8GxOcraSVIajki1cMlOBQwIaibB2NE6KAwq1Zh6NnsNYucy6qFM+136lXfBchQ1Nx4FDRZQgt8VRqTMy/OQFpr2nTbWWbRU4gRFpKC3R0518DqUH0Qm612kPWniKku/QzUUBSe1PSVljBaZCyyRx0OB1a1/8MexboKRnPXuTDnmPa9UPfuH4VO0q+qYkjV2KUzP6e5vIP5aQ6USPrMie7MmAHFJzwAMIbLjgkTVx91GWtYqg/t7qBlvrdBRLIPPsy/DSOqa+2+4hABouVCPZrBMCMLzstPPQoqZAyiCqcKb2HqWSU0h9Bhx19yoIcbHCeI3zsQs8PqIBjUL4mO6VQT4lzHy0e3M61Xsdd8S1GtsakSetTvEtMdUwCEDfBA5PRRTLOVYTY+g="; - public static ItemStack byPlayer(Player player) { - if (Bukkit.getOnlineMode()) { - return XSkull.createItem().profile(new Profileable.PlayerProfileable(player)).apply(); - } - - String textureValue = Nms.getImplementations().getPlayer().getProfile(player).getTextureValue(); - if (textureValue != null) { - return byTextureValue(textureValue); - } + public static ItemStack byProfile(GameProfile profile) { + ItemStack item = Objects.requireNonNull(XMaterial.PLAYER_HEAD.parseItem()); + SkullMeta meta = (SkullMeta) Objects.requireNonNull(item.getItemMeta()); + applyProfile(meta, profile); + item.setItemMeta(meta); + return item; + } - return createDefaultSkull(player.getUniqueId()); + public static ItemStack byPlayer(Player player) { + return byProfile(Nms.getImplementations().getPlayer().getProfile(player)); } - public static ItemStack byUuid(UUID uuid) { - return XSkull.createItem().profile(new Profileable.UUIDProfileable(uuid)).apply(); + public static ItemStack byTextureValue(String textureValue) { + return byProfile(Nms.getImplementations().getPlayer().createProfileByTextureValue(textureValue)); } - public static ItemStack byUsername(String username) { - return XSkull.createItem().profile(new Profileable.StringProfileable(username, ProfileInputType.USERNAME)).apply(); + public static ItemStack byTextureUrl(String textureUrl) { + return byProfile(Nms.getImplementations().getPlayer().createProfileByUrl(textureUrl)); } - public static ItemStack byTextureValue(String textureValue) { - return XSkull.createItem().profile(new Profileable.StringProfileable(textureValue, ProfileInputType.BASE64)).apply(); + public static ItemStack byTextureUrlHash(String textureUrlHash) { + return byTextureUrl("https://textures.minecraft.net/texture/" + textureUrlHash); } - public static ItemStack byTextureUrl(String textureUrl) { - return XSkull.createItem().profile(new Profileable.StringProfileable(textureUrl, ProfileInputType.TEXTURE_URL)).apply(); + public static ItemStack createSteve() { + return byTextureValue(STEVE_TEXTURE); } - public static ItemStack byTextureHash(String textureHash) { - return XSkull.createItem().profile(new Profileable.StringProfileable(textureHash, ProfileInputType.TEXTURE_HASH)).apply(); + public static ItemStack createAlex() { + return byTextureValue(ALEX_TEXTURE); } - private static ItemStack createDefaultSkull(UUID uuid) { - String textureValue = STEVE_TEXTURE; + public static ItemStack createDefaultSkullForUuid(UUID uuid) { if ((uuid.hashCode() & 1) != 0) { - textureValue = ALEX_TEXTURE; + return byTextureValue(ALEX_TEXTURE); + } + return byTextureValue(STEVE_TEXTURE); + } + + private static Method skullMetaSetProfile = null; + private static Field skullMetaProfileField = null; + private static boolean setProfileUsesResolvable = false; + + private static void applyProfile(SkullMeta skullMeta, GameProfile profile) { + if (skullMetaSetProfile == null && profile.getMojangResolvableGameProfile() != null) { + try { + skullMetaSetProfile = skullMeta.getClass().getDeclaredMethod("setProfile", profile.getMojangResolvableGameProfile().getClass()); + skullMetaSetProfile.setAccessible(true); + setProfileUsesResolvable = true; + } catch (ReflectiveOperationException ignored) { + } + } + if (skullMetaSetProfile == null) { + try { + skullMetaSetProfile = skullMeta.getClass().getDeclaredMethod("setProfile", profile.getMojangGameProfile().getClass()); + skullMetaSetProfile.setAccessible(true); + } catch (ReflectiveOperationException ignored) { + } } - return XSkull.createItem().profile(new Profileable.StringProfileable(textureValue, ProfileInputType.BASE64)).apply(); + if (skullMetaSetProfile != null) { + try { + skullMetaSetProfile.invoke(skullMeta, setProfileUsesResolvable ? profile.getMojangResolvableGameProfile() : profile.getMojangGameProfile()); + } catch (IllegalAccessException | InvocationTargetException ex) { + throw new RuntimeException(ex); + } + return; + } + + if (skullMetaProfileField == null) { + try { + skullMetaProfileField = skullMeta.getClass().getDeclaredField("profile"); + skullMetaProfileField.setAccessible(true); + } catch (ReflectiveOperationException ex) { + throw new RuntimeException("Unable to find compatible #setProfile method or profile field", ex); + } + } + + try { + skullMetaProfileField.set(skullMeta, profile.getMojangGameProfile()); + } catch (IllegalAccessException | IllegalArgumentException ex) { + throw new RuntimeException("Encountered an error while setting the profile field", ex); + } } } diff --git a/NMS/NMS-API/src/main/java/com/craftaro/core/nms/entity/NMSPlayer.java b/NMS/NMS-API/src/main/java/com/craftaro/core/nms/entity/NMSPlayer.java index 685212a6..5a2d03b2 100644 --- a/NMS/NMS-API/src/main/java/com/craftaro/core/nms/entity/NMSPlayer.java +++ b/NMS/NMS-API/src/main/java/com/craftaro/core/nms/entity/NMSPlayer.java @@ -2,9 +2,27 @@ import com.craftaro.core.nms.entity.player.GameProfile; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import java.util.UUID; public interface NMSPlayer { void sendPacket(Player p, Object packet); GameProfile getProfile(Player p); + + GameProfile createProfile(UUID id, String name, @Nullable String textureValue); + + default GameProfile createProfileByUrl(String url) { + UUID id = UUID.nameUUIDFromBytes(("SongodaCore:" + url).getBytes(StandardCharsets.UTF_8)); + String rawTextureValue = "{\"textures\":{\"SKIN\":{\"url\":\"" + url + "\"}}}"; + return createProfile(id, "by_SongodaCore", Base64.getEncoder().encodeToString(rawTextureValue.getBytes())); + } + + default GameProfile createProfileByTextureValue(String textureValue) { + UUID id = UUID.nameUUIDFromBytes(("SongodaCore:" + textureValue).getBytes(StandardCharsets.UTF_8)); + return createProfile(id, "by_SongodaCore", textureValue); + } } diff --git a/NMS/NMS-API/src/main/java/com/craftaro/core/nms/entity/player/GameProfile.java b/NMS/NMS-API/src/main/java/com/craftaro/core/nms/entity/player/GameProfile.java index 1657c67d..e3fbcab1 100644 --- a/NMS/NMS-API/src/main/java/com/craftaro/core/nms/entity/player/GameProfile.java +++ b/NMS/NMS-API/src/main/java/com/craftaro/core/nms/entity/player/GameProfile.java @@ -8,6 +8,7 @@ public class GameProfile { private final Object mojangGameProfile; + private final Object mojangResolvableGameProfile; private final UUID id; private final String name; @@ -16,6 +17,7 @@ public class GameProfile { public GameProfile( Object mojangGameProfile, + @Nullable Object mojangResolvableGameProfile, UUID id, String name, @@ -23,6 +25,8 @@ public GameProfile( @Nullable String textureSignature ) { this.mojangGameProfile = Objects.requireNonNull(mojangGameProfile); + this.mojangResolvableGameProfile = mojangResolvableGameProfile; + this.id = Objects.requireNonNull(id); this.name = Objects.requireNonNull(name); @@ -34,6 +38,10 @@ public Object getMojangGameProfile() { return this.mojangGameProfile; } + public @Nullable Object getMojangResolvableGameProfile() { + return this.mojangResolvableGameProfile; + } + public @NotNull UUID getId() { return this.id; } diff --git a/NMS/NMS-v1_10_R1/src/main/java/com/craftaro/core/nms/v1_10_R1/entity/NMSPlayerImpl.java b/NMS/NMS-v1_10_R1/src/main/java/com/craftaro/core/nms/v1_10_R1/entity/NMSPlayerImpl.java index 7dff9552..0ba9d966 100644 --- a/NMS/NMS-v1_10_R1/src/main/java/com/craftaro/core/nms/v1_10_R1/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_10_R1/src/main/java/com/craftaro/core/nms/v1_10_R1/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.server.v1_10_R1.Packet; import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_11_R1/src/main/java/com/craftaro/core/nms/v1_11_R1/entity/NMSPlayerImpl.java b/NMS/NMS-v1_11_R1/src/main/java/com/craftaro/core/nms/v1_11_R1/entity/NMSPlayerImpl.java index 2b64a6b7..47734ba8 100644 --- a/NMS/NMS-v1_11_R1/src/main/java/com/craftaro/core/nms/v1_11_R1/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_11_R1/src/main/java/com/craftaro/core/nms/v1_11_R1/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.server.v1_11_R1.Packet; import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_12_R1/src/main/java/com/craftaro/core/nms/v1_12_R1/entity/NMSPlayerImpl.java b/NMS/NMS-v1_12_R1/src/main/java/com/craftaro/core/nms/v1_12_R1/entity/NMSPlayerImpl.java index 9abd7d94..ec8e6bfe 100644 --- a/NMS/NMS-v1_12_R1/src/main/java/com/craftaro/core/nms/v1_12_R1/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_12_R1/src/main/java/com/craftaro/core/nms/v1_12_R1/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.server.v1_12_R1.Packet; import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_13_R1/src/main/java/com/craftaro/core/nms/v1_13_R1/entity/NMSPlayerImpl.java b/NMS/NMS-v1_13_R1/src/main/java/com/craftaro/core/nms/v1_13_R1/entity/NMSPlayerImpl.java index 1643bcf8..6f2824cf 100644 --- a/NMS/NMS-v1_13_R1/src/main/java/com/craftaro/core/nms/v1_13_R1/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_13_R1/src/main/java/com/craftaro/core/nms/v1_13_R1/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.server.v1_13_R1.Packet; import org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_13_R2/src/main/java/com/craftaro/core/nms/v1_13_R2/entity/NMSPlayerImpl.java b/NMS/NMS-v1_13_R2/src/main/java/com/craftaro/core/nms/v1_13_R2/entity/NMSPlayerImpl.java index 90748165..b678dffb 100644 --- a/NMS/NMS-v1_13_R2/src/main/java/com/craftaro/core/nms/v1_13_R2/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_13_R2/src/main/java/com/craftaro/core/nms/v1_13_R2/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.server.v1_13_R2.Packet; import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_14_R1/src/main/java/com/craftaro/core/nms/v1_14_R1/entity/NMSPlayerImpl.java b/NMS/NMS-v1_14_R1/src/main/java/com/craftaro/core/nms/v1_14_R1/entity/NMSPlayerImpl.java index 0d55dd52..71b8e21a 100644 --- a/NMS/NMS-v1_14_R1/src/main/java/com/craftaro/core/nms/v1_14_R1/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_14_R1/src/main/java/com/craftaro/core/nms/v1_14_R1/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.server.v1_14_R1.Packet; import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_15_R1/src/main/java/com/craftaro/core/nms/v1_15_R1/entity/NMSPlayerImpl.java b/NMS/NMS-v1_15_R1/src/main/java/com/craftaro/core/nms/v1_15_R1/entity/NMSPlayerImpl.java index 2e2717ce..93207141 100644 --- a/NMS/NMS-v1_15_R1/src/main/java/com/craftaro/core/nms/v1_15_R1/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_15_R1/src/main/java/com/craftaro/core/nms/v1_15_R1/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.server.v1_15_R1.Packet; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_16_R1/src/main/java/com/craftaro/core/nms/v1_16_R1/entity/NMSPlayerImpl.java b/NMS/NMS-v1_16_R1/src/main/java/com/craftaro/core/nms/v1_16_R1/entity/NMSPlayerImpl.java index 747cb92a..6db47e45 100644 --- a/NMS/NMS-v1_16_R1/src/main/java/com/craftaro/core/nms/v1_16_R1/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_16_R1/src/main/java/com/craftaro/core/nms/v1_16_R1/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.server.v1_16_R1.Packet; import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_16_R2/src/main/java/com/craftaro/core/nms/v1_16_R2/entity/NMSPlayerImpl.java b/NMS/NMS-v1_16_R2/src/main/java/com/craftaro/core/nms/v1_16_R2/entity/NMSPlayerImpl.java index 4eec81b1..06dd87f3 100644 --- a/NMS/NMS-v1_16_R2/src/main/java/com/craftaro/core/nms/v1_16_R2/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_16_R2/src/main/java/com/craftaro/core/nms/v1_16_R2/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.server.v1_16_R2.Packet; import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_16_R3/src/main/java/com/craftaro/core/nms/v1_16_R3/entity/NMSPlayerImpl.java b/NMS/NMS-v1_16_R3/src/main/java/com/craftaro/core/nms/v1_16_R3/entity/NMSPlayerImpl.java index 32a7d93b..289d7093 100644 --- a/NMS/NMS-v1_16_R3/src/main/java/com/craftaro/core/nms/v1_16_R3/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_16_R3/src/main/java/com/craftaro/core/nms/v1_16_R3/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.server.v1_16_R3.Packet; import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_17_R1/src/main/java/com/craftaro/core/nms/v1_17_R1/entity/NMSPlayerImpl.java b/NMS/NMS-v1_17_R1/src/main/java/com/craftaro/core/nms/v1_17_R1/entity/NMSPlayerImpl.java index 5330ae72..0b949086 100644 --- a/NMS/NMS-v1_17_R1/src/main/java/com/craftaro/core/nms/v1_17_R1/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_17_R1/src/main/java/com/craftaro/core/nms/v1_17_R1/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_18_R1/src/main/java/com/craftaro/core/nms/v1_18_R1/entity/NMSPlayerImpl.java b/NMS/NMS-v1_18_R1/src/main/java/com/craftaro/core/nms/v1_18_R1/entity/NMSPlayerImpl.java index a7732487..095c02b7 100644 --- a/NMS/NMS-v1_18_R1/src/main/java/com/craftaro/core/nms/v1_18_R1/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_18_R1/src/main/java/com/craftaro/core/nms/v1_18_R1/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_18_R2/src/main/java/com/craftaro/core/nms/v1_18_R2/entity/NMSPlayerImpl.java b/NMS/NMS-v1_18_R2/src/main/java/com/craftaro/core/nms/v1_18_R2/entity/NMSPlayerImpl.java index 54933af7..7f28fc9f 100644 --- a/NMS/NMS-v1_18_R2/src/main/java/com/craftaro/core/nms/v1_18_R2/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_18_R2/src/main/java/com/craftaro/core/nms/v1_18_R2/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_19_0/src/main/java/com/craftaro/core/nms/v1_19_0/entity/NMSPlayerImpl.java b/NMS/NMS-v1_19_0/src/main/java/com/craftaro/core/nms/v1_19_0/entity/NMSPlayerImpl.java index 922ea47c..6c7c77d2 100644 --- a/NMS/NMS-v1_19_0/src/main/java/com/craftaro/core/nms/v1_19_0/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_19_0/src/main/java/com/craftaro/core/nms/v1_19_0/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_19_R1/src/main/java/com/craftaro/core/nms/v1_19_R1/entity/NMSPlayerImpl.java b/NMS/NMS-v1_19_R1/src/main/java/com/craftaro/core/nms/v1_19_R1/entity/NMSPlayerImpl.java index 10ab6ef7..1c831a40 100644 --- a/NMS/NMS-v1_19_R1/src/main/java/com/craftaro/core/nms/v1_19_R1/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_19_R1/src/main/java/com/craftaro/core/nms/v1_19_R1/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_19_R2/src/main/java/com/craftaro/core/nms/v1_19_R2/entity/NMSPlayerImpl.java b/NMS/NMS-v1_19_R2/src/main/java/com/craftaro/core/nms/v1_19_R2/entity/NMSPlayerImpl.java index 1adc7ced..47795b2a 100644 --- a/NMS/NMS-v1_19_R2/src/main/java/com/craftaro/core/nms/v1_19_R2/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_19_R2/src/main/java/com/craftaro/core/nms/v1_19_R2/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_19_R3/src/main/java/com/craftaro/core/nms/v1_19_R3/entity/NMSPlayerImpl.java b/NMS/NMS-v1_19_R3/src/main/java/com/craftaro/core/nms/v1_19_R3/entity/NMSPlayerImpl.java index f7462b6d..146ce57e 100644 --- a/NMS/NMS-v1_19_R3/src/main/java/com/craftaro/core/nms/v1_19_R3/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_19_R3/src/main/java/com/craftaro/core/nms/v1_19_R3/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_20_R1/src/main/java/com/craftaro/core/nms/v1_20_R1/entity/NMSPlayerImpl.java b/NMS/NMS-v1_20_R1/src/main/java/com/craftaro/core/nms/v1_20_R1/entity/NMSPlayerImpl.java index de89a3a1..ebf82e68 100644 --- a/NMS/NMS-v1_20_R1/src/main/java/com/craftaro/core/nms/v1_20_R1/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_20_R1/src/main/java/com/craftaro/core/nms/v1_20_R1/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_20_R2/src/main/java/com/craftaro/core/nms/v1_20_R2/entity/NMSPlayerImpl.java b/NMS/NMS-v1_20_R2/src/main/java/com/craftaro/core/nms/v1_20_R2/entity/NMSPlayerImpl.java index 2b193b23..492aed3c 100644 --- a/NMS/NMS-v1_20_R2/src/main/java/com/craftaro/core/nms/v1_20_R2/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_20_R2/src/main/java/com/craftaro/core/nms/v1_20_R2/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_20_R3/src/main/java/com/craftaro/core/nms/v1_20_R3/entity/NMSPlayerImpl.java b/NMS/NMS-v1_20_R3/src/main/java/com/craftaro/core/nms/v1_20_R3/entity/NMSPlayerImpl.java index c5b43fb5..d800e59b 100644 --- a/NMS/NMS-v1_20_R3/src/main/java/com/craftaro/core/nms/v1_20_R3/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_20_R3/src/main/java/com/craftaro/core/nms/v1_20_R3/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_20_R4/src/main/java/com/craftaro/core/nms/v1_20_R4/entity/NMSPlayerImpl.java b/NMS/NMS-v1_20_R4/src/main/java/com/craftaro/core/nms/v1_20_R4/entity/NMSPlayerImpl.java index 88029745..31d3a67a 100644 --- a/NMS/NMS-v1_20_R4/src/main/java/com/craftaro/core/nms/v1_20_R4/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_20_R4/src/main/java/com/craftaro/core/nms/v1_20_R4/entity/NMSPlayerImpl.java @@ -4,8 +4,12 @@ import com.craftaro.core.nms.entity.player.GameProfile; import com.mojang.authlib.properties.Property; import net.minecraft.network.protocol.Packet; +import net.minecraft.world.item.component.ResolvableProfile; import org.bukkit.craftbukkit.v1_20_R4.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +20,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +45,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + new ResolvableProfile(profile), profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_21_R1/src/main/java/com/craftaro/core/nms/v1_21_R1/entity/NMSPlayerImpl.java b/NMS/NMS-v1_21_R1/src/main/java/com/craftaro/core/nms/v1_21_R1/entity/NMSPlayerImpl.java index c0676e77..51780790 100644 --- a/NMS/NMS-v1_21_R1/src/main/java/com/craftaro/core/nms/v1_21_R1/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_21_R1/src/main/java/com/craftaro/core/nms/v1_21_R1/entity/NMSPlayerImpl.java @@ -4,8 +4,12 @@ import com.craftaro.core.nms.entity.player.GameProfile; import com.mojang.authlib.properties.Property; import net.minecraft.network.protocol.Packet; +import net.minecraft.world.item.component.ResolvableProfile; import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +20,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +45,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + new ResolvableProfile(profile), profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_8_R1/src/main/java/com/craftaro/core/nms/v1_8_R1/entity/NMSPlayerImpl.java b/NMS/NMS-v1_8_R1/src/main/java/com/craftaro/core/nms/v1_8_R1/entity/NMSPlayerImpl.java index d9e1cdb7..5e99b1b6 100644 --- a/NMS/NMS-v1_8_R1/src/main/java/com/craftaro/core/nms/v1_8_R1/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_8_R1/src/main/java/com/craftaro/core/nms/v1_8_R1/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.server.v1_8_R1.Packet; import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_8_R2/src/main/java/com/craftaro/core/nms/v1_8_R2/entity/NMSPlayerImpl.java b/NMS/NMS-v1_8_R2/src/main/java/com/craftaro/core/nms/v1_8_R2/entity/NMSPlayerImpl.java index 8670c078..19c81d5d 100644 --- a/NMS/NMS-v1_8_R2/src/main/java/com/craftaro/core/nms/v1_8_R2/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_8_R2/src/main/java/com/craftaro/core/nms/v1_8_R2/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.server.v1_8_R2.Packet; import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_8_R3/src/main/java/com/craftaro/core/nms/v1_8_R3/entity/NMSPlayerImpl.java b/NMS/NMS-v1_8_R3/src/main/java/com/craftaro/core/nms/v1_8_R3/entity/NMSPlayerImpl.java index f67a26bc..01517e73 100644 --- a/NMS/NMS-v1_8_R3/src/main/java/com/craftaro/core/nms/v1_8_R3/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_8_R3/src/main/java/com/craftaro/core/nms/v1_8_R3/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.server.v1_8_R3.Packet; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_9_R1/src/main/java/com/craftaro/core/nms/v1_9_R1/entity/NMSPlayerImpl.java b/NMS/NMS-v1_9_R1/src/main/java/com/craftaro/core/nms/v1_9_R1/entity/NMSPlayerImpl.java index 88711eb9..594e3070 100644 --- a/NMS/NMS-v1_9_R1/src/main/java/com/craftaro/core/nms/v1_9_R1/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_9_R1/src/main/java/com/craftaro/core/nms/v1_9_R1/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.server.v1_9_R1.Packet; import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(), diff --git a/NMS/NMS-v1_9_R2/src/main/java/com/craftaro/core/nms/v1_9_R2/entity/NMSPlayerImpl.java b/NMS/NMS-v1_9_R2/src/main/java/com/craftaro/core/nms/v1_9_R2/entity/NMSPlayerImpl.java index ccf8b79a..5ba70b63 100644 --- a/NMS/NMS-v1_9_R2/src/main/java/com/craftaro/core/nms/v1_9_R2/entity/NMSPlayerImpl.java +++ b/NMS/NMS-v1_9_R2/src/main/java/com/craftaro/core/nms/v1_9_R2/entity/NMSPlayerImpl.java @@ -6,6 +6,9 @@ import net.minecraft.server.v1_9_R2.Packet; import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer; import org.bukkit.entity.Player; +import org.jetbrains.annotations.Nullable; + +import java.util.UUID; public class NMSPlayerImpl implements NMSPlayer { @Override @@ -16,7 +19,20 @@ public void sendPacket(Player p, Object packet) { @Override public GameProfile getProfile(Player p) { com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + return wrapProfile(profile); + } + + @Override + public GameProfile createProfile(UUID id, String name, @Nullable String textureValue) { + com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile(id, name); + if (textureValue != null) { + profile.getProperties().put("textures", new Property("textures", textureValue)); + } + + return wrapProfile(profile); + } + private GameProfile wrapProfile(com.mojang.authlib.GameProfile profile) { String textureValue = null; String textureSignature = null; for (Property property : profile.getProperties().get("textures")) { @@ -28,6 +44,7 @@ public GameProfile getProfile(Player p) { return new GameProfile( profile, + null, profile.getId(), profile.getName(),