Beispiel #1
0
 public function getEffects()
 {
     return [[Effect::getEffect(Effect::HUNGER)->setDuration(30 * 20), 0.3]];
 }
 public function getEffects()
 {
     return [[Effect::getEffect(Effect::ABSORPTION)->setDuration(120 * 20), 1], [Effect::getEffect(Effect::REGENERATION)->setDuration(30 * 20)->setAmplifier(4), 1], [Effect::getEffect(Effect::FIRE_RESISTANCE)->setDuration(5 * 60 * 20), 1], [Effect::getEffect(Effect::DAMAGE_RESISTANCE)->setDuration(5 * 60 * 20), 1]];
 }
 public function getEffects()
 {
     return [Effect::getEffect(Effect::POISON)->setDuration(4 * 20) => 0.6];
 }
Beispiel #4
0
 public function getEffects()
 {
     return [[Effect::getEffect(Effect::ABSORPTION)->setDuration(120 * 20), 1], [Effect::getEffect(Effect::REGENERATION)->setDuration(2 * 20)->setAmplifier(1), 1]];
 }
Beispiel #5
0
 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     if (count($args) < 2) {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
         return true;
     }
     $player = $sender->getServer()->getPlayer($args[0]);
     if ($player === null) {
         $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.player.notFound"));
         return true;
     }
     if (strtolower($args[1]) === "clear") {
         foreach ($player->getEffects() as $effect) {
             $player->removeEffect($effect->getId());
         }
         $sender->sendMessage(new TranslationContainer("commands.effect.success.removed.all", [$player->getDisplayName()]));
         return true;
     }
     $effect = Effect::getEffectByName($args[1]);
     if ($effect === null) {
         $effect = Effect::getEffect((int) $args[1]);
     }
     if ($effect === null) {
         $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.effect.notFound", [(string) $args[1]]));
         return true;
     }
     $duration = 300;
     $amplification = 0;
     if (count($args) >= 3) {
         $duration = (int) $args[2];
         if (!$effect instanceof InstantEffect) {
             $duration *= 20;
         }
     } elseif ($effect instanceof InstantEffect) {
         $duration = 1;
     }
     if (count($args) >= 4) {
         $amplification = (int) $args[3];
     }
     if (count($args) >= 5) {
         $v = strtolower($args[4]);
         if ($v === "on" or $v === "true" or $v === "t" or $v === "1") {
             $effect->setVisible(false);
         }
     }
     if ($duration === 0) {
         if (!$player->hasEffect($effect->getId())) {
             if (count($player->getEffects()) === 0) {
                 $sender->sendMessage(new TranslationContainer("commands.effect.failure.notActive.all", [$player->getDisplayName()]));
             } else {
                 $sender->sendMessage(new TranslationContainer("commands.effect.failure.notActive", [$effect->getName(), $player->getDisplayName()]));
             }
             return true;
         }
         $player->removeEffect($effect->getId());
         $sender->sendMessage(new TranslationContainer("commands.effect.success.removed", [$effect->getName(), $player->getDisplayName()]));
     } else {
         $effect->setDuration($duration)->setAmplifier($amplification);
         $player->addEffect($effect);
         self::broadcastCommandMessage($sender, new TranslationContainer("%commands.effect.success", [$effect->getName(), $effect->getId(), $effect->getAmplifier(), $player->getDisplayName(), $effect->getDuration() / 20]));
     }
     return true;
 }
Beispiel #6
0
 public function getEffects()
 {
     $effect = [];
     switch ($this->meta) {
         case Potion::NIGHT_VISION:
             $effect = [[Effect::getEffect(Effect::NIGHT_VISION)->setAmplifier(0)->setDuration(3 * 60 * 20), 1]];
             break;
         case Potion::NIGHT_VISION_T:
             $effect = [[Effect::getEffect(Effect::NIGHT_VISION)->setAmplifier(0)->setDuration(8 * 60 * 20), 1]];
             break;
         case Potion::INVISIBILITY:
             $effect = [[Effect::getEffect(Effect::INVISIBILITY)->setAmplifier(0)->setDuration(3 * 60 * 20), 1]];
             break;
         case Potion::INVISIBILITY_T:
             $effect = [[Effect::getEffect(Effect::INVISIBILITY)->setAmplifier(0)->setDuration(8 * 60 * 20), 1]];
             break;
         case Potion::LEAPING:
             $effect = [[Effect::getEffect(Effect::JUMP)->setAmplifier(0)->setDuration(3 * 60 * 20), 1]];
             break;
         case Potion::LEAPING_T:
             $effect = [[Effect::getEffect(Effect::JUMP)->setAmplifier(0)->setDuration(8 * 60 * 20), 1]];
             break;
         case Potion::LEAPING_TWO:
             $effect = [[Effect::getEffect(Effect::JUMP)->setAmplifier(1)->setDuration(1.5 * 60 * 20), 1]];
             break;
         case Potion::FIRE_RESISTANCE:
             $effect = [[Effect::getEffect(Effect::FIRE_RESISTANCE)->setAmplifier(0)->setDuration(3 * 60 * 20), 1]];
             break;
         case Potion::FIRE_RESISTANCE_T:
             $effect = [[Effect::getEffect(Effect::FIRE_RESISTANCE)->setAmplifier(0)->setDuration(8 * 60 * 20), 1]];
             break;
         case Potion::SPEED:
             $effect = [[Effect::getEffect(Effect::SPEED)->setAmplifier(0)->setDuration(3 * 60 * 20), 1]];
             break;
         case Potion::SPEED_T:
             $effect = [[Effect::getEffect(Effect::SPEED)->setAmplifier(0)->setDuration(8 * 60 * 20), 1]];
             break;
         case Potion::SPEED_TWO:
             $effect = [[Effect::getEffect(Effect::SPEED)->setAmplifier(1)->setDuration(1.5 * 60 * 20), 1]];
             break;
         case Potion::SLOWNESS:
             $effect = [[Effect::getEffect(Effect::SLOWNESS)->setAmplifier(0)->setDuration(1 * 60 * 20), 1]];
             break;
         case Potion::SLOWNESS_T:
             $effect = [[Effect::getEffect(Effect::SLOWNESS)->setAmplifier(0)->setDuration(4 * 60 * 20), 1]];
             break;
         case Potion::WATER_BREATHING:
             $effect = [[Effect::getEffect(Effect::WATER_BREATHING)->setAmplifier(0)->setDuration(3 * 60 * 20), 1]];
             break;
         case Potion::WATER_BREATHING_T:
             $effect = [[Effect::getEffect(Effect::WATER_BREATHING)->setAmplifier(0)->setDuration(8 * 60 * 20), 1]];
             break;
         case Potion::POISON:
             $effect = [[Effect::getEffect(Effect::POISON)->setAmplifier(0)->setDuration(45 * 20), 1]];
             break;
         case Potion::POISON_T:
             $effect = [[Effect::getEffect(Effect::POISON)->setAmplifier(0)->setDuration(2 * 60 * 20), 1]];
             break;
         case Potion::POISON_TWO:
             $effect = [[Effect::getEffect(Effect::POISON)->setAmplifier(0)->setDuration(22 * 20), 1]];
             break;
         case Potion::REGENERATION:
             $effect = [[Effect::getEffect(Effect::REGENERATION)->setAmplifier(0)->setDuration(45 * 20), 1]];
             break;
         case Potion::REGENERATION_T:
             $effect = [[Effect::getEffect(Effect::REGENERATION)->setAmplifier(0)->setDuration(2 * 60 * 20), 1]];
             break;
         case Potion::REGENERATION_TWO:
             $effect = [[Effect::getEffect(Effect::REGENERATION)->setAmplifier(1)->setDuration(22 * 20), 1]];
             break;
         case Potion::STRENGTH:
             $effect = [[Effect::getEffect(Effect::STRENGTH)->setAmplifier(0)->setDuration(3 * 60 * 20), 1]];
             break;
         case Potion::STRENGTH_T:
             $effect = [[Effect::getEffect(Effect::STRENGTH)->setAmplifier(0)->setDuration(8 * 60 * 20), 1]];
             break;
         case Potion::STRENGTH_TWO:
             $effect = [[Effect::getEffect(Effect::STRENGTH)->setAmplifier(1)->setDuration(1.5 * 60 * 20), 1]];
             break;
         case Potion::WEAKNESS:
             $effect = [[Effect::getEffect(Effect::WEAKNESS)->setAmplifier(0)->setDuration(1.5 * 60 * 20), 1]];
             break;
         case Potion::WEAKNESS_T:
             $effect = [[Effect::getEffect(Effect::WEAKNESS)->setAmplifier(0)->setDuration(4 * 60 * 20), 1]];
             break;
         case Potion::HEALING:
             $effect = [[Effect::getEffect(Effect::HEALING)->setAmplifier(0)->setDuration(1), 1]];
             break;
         case Potion::HEALING_TWO:
             $effect = [[Effect::getEffect(Effect::HEALING)->setAmplifier(1)->setDuration(1), 1]];
             break;
         case Potion::HARMING:
             $effect = [[Effect::getEffect(Effect::HARMING)->setAmplifier(0)->setDuration(1), 1]];
             break;
         case Potion::HARMING_TWO:
             $effect = [[Effect::getEffect(Effect::HARMING)->setAmplifier(1)->setDuration(1), 1]];
             break;
         default:
             $effect = [];
             break;
     }
     return $effect;
 }
