I have a plugin that i am working on which involves menus and hotbar items and I have a menu for cosmetics and i want it to give that player an effect, like when you tap down on the book it enables speed and when you click it again it disables it. How would I do that?
Use PlayerInteractEvent, get the item player interacts with, if the id is what you want give player effect. If player already has effect, remove the effect. See these; For effects: https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/Effect.php#L36 For adding effects: https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/entity/Living.php#L237 For PlayerInteractEvent and getting the item: https://github.com/pmmp/PocketMine-...mine/event/player/PlayerInteractEvent.php#L89 TIP: Always try checking the source code to find out how you can do stuff. (or use an IDE)
Am I missing something? }elseif($item->getId() === Item::BOOK and stripos($item->getName(), "speed") !== false) { $event->getPlayer()->addEffect(Effect $effect){