DevNatan / inventory-framework

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

Scheduler is still running and breaks after resume. #609

Closed ch4ika closed 11 months ago

ch4ika commented 11 months ago

Is there an existing issue for this?

🐛 Describe the bug

I noticed that if you use config.scheduleUpdate and then go to the next view, the scheduler is still running and then as soon as you use context.back it stops running at all.

It should stop running when you change a view and continue running after you return.

✔️ Expected behavior

No response

👣 Steps to Reproduce

    @Override
    public void onInit(@NotNull ViewConfigBuilder config) {
        config.title("Inventory");
        config.layout("XXXXXXXXX", "XXXOOOOOX", "XXXXXXXXX");
        config.scheduleUpdate(20L);
        config.transitiveInitialData(true);
    }
  1. Create a Component and go to the next view. (Scheduler will still run)
    private void onSelect(SlotClickContext context) {
            context.openForPlayer(BoosterBuyView.class);
    }
  2. Then use context.back in the view. (Scheduler will stop, but should started again)
    private void onBack(SlotClickContext context) {
       context.back();
    }

💻 Platform

⭐ Server Version

1.20.2 paper

📚 Library Version

3.1.0

✍️ Additional context

No response