I have been working on a plugin but I have the doubt, If I have a command "/test" for example, and I want the player to put "/test", grant "regeneration" or some enchantment, to each player near the in 5 blocks for example, how could I do this in my plugin? , or if I can at least do it.
or if you want to give effect in a square you can youse this code: PHP: public function onMove(PlayerMoveEvent $event){ $nextPos = $event->getTo()->asVector3(); $x = $nextPos->getX(); $z = $nextPos->getZ(); if ($x1 /*first X*/ > $x2 /*second X */){ if ($z1 /*first Z*/ > $z2 /*second Z*/){ if ($x1 > $x and $x < $x2){ if ($z1 > $z and $z < $z2){ //add effect... } } }else{//Z1 < Z2 if ($x1 > $x and $x < $x2){ if ($z1 < $z and $z > $z2){ //add effect... } } } }else{//X1 < X2 or X1 = X2 if ($z1 /*first Z*/ > $z2 /*second Z*/){ if ($x1 < $x and $x > $x2){ if ($z1 > $z and $z < $z2){ //add effect... } } }else{//Z1 < Z2 if ($x1 < $x and $x > $x2){ if ($z1 < $z and $z > $z2){ //add effect... } } } } }
PHP: $player = Player;foreach($player->getServer()->getOnlinePlayers() as $onlinePlayer) { if($player->distance($onlinePlayer->asVector3()) <= 5) { $onlinePlayer->addEffect(new EffectInstance(Effect::getEffect(Effect::REGENERATION))); }}
Hello @Znightmare123 , PHP: $GodWeedZao =new EffectInstance(Effect::getEffect(Effect::NAME), TIME* 20, 1, true);//NAME => name of effect//TIME => time to add effect in player$player->addEffect($GodWeedZao); SOLVED?