FloatingTexts/src/Ad5001/FloatingTexts/SetNameTagVisibleTask.php

32 lines
852 B
PHP
Raw Normal View History

2017-04-05 08:17:52 +00:00
<?php
# FloatingTexts
# A new production from Ad5001 generated using ImagicalPlugCreator by Ad5001 (C) 2017
namespace Ad5001\FloatingTexts;
use pocketmine\Server;
use pocketmine\Player;
use pocketmine\plugin\PluginBase;
use pocketmine\entity\Entity;
2018-06-10 08:42:31 +00:00
class SetNameTagVisibleTask extends \pocketmine\scheduler\Task {
2018-06-10 08:42:06 +00:00
public $owner;
public function __construct($owner){$this->owner = $owner;}
2017-04-05 08:17:52 +00:00
/*
RUns when the task runs
@param $tick int
@return void
*/
public function onRun($tick) {
2018-06-10 08:43:09 +00:00
foreach($this->owner->getServer()->getLevels() as $level) {
2017-04-05 08:17:52 +00:00
foreach ($level->getEntities() as $et) {
if(isset($et->namedtag->isUsedToFloat)) {
$et->setNameTagAlwaysVisible(true);
$et->setNameTagVisible(true);
$et->setImmobile(true);
}
}
}
}
2018-06-10 08:42:06 +00:00
}