Hi, I coded a plugin, and it fails at this line of code: PHP: $player->getInventory()->addItem(new ItemBlock(Block::get($itemname), "10", $count)); Error is: 13:36:01 [CRITICAL] Could not pass event pocketmine\event\player\PlayerInteractEvent to EasyRewards v1.1.2: Class kjjnetwork\EasyRewards\ItemBlock not found on kjjnetwork\EasyRewards\Main 13:36:01 [CRITICAL] ClassNotFoundException: "Class kjjnetwork\EasyRewards\ItemBlock not found" (EXCEPTION) in "/src/spl/BaseClassLoader" at line 144 Please help
The error is not related to the part of code you wrote here. Check plugin.yml file. The error is there
It is an class error. Make sure that class name and file name is all same. This is a quote from @PEMapModder.
Yes, I can: plugin.yml: Spoiler Code: name: EasyRewards api: [1.3.1] version: 1.1.2 load: POSTWORLD main: kjjnetwork\EasyRewards\Main author: kjjnetwork website: http://www.kjjserver.com commands: permissions: Main.php: Spoiler PHP: <?phpnamespace kjjnetwork\EasyRewards;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\Server;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\event\player\PlayerInteractEvent;use pocketmine\math\Vector3;use pocketmine\tile\Sign;use pocketmine\event\block\SignChangeEvent;use pocketmine\level\Position;use pocketmine\entity\Entity;use pocketmine\event\block\BlockPlaceEvent;use pocketmine\event\block\BlockBreakEvent;use pocketmine\item\Item;use pocketmine\tile\Tile;use pocketmine\Player;use pocketmine\item/ItemBlock;use onebone\economyapi\EconomyAPI;class Main extends PluginBase implements Listener{ private $api, $server, $path; public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this, $this); } public function playerBlockTouch(PlayerInteractEvent $event){ if($event->getBlock()->getID() == 323 || $event->getBlock()->getID() == 63 || $event->getBlock()->getID() == 68){ $sign = $event->getPlayer()->getLevel()->getTile($event->getBlock()); if(!($sign instanceof Sign)){ return; } $sign = $sign->getText(); if($sign[0]=='[REWARD]'){ if(empty($sign[2]) !== true){ $itemname = $sign[1]; $count = $sign[2]; $money = $sign[3]; $player = $event->getPlayer(); $playername = $player->getName(); EconomyAPI::getInstance()->addMoney($player, $money); $player->getInventory()->addItem(new ItemBlock(Block::get($itemname), "10", $count)); $this->getServer()->broadcastMessage("[server] Player '".$playername."' just got cool rewards!"); $event->getPlayer()->sendMessage("[server] Reward given! Thanks for playing on KJJ!"); }else{ $event->getPlayer()->sendMessage("[server] Reward sign is broken! Please report to [email protected]"); } } } } } Thank you! AddMoney part is working, but not giving items.
You should just use Item::get or Item::fromString, which means you need to do use ....something...\Item
Yay! It works now! Thanks so much for all your help! I also had to add pocketmine\block\Block Now it works