In game when i tap ground with item no errors happen in console and nothing happens in game trying to make it give effects when tapping Code : public function onTap(PlayerInteractEvent $event){ $player = $event->getPlayer(); if($event->getBlock()->getId() == 296){ $player = $event->getPlayer(); $effects = Effect::getEffect(Effect::BLINDNESS)->setDuration(5*20)->setAmplifier(1); $effects = Effect::getEffect(Effect::STRENGTH)->setDuration(30*20)->setAmplifier(2); $effects = Effect::getEffect(Effect::SLOWNESS)->setDuration(15*20)->setAmplifier(1); $player-addEffect($effects); $player->getInventory()->setItemInHand(Item::get(0)); } } }
1. Use the code insert button (Tap/Click the plus sign) 2. You defined $player twice. 3. Wheat isn't a block. Here's my edit of it: PHP: public function handleInteract(PlayerInteractEvent $event){ $player = $event->getPlayer(); if($event->getItem()->getId() === 296){ $effect1 = Effect::getEffect(Effect::BLINDNESS)->setDuration(5*20)->setAmplifier(1); $effect2 = Effect::getEffect(Effect::STRENGTH)->setDuration(30*20)->setAmplifier(2); $effect3 = Effect::getEffect(Effect::SLOWNESS)->setDuration(15*20)->setAmplifier(1); foreach([$effect1, $effect2, $effect3] as $effect){ $player->addEffect($effect); } $player->getInventory()->setItemInHand(ItemFactory::get(Item::AIR)); } }
Error: syntax error, unexpected 'public function handleIntera' (T_STRING), expecting function (T_FUNCTION) File: /Weed/src/iCirgio/Weed/Main Line: 20 Type: notice THIS CRASH WAS CAUSED BY A PLUGIN Code: [11] use pocketmine\entity\Effect; [12] [13] class Main extends PluginBase implements Listener { [14] [15] [16] public function onEnable(){ [17] $this->getServer()->getPluginManager()->registerEvents($this, $this); [18] [19] } [20] public function handleInteract(PlayerInteractEvent $event){ [21] [22] $player = $event->getPlayer(); [23] if($event->getItem()->getId() === 296){ [24] [25] $effect1 = Effect::getEffect(Effect::BLINDNESS)->setDuration(5*20)->setAmplifier(1); [26] $effect2 = Effect::getEffect(Effect::STRENGTH)->setDuration(30*20)->setAmplifier(2); [27] $effect3 = Effect::getEffect(Effect::SLOWNESS)->setDuration(15*20)->setAmplifier(1); [28] [29] foreach([$effect1, $effect2, $effect3] as $effect){ [30] $player->addEffect($effect); Backtrace: #0 (): spl_autoload_call(string iCirgio\Weed\Main) #1 /src/pocketmine/plugin/FolderPluginLoader(76): class_exists(string iCirgio\Weed\Main, boolean 1) #2 /src/pocketmine/plugin/PluginManager(159): pocketmine\plugin\FolderPluginLoader->loadPlugin(string /home/multicraft/servers/server6498/plugins/Weed) #3 /src/pocketmine/plugin/PluginManager(346): pocketmine\plugin\PluginManager->loadPlugin(string /home/multicraft/servers/server6498/plugins/Weed, array Array()) #4 /src/pocketmine/Server(1898): pocketmine\plugin\PluginManager->loadPlugins(string /home/multicraft/servers/server6498/plugins/) #5 /src/pocketmine/PocketMine(492): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string phar:///home/multicraft/jar/pocketmine/genisys/1.1.0/GenisysPro.phar/, string /home/multicraft/servers/server6498/, string /home/multicraft/servers/server6498/plugins/) #6 (9): include(string phar:///home/multicraft/jar/pocketmine/genisys/1.1.0/GenisysPro.phar/src/pocketmine/PocketMine.php) GenisysPro version: 25992fe8b5b7c55702d800ed237f98057259c505 [Protocol 113; API 3.0.1] uname -a: Linux mc30.vgmc.us 2.6.32-696.3.2.el6.x86_64 #1 SMP Tue Jun 20 01:26:55 UTC 2017 x86_64 PHP version: 7.0.19 Zend version: 3.0.0 OS : Linux, linux Server uptime: 0 seconds Number of loaded worlds: 0 Players online: 0/2 Loaded plugins:
Maybe try this? PHP: public function nOhELPfoRsPOoNs(UserGetHelpFromUsEvent $ev){ $user = $ev->getPlayer(); if($user instanceof SpoonUser){ $ev->setCancelled(); $user->sendMessage("Nope. Not happening."); } elseif($user instanceof PeopleWhoWantToGetTheRealPocketMine){ $user->sendMessage("poggit.pmmp.io"); }}