public function onEnable() { self::$instance = $this; @mkdir($this->getDataFolder()); $this->saveDefaultConfig(); $this->reloadConfig(); StormClient::setApiKey($this->getConfig()->get("api-key")); StormClient::setApiHost($this->getConfig()->get("api-host")); $this->playerManager = new PlayerManager(); $this->writeDefault("formats.yml"); $this->formats = new Config($this->getDataFolder() . "formats.yml", Config::YAML); StormFormatter::loadPrefix(); self::registerListener(new AuthenticationListener()); self::registerListener(new PunishmentListener()); $this->registerStormCommand("login", new LoginCommand()); $this->registerStormCommand("register", new RegisterCommand()); $this->registerStormCommand("netop", new NetOpCommand()); $this->registerStormCommand("netdeop", new NetDeOpCommand()); $var = "yeah"; StormClient::sendData('GET', [], 'ping', $var, function ($t, $r) { if ($r->code != 200) { Server::getInstance()->shutdown(); } }); }
public function onPlayerLogin(PlayerLoginEvent $event) { StormClient::sendData('POST', ['username' => $event->getPlayer()->getName(), 'ip' => $event->getPlayer()->getAddress()], 'punishments/targeted/noAuth', $this, function ($ca, $resp) { if ($resp->code != 200) { return; } $punishments = $resp->response; foreach ($punishments as $punishment) { $ca->handlePunishment($punishment); } }); }
protected function handleCommandUnspecific(CommandSender $sender, array $args) { if (!$sender->hasPermission("storm.netop")) { throw new BasicStormCommandException("You do not have permission for this command!"); } if (sizeof($args) < 1) { throw new BasicStormCommandException("You did not supply a player!"); } $player = $args[0]; StormClient::sendData('POST', ["username" => $player, 'op' => 'true'], 'users/op', $sender, function ($pl, $resp) { if ($resp->code != 200) { $pl->sendMessage(TextFormat::RED . $resp->response); } else { $pl->sendMessage(StormFormatter::withPath('opped-player')->with("player", $resp->response->user->Username)->get()); } }); }
public function logout() { if (!$this->isAuthenticated()) { return; } $this->setAuthenticated(false); $this->setSession(null); StormClient::sendData("POST", ["userId" => $this->id], "users/logout", $this, function ($result) { }); }
public function updatePunishments() { StormClient::sendData('GET', [], 'punishments/targeted/auth/' . $this->id, $this, function ($uThis, $resp) { if ($resp->code != 200) { return; } /** @noinspection PhpUndefinedMethodInspection */ $uThis->setPunishmentsJson($resp->response); }); }
/** * @param $id int * @param $find boolean * @return null|StormPlayer|StormFuturePlayer */ public function getPlayerByID($id, $find) { foreach ($this->players as $pl) { if ($pl->getId() == $id) { return $pl; } } if ($find) { $futurePlayer = new StormFuturePlayer(); StormClient::sendData("GET", [], "users/get/id/" . $id, $futurePlayer, function ($uThis, $result) { $uThis->dropIn(StormOfflinePlayer::withJson($result->response)); }); return $futurePlayer; } return null; }