Solved I have no idea how I'm causing this StackOverflow Error

Discussion in 'Spigot Plugin Development' started by HoiTemmieColeg, Feb 28, 2020.

  1. I'm not sure what I'm doing, but I have this code for if someone presses escape on a menu they aren't supposed to press escape on.

    Code (Java):
    public void onHubInventoryClose(InventoryCloseEvent closeEvent) {
        if ( (closeEvent.getInventory().equals(hubMenu)) && ((closeEvent.getPlayer().getLocation().getWorld().equals(Bukkit.getWorld("hub")))) ) {
    When I press escape, the menu comes back, and then a very long stack trace prints which basically says StackOverflowError and says that the error is on the line closeEvent.getPlayer().openInventory(hubMenu); and afterwards if I press escape, the menu doesn't come back.

    Any ideas as to why this could be happening?
  2. what happens if you delay that call to the next tick? might be a bug within minecraft or just a design choice that you have to work around
  3. Delaying it by 1 tick seems to have fixed the issue. Thank you so much!

    Marked as SOLVED