Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.4 kB
1
Indexable
Never
<?php

namespace MyPlugin;

use pocketmine\{Player, Server};
use pocketmine\command\{Command, CommandSender};
use pocketmine\entity\Entity;
use pocketmine\plugin\PluginBase;

class MyPlugin extends PluginBase {

    public function onEnable(){
        $this->getLogger()->info("Plugin enabled!");
    }

    public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args): bool {
        if(strtolower($cmd->getName()) === "lole") {
            $testol = new TestolEntity($sender->getPosition());
            $testol->spawnToAll();
            $testol->setNameTag("привет");
            $sender->sendMessage("Testol spawned with nametag 'привет'");
            return true;
        }
        return false;
    }
}

class TestolEntity extends Entity {
    const NETWORK_ID = self::FALLING_BLOCK;

    public function __construct($pos) {
        parent::__construct($pos->getLevel(), Entity::createBaseNBT($pos));
    }

    public function getName(): string {
        return "Testol";
    }

    public function getNametag(): string {
        return "привет";
    }

    public function getScoreTag(): string {
        return "";
    }

    public function getFormattedName(): string {
        return $this->getNametag();
    }

    public function saveNBT(): void {
    }
}