From 27115b20e8cfd9a528e5d26dbf0697ad2da650fd Mon Sep 17 00:00:00 2001 From: Christian Koop Date: Fri, 19 Jul 2024 17:34:23 +0200 Subject: [PATCH 1/6] fix: Fix NullpointerException when MarketplaceUrl is null in OverviewGUI --- .../core/core/SongodaCoreOverviewGUI.java | 27 +++++-------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/Core/src/main/java/com/craftaro/core/core/SongodaCoreOverviewGUI.java b/Core/src/main/java/com/craftaro/core/core/SongodaCoreOverviewGUI.java index ff1f837c..f556059b 100644 --- a/Core/src/main/java/com/craftaro/core/core/SongodaCoreOverviewGUI.java +++ b/Core/src/main/java/com/craftaro/core/core/SongodaCoreOverviewGUI.java @@ -23,34 +23,19 @@ final class SongodaCoreOverviewGUI extends Gui { for (int i = 0; i < plugins.size(); ++i) { final PluginInfo plugin = plugins.get(i); - if (plugin.hasUpdate()) { - setButton(i, GuiUtils.createButtonItem(plugin.getIcon() != null ? plugin.getIcon() : XMaterial.STONE, - ChatColor.GOLD + plugin.getJavaPlugin().getName(), - ChatColor.GRAY + "Latest Version: " + plugin.getLatestVersion(), - ChatColor.GRAY + "Installed Version: " + plugin.getJavaPlugin().getDescription().getVersion(), - "", - "Change log:", - plugin.getChangeLog(), - "", - ChatColor.GOLD + "Click for the marketplace page link.", - ChatColor.GOLD + "Right Click to edit plugin settings." - ), - ClickType.LEFT, (event) -> event.player.sendMessage(plugin.getMarketplaceLink())); - setAction(i, ClickType.RIGHT, (event) -> event.manager.showGUI(event.player, new PluginConfigGui(plugin.getJavaPlugin(), event.gui))); - highlightItem(i); - - continue; - } + boolean hasMarketplaceLink = plugin.getMarketplaceLink() != null && !plugin.getMarketplaceLink().isEmpty(); setButton(i, GuiUtils.createButtonItem(plugin.getIcon() != null ? plugin.getIcon() : XMaterial.STONE, ChatColor.GOLD + plugin.getJavaPlugin().getName(), ChatColor.GRAY + "Installed Version: " + plugin.getJavaPlugin().getDescription().getVersion(), "", - ChatColor.GOLD + "Click for the marketplace page link.", + hasMarketplaceLink ? (ChatColor.GOLD + "Click for the marketplace page link.") : "", ChatColor.GOLD + "Right Click to edit plugin settings." ), - ClickType.LEFT, (event) -> event.player.sendMessage(plugin.getMarketplaceLink())); - setAction(i, ClickType.RIGHT, (event) -> event.manager.showGUI(event.player, new PluginConfigGui(plugin.getJavaPlugin(), event.gui))); + ClickType.RIGHT, (event) -> event.manager.showGUI(event.player, new PluginConfigGui(plugin.getJavaPlugin(), event.gui))); + if (hasMarketplaceLink) { + setAction(i, ClickType.LEFT, (event) -> event.player.sendMessage(plugin.getMarketplaceLink())); + } } } } From 54494c8ad901a9334708f2373f7095183d26ad83 Mon Sep 17 00:00:00 2001 From: Christian Koop Date: Fri, 19 Jul 2024 17:35:36 +0200 Subject: [PATCH 2/6] fix!: remove dependance on `update.songoda.com` which is not available This also gets rid of auto-download of different locale files as the services providing them finally stopped working. --- .../java/com/craftaro/core/SongodaCore.java | 92 +------------------ .../com/craftaro/core/core/LocaleModule.java | 64 ------------- .../com/craftaro/core/core/PluginInfo.java | 48 ---------- 3 files changed, 4 insertions(+), 200 deletions(-) delete mode 100644 Core/src/main/java/com/craftaro/core/core/LocaleModule.java diff --git a/Core/src/main/java/com/craftaro/core/SongodaCore.java b/Core/src/main/java/com/craftaro/core/SongodaCore.java index 4a7bd77f..cf833887 100644 --- a/Core/src/main/java/com/craftaro/core/SongodaCore.java +++ b/Core/src/main/java/com/craftaro/core/SongodaCore.java @@ -2,14 +2,11 @@ import com.craftaro.core.commands.CommandManager; import com.craftaro.core.compatibility.ClientVersion; -import com.craftaro.core.core.LocaleModule; import com.craftaro.core.core.PluginInfo; -import com.craftaro.core.core.PluginInfoModule; import com.craftaro.core.core.SongodaCoreCommand; import com.craftaro.core.core.SongodaCoreDiagCommand; import com.cryptomorin.xseries.XMaterial; import org.bukkit.Bukkit; -import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; @@ -20,24 +17,14 @@ import org.bukkit.plugin.ServicePriority; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitTask; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.net.HttpURLConnection; -import java.net.URL; import java.util.ArrayList; -import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Objects; import java.util.Set; -import java.util.UUID; import java.util.logging.Level; public class SongodaCore { @@ -230,55 +217,11 @@ private void register(JavaPlugin plugin, int pluginID, String icon, String libra getLogger().info(getPrefix() + "Hooked " + plugin.getName() + "."); PluginInfo info = new PluginInfo(plugin, pluginID, icon, libraryVersion); - // don't forget to check for language pack updates ;) - info.addModule(new LocaleModule()); - registeredPlugins.add(info); - this.tasks.add(Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> update(info), 60L)); - } - - /** - * @deprecated Seems useless and will probably be replaced in the near future - */ - @Deprecated - private void update(PluginInfo plugin) { - try { - URL url = new URL("https://update.songoda.com/index.php?plugin=" + plugin.getSongodaId() - + "&version=" + plugin.getJavaPlugin().getDescription().getVersion() - + "&updaterVersion=" + updaterVersion); - HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); - urlConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11"); - urlConnection.setRequestProperty("Accept", "*/*"); - urlConnection.setConnectTimeout(5000); - InputStream is = urlConnection.getInputStream(); - InputStreamReader isr = new InputStreamReader(is); - - int numCharsRead; - char[] charArray = new char[1024]; - StringBuilder sb = new StringBuilder(); - while ((numCharsRead = isr.read(charArray)) > 0) { - sb.append(charArray, 0, numCharsRead); - } - urlConnection.disconnect(); - - String jsonString = sb.toString(); - JSONObject json = (JSONObject) new JSONParser().parse(jsonString); - - plugin.setLatestVersion((String) json.get("latestVersion")); - plugin.setMarketplaceLink((String) json.get("link")); - plugin.setNotification((String) json.get("notification")); - plugin.setChangeLog((String) json.get("changeLog")); - - plugin.setJson(json); - - for (PluginInfoModule module : plugin.getModules()) { - module.run(plugin); - } - } catch (IOException ex) { - final String er = ex.getMessage(); - getLogger().log(Level.FINE, "Connection with Songoda servers failed: " + (er.contains("URL") ? er.substring(0, er.indexOf("URL") + 3) : er)); - } catch (ParseException ex) { - getLogger().log(Level.FINE, "Failed to parse json for " + plugin.getJavaPlugin().getName() + " update check"); + if (plugin.getDescription().getWebsite() != null && plugin.getDescription().getWebsite().contains("songoda.com/")) { + info.setMarketplaceLink(plugin.getDescription().getWebsite()); } + + registeredPlugins.add(info); } public static List getPlugins() { @@ -391,33 +334,6 @@ void onEnable(PluginEnableEvent event) { } private class EventListener implements Listener { - final HashMap lastCheck = new HashMap<>(); - - @EventHandler - void onLogin(PlayerLoginEvent event) { - final Player player = event.getPlayer(); - - // don't spam players with update checks - long now = System.currentTimeMillis(); - Long last = this.lastCheck.get(player.getUniqueId()); - - if (last != null && now - 10000 < last) { - return; - } - - this.lastCheck.put(player.getUniqueId(), now); - - // is this player good to revieve update notices? - if (!event.getPlayer().isOp() && !player.hasPermission("songoda.updatecheck")) return; - - // check for updates! ;) - for (PluginInfo plugin : getPlugins()) { - if (plugin.getNotification() != null && plugin.getJavaPlugin().isEnabled()) - Bukkit.getScheduler().runTaskLaterAsynchronously(plugin.getJavaPlugin(), () -> - player.sendMessage("[" + plugin.getJavaPlugin().getName() + "] " + plugin.getNotification()), 10L); - } - } - @EventHandler void onDisable(PluginDisableEvent event) { // don't track disabled plugins diff --git a/Core/src/main/java/com/craftaro/core/core/LocaleModule.java b/Core/src/main/java/com/craftaro/core/core/LocaleModule.java deleted file mode 100644 index 53126634..00000000 --- a/Core/src/main/java/com/craftaro/core/core/LocaleModule.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.craftaro.core.core; - -import com.craftaro.core.locale.Locale; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; - -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.logging.Level; -import java.util.logging.Logger; - -public class LocaleModule implements PluginInfoModule { - @Override - public void run(PluginInfo plugin) { - if (plugin.getJavaPlugin() == null || plugin.getSongodaId() <= 0) { - return; - } - - try { - JSONObject json = plugin.getJson(); - JSONArray files = (JSONArray) json.get("neededFiles"); - - for (Object o : files) { - JSONObject file = (JSONObject) o; - - if (file.get("type").equals("locale")) { - downloadLocale(plugin, (String) file.get("link"), (String) file.get("name")); - } - } - } catch (IOException ex) { - Logger.getLogger(LocaleModule.class.getName()).log(Level.INFO, "Failed to check for locale files: " + ex.getMessage()); - } - } - - void downloadLocale(PluginInfo plugin, String link, String fileName) throws IOException { - URL url = new URL(link); - - HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); - urlConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11"); - urlConnection.setRequestProperty("Accept", "*/*"); - urlConnection.setInstanceFollowRedirects(true); - urlConnection.setConnectTimeout(5000); - - // do we need to follow a redirect? - int status = urlConnection.getResponseCode(); - if (status == HttpURLConnection.HTTP_MOVED_TEMP || status == HttpURLConnection.HTTP_MOVED_PERM || status == HttpURLConnection.HTTP_SEE_OTHER) { - // get redirect url from "location" header field - String newUrl = urlConnection.getHeaderField("Location"); - // get the cookie if needed - String cookies = urlConnection.getHeaderField("Set-Cookie"); - // open the new connnection again - urlConnection = (HttpURLConnection) new URL(newUrl).openConnection(); - urlConnection.setRequestProperty("Cookie", cookies); - urlConnection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11"); - urlConnection.setRequestProperty("Accept", "*/*"); - urlConnection.setConnectTimeout(5000); - } - - Locale.saveLocale(plugin.getJavaPlugin(), urlConnection.getInputStream(), fileName); - - urlConnection.disconnect(); - } -} diff --git a/Core/src/main/java/com/craftaro/core/core/PluginInfo.java b/Core/src/main/java/com/craftaro/core/core/PluginInfo.java index c135b75a..ec45a6b1 100644 --- a/Core/src/main/java/com/craftaro/core/core/PluginInfo.java +++ b/Core/src/main/java/com/craftaro/core/core/PluginInfo.java @@ -4,7 +4,6 @@ import com.craftaro.core.dependency.DependencyLoader; import com.cryptomorin.xseries.XMaterial; import org.bukkit.plugin.java.JavaPlugin; -import org.json.simple.JSONObject; import java.util.ArrayList; import java.util.Collections; @@ -18,12 +17,7 @@ public final class PluginInfo { private final String coreLibraryVersion; private final List modules = new ArrayList<>(); - private boolean hasUpdate = false; - private String latestVersion; - private String notification; - private String changeLog; private String marketplaceLink; - private JSONObject json; public PluginInfo(JavaPlugin javaPlugin, int songodaId, String icon, String coreLibraryVersion) { this.javaPlugin = javaPlugin; @@ -33,40 +27,6 @@ public PluginInfo(JavaPlugin javaPlugin, int songodaId, String icon, String core this.coreLibraryVersion = coreLibraryVersion; } - public String getLatestVersion() { - return this.latestVersion; - } - - public void setLatestVersion(String latestVersion) { - this.latestVersion = latestVersion; - - this.hasUpdate = latestVersion != null && !latestVersion.isEmpty() && !this.javaPlugin.getDescription().getVersion().equalsIgnoreCase(latestVersion); - } - - public String getNotification() { - return this.notification; - } - - public void setNotification(String notification) { - this.notification = notification; - } - - public boolean hasUpdate() { - return this.hasUpdate; - } - - public void setHasUpdate(boolean hasUpdate) { - this.hasUpdate = hasUpdate; - } - - public String getChangeLog() { - return this.changeLog; - } - - public void setChangeLog(String changeLog) { - this.changeLog = changeLog; - } - public String getMarketplaceLink() { return this.marketplaceLink; } @@ -75,14 +35,6 @@ public void setMarketplaceLink(String marketplaceLink) { this.marketplaceLink = marketplaceLink; } - public JSONObject getJson() { - return this.json; - } - - public void setJson(JSONObject json) { - this.json = json; - } - public PluginInfoModule addModule(PluginInfoModule module) { this.modules.add(module); From 157150a2f19b5af2dcdc620186d89807f36485f7 Mon Sep 17 00:00:00 2001 From: Christian Koop Date: Fri, 19 Jul 2024 19:12:35 +0200 Subject: [PATCH 3/6] feat: introduce MajorServerVersion class based on old ServerVersion class FSB has too many usages of the ServerVersion class and I don't feel like updating 50+ or 100+ or whatever uses of it. It takes too much brain time for me to re-think the version constraints --- .../compatibility/MajorServerVersion.java | 95 +++++++++++++++++++ .../core/compatibility/ServerVersion.java | 2 +- 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 Compatibility/src/main/java/com/craftaro/core/compatibility/MajorServerVersion.java diff --git a/Compatibility/src/main/java/com/craftaro/core/compatibility/MajorServerVersion.java b/Compatibility/src/main/java/com/craftaro/core/compatibility/MajorServerVersion.java new file mode 100644 index 00000000..9a77e884 --- /dev/null +++ b/Compatibility/src/main/java/com/craftaro/core/compatibility/MajorServerVersion.java @@ -0,0 +1,95 @@ +package com.craftaro.core.compatibility; + +import org.apache.commons.lang3.ArrayUtils; + +public enum MajorServerVersion { + UNKNOWN, V1_7, V1_8, V1_9, V1_10, V1_11, V1_12, V1_13, V1_14, V1_15, V1_16, V1_17, V1_18, V1_19, V1_20, V1_21, V1_22, V1_23; + + private static final MajorServerVersion SERVER_VERSION = getVersion(); + + public boolean isLessThan(MajorServerVersion other) { + if (SERVER_VERSION == UNKNOWN) { + return false; + } + + return this.ordinal() < other.ordinal(); + } + + public boolean isAtOrBelow(MajorServerVersion other) { + if (SERVER_VERSION == UNKNOWN && other != UNKNOWN) { + return false; + } + + return this.ordinal() <= other.ordinal(); + } + + public boolean isGreaterThan(MajorServerVersion other) { + if (SERVER_VERSION == UNKNOWN) { + return false; + } + + return this.ordinal() > other.ordinal(); + } + + public boolean isAtLeast(MajorServerVersion other) { + if (SERVER_VERSION == UNKNOWN && other != UNKNOWN) { + return false; + } + + return this.ordinal() >= other.ordinal(); + } + + public static MajorServerVersion getServerVersion() { + return SERVER_VERSION; + } + + public static boolean isServerVersion(MajorServerVersion version) { + return SERVER_VERSION == version; + } + + public static boolean isServerVersion(MajorServerVersion... versions) { + return ArrayUtils.contains(versions, SERVER_VERSION); + } + + public static boolean isServerVersionAbove(MajorServerVersion version) { + if (SERVER_VERSION == UNKNOWN) { + return false; + } + + return SERVER_VERSION.ordinal() > version.ordinal(); + } + + public static boolean isServerVersionAtLeast(MajorServerVersion version) { + if (SERVER_VERSION == UNKNOWN && version != UNKNOWN) { + return false; + } + + return SERVER_VERSION.ordinal() >= version.ordinal(); + } + + public static boolean isServerVersionAtOrBelow(MajorServerVersion version) { + if (SERVER_VERSION == UNKNOWN && version != UNKNOWN) { + return false; + } + + return SERVER_VERSION.ordinal() <= version.ordinal(); + } + + public static boolean isServerVersionBelow(MajorServerVersion version) { + if (SERVER_VERSION == UNKNOWN) { + return false; + } + + return SERVER_VERSION.ordinal() < version.ordinal(); + } + + private static MajorServerVersion getVersion() { + for (MajorServerVersion version : values()) { + if (ServerVersion.serverPackageVersion.toUpperCase().startsWith(version.name())) { + return version; + } + } + + return UNKNOWN; + } +} diff --git a/Compatibility/src/main/java/com/craftaro/core/compatibility/ServerVersion.java b/Compatibility/src/main/java/com/craftaro/core/compatibility/ServerVersion.java index 5569293b..e77fe9f7 100644 --- a/Compatibility/src/main/java/com/craftaro/core/compatibility/ServerVersion.java +++ b/Compatibility/src/main/java/com/craftaro/core/compatibility/ServerVersion.java @@ -60,7 +60,7 @@ public enum ServerVersion { ; - private static final String serverPackageVersion; + static final String serverPackageVersion; private static final String serverReleaseVersion; private static final ServerVersion serverVersion; private static final boolean isMocked; From 9aad7f63f3ee6b2efb21bdeabcf810fb592ab839 Mon Sep 17 00:00:00 2001 From: Christian Koop Date: Fri, 19 Jul 2024 19:14:07 +0200 Subject: [PATCH 4/6] feat: Add NMSPlayer#getProfile(Player) method to get the GameProfile --- .../craftaro/core/nms/entity/NMSPlayer.java | 3 ++ .../core/nms/entity/player/GameProfile.java | 52 +++++++++++++++++++ .../nms/v1_10_R1/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_11_R1/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_12_R1/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_13_R1/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_13_R2/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_14_R1/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_15_R1/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_16_R1/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_16_R2/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_16_R3/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_17_R1/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_18_R1/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_18_R2/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_19_0/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_19_R1/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_19_R2/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_19_R3/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_20_R1/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_20_R2/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_20_R3/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_20_R4/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_21_R1/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_8_R1/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_8_R2/entity/NMSPlayerImpl.java | 26 +++++++++- .../nms/v1_8_R3/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_9_R1/entity/NMSPlayerImpl.java | 24 +++++++++ .../nms/v1_9_R2/entity/NMSPlayerImpl.java | 24 +++++++++ 29 files changed, 704 insertions(+), 1 deletion(-) create mode 100644 NMS/NMS-API/src/main/java/com/craftaro/core/nms/entity/player/GameProfile.java 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 c8471cf5..685212a6 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 @@ -1,7 +1,10 @@ package com.craftaro.core.nms.entity; +import com.craftaro.core.nms.entity.player.GameProfile; import org.bukkit.entity.Player; public interface NMSPlayer { void sendPacket(Player p, Object packet); + + GameProfile getProfile(Player p); } 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 new file mode 100644 index 00000000..1657c67d --- /dev/null +++ b/NMS/NMS-API/src/main/java/com/craftaro/core/nms/entity/player/GameProfile.java @@ -0,0 +1,52 @@ +package com.craftaro.core.nms.entity.player; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Objects; +import java.util.UUID; + +public class GameProfile { + private final Object mojangGameProfile; + + private final UUID id; + private final String name; + private final String textureValue; + private final String textureSignature; + + public GameProfile( + Object mojangGameProfile, + + UUID id, + String name, + @Nullable String textureValue, + @Nullable String textureSignature + ) { + this.mojangGameProfile = Objects.requireNonNull(mojangGameProfile); + + this.id = Objects.requireNonNull(id); + this.name = Objects.requireNonNull(name); + this.textureValue = textureValue; + this.textureSignature = textureSignature; + } + + public Object getMojangGameProfile() { + return this.mojangGameProfile; + } + + public @NotNull UUID getId() { + return this.id; + } + + public @NotNull String getName() { + return this.name; + } + + public @Nullable String getTextureValue() { + return this.textureValue; + } + + public @Nullable String getTextureSignature() { + return this.textureSignature; + } +} 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 564965ee..4382ae85 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_10_R1.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.server.v1_10_R1.Packet; import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().playerConnection.sendPacket((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 4098d5c7..a4f3f1f9 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_11_R1.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.server.v1_11_R1.Packet; import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().playerConnection.sendPacket((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 8d4db3b0..d730bf77 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_12_R1.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.server.v1_12_R1.Packet; import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().playerConnection.sendPacket((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 20c2e043..70b00535 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_13_R1.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.server.v1_13_R1.Packet; import org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().playerConnection.sendPacket((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 f6b164ff..d0f95ef6 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_13_R2.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.server.v1_13_R2.Packet; import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().playerConnection.sendPacket((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 a05441ec..fff85165 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_14_R1.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.server.v1_14_R1.Packet; import org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().playerConnection.sendPacket((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 a49aeb11..dab2d411 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_15_R1.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.server.v1_15_R1.Packet; import org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().playerConnection.sendPacket((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 80b8aa06..312266cd 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_16_R1.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.server.v1_16_R1.Packet; import org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().playerConnection.sendPacket((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 b3bdf4f1..068e5e86 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_16_R2.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.server.v1_16_R2.Packet; import org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().playerConnection.sendPacket((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 9343a130..18d00a2f 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_16_R3.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.server.v1_16_R3.Packet; import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().playerConnection.sendPacket((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 1eb1eb31..098c462b 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_17_R1.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().b.sendPacket((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 52c9eab1..d345ec14 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_18_R1.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().connection.send((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 426c4cc4..58aa1f5b 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_18_R2.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().connection.send((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 abe60ff9..9dbf1f9e 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_19_0.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().connection.send((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 36b465d4..1aea152f 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_19_R1.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().connection.send((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 ccef0966..d455020f 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_19_R2.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().connection.send((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 e7dc6bbb..af08d99e 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_19_R3.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().connection.send((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 b2c9bfc7..a99d68d4 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_20_R1.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().connection.send((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 49ab1035..3eb0aa2c 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_20_R2.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().connection.send((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.name().equals("SKIN")) { + textureValue = property.value(); + textureSignature = property.signature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 3c3a22da..da5641df 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_20_R3.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().connection.send((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.name().equals("SKIN")) { + textureValue = property.value(); + textureSignature = property.signature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 9a96c313..bd29862f 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_20_R4.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_20_R4.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().connection.send((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.name().equals("SKIN")) { + textureValue = property.value(); + textureSignature = property.signature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 29280549..3de30723 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_21_R1.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.network.protocol.Packet; import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().connection.send((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getGameProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.name().equals("SKIN")) { + textureValue = property.value(); + textureSignature = property.signature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 5dba5fe5..8a94109d 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_8_R1.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.server.v1_8_R1.Packet; import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().playerConnection.sendPacket((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 aa95f1d6..a32d69ba 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_8_R2.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.server.v1_8_R2.Packet; import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -8,6 +10,28 @@ public class NMSPlayerImpl implements NMSPlayer { @Override public void sendPacket(Player p, Object packet) { - ((CraftPlayer) p).getHandle().playerConnection.sendPacket((Packet) packet); + ((CraftPlayer) p).getHandle().playerConnection.sendPacket((Packet) packet); + } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); } } 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 687c0b57..5e6d6889 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_8_R3.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.server.v1_8_R3.Packet; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().playerConnection.sendPacket((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 ddadf602..9a855fcf 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_9_R1.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.server.v1_9_R1.Packet; import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().playerConnection.sendPacket((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } 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 69348a94..526cf9d3 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 @@ -1,6 +1,8 @@ package com.craftaro.core.nms.v1_9_R2.entity; import com.craftaro.core.nms.entity.NMSPlayer; +import com.craftaro.core.nms.entity.player.GameProfile; +import com.mojang.authlib.properties.Property; import net.minecraft.server.v1_9_R2.Packet; import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer; import org.bukkit.entity.Player; @@ -10,4 +12,26 @@ public class NMSPlayerImpl implements NMSPlayer { public void sendPacket(Player p, Object packet) { ((CraftPlayer) p).getHandle().playerConnection.sendPacket((Packet) packet); } + + public GameProfile getProfile(Player p) { + com.mojang.authlib.GameProfile profile = ((CraftPlayer) p).getHandle().getProfile(); + + String textureValue = null; + String textureSignature = null; + for (Property property : profile.getProperties().get("textures")) { + if (property.getName().equals("SKIN")) { + textureValue = property.getValue(); + textureSignature = property.getSignature(); + } + } + + return new GameProfile( + profile, + + profile.getId(), + profile.getName(), + textureValue, + textureSignature + ); + } } From d91c675bb78582305367634b2b0ea7964948745b Mon Sep 17 00:00:00 2001 From: Christian Koop Date: Fri, 19 Jul 2024 19:15:19 +0200 Subject: [PATCH 5/6] feat: introduce new SkullItemCreator class for use instead of XSkull If the XSkull class changes again, we only have to update the Core's implementation. The #byPlayer method also handles offline mode servers better than XSkull which essentially just fails right now --- .../craftaro/core/utils/SkullItemCreator.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Core/src/main/java/com/craftaro/core/utils/SkullItemCreator.java diff --git a/Core/src/main/java/com/craftaro/core/utils/SkullItemCreator.java b/Core/src/main/java/com/craftaro/core/utils/SkullItemCreator.java new file mode 100644 index 00000000..98db7e6a --- /dev/null +++ b/Core/src/main/java/com/craftaro/core/utils/SkullItemCreator.java @@ -0,0 +1,58 @@ +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 org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +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); + } + + return createDefaultSkull(player.getUniqueId()); + } + + public static ItemStack byUuid(UUID uuid) { + return XSkull.createItem().profile(new Profileable.UUIDProfileable(uuid)).apply(); + } + + public static ItemStack byUsername(String username) { + return XSkull.createItem().profile(new Profileable.StringProfileable(username, ProfileInputType.USERNAME)).apply(); + } + + public static ItemStack byTextureValue(String textureValue) { + return XSkull.createItem().profile(new Profileable.StringProfileable(textureValue, ProfileInputType.BASE64)).apply(); + } + + public static ItemStack byTextureUrl(String textureUrl) { + return XSkull.createItem().profile(new Profileable.StringProfileable(textureUrl, ProfileInputType.TEXTURE_URL)).apply(); + } + + public static ItemStack byTextureHash(String textureHash) { + return XSkull.createItem().profile(new Profileable.StringProfileable(textureHash, ProfileInputType.TEXTURE_HASH)).apply(); + } + + private static ItemStack createDefaultSkull(UUID uuid) { + String textureValue = STEVE_TEXTURE; + if ((uuid.hashCode() & 1) != 0) { + textureValue = ALEX_TEXTURE; + } + + return XSkull.createItem().profile(new Profileable.StringProfileable(textureValue, ProfileInputType.BASE64)).apply(); + } +} From 4cd0c02aea66ed86c8f5ba892037a7fc29d04f58 Mon Sep 17 00:00:00 2001 From: Christian Koop Date: Fri, 19 Jul 2024 19:36:57 +0200 Subject: [PATCH 6/6] Release v3.2.0-SNAPSHOT --- Compatibility/pom.xml | 2 +- Core/pom.xml | 2 +- NMS/NMS-API/pom.xml | 2 +- NMS/NMS-v1_10_R1/pom.xml | 2 +- NMS/NMS-v1_11_R1/pom.xml | 2 +- NMS/NMS-v1_12_R1/pom.xml | 2 +- NMS/NMS-v1_13_R1/pom.xml | 2 +- NMS/NMS-v1_13_R2/pom.xml | 2 +- NMS/NMS-v1_14_R1/pom.xml | 2 +- NMS/NMS-v1_15_R1/pom.xml | 2 +- NMS/NMS-v1_16_R1/pom.xml | 2 +- NMS/NMS-v1_16_R2/pom.xml | 2 +- NMS/NMS-v1_16_R3/pom.xml | 2 +- NMS/NMS-v1_17_R1/pom.xml | 2 +- NMS/NMS-v1_18_R1/pom.xml | 2 +- NMS/NMS-v1_18_R2/pom.xml | 2 +- NMS/NMS-v1_19_0/pom.xml | 2 +- NMS/NMS-v1_19_R1/pom.xml | 2 +- NMS/NMS-v1_19_R2/pom.xml | 2 +- NMS/NMS-v1_19_R3/pom.xml | 2 +- NMS/NMS-v1_20_R1/pom.xml | 2 +- NMS/NMS-v1_20_R2/pom.xml | 2 +- NMS/NMS-v1_20_R3/pom.xml | 2 +- NMS/NMS-v1_20_R4/pom.xml | 2 +- NMS/NMS-v1_21_R1/pom.xml | 2 +- NMS/NMS-v1_8_R1/pom.xml | 2 +- NMS/NMS-v1_8_R2/pom.xml | 2 +- NMS/NMS-v1_8_R3/pom.xml | 2 +- NMS/NMS-v1_9_R1/pom.xml | 2 +- NMS/NMS-v1_9_R2/pom.xml | 2 +- NMS/NMS/pom.xml | 2 +- pom.xml | 2 +- 32 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Compatibility/pom.xml b/Compatibility/pom.xml index 712f7a7e..2fc553f5 100644 --- a/Compatibility/pom.xml +++ b/Compatibility/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../pom.xml CraftaroCore-Compatibility diff --git a/Core/pom.xml b/Core/pom.xml index 284bc606..16661964 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../pom.xml CraftaroCore diff --git a/NMS/NMS-API/pom.xml b/NMS/NMS-API/pom.xml index 81ff3e88..7aab8772 100644 --- a/NMS/NMS-API/pom.xml +++ b/NMS/NMS-API/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-API diff --git a/NMS/NMS-v1_10_R1/pom.xml b/NMS/NMS-v1_10_R1/pom.xml index af7237fb..34c073d4 100644 --- a/NMS/NMS-v1_10_R1/pom.xml +++ b/NMS/NMS-v1_10_R1/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_10_R1 diff --git a/NMS/NMS-v1_11_R1/pom.xml b/NMS/NMS-v1_11_R1/pom.xml index 7a606407..60170d4b 100644 --- a/NMS/NMS-v1_11_R1/pom.xml +++ b/NMS/NMS-v1_11_R1/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_11_R1 diff --git a/NMS/NMS-v1_12_R1/pom.xml b/NMS/NMS-v1_12_R1/pom.xml index 8a4ac42d..7191879c 100644 --- a/NMS/NMS-v1_12_R1/pom.xml +++ b/NMS/NMS-v1_12_R1/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_12_R1 diff --git a/NMS/NMS-v1_13_R1/pom.xml b/NMS/NMS-v1_13_R1/pom.xml index 33416321..3670936a 100644 --- a/NMS/NMS-v1_13_R1/pom.xml +++ b/NMS/NMS-v1_13_R1/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_13_R1 diff --git a/NMS/NMS-v1_13_R2/pom.xml b/NMS/NMS-v1_13_R2/pom.xml index 389ec3ba..65d16b5b 100644 --- a/NMS/NMS-v1_13_R2/pom.xml +++ b/NMS/NMS-v1_13_R2/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_13_R2 diff --git a/NMS/NMS-v1_14_R1/pom.xml b/NMS/NMS-v1_14_R1/pom.xml index bb6fe301..3b4e1c14 100644 --- a/NMS/NMS-v1_14_R1/pom.xml +++ b/NMS/NMS-v1_14_R1/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_14_R1 diff --git a/NMS/NMS-v1_15_R1/pom.xml b/NMS/NMS-v1_15_R1/pom.xml index 72e0df93..0f6c458e 100644 --- a/NMS/NMS-v1_15_R1/pom.xml +++ b/NMS/NMS-v1_15_R1/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_15_R1 diff --git a/NMS/NMS-v1_16_R1/pom.xml b/NMS/NMS-v1_16_R1/pom.xml index a8abb55d..0ed2f75e 100644 --- a/NMS/NMS-v1_16_R1/pom.xml +++ b/NMS/NMS-v1_16_R1/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_16_R1 diff --git a/NMS/NMS-v1_16_R2/pom.xml b/NMS/NMS-v1_16_R2/pom.xml index 93fee222..9ee2a67b 100644 --- a/NMS/NMS-v1_16_R2/pom.xml +++ b/NMS/NMS-v1_16_R2/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_16_R2 diff --git a/NMS/NMS-v1_16_R3/pom.xml b/NMS/NMS-v1_16_R3/pom.xml index 5af9f7b9..4bb228b4 100644 --- a/NMS/NMS-v1_16_R3/pom.xml +++ b/NMS/NMS-v1_16_R3/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_16_R3 diff --git a/NMS/NMS-v1_17_R1/pom.xml b/NMS/NMS-v1_17_R1/pom.xml index 6f4a624f..6d21a564 100644 --- a/NMS/NMS-v1_17_R1/pom.xml +++ b/NMS/NMS-v1_17_R1/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_17_R1 diff --git a/NMS/NMS-v1_18_R1/pom.xml b/NMS/NMS-v1_18_R1/pom.xml index f38646b5..d77f526d 100644 --- a/NMS/NMS-v1_18_R1/pom.xml +++ b/NMS/NMS-v1_18_R1/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_18_R1 diff --git a/NMS/NMS-v1_18_R2/pom.xml b/NMS/NMS-v1_18_R2/pom.xml index 8eb2dd58..0bffc542 100644 --- a/NMS/NMS-v1_18_R2/pom.xml +++ b/NMS/NMS-v1_18_R2/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_18_R2 diff --git a/NMS/NMS-v1_19_0/pom.xml b/NMS/NMS-v1_19_0/pom.xml index 369530c4..74d22bef 100644 --- a/NMS/NMS-v1_19_0/pom.xml +++ b/NMS/NMS-v1_19_0/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_19_0 diff --git a/NMS/NMS-v1_19_R1/pom.xml b/NMS/NMS-v1_19_R1/pom.xml index 6c5e1422..911ebcab 100644 --- a/NMS/NMS-v1_19_R1/pom.xml +++ b/NMS/NMS-v1_19_R1/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_19_R1 diff --git a/NMS/NMS-v1_19_R2/pom.xml b/NMS/NMS-v1_19_R2/pom.xml index a812d1af..b9ccfde0 100644 --- a/NMS/NMS-v1_19_R2/pom.xml +++ b/NMS/NMS-v1_19_R2/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_19_R2 diff --git a/NMS/NMS-v1_19_R3/pom.xml b/NMS/NMS-v1_19_R3/pom.xml index fb575a2c..b70e3a58 100644 --- a/NMS/NMS-v1_19_R3/pom.xml +++ b/NMS/NMS-v1_19_R3/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_19_R3 diff --git a/NMS/NMS-v1_20_R1/pom.xml b/NMS/NMS-v1_20_R1/pom.xml index 8c57455f..916a79be 100644 --- a/NMS/NMS-v1_20_R1/pom.xml +++ b/NMS/NMS-v1_20_R1/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_20_R1 diff --git a/NMS/NMS-v1_20_R2/pom.xml b/NMS/NMS-v1_20_R2/pom.xml index 22f10101..72ee40cd 100644 --- a/NMS/NMS-v1_20_R2/pom.xml +++ b/NMS/NMS-v1_20_R2/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_20_R2 diff --git a/NMS/NMS-v1_20_R3/pom.xml b/NMS/NMS-v1_20_R3/pom.xml index b61ec8c2..eb352750 100644 --- a/NMS/NMS-v1_20_R3/pom.xml +++ b/NMS/NMS-v1_20_R3/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_20_R3 diff --git a/NMS/NMS-v1_20_R4/pom.xml b/NMS/NMS-v1_20_R4/pom.xml index 83bf6365..aef75a14 100644 --- a/NMS/NMS-v1_20_R4/pom.xml +++ b/NMS/NMS-v1_20_R4/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_20_R4 diff --git a/NMS/NMS-v1_21_R1/pom.xml b/NMS/NMS-v1_21_R1/pom.xml index 60d61398..2b26ee8e 100644 --- a/NMS/NMS-v1_21_R1/pom.xml +++ b/NMS/NMS-v1_21_R1/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_21_R1 diff --git a/NMS/NMS-v1_8_R1/pom.xml b/NMS/NMS-v1_8_R1/pom.xml index bfd28d94..63b2b4f8 100644 --- a/NMS/NMS-v1_8_R1/pom.xml +++ b/NMS/NMS-v1_8_R1/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_8_R1 diff --git a/NMS/NMS-v1_8_R2/pom.xml b/NMS/NMS-v1_8_R2/pom.xml index d22a6c3c..fc0dfbd5 100644 --- a/NMS/NMS-v1_8_R2/pom.xml +++ b/NMS/NMS-v1_8_R2/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_8_R2 diff --git a/NMS/NMS-v1_8_R3/pom.xml b/NMS/NMS-v1_8_R3/pom.xml index e7a05fe3..422c3fde 100644 --- a/NMS/NMS-v1_8_R3/pom.xml +++ b/NMS/NMS-v1_8_R3/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_8_R3 diff --git a/NMS/NMS-v1_9_R1/pom.xml b/NMS/NMS-v1_9_R1/pom.xml index 9f6f60c1..7ff5fd62 100644 --- a/NMS/NMS-v1_9_R1/pom.xml +++ b/NMS/NMS-v1_9_R1/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_9_R1 diff --git a/NMS/NMS-v1_9_R2/pom.xml b/NMS/NMS-v1_9_R2/pom.xml index 6ca8a94f..8c6ffe3a 100644 --- a/NMS/NMS-v1_9_R2/pom.xml +++ b/NMS/NMS-v1_9_R2/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS-v1_9_R2 diff --git a/NMS/NMS/pom.xml b/NMS/NMS/pom.xml index fd62cef7..b44d6efd 100644 --- a/NMS/NMS/pom.xml +++ b/NMS/NMS/pom.xml @@ -7,7 +7,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT ../../pom.xml CraftaroCore-NMS diff --git a/pom.xml b/pom.xml index b3cf2197..c90915d1 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.craftaro CraftaroCore-Modules - 3.1.0-SNAPSHOT + 3.2.0-SNAPSHOT pom