InventoryClickEvent in Creative mode

Discussion in 'Plugin Development' started by knokko, Jan 17, 2019.

Thread Status:
Not open for further replies.
  1. First of all, I hope I am posting this in the right section. If not, please tell me what the right place is.

    I think I found a bug:
    One of my plug-ins relies on information that is contained in every InventoryClickEvent. However, the information given in the event is quite poor in creative mode. In creative mode:
    -The method getAction() always returns InventoryAction.PLACE_ALL
    -The method isLeftClick() always returns true
    -The method isRightClick() always returns false
    -The method isShiftClick() always returns false

    I tested this with the following plug-in code where that plug-in is the only plug-in on my local server:
    Code:
    import org.bukkit.Bukkit;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.inventory.InventoryClickEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class TestPlugin extends JavaPlugin implements Listener {
       
        @Override
        public void onEnable() {
            Bukkit.getPluginManager().registerEvents(this, this);
        }
       
        @EventHandler
        public void onInvClick(InventoryClickEvent event) {
            System.out.println("action is " + event.getAction());
            System.out.println("leftClick is " + event.isLeftClick() + " and rightClick is " + event.isRightClick()
            + " and shiftClick is " + event.isShiftClick());
        }
    }
    The information sent to the console should show that the problem probably lies in Bukkit. I have tested it on the latest craftbukkit for the minecraft versions 1.12 and 1.10. The problem occurred on both versions.

    You should be able to reproduce the bug by exporting a plug-in with the code above, starting your minecraft client, click around in your inventory and watch the console.

    Even though everything works fine in Survival mode, this is still very annoying for testing plug-ins and it could even cause problems for plug-ins that rely on this information in creative mode.
     
Thread Status:
Not open for further replies.

Share This Page