What's the correct way to stuck an ItemStack inside a player's Inventory?

Discussion in 'Spigot Plugin Development' started by HorrendousEntity, Jun 23, 2018.

Thread Status:
Not open for further replies.
  1. I've been attempting to deal with this issue for a long time;
    Example: Imagine you had been developing your Hub Server, and in order to move across the Minigames -
    You started making a special navigator plugin(Right click it to open a Teleporter GUI).

    Now the mission is really simple: Prevent any possible ways that the compass can be moved from its slot!
    A few examples: Clicking it, Shift-Clicking it, Dragging it, Externally Dropping it, Internally Dropping it...
    I can think about many ways(Some of them Idk how to handle!) of cracking the system.

    I'm posting this because I feel there's a secret little piece of code/idea which can kill those tons of events handling - and everybody knows it except me.
    Please help.
     
  2. I think cancelling InventoryInteractEvent or whatever it's called prevents all of that
     
  3. InvenotryInteractEvent is indeed the abstract class of Inventory triggers events, But what about PlayerDropEvent as I mentioned?
    There are so many possibilities which I can think of....
     
  4. Use InventoryInteractEvent and just cancel it as you normally would. It will work.
     
  5. Here's the exact heirarchy for the example I gave: PlayerDropItemEvent extends PlayerEvent extends Event
    I might be blind, but according to your suggestion - do you see InventoryInteractEvent there?
     
  6. DavidDevelops

    Supporter

    No hes right... Before a item is dropped from a inventory im pretty sure that event is fired, Thats how i cancelled it iin my GUIs...
     
  7. InventoryClickEvent gets triggered when something happens inside the Inventory, read my whole post and encounter how many possibilites outside the Inventory can a player perform.
     
  8. And that's why you should use InteractEvent, not ClickEvent.
     
  9. It seems you're not much familiar with the API.
    Read one comment above, what I replied to the guy who offered the exact same event handling.
     
  10. What does "Externally dropping it" mean?
     
  11. DavidDevelops

    Supporter

    He is not familiar? Uh, He is the one with a GUI plugin that (as far as I know) works perfectly fine... Can you at least TRY using the event before saying we're wrong? Don't ask for help you won't even take... smh
     
  12. Externally Drop - You hold your item(When your inventory is not opened and you can move) - Then you press Q to drop the ItemExternally Internal Drop - You put your cursor on the desired item and simply press Q
     
  13. Within a second I proved that your help doesn't help me, I asked for valid type of help and if you can't understand it....
    In my native language we say: "Be Healty.".
     
  14. Oh. For the external dropping part PlayerDropItemEvent should do fine, for the internal part, still, InventoryInteractEvent (PlayerDropItemEvent maybe covers that too)

    (if you just instantly deny this without testing I won't bother anymore. Stop doing that.)
     
  15. Use InventoryClickEvent, check if the inventory is the player's inventory, if so, check if the slot is the slot containing the compass and then cancel the event.

    As for dropping, use the PlayerDropEvent and check if the players active slot is the same slot as the compass, if so, cancel the event.
     
    • Friendly Friendly x 1
  16. You're right, but he will tell you you're wrong for some reason.
     
  17. Brilliant idea for handling the inside-inventory events.
    what about the outside? I don't know how many possibilites actually can happen
     
Thread Status:
Not open for further replies.