Solved Infinite loop?

Discussion in 'Plugin Development' started by Orange Tabby, Jan 2, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    Orange Tabby

    Solved: I am an idiot, that should be ".runTaskLater" not ".runTaskTimer" sorry about that. lol

    Hi, I am trying to make a kit plugin, and I want the player to be forced to select a kit. But as I was making the inventory reopen after they close it, I ran into an infinite loop problem. When I run the code below I get spammed with "Closed". Why is the InventoryCloseEvent repeating?

        public void onPlayerCloseInventory(final InventoryCloseEvent e) {
            if (e.getInventory().getName().equals("Custom Menu")) {
                final Player p = (Player) e.getPlayer();
                new BukkitRunnable() {
                    public void run() {
                }.runTaskTimer(kitPvp, 0, 20);
    Last edited: Jan 2, 2017
  2. Offline


    you might be better off making one global loop that iterates through online players and checks if they have selected a kit. You could keep a boolean Hashmap to save if they have selected a kit or not.
Thread Status:
Not open for further replies.

Share This Page