Skip to content

Commit a964e3d

Browse files
Actually fix television GUIs
1 parent 056ea32 commit a964e3d

File tree

8 files changed

+12
-21
lines changed

8 files changed

+12
-21
lines changed

src/main/java/me/eccentric_nz/TARDIS/lazarus/TARDISTelevisionInventory.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,13 @@ private ItemStack[] getItemStack() {
5858
if (PlayerHeadCache.DOCTORS.isEmpty()) {
5959
for (Skin doctor : DoctorSkins.DOCTORS) {
6060
ItemStack is = ItemStack.of(Material.PLAYER_HEAD, 1);
61-
ItemMeta im = is.getItemMeta();
61+
SkullMeta im = (SkullMeta) is.getItemMeta();
6262
SkinUtils.getHeadProfile(doctor).thenAccept(playerProfile -> {
6363
is.setData(DataComponentTypes.PROFILE, ResolvableProfile.resolvableProfile(playerProfile));
6464
String[] name = doctor.name().split(" - ");
6565
im.displayName(Component.text(name[0]));
6666
im.lore(List.of(Component.text(name[1])));
67+
im.setPlayerProfile(playerProfile);
6768
is.setItemMeta(im);
6869
// cache the item stack
6970
PlayerHeadCache.DOCTORS.add(is);
@@ -84,6 +85,7 @@ private ItemStack[] getItemStack() {
8485
SkullMeta im = (SkullMeta) is.getItemMeta();
8586
SkinUtils.getHeadProfile(companion).thenAccept(playerProfile -> {
8687
is.setData(DataComponentTypes.PROFILE, ResolvableProfile.resolvableProfile(playerProfile));
88+
im.setPlayerProfile(playerProfile);
8789
im.displayName(Component.text(companion.name()));
8890
is.setItemMeta(im);
8991
// cache the item stack
@@ -105,6 +107,7 @@ private ItemStack[] getItemStack() {
105107
SkullMeta im = (SkullMeta) is.getItemMeta();
106108
SkinUtils.getHeadProfile(character).thenAccept(playerProfile -> {
107109
is.setData(DataComponentTypes.PROFILE, ResolvableProfile.resolvableProfile(playerProfile));
110+
im.setPlayerProfile(playerProfile);
108111
im.displayName(Component.text(character.name()));
109112
is.setItemMeta(im);
110113
// cache the item stack

src/main/java/me/eccentric_nz/TARDIS/skins/SkinUtils.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.google.gson.JsonParser;
2424
import com.mojang.authlib.GameProfile;
2525
import com.mojang.authlib.properties.Property;
26-
import com.mojang.authlib.properties.PropertyMap;
2726
import io.papermc.paper.datacomponent.item.ResolvableProfile;
2827
import me.eccentric_nz.TARDIS.TARDIS;
2928
import me.eccentric_nz.TARDIS.custommodels.keys.CybermanVariant;
@@ -36,17 +35,13 @@
3635
import org.bukkit.NamespacedKey;
3736
import org.bukkit.attribute.Attribute;
3837
import org.bukkit.craftbukkit.entity.CraftPlayer;
39-
import org.bukkit.craftbukkit.profile.CraftPlayerProfile;
4038
import org.bukkit.entity.Player;
4139
import org.bukkit.inventory.EquipmentSlot;
4240
import org.bukkit.inventory.ItemStack;
4341
import org.bukkit.inventory.PlayerInventory;
4442
import org.bukkit.inventory.meta.ItemMeta;
4543
import org.bukkit.persistence.PersistentDataType;
46-
import org.bukkit.profile.PlayerTextures;
4744

48-
import java.net.MalformedURLException;
49-
import java.net.URI;
5045
import java.nio.charset.StandardCharsets;
5146
import java.util.Base64;
5247
import java.util.HashMap;
@@ -59,20 +54,16 @@ public class SkinUtils {
5954
private static final UUID uuid = UUID.fromString("622bb234-0a3e-46d7-9e1d-ed1f03c76011");
6055

6156
public static CompletableFuture<PlayerProfile> getHeadProfile(Skin skin) {
62-
// GameProfile profile = new GameProfile(uuid, "TARDIS_Skin");
6357
ResolvableProfile profile = ResolvableProfile.resolvableProfile()
6458
.uuid(uuid)
59+
.name("TARDIS_Skin")
6560
.addProperty(new ProfileProperty("textures", skin.value(), skin.signature()))
6661
.build();
6762
CompletableFuture<PlayerProfile> futureProfile = profile.resolve();
6863
return futureProfile.thenApply(playerProfile -> {
69-
PlayerTextures textures = playerProfile.getTextures();
64+
playerProfile.getProperties().removeIf(profileProperty -> profileProperty.getName().equals("textures"));
65+
playerProfile.getProperties().add(new ProfileProperty("textures", skin.value(), skin.signature()));
7066
// PlayerTextures.SkinModel model = (skin.slim()) ? PlayerTextures.SkinModel.SLIM : PlayerTextures.SkinModel.CLASSIC;
71-
try {
72-
textures.setSkin(URI.create(skin.url()).toURL(), PlayerTextures.SkinModel.CLASSIC);
73-
} catch (MalformedURLException e) {
74-
TARDIS.plugin.debug("Bad URL: " + skin.url());
75-
}
7667
return playerProfile;
7768
});
7869
}

src/main/java/me/eccentric_nz/TARDIS/skins/tv/TVCharactersInventory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ private ItemStack[] getItemStack() {
5050
SkullMeta im = (SkullMeta) is.getItemMeta();
5151
SkinUtils.getHeadProfile(character).thenAccept(playerProfile -> {
5252
is.setData(DataComponentTypes.PROFILE, ResolvableProfile.resolvableProfile(playerProfile));
53+
im.setPlayerProfile(playerProfile);
5354
im.displayName(Component.text(character.name()));
5455
is.setItemMeta(im);
5556
// cache the item stack

src/main/java/me/eccentric_nz/TARDIS/skins/tv/TVCompanionsInventory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ private ItemStack[] getItemStack() {
5050
SkullMeta im = (SkullMeta) is.getItemMeta();
5151
SkinUtils.getHeadProfile(companion).thenAccept(playerProfile -> {
5252
is.setData(DataComponentTypes.PROFILE, ResolvableProfile.resolvableProfile(playerProfile));
53+
im.setPlayerProfile(playerProfile);
5354
im.displayName(Component.text(companion.name()));
5455
is.setItemMeta(im);
5556
// cache the item stack

src/main/java/me/eccentric_nz/TARDIS/skins/tv/TVCyberInventory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ private ItemStack[] getItemStack() {
4949
SkullMeta im = (SkullMeta) is.getItemMeta();
5050
SkinUtils.getHeadProfile(variant).thenAccept(playerProfile -> {
5151
is.setData(DataComponentTypes.PROFILE, ResolvableProfile.resolvableProfile(playerProfile));
52+
im.setPlayerProfile(playerProfile);
5253
im.displayName(Component.text(variant.name()));
5354
is.setItemMeta(im);
5455
// cache the item stack

src/main/java/me/eccentric_nz/TARDIS/skins/tv/TVDoctorsInventory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ private ItemStack[] getItemStack() {
5151
SkullMeta im = (SkullMeta) is.getItemMeta();
5252
SkinUtils.getHeadProfile(doctor).thenAccept(playerProfile -> {
5353
is.setData(DataComponentTypes.PROFILE, ResolvableProfile.resolvableProfile(playerProfile));
54+
im.setPlayerProfile(playerProfile);
5455
String[] name = doctor.name().split(" - ");
5556
im.displayName(Component.text(name[0]));
5657
im.lore(List.of(Component.text(name[1])));

src/main/java/me/eccentric_nz/TARDIS/skins/tv/TVMonstersInventory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ private ItemStack[] getItemStack() {
4949
SkullMeta im = (SkullMeta) is.getItemMeta();
5050
SkinUtils.getHeadProfile(monster).thenAccept(playerProfile -> {
5151
is.setData(DataComponentTypes.PROFILE, ResolvableProfile.resolvableProfile(playerProfile));
52+
im.setPlayerProfile(playerProfile);
5253
im.displayName(Component.text(monster.name()));
5354
is.setItemMeta(im);
5455
// cache the item stack

src/main/java/me/eccentric_nz/TARDIS/skins/tv/TVSkinListener.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,11 @@
3131
import org.bukkit.inventory.meta.ItemMeta;
3232
import org.bukkit.inventory.meta.components.CustomModelDataComponent;
3333

34-
import java.util.List;
3534
import java.util.UUID;
3635

3736
public class TVSkinListener extends TARDISMenuListener {
3837

3938
private final TARDIS plugin;
40-
private final List<String> titles = List.of(
41-
"Doctor Skins",
42-
"Companion Skins",
43-
"Character Skins",
44-
"Monster Skins",
45-
"Cyberman Skins"
46-
);
4739

4840
public TVSkinListener(TARDIS plugin) {
4941
super(plugin);

0 commit comments

Comments
 (0)