Disable moving items using number keys

Discussion in 'Plugin Development' started by Hadenir, Aug 28, 2015.

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

    Hadenir

    Hello!
    How can I prevent players from moving items in their inventory using 1-9 keys? I tried to cancel InventoryClickEvent, but it doesn't work. :(
     
  2. Offline

    The_BloodHound

    You shouldn't be able to move items with the 1-9 keys. Unfortunately, I was looking through the Referenced Library and testing different things but was unsuccessful in finding a solution. Maybe someone else better can find a solution.
     
    Last edited: Aug 28, 2015
  3. Offline

    567legodude

    @Hadenir The only thing I can think of is PlayerItemHeldEvent, which is called "when a player changes their currently held item"
     
  4. Offline

    Hadenir

    @567legodude I think it won't help. I don't want to listen for change item in player's hand but for change items in whole inventory
     
  5. Offline

    mine-care

    @Hadenir Wait you mean when they hold the mouse over the item and then press 1-9 and it moves in their inventory?
     
  6. Offline

    Konato_K

    @Hadenir InventoryClickEvent gets called as far as I remember, I have done this before with it.
     
  7. Offline

    Hadenir

    @mine-care No, when they open inventory with "E" and try to move items by hovering mouse at an item and clicking number key (1-9).

    @Konato_K Yes, InventoryClickEvent gets called, but canceling it COPY the item to the chosen slot :(
     
  8. Offline

    Monkey_Swag

    @Hadenir use player#updateInventory(); after canceling the event
     
  9. Offline

    Konato_K

    @Hadenir That copy is client side, updating inventory may work as said.
     
  10. Offline

    Hadenir

    I use updateInventory() and now the problem is only on creative mode.
     
Thread Status:
Not open for further replies.

Share This Page