For older PocketMine versions I used this code for changing the player sizes: PHP: $player->setDataProperty(Entity::DATA_SCALE, Entity::DATA_TYPE_FLOAT, 1.5); this code for adding effects: PHP: $effect = Effect::getEffect(13);$effect->setDuration(999);$effect->setAmplifier(1);$effect->setVisible(false);$player->addEffect($effect); and this code for setting boots: PHP: $player->getInventory()->setBoots(Item::get(313, 0, 1));
1. Use Entity:: getDataPropertyManager(). 2. Living::addEffect() require EffectInstance to be passed as the first parameter. Enclose your Effect into an EffectInstance class. PHP: $effect = Effect::getEffect(13);$player->addEffect(new EffectInstance($effect, 999, 1)); 3. https://forums.pmmp.io/threads/undefined-method-but-i-was-using-it-before.5461/
Since you're setting the scale, why not use Entity::setScale(1.5) instead of setting it's data property. Entity::setScale() method will also change the bounding box of the Entity which is a plus.
I get this error now: Code: 24.03 05:19:27 [Server] Server thread/CRITICAL Could not execute task MalakasPlayzMC\rainbowArmor: Return value of pocketmine\entity\Living::getArmorInventory() must be an instance of pocketmine\inventory\ArmorInventory, null returned 24.03 05:19:27 [Server] Server thread/CRITICAL TypeError: "Return value of pocketmine\entity\Living::getArmorInventory() must be an instance of pocketmine\inventory\ArmorInventory, null returned" (EXCEPTION) in "src/pocketmine/entity/Living" at line 427 24.03 05:19:27 [Server] Server thread/DEBUG #0 Plugin.phar/src/MalakasPlayzMC/Plugin(2503): pocketmine\entity\Living->getArmorInventory() 24.03 05:19:27 [Server] Server thread/DEBUG #1 src/pocketmine/scheduler/TaskHandler(160): MalakasPlayzMC\rainbowArmor->onRun(integer 15541) 24.03 05:19:27 [Server] Server thread/DEBUG #2 src/pocketmine/scheduler/ServerScheduler(327): pocketmine\scheduler\TaskHandler->run(integer 15541) 24.03 05:19:27 [Server] Server thread/DEBUG #3 src/pocketmine/Server(2499): pocketmine\scheduler\ServerScheduler->mainThreadHeartbeat(integer 15541) 24.03 05:19:27 [Server] Server thread/DEBUG #4 src/pocketmine/Server(2239): pocketmine\Server->tick() 24.03 05:19:27 [Server] Server thread/DEBUG #5 src/pocketmine/Server(2115): pocketmine\Server->tickProcessor() 24.03 05:19:27 [Server] Server thread/DEBUG #6 src/pocketmine/Server(1701): pocketmine\Server->start() 24.03 05:19:27 [Server] Server thread/DEBUG #7 src/pocketmine/PocketMine(305): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string /, string /plugins/) 24.03 05:19:27 [Server] Server thread/DEBUG #8 /custom.phar(1): require(string phar:///custom.phar/src/pocketmine/PocketMine.php) Here is my code: PHP: class rainbowArmor extends PluginTask{ public function __construct(LobbyCore $plugin) { parent::__construct($plugin); $this->plugin = $plugin; } public function onRun($tick) { foreach($this->plugin->rarmor as $p){ $helmeta = array(298, 302, 306, 310, 314); $chestplatea = array(299, 303, 307, 311, 315); $leggingsa = array(300, 304, 308, 312, 316); $bootsa = array(301, 305, 309, 313, 317); $helmet = Item::get($helmeta[array_rand($helmeta)]); $chestplate = Item::get($chestplatea[array_rand($chestplatea)]); $leggings = Item::get($leggingsa[array_rand($leggingsa)]); $boots = Item::get($bootsa[array_rand($bootsa)]); if(!$helmet == null || !$chestplate == null || !$leggings == null || !$boots == null){ $p->getArmorInventory()->setHelmet($helmet); $p->getArmorInventory()->setChestplate($chestplate); $p->getArmorInventory()->setLeggings($leggings); $p->getArmorInventory()->setBoots($boots); } } }}
PHP: $in = $event->getPlayer()->getInventory()->getItemInHand()->getCustomName(); if($in == TextFormat::RESET . TextFormat::GOLD . "Colorful" . TextFormat::RESET . TextFormat::GOLD . " Armor"); { if(in_array($player, $this->rarmor)){ unset($this->rarmor[array_search($player, $this->rarmor)]); $player->getArmorInventory()->setHelmet(Item::get(0)); $player->getArmorInventory()->setChestplate(Item::get(0)); $player->getArmorInventory()->setLeggings(Item::get(0)); $player->getArmorInventory()->setBoots(Item::get(0)); $player->sendMessage($prefix . TextFormat::RESET . TextFormat::RED . "You have disabled your " . TextFormat::GOLD . "Colorful Armor"); }else{ array_push($this->rarmor, $player); $player->sendMessage($prefix . TextFormat::RESET . TextFormat::GREEN . "You have enabled your " . TextFormat::GOLD . "Colorful Armor"); } }
Well, fixed that issue. I have an issue with the interact event. When the player taps somewhere (even without the item with the name I have set), this is getting enabled and disabled. Is this a pocketmine bug?