so i made a border plugin and it works great but the border doesn't work once you join and move the border is trigged for some reason Code PHP: <?phpnamespace TB\Border;use pocketmine\Server;use pocketmine\Player;use pocketmine\plugin\PluginBase;use pocketmine\event\Listener;use pocketmine\event\player\PlayerMoveEvent;use pocketmine\utils\Config;class Main extends PluginBase implements Listener { public function onEnable(){ $this->getServer()->getLogger()->info("World Border Plugin Made by TB!"); $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->saveDefaultConfig(); } public function retrieveData($data){ return $this->getConfig()->get($data); } public function onMove(PlayerMoveEvent $ev){ $x = $ev->getPlayer()->x; $z = $ev->getPlayer()->z; $minZ = $this->retrieveData("minZ"); $maxZ = $this->retrieveData("maxZ"); $minX = $this->retrieveData("minX"); $maxX = $this->retrieveData("maxX"); if($minX <= $x and $x <= $maxX and $minZ <= $z and $z <= $maxZ){ $ev->setCancelled(true); $message = array($this->retrieveData("Message1"), $this->retrieveData("Message2")); $ev->getPlayer()->addTitle($message[0], $message[1], 90, 40, 90); $this->getServer()->getLogger()->warning($minX . " " . $maxX . " / " . $minZ . " " . $maxZ); } }} Config: Code: maxX: 1000 minX: -1000 maxZ: 1000 minZ: -1000 Message1: "World Border" Message2: "You Reached The World Border"
PHP: $x >= $minX and $x <= $maxX and $z <= $minZ and $z <= $maxZ// Player inside border//else// Player outside border//Cancel the event
doeesnt work PHP: if($x >= $minX and $x <= $maxX and $z <= $minZ and $z <= $maxZ){ $ev->setCancelled(false); } else { $message = array($this->retrieveData("Message1"), $this->retrieveData("Message2")); $ev->getPlayer()->addTitle($message[0], $message[1], 90, 40, 90); $ev->setCancelled(true); } }} https://github.com/Teamblocket/Border/blob/master/src/TB/Border/Main.php
but he used it on PlayerMoveEvent, so automatically it checked when player move. I never create plugin to make border or area. Of course there is many example of this case, thanks for @aliuly to create it https://github.com/Muirfield/WorldProtect/blob/master/src/aliuly/worldprotect/WpBordersMgr.php#L105