Ejemplo n.º 1
0
 /**
  * @param BuyCraft $main
  * @param array $data
  * @param bool $player
  */
 public function __construct(BuyCraft $main, $data = [], $player = false)
 {
     DebugUtils::construct($this);
     if ($main->getConfig()->get("https")) {
         $this->apiUrl = "https://api.buycraft.net/v4";
     } else {
         $this->apiUrl = "http://api.buycraft.net/v4";
     }
     $data["secret"] = $main->getConfig()->get("secret");
     $data["playersOnline"] = count($main->getServer()->getOnlinePlayers());
     $this->data = serialize($data);
     $this->player = $player;
     $this->isAuthenticated = $main->isAuthenticated();
     $this->autoloader = unserialize(serialize($main->getServer()->getLoader()));
     //TODO improve this
     $this->onConfig($main);
 }
Ejemplo n.º 2
0
 public function onConfig(BuyCraft $plugin)
 {
     $data = $this->getData();
     $data["action"] = Actions::COMMANDS;
     $data["do"] = Actions::DO_LOOKUP;
     if (is_array($data["users"])) {
         $data["users"] = json_encode($data["users"]);
         //I think that's right
     }
     $data["offlineCommandLimit"] = $plugin->getConfig()->get('commandThrottleCount');
     $this->setData($data);
 }
Ejemplo n.º 3
0
 public function onOutput(BuyCraft $main, CommandSender $sender)
 {
     $out = $this->getOutput()['payload'];
     if ($out !== null && $out !== false) {
         if (isset($out['url']) && $out['url'] !== null) {
             $sender->sendMessage($main->getConfig()->get('pleaseVisit') . ": " . $out['url']);
         } else {
             $sender->sendMessage($out['errormessage']);
         }
     } else {
         $sender->sendMessage("HTTP request error during url shortening.");
     }
 }
Ejemplo n.º 4
0
 public function __construct(BuyCraft $main)
 {
     parent::__construct($main->getConfig()->get('buyCommand'), "Buy command!", "/buy", []);
     $this->main = $main;
 }