I was trying to make a plugin that I use the item if the player moved but I was trying to put it so that when using the EX item: I have 32 stone blocks and I use one with 31 blocks, but this is giving an error what is happening? PHP: public function onLeapPluginInteract(PlayerInteractEvent $event) { $player = $event->getPlayer(); $config = new Config($this->getDataFolder() . "Config.yml", Config::YAML); if($event->getItem()->getID() === 401) { if(!isset($this->cd[$player->getName() $inventory->removeItem(Item::get(Item::FIREEORKS, 0, 1));
ok, so i see you are using the code i gave you before. Remove the if !isset($this->cd remove the $config use the code below to remove an 1 of the item from the players inventory $player->getInventory()->setItemInHand($item->setCount($item->getCount() - 1)); and please specify what you mean by "i use the item if the player moved" then i can help you with the moving part
well i'm making a launcher plugin for factions it is working but i wanted to put it for the items to end and for now it's getting like this, right? PHP: public function onLeapPluginInteract (PlayerInteractEvent $ event) { $ player = $ event-> getPlayer (); $ config = new Config ($ this-> getDataFolder (). "Config.yml", Config :: YAML); if ($ event-> getItem () -> getID () === 401) { $ player-> getInventory () -> setItemInHand ($ item-> setCount ($ item-> getCount () - 1)); [$ player-> getName ()])) { $ this-> cd [$ player-> getName ()] = time () + $ config-> get ("cooldown"); [/ PHP] [/ PHP] [/ PHP]
use this code to add a item to the players inventory $player->getInventory()->addItem(Item::get(351, 3, 1)); // = 1 Cocoa Bean