Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace EntityText;
- use pocketmine\Server;
- use pocketmine\Player;
- use pocketmine\math\Vector3;
- use pocketmine\utils\Config;
- use pocketmine\event\Listener;
- use pocketmine\plugin\PluginBase;
- use pocketmine\event\player\PlayerJoinEvent;
- use pocketmine\network\protocol\AddEntityPacket;
- use pocketmine\level\particle\FloatingTextParticle;
- class Main extends PluginBase implements Listener
- {
- public function onEnable()
- {
- $this->getServer()->getPluginManager()->registerEvents($this, $this);
- @mkdir($this->getDataFolder());
- $this->config = new Config($this->getDataFolder() . "config.yml", Config::YAML, array(
- 'Типы сущностей' => array(
- '0' => 'Без сущности',
- '1' => 'Пузырёк опыта',
- '2' => 'Око края',
- '3' => 'Снаряд шалкера',
- '4' => 'Яйцо',
- '5' => 'Пузырек с водой'
- ),
- 'Texts' => array(
- array(
- 'Coordinates' => '0 0 0',
- 'Text' => 'Example',
- 'Type' => 1
- ),
- array(
- 'Coordinates' => '1 1 1',
- 'Text' => 'Example #2',
- 'Type' => 2
- )
- )
- ));
- $this->getLogger()->info('Плагин включен');
- }
- public function onPJE(PlayerJoinEvent $event)
- {
- $player = $event->getPlayer();
- foreach($this->config->get('Texts') as $item){
- $coordinates = explode(' ', $item['Coordinates']);
- $coordinates[1] += 1.25;
- foreach(array_reverse(explode('\n', $item['Text']), true) as $index => $text) {
- $text = str_replace('{player}', $player->getName(), $text);
- $player->getLevel()->addParticle(new FloatingTextParticle(new Vector3($coordinates[0], $coordinates[1] + ((count(explode('\n', $item['Text'])) - $index) / 4.175 - 0.8), $coordinates[2]), null, $text), array($player));
- }
- switch($item['Type']) {
- case '0':
- $type = 0;
- break;
- case '1':
- $type = 68;
- break;
- case '2':
- $type = 70;
- break;
- case '3':
- $type = 76;
- break;
- case '4':
- $type = 82;
- break;
- case '5':
- $type = 86;
- break;
- default:
- $type = 70;
- break;
- }
- if($type != 0) {
- $pk = new AddEntityPacket();
- $pk->eid = mt_rand(1111, 9999);
- $pk->type = $type;
- $pk->x = $coordinates[0];
- $pk->y = $coordinates[1] - 1.25;
- $pk->z = $coordinates[2];
- $pk->yaw = 0;
- $pk->pitch = 0;
- $pk->metadata = [];
- $player->dataPacket($pk);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement