Ejemplo n.º 1
0
 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();
         }
     });
 }
Ejemplo n.º 2
0
 protected function handleCommandPlayer(StormPlayer $sender, array $args)
 {
     if ($sender->isAuthenticated()) {
         throw new BasicStormCommandException("You are already authenticated!");
     }
     if (sizeof($args) < 1) {
         throw new BasicStormCommandException("You must supply a password!");
     }
     $sender->logUserIn($args[0]);
     $sender->getPocketMinePlayer()->sendMessage(StormFormatter::withPath("awaiting-auth-callback")->get());
 }
Ejemplo n.º 3
0
 protected function handleCommandPlayer(StormPlayer $sender, array $args)
 {
     if ($sender->isAuthenticated()) {
         throw new BasicStormCommandException("You are already authenticated!");
     }
     if (sizeof($args) < 3 || $args[1] !== $args[2]) {
         throw new BasicStormCommandException("Correct usage: [email] [password] [password again]");
     }
     $sender->register($args[1], $args[0]);
     $sender->getPocketMinePlayer()->sendMessage(StormFormatter::withPath("awaiting-register-callback")->get());
 }
Ejemplo n.º 4
0
 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 onPlayerAuthenticateError(PlayerAuthenticationErrorEvent $event)
 {
     $event->getPlayer()->getPocketMinePlayer()->sendMessage(StormFormatter::withPath("player-auth-fail")->with("message", $event->getError())->get());
 }