Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Error on gui close #63

Open
4 tasks done
gkhaavik opened this issue Jun 28, 2024 · 5 comments
Open
4 tasks done

[BUG] Error on gui close #63

gkhaavik opened this issue Jun 28, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@gkhaavik
Copy link

gkhaavik commented Jun 28, 2024

I just expect the inventory to close, without returning an error. Whenever I close a custom gui, I get the following error: https://pastebin.com/cyLdfn5d. I using version 4.3.0 of obliviate-invs:core with maven and 4.3.0 using the pagination api. And my minecraft server is running paper 1.21 dev builds.

Checklist

Ensure you've done everything in this list before submitting the issue. (Just put the 'X' char between brackets.)

  • I explained the expected behavior.
  • I explained current behavior.
  • I shared console outputs or I said there is no output.
  • I did not assume that people already knew what I was doing.
@gkhaavik gkhaavik added the bug Something isn't working label Jun 28, 2024
@hamza-cskn
Copy link
Owner

We haven't officially added support for Obliviate-invs in 1.21. Of course, you can use it but I have doubts. Can you provide the GUI code?

@gkhaavik
Copy link
Author

public class MainMenuGui extends Gui {
    private final MarketManager market;

    public MainMenuGui(@Nonnull Player player, MarketManager market) {
        super(player, "main-menu", "Marketplace", 6);
        this.market = market;

        this.pagination.registerPageSlots(2, 3, 4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 16, 17, 20, 21, 22, 23, 24, 25, 26, 29, 30, 31, 32, 33, 34, 35);
    }


    private final PaginationManager pagination = new PaginationManager(this);

    private Filter selectedFilter = Filter.PRICE_LOW_TO_HIGH;
    private Category selectedCategory = Category.ALL;

    @Override
    public void onOpen(InventoryOpenEvent event) {
//        Add border
        for (int i = 1; i <= 53; i++) {
            if (i % 9 == 1 || (i >= 38 && i <= 45)) {
                addItem(i, new Icon(Material.BLACK_STAINED_GLASS_PANE).setName(" "));
            }
        }

        //        Add categories to the side
        rebuildCategoryIcons();

        addItem(47, new Icon(Material.EMERALD_BLOCK).setName("§aCreate Listing").onClick(e -> {

        }));

        addItem(48, new Icon(Material.CHEST).setName("§aMy Listings").onClick(e -> {

        }));

        addItem(49, new Icon(Material.EMERALD).setName("§aBought Items").onClick(e -> {

        }));

        addItem(50, rebuildFilterIcon().onClick(e -> {
            switch (selectedFilter) {
                case PRICE_LOW_TO_HIGH:
                    selectedFilter = Filter.PRICE_HIGH_TO_LOW;
                    break;
                case PRICE_HIGH_TO_LOW:
                    selectedFilter = Filter.ALPHABETICAL;
                    break;
                case ALPHABETICAL:
                    selectedFilter = Filter.RARITY;
                    break;
                case RARITY:
                    selectedFilter = Filter.PRICE_LOW_TO_HIGH;
                    break;
            }

            addItem(50, rebuildFilterIcon());
            calculateAndUpdatePagination();
        }));

        addItem(51, new Icon(Material.COMPASS).setName("§aSearch").onClick(e -> {

        }));

        calculateAndUpdatePagination();

        addItem(52, new Icon(Material.ARROW).setName("§aPrevious").onClick(e -> {
            if (pagination.getCurrentPage() != 0) {
                pagination.goPreviousPage();
                calculateAndUpdatePagination();
            }
        }));

        addItem(53, new Icon(Material.ARROW).setName("§aNext").onClick(e -> {
            if (!pagination.isLastPage()) {
                pagination.goNextPage();
                calculateAndUpdatePagination();
            }
        }));
    }
}
    ```

@gkhaavik
Copy link
Author

After closing the gui, the player inventory acts as the gui, meaning players cant interact with their inventory

@gkhaavik
Copy link
Author

an easy fix, is to just overwrite the onClose method on the gui

@hamza-cskn
Copy link
Owner

Thank you for the observations. I'll be interested as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants