Fixing a small bug with entity not reloading on default world.
This commit is contained in:
parent
0f60a47a05
commit
dee0e518a8
1 changed files with 13 additions and 11 deletions
|
@ -19,12 +19,14 @@ class Main extends PluginBase implements \pocketmine\event\Listener {
|
||||||
public function onEnable() {
|
public function onEnable() {
|
||||||
$this->getServer()->getPluginManager()->registerEvents($this, $this);
|
$this->getServer()->getPluginManager()->registerEvents($this, $this);
|
||||||
$this->sessions = [];
|
$this->sessions = [];
|
||||||
}
|
foreach ($this->getServer()->getDefaultLevel()->getEntities() as $et) {
|
||||||
|
if(isset($et->namedtag->isUsedToFloat)) {
|
||||||
/*
|
$et->addEffect(\pocketmine\entity\Effect::getEffectByName("invisibility")->setDuration(99999)->setVisible(false));
|
||||||
Called when the plugin disables
|
$et->setNameTagAlwaysVisible(true);
|
||||||
*/
|
$et->setNameTagVisible(true);
|
||||||
public function onDisable() {
|
$et->setImmobile(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -83,11 +85,11 @@ class Main extends PluginBase implements \pocketmine\event\Listener {
|
||||||
*/
|
*/
|
||||||
public function onLevelLoad(\pocketmine\event\level\LevelLoadEvent $event) {
|
public function onLevelLoad(\pocketmine\event\level\LevelLoadEvent $event) {
|
||||||
foreach ($event->getLevel()->getEntities() as $et) {
|
foreach ($event->getLevel()->getEntities() as $et) {
|
||||||
if(isset($event->getEntity()->namedtag->isUsedToFloat)) {
|
if(isset($et->namedtag->isUsedToFloat)) {
|
||||||
$event->getEntity()->addEffect(\pocketmine\entity\Effect::getEffectByName("invisibility")->setDuration(99999)->setVisible(false));
|
$et->addEffect(\pocketmine\entity\Effect::getEffectByName("invisibility")->setDuration(99999)->setVisible(false));
|
||||||
$event->getEntity()->setNameTagAlwaysVisible(true);
|
$et->setNameTagAlwaysVisible(true);
|
||||||
$event->getEntity()->setNameTagVisible(true);
|
$et->setNameTagVisible(true);
|
||||||
$event->getEntity()->setImmobile(true);
|
$et->setImmobile(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue