Ok, this probably sounds dumb to some people, but how do you make a command run when you attempt to mine with the item in your hand? I know a few servers that have this feature. (Ex. LifeBoat)
You can create a new Listener, and add a handler for BlockBreakEvent. You then check if the ID and meta of the held item are the desired ones, using Player->getInventory()->getItemInHand(), and execute the code/command you want to, if the event meets those requirements.
Hmm, but is there a way I can add multiple items to the hotbar & have the item be removed from their inventory completely after excuting the command?
Code: public function whenMine(WhenPlayerStartToMineABlockEvent $event){ $player = $event->getPlayer(); } // Enjoy?? Spoiler: Anyhow, here Anyhow, use PlayerInteractEvent, or BlockBreakEvent. Just like @SOFe said.
i already know this. I only reopened this to figure out how to give the player the item (appear in there hotbar) and then removing the item from there invetory entirely after they use the action. (Also, maybe submenus with item start to mine event)
I know that. I just want to know why you would want that to happen. Do you want to make the item show as something like a "status" icon when he is mining, and disappear when the finger leaves the screen? Or do you just want it because the command you run requires the player to have that item in the hotbar, etc.?
I want to give them items, I like the way the hotbar works. Also I am intrested in having multiple items appear in there hotbar & have submenus with more items in there hotbars (kits)
UPDATE: I am trying achive a hotbar menu, as seen on LifeBoat BedWars shop, you press a item (such as a snowball) and it brings you to a new menu with more items (options) to choose from to execute a command. I am attempting to use this same method to create a plugin for kits. When you do /kit this sub menu will appear. I have been working recently on trying to make this function but I can't get it to function properly.