DevNatan / inventory-framework

Minecraft Inventory API framework
MIT License
127 stars 22 forks source link

Doubt #666

Closed kaiquyricardo closed 3 weeks ago

kaiquyricardo commented 7 months ago

I'm unsure about opening the menu because it's not opening

` private final ViewFrame viewFrame = ViewFrame.create(this);

public void registerViews(View... views) {
    viewFrame.register(views);
}

` public class RewardsView extends View {

private final OnlineTimePlugin plugin;
private final State<UserCache> userCacheState = initialState("userCache");

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)
                    .texture(!user.canCollect(reward) || user.getRewards().contains(reward.getId()) ? "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvM2VkMWFiYTczZjYzOWY0YmM0MmJkNDgxOTZjNzE1MTk3YmUyNzEyYzNiOTYyYzk3ZWJmOWU5ZWQ4ZWZhMDI1In19fQ==" : reward.getTexture())
                    .name(reward.getName())
                    .lore(reward.getLore())
                    .build())
            ).onClick(click -> {

            });
        }
);

@Override
public void onInit(@NotNull ViewConfigBuilder config) {
    config.title("Tempo 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();
}

`

`

luapascoal commented 7 months ago

Are you using the correct version?

ViewFrame creation:

final ViewFrame viewFrame = ViewFrame.create(this)
            .with(/*new ExampleView()*/)
            .register()

https://github.com/DevNatan/inventory-framework/wiki/Basic-Usage#registering-our-views

ch4ika commented 7 months ago

Nah the latest version is still very unstable and has a lot of errors. Stable one was 3.0.8.

luapascoal commented 7 months ago

Nah the latest version is still very unstable and has a lot of errors. Stable one was 3.0.8.

Yeah, I know.

kaiquyricardo commented 6 months ago

Nah the latest version is still very unstable and has a lot of errors. Stable one was 3.0.8.

I was using 3.0.8, but when using something to execute on the console, such as gaining just one block of stone, the player ends up receiving 2

luapascoal commented 6 months ago

Nah the latest version is still very unstable and has a lot of errors. Stable one was 3.0.8.

I was using 3.0.8, but when using something to execute on the console, such as gaining just one block of stone, the player ends up receiving 2

It's not an IF problem.