Skip to content

Commit

Permalink
Fix legacy skull texture loading
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Jan 2, 2023
1 parent fda3c9d commit aa59e15
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
20 changes: 18 additions & 2 deletions main/src/main/java/net/citizensnpcs/Citizens.java
Expand Up @@ -109,6 +109,8 @@ public void updateInventoryTitle(Player player, InventoryView view, String newTi
private NPCSelector selector;
private StoredShops shops;
private final SkullMetaProvider skullMetaProvider = new SkullMetaProvider() {
private boolean SUPPORT_OWNER_PROFILE = true;

@Override
public String getTexture(SkullMeta meta) {
GameProfile profile = NMS.getProfile(meta);
Expand All @@ -118,8 +120,22 @@ public String getTexture(SkullMeta meta) {

@Override
public void setTexture(String string, SkullMeta meta) {
UUID uuid = meta.getOwningPlayer() == null ? UUID.randomUUID() : meta.getOwningPlayer().getUniqueId();
NMS.setProfile(meta, new GameProfile(uuid, string));
GameProfile profile = NMS.getProfile(meta);
if (profile == null) {
if (SUPPORT_OWNER_PROFILE) {
try {
profile = new GameProfile(meta.getOwnerProfile().getUniqueId(),
meta.getOwnerProfile().getName());
} catch (Exception e) {
SUPPORT_OWNER_PROFILE = false;
}
}
if (profile == null) {
profile = new GameProfile(UUID.randomUUID(), null);
}
}
profile.getProperties().put("textures", new Property("textures", string));
NMS.setProfile(meta, profile);
}
};
private CitizensSpeechFactory speechFactory;
Expand Down
4 changes: 2 additions & 2 deletions main/src/main/java/net/citizensnpcs/trait/ShopTrait.java
Expand Up @@ -189,7 +189,7 @@ public void changePage(int newPage) {
NPCShopItem item = shopPage.getItem(i);

if (item != null) {
slot.setItemStack(item.display);
slot.setItemStack(item.getDisplayItem(null));
}

final int idx = i;
Expand Down Expand Up @@ -405,7 +405,7 @@ public NPCShopItemEditor(NPCShopItem item, Consumer<NPCShopItem> consumer) {
public void initialise(MenuContext ctx) {
this.ctx = ctx;
if (modified.display != null) {
ctx.getSlot(9 * 4 + 4).setItemStack(modified.display);
ctx.getSlot(9 * 4 + 4).setItemStack(modified.getDisplayItem(null));
}
ctx.getSlot(9 * 3 + 3).setItemStack(new ItemStack(Util.getFallbackMaterial("OAK_SIGN", "SIGN")),
"Set message to send on click, currently:",
Expand Down

0 comments on commit aa59e15

Please sign in to comment.