Exceptionflug / protocolize

A lightweight BungeeCord / Velocity protocol framework supporting items
MIT License
300 stars 39 forks source link

inventory error #220

Open bulat5280 opened 10 months ago

bulat5280 commented 10 months ago

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

Fedox-die-Ente commented 9 months ago

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