protocolize icon indicating copy to clipboard operation
protocolize copied to clipboard

inventory error

Open bulat5280 opened this issue 2 years ago • 1 comments

Describe the bug Kick and error when opening inventory

To Reproduce Steps to reproduce the behavior:

  1. Write the plugin with code:
 ProtocolizePlayer player = Protocolize.playerProvider().player(((Player) invocation.source()).getUniqueId());
            final Inventory inventory = new Inventory(InventoryType.GENERIC_9X6).title(ChatElement.ofLegacyText("Inventory name")).onClick(inventoryClick -> inventoryClick.cancelled(true));
            List<BaseItemStack> items = new ArrayList<>();
            Database.getAllRanks(true).forEach((key, value) -> {
                BaseItemStack itemStack = new ItemStack(ItemType.PLAYER_HEAD);
                itemStack.displayName(key);
                try {
                    final Optional<MojangSkinDataResult> playerSkin = SkinsRestorerProvider.get().getSkinStorage().getPlayerSkin(key, true);
                    if (playerSkin.isPresent()) {
                        CompoundTag skullOwner = itemStack.nbtData().getCompoundTag("SkullOwner");
                        if (skullOwner == null) {
                            skullOwner = new CompoundTag();
                        }
                        skullOwner.put("Name", new StringTag(key));
                        CompoundTag properties = skullOwner.getCompoundTag("Properties");
                        if (properties == null) {
                            properties = new CompoundTag();
                        }
                        final CompoundTag texture = new CompoundTag();
                        texture.put("Value", new StringTag(playerSkin.get().getSkinProperty().getValue()));
                        final ListTag<CompoundTag> textures = new ListTag<>(CompoundTag.class);
                        textures.add(texture);
                        properties.put("textures", textures);
                        skullOwner.put("Properties", properties);
                        itemStack.nbtData().put("SkullOwner", skullOwner);
                    }
                } catch (DataRequestException e) {
                    e.printStackTrace();
                }
                items.add(itemStack);
            });
            inventory.items(items);
            player.openInventory(inventory);

Expected behavior The player will not kick and the inventory will open.

Screenshots image

Proxy environment Velocity last version installed protocolize and protocolize-legacy-velocity

Minecraft versions used 1.12.2

bulat5280 avatar Jan 16 '24 19:01 bulat5280

I guess its a problem with the nbt things and not the Library

feeeedox avatar Feb 18 '24 01:02 feeeedox