Beispiel #7
0
 public function kill()
 {
     $color = Potion::getColor($this->getData());
     $this->getLevel()->addParticle(new SpellParticle($this, $color[0], $color[1], $color[2]));
     $players = $this->getViewers();
     foreach ($players as $p) {
         if ($p->distance($this) <= 6) {
             switch ($this->getData()) {
                 case Potion::NIGHT_VISION:
                     $p->addEffect(Effect::getEffect(Effect::NIGHT_VISION)->setAmplifier(0)->setDuration(3 * 60 * 20));
                     break;
                 case Potion::NIGHT_VISION_T:
                     $p->addEffect(Effect::getEffect(Effect::NIGHT_VISION)->setAmplifier(0)->setDuration(8 * 60 * 20));
                     break;
                 case Potion::INVISIBILITY:
                     $p->addEffect(Effect::getEffect(Effect::INVISIBILITY)->setAmplifier(0)->setDuration(3 * 60 * 20));
                     break;
                 case Potion::INVISIBILITY_T:
                     $p->addEffect(Effect::getEffect(Effect::INVISIBILITY)->setAmplifier(0)->setDuration(8 * 60 * 20));
                     break;
                 case Potion::LEAPING:
                     $p->addEffect(Effect::getEffect(Effect::JUMP)->setAmplifier(0)->setDuration(3 * 60 * 20));
                     break;
                 case Potion::LEAPING_T:
                     $p->addEffect(Effect::getEffect(Effect::JUMP)->setAmplifier(0)->setDuration(8 * 60 * 20));
                     break;
                 case Potion::LEAPING_TWO:
                     $p->addEffect(Effect::getEffect(Effect::JUMP)->setAmplifier(1)->setDuration(1.5 * 60 * 20));
                     break;
                 case Potion::FIRE_RESISTANCE:
                     $p->addEffect(Effect::getEffect(Effect::FIRE_RESISTANCE)->setAmplifier(0)->setDuration(3 * 60 * 20));
                     break;
                 case Potion::FIRE_RESISTANCE_T:
                     $p->addEffect(Effect::getEffect(Effect::FIRE_RESISTANCE)->setAmplifier(0)->setDuration(8 * 60 * 20));
                     break;
                 case Potion::SPEED:
                     $p->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(0)->setDuration(3 * 60 * 20));
                     break;
                 case Potion::SPEED_T:
                     $p->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(0)->setDuration(8 * 60 * 20));
                     break;
                 case Potion::SPEED_TWO:
                     $p->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(1)->setDuration(1.5 * 60 * 20));
                     break;
                 case Potion::SLOWNESS:
                     $p->addEffect(Effect::getEffect(Effect::SLOWNESS)->setAmplifier(0)->setDuration(1 * 60 * 20));
                     break;
                 case Potion::SLOWNESS_T:
                     $p->addEffect(Effect::getEffect(Effect::SLOWNESS)->setAmplifier(0)->setDuration(4 * 60 * 20));
                     break;
                 case Potion::WATER_BREATHING:
                     $p->addEffect(Effect::getEffect(Effect::WATER_BREATHING)->setAmplifier(0)->setDuration(3 * 60 * 20));
                     break;
                 case Potion::WATER_BREATHING_T:
                     $p->addEffect(Effect::getEffect(Effect::WATER_BREATHING)->setAmplifier(0)->setDuration(8 * 60 * 20));
                     break;
                 case Potion::POISON:
                     $p->addEffect(Effect::getEffect(Effect::POISON)->setAmplifier(0)->setDuration(45 * 20));
                     break;
                 case Potion::POISON_T:
                     $p->addEffect(Effect::getEffect(Effect::POISON)->setAmplifier(0)->setDuration(2 * 60 * 20));
                     break;
                 case Potion::POISON_TWO:
                     $p->addEffect(Effect::getEffect(Effect::POISON)->setAmplifier(0)->setDuration(22 * 20));
                     break;
                 case Potion::REGENERATION:
                     $p->addEffect(Effect::getEffect(Effect::REGENERATION)->setAmplifier(0)->setDuration(45 * 20));
                     break;
                 case Potion::REGENERATION_T:
                     $p->addEffect(Effect::getEffect(Effect::REGENERATION)->setAmplifier(0)->setDuration(2 * 60 * 20));
                     break;
                 case Potion::REGENERATION_TWO:
                     $p->addEffect(Effect::getEffect(Effect::REGENERATION)->setAmplifier(1)->setDuration(22 * 20));
                     break;
                 case Potion::STRENGTH:
                     $p->addEffect(Effect::getEffect(Effect::STRENGTH)->setAmplifier(0)->setDuration(3 * 60 * 20));
                     break;
                 case Potion::STRENGTH_T:
                     $p->addEffect(Effect::getEffect(Effect::STRENGTH)->setAmplifier(0)->setDuration(8 * 60 * 20));
                     break;
                 case Potion::STRENGTH_TWO:
                     $p->addEffect(Effect::getEffect(Effect::STRENGTH)->setAmplifier(1)->setDuration(1.5 * 60 * 20));
                     break;
                 case Potion::WEAKNESS:
                     $p->addEffect(Effect::getEffect(Effect::WEAKNESS)->setAmplifier(0)->setDuration(1.5 * 60 * 20));
                     break;
                 case Potion::WEAKNESS_T:
                     $p->addEffect(Effect::getEffect(Effect::WEAKNESS)->setAmplifier(0)->setDuration(4 * 60 * 20));
                     break;
                 case Potion::HEALING:
                     $p->addEffect(Effect::getEffect(Effect::HEALING)->setAmplifier(0)->setDuration(1));
                     break;
                 case Potion::HEALING_TWO:
                     $p->addEffect(Effect::getEffect(Effect::HEALING)->setAmplifier(1)->setDuration(1));
                     break;
                 case Potion::HARMING:
                     $p->addEffect(Effect::getEffect(Effect::HARMING)->setAmplifier(0)->setDuration(1));
                     break;
                 case Potion::HARMING_TWO:
                     $p->addEffect(Effect::getEffect(Effect::HARMING)->setAmplifier(1)->setDuration(1));
                     break;
             }
         }
     }
     parent::kill();
 }
Beispiel #8
0
 public function getEffects()
 {
     return [[Effect::getEffect(Effect::NAUSEA)->setDuration(15 * 20)->setAmplifier(1), 1], [Effect::getEffect(Effect::HUNGER)->setDuration(15 * 20)->setAmplifier(2), 1], [Effect::getEffect(Effect::POISON)->setDuration(60 * 20)->setAmplifier(3), 1]];
 }
Beispiel #9
0
 protected function initEntity()
 {
     if (isset($this->namedtag->ActiveEffects)) {
         foreach ($this->namedtag->ActiveEffects->getValue() as $e) {
             $effect = Effect::getEffect($e["Id"]);
             if ($effect === null) {
                 continue;
             }
             $effect->setAmplifier($e["Amplifier"])->setDuration($e["Duration"])->setVisible($e["ShowParticles"] > 0);
             $this->addEffect($effect);
         }
     }
     if (isset($this->namedtag->CustomName)) {
         $this->setNameTag($this->namedtag["CustomName"]);
         if (isset($this->namedtag->CustomNameVisible)) {
             $this->setNameTagVisible($this->namedtag["CustomNameVisible"] > 0);
         }
     }
     $this->scheduleUpdate();
 }