Git Product home page Git Product logo

Comments (5)

iKstruuh avatar iKstruuh commented on August 14, 2024

Is the project abandoned? (This is my other account)

from spigui.

SamJakob avatar SamJakob commented on August 14, 2024

No, it's not I just missed this issue somehow...


Ah I see - so the simplest solution in other words would just be a matter of also checking if we've switched between having or not having pagination?

from spigui.

iKstruuh avatar iKstruuh commented on August 14, 2024

No, it's not I just missed this issue somehow...

Ah I see - so the simplest solution in other words would just be a matter of also checking if we've switched between having or not having pagination?

I guess... As I said, when we use menu.setAutomaticPaginationEnabled(false); before opening the inventory, the scheduler is cancelled because the API thinks that a new inventory is opening.

from spigui.

PrayRNGesus avatar PrayRNGesus commented on August 14, 2024

Hi, to summarize I found a bug on an if statement in the refreshInventory() method.

// If the new size is different, we'll need to open a new inventory.
if (viewer.getOpenInventory().getTopInventory().getSize() != getPageSize() + (getMaxPage() > 0 ? 9 : 0)) {
    viewer.openInventory(getInventory());
    return;
}

My code:

SGMenu menu = Main.spiGUI.create("&eInventory", 2);
menu.setAutomaticPaginationEnabled(false);
//Buttons stuff
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
BukkitTask task = scheduler.runTaskTimer(plugin, new Runnable() {
    @Override
    public void run() {
        menu.clearAllButStickiedSlots();
        //Set buttons stuff again
        menu.refreshInventory(p);
    }
}, 0L, 20L);
menu.setOnClose(inventory -> {
    if (task != null) scheduler.cancelTask(task.getTaskId());
});

The problem is that when I use menu.setAutomaticPaginationEnabled(false); the previous if statement is called and the scheduler is cancelled because it opens a new inventory and that must not happen because I am not modifying the inventory size after opening the inventory.

If you just read a little into the code you will find (in the refresh method):
viewer.getOpenInventory().getTopInventory().setContents(this.getInventory().getContents());

If you just use your brain to replace the variables such as viewer, and this, (this meaning inventory) then you can easily refresh the inventory without using the method.

player.getOpenInventory().getTopInventory().setContents(menu.getInventory().getContents());

from spigui.

iKstruuh avatar iKstruuh commented on August 14, 2024

Currently am using another GUI API, so I don't need this more.

from spigui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.