FIXING BUGS...

This commit is contained in:
Adsooi 2017-04-05 10:17:52 +02:00
parent dee0e518a8
commit ffe5ff3acb
2 changed files with 31 additions and 9 deletions

View file

@ -19,14 +19,7 @@ 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) { $this->getServer()->getScheduler()->scheduleRepeatingTask(new SetNameTagVisibleTask($this),10);
if(isset($et->namedtag->isUsedToFloat)) {
$et->addEffect(\pocketmine\entity\Effect::getEffectByName("invisibility")->setDuration(99999)->setVisible(false));
$et->setNameTagAlwaysVisible(true);
$et->setNameTagVisible(true);
$et->setImmobile(true);
}
}
} }
/* /*
@ -61,7 +54,7 @@ class Main extends PluginBase implements \pocketmine\event\Listener {
if($event instanceof \pocketmine\event\entity\EntityDamageByEntityEvent) { if($event instanceof \pocketmine\event\entity\EntityDamageByEntityEvent) {
if($event->getDamager() instanceof Player && if($event->getDamager() instanceof Player &&
isset($this->sessions[$event->getDamager()->getName()])) { isset($this->sessions[$event->getDamager()->getName()])) {
$event->getEntity()->addEffect(\pocketmine\entity\Effect::getEffectByName("invisibility")->setDuration(99999)->setVisible(false)); $event->getEntity()->addEffect(\pocketmine\entity\Effect::getEffectByName("invisibility")->setAmbiant(true)->setVisible(false));
$event->getEntity()->setNameTag($this->sessions[$event->getDamager()->getName()]); $event->getEntity()->setNameTag($this->sessions[$event->getDamager()->getName()]);
$event->getEntity()->setNameTagAlwaysVisible(true); $event->getEntity()->setNameTagAlwaysVisible(true);
$event->getEntity()->setNameTagVisible(true); $event->getEntity()->setNameTagVisible(true);

View file

@ -0,0 +1,29 @@
<?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;
class SetNameTagVisibleTask extends \pocketmine\scheduler\PluginTask {
/*
RUns when the task runs
@param $tick int
@return void
*/
public function onRun($tick) {
foreach($this->getOwner()->getServer()->getLevels() as $level) {
foreach ($level->getEntities() as $et) {
if(isset($et->namedtag->isUsedToFloat)) {
$et->setNameTagAlwaysVisible(true);
$et->setNameTagVisible(true);
$et->setImmobile(true);
}
}
}
}
}