/u/logorkill_0
Guest
Member
Hey there, Im not used to ask for help on reddit, but Im really stuck since days now and can't find a way to fix my problem...
I just want to make a GUI with a playerHead in it that's it, my code work from 1.8 to 1.20, but on 1.21 the head has no texture Idk why... I get 0 error in the console and can't find what method should I use now, can someone give me a tips please !
Btw Im on the 1.13 API and prefer it to make plugins fully compatible from 1.8.x to 1.20.x.
Here is my method so far
I know this is not clean at all but honestly I spent so many hours trying so many things that the method is a bit crazy now
Thanks to anyone reading this !
submitted by /u/logorkill_0
[link] [comments]
Continue reading...
free plugins
minecraft paid for free
spigotmc
SpigotMC
free minecraft paid plugins
free minecraft plugins
aac free
ewg free
Minecraft Premium Plugins
ewg free download
litebans free
epicworldgenerator free
free schematics
leaked schematics minecraft
schematics
schematics leaked
schematics free
minecraft schematics free
paid minecraft schematics free
paid minecraft schematics for free
free cracked plugins
free cracked minecraft plugins
plugins
featherboard download
featherboard plugin download
antiaura download
minecraft plugins
xenforo leaked
xenforo for free
xenforo addons
I just want to make a GUI with a playerHead in it that's it, my code work from 1.8 to 1.20, but on 1.21 the head has no texture Idk why... I get 0 error in the console and can't find what method should I use now, can someone give me a tips please !
Btw Im on the 1.13 API and prefer it to make plugins fully compatible from 1.8.x to 1.20.x.
Here is my method so far
public static ItemStack getCustomHead(String url) { // Handle material differences between versions ItemStack head = new ItemStack(Materials. PLAYER_HEAD .get(), 1, (short) 3); SkullMeta meta = (SkullMeta) head.getItemMeta(); if (url == null || url.isEmpty() || meta == null) return head; try { // ======== 1.20.5+ Modern API Path ======== Class<?> profileClass = Class. forName ("org.bukkit.profile.PlayerProfile"); Class<?> texturesClass = Class. forName ("org.bukkit.profile.PlayerTextures"); // Create profile Method createProfile = Bukkit.class.getMethod("createPlayerProfile", UUID.class, String.class); Object profile = createProfile.invoke(null, UUID. randomUUID (), "CustomHead"); // Set texture via URL Method getTextures = profileClass.getMethod("getTextures"); Object textures = getTextures.invoke(profile); String httpsUrl = url.replace("http://", "https://"); Method setSkin = texturesClass.getMethod("setSkin", URL.class); setSkin.invoke(textures, new URL(httpsUrl)); Method setTexturesMethod = profileClass.getMethod("setTextures", texturesClass); setTexturesMethod.invoke(profile, textures); // Apply to skull Method setPlayerProfile = SkullMeta.class.getMethod("setPlayerProfile", profileClass); setPlayerProfile.invoke(meta, profile); } catch (ClassNotFoundException | NoSuchMethodException e) { // ======== 1.8–1.20.4 Fallback ======== UUID uuid = UUID. nameUUIDFromBytes (url.getBytes()); GameProfile profile = new GameProfile(uuid, "CustomHead"); String textureJson = "{\"textures\":{\"SKIN\":{\"url\":\"" + url + "\"}}}"; profile.getProperties().put("textures", new Property("textures", Base64. getEncoder ().encodeToString(textureJson.getBytes()))); try { // Spigot 1.16–1.20 Method setProfile = meta.getClass().getDeclaredMethod("setProfile", GameProfile.class); setProfile.setAccessible(true); setProfile.invoke(meta, profile); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) { // Spigot 1.8–1.15 try { Field profileField = meta.getClass().getDeclaredField("profile"); profileField.setAccessible(true); profileField.set(meta, profile); } catch (Exception ignored) {} } } catch (Exception e) { e.printStackTrace(); } head.setItemMeta(meta); return head; }
I know this is not clean at all but honestly I spent so many hours trying so many things that the method is a bit crazy now
Thanks to anyone reading this !
submitted by /u/logorkill_0
[link] [comments]
Continue reading...
free plugins
minecraft paid for free
spigotmc
SpigotMC
free minecraft paid plugins
free minecraft plugins
aac free
ewg free
Minecraft Premium Plugins
ewg free download
litebans free
epicworldgenerator free
free schematics
leaked schematics minecraft
schematics
schematics leaked
schematics free
minecraft schematics free
paid minecraft schematics free
paid minecraft schematics for free
free cracked plugins
free cracked minecraft plugins
plugins
featherboard download
featherboard plugin download
antiaura download
minecraft plugins
xenforo leaked
xenforo for free
xenforo addons