foreach ($this->getServer()->getLevels() as $level) { foreach ($level->getEntities() as $entity) { if ($entity instanceof TradeNPC) { file_put_contents($this->getDataFolder() . $entity->getNameTag() . ".dat", $entity->getSaveNBT());
PHP: foreach ($this->getServer()->->getWorldManager()->getWorlds() as $world) {foreach ($world->getEntities() as $entity) {if ($entity instanceof TradeNPC) {file_put_contents($this->getDataFolder() . $entity->getNameTag() . ".dat", $entity->getSaveNBT()); } }}