Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-6552

Some inventory types reset cursor on switch

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • This server is running CraftBukkit version 3137-Spigot-66f9d3c-85b8c1f (MC: 1.17) (Implementing API version 1.17-R0.1-SNAPSHOT)
    • Yes

      When the player has a chest inventory type open and you player#openInventory another chest inventory type, it will not reset the player's cursor, however, if you use the dispenser inventory type for example it will!

       

      Works fine:

       

          @EventHandler(priority = EventPriority.LOWEST)
          public void a(BlockBreakEvent event)
          {
              final Inventory inv1 = Bukkit.createInventory(null, InventoryType.CHEST);
              inv1.addItem(new ItemStack(Material.ACACIA_BOAT));        final Inventory inv2 = Bukkit.createInventory(null, InventoryType.CHEST);
              inv2.addItem(new ItemStack(Material.ANDESITE));        event.getPlayer().openInventory(inv1);        Bukkit.getScheduler().runTaskLater(DevTest.getInstance(), () -> {            event.getPlayer().openInventory(inv2);        }, 60);
          }
      

       

      Doesn't work and resets the player's cursor.

       

          @EventHandler(priority = EventPriority.LOWEST)
          public void b(BlockPlaceEvent event)
          {
              final Inventory inv1 = Bukkit.createInventory(null, InventoryType.DISPENSER);
              inv1.addItem(new ItemStack(Material.ACACIA_BOAT));        final Inventory inv2 = Bukkit.createInventory(null, InventoryType.DISPENSER);
              inv2.addItem(new ItemStack(Material.ANDESITE));        event.getPlayer().openInventory(inv1);        Bukkit.getScheduler().runTaskLater(DevTest.getInstance(), () -> {            event.getPlayer().openInventory(inv2);        }, 60);
          }
      

       

            Unassigned Unassigned
            HexedHero HexedHero
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: