inventory-framework icon indicating copy to clipboard operation
inventory-framework copied to clipboard

Duplicated Item

Open kaiquyricardo opened this issue 1 year ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

🐛 Describe the bug

When using a command such as giving an item to a player on pagination, the item is duplicated when received, for example a rock. 2 stones are coming instead of 1


Bukkit.dispatchCommand(Bukkit.getConsoleSender(),"give " + player.getName() + " minecraft:stone");

✔️ Expected behavior

No response

👣 Steps to Reproduce



    private final State<Pagination> paginationState = lazyPaginationState(
            (context) -> rewardList(),
            (context, item, index, reward) -> {
                final UserCache uCache = userCacheState.get(context);
                final User user = uCache.getByUser(context.getPlayer().getName());

                item.onRender(rewardItem -> rewardItem.setItem(new ItemBuilder(Material.SKULL_ITEM)
                        .build())
                ).onClick(click -> {
                    final Player player = context.getPlayer();

        
                    Bukkit.dispatchCommand(
                            Bukkit.getConsoleSender(),
                            "give " + player.getName() + " minecraft:stone"
                    );
                });
            }
    );
 
    @Override
    public void onInit(@NotNull ViewConfigBuilder config) {
        config.title("Time Online")
                .size(5)
                .scheduleUpdate(20L)
                .layout(
                        "         ",
                        "         ",
                        " OOOOOOO ",
                        " OOOOOOO ",
                        "         "
                )
                .cancelOnPickup()
                .cancelOnDrag()
                .cancelOnClick()
                .cancelOnDrop()
                .build();
    }
 
    public List<Reward> rewardList() {
        final RewardsCache rCache = plugin.getRewardsCache();

        return rCache.getCachedElements();
    } 

💻 Platform

  • [X] Bukkit
  • [ ] Sponge
  • [ ] Other

⭐ Server Version

1.8

📚 Library Version

v3.0.8

✍️ Additional context

No response

kaiquyricardo avatar May 04 '24 12:05 kaiquyricardo

The error was tested in my code and it didn't work. Are you sure you are registering the View correctly? image image

(tested using other types of state as well)

luapascoal avatar May 05 '24 07:05 luapascoal

O erro foi testado no meu código e não funcionou. Tem certeza de que está registrando o View corretamente? imagem imagem

(testado usando outros tipos de estado também)

do it to give an item directly from the console

kaiquyricardo avatar May 05 '24 07:05 kaiquyricardo

O erro foi testado no meu código e não funcionou. Tem certeza de que está registrando o View corretamente? imagem imagem (testado usando outros tipos de estado também)

do it to give an item directly from the console

image Same.

If you need help, message me on discord: luapascoal.

luapascoal avatar May 05 '24 07:05 luapascoal