public function onPlayerMove(PlayerMoveEvent $event) { $player = $event->getPlayer(); $pname = strtolower($player->getName()); $levelName = $player->getLevel()->getName(); $players_in_tracker = isset($this->playerLocationTracker[$pname]); if (!$this->plugin->isLevelLoaded($levelName)) { if ($players_in_tracker) { unset($this->playerLocationTracker[$pname]); } return; } $plot = $this->plugin->getPlotByPosition($player->getPosition()); // if users not in a plot make sure unset if (is_null($plot) && $players_in_tracker) { unset($this->playerLocationTracker[$pname]); return; } if (is_null($plot)) { return; } // if user was not previously tracked then save pos and return if (!$players_in_tracker && !is_null($plot)) { $this->playerLocationTracker[$pname] = $plot; $this->plugin->getServer()->dispatchCommand($player, "p info summary"); return; } // if user has moved if ($plot->X != $this->playerLocationTracker[$pname]->X || $plot->Z != $this->playerLocationTracker[$pname]->Z) { $this->playerLocationTracker[$pname] = $plot; $this->plugin->getServer()->dispatchCommand($player, "p info summary"); return; } }
public function __construct(MyPlot $plugin) { $this->plugin = $plugin; $this->buddyChannels = $plugin->getServer()->getPluginManager()->getPlugin("BuddyChannels"); if (!is_null($this->buddyChannels)) { $this->buddyChannels->registerFormatter($this, true); $plugin->getLogger()->info("Registered to BuddyChannels"); } else { $plugin->getLogger()->error("Could not join to BuddyChannels"); } }