public function validateAPIKey() { // validate api key $votingAPIKey = $this->apiKey; $url = "http://minecraftpocket-servers.com/api/?object=servers&element=detail"; $url .= "&key=" . urlencode($votingAPIKey); $response_raw = file_get_contents($url); $response = json_decode($response_raw); if (json_last_error() != JSON_ERROR_NONE) { $err = TextFormat::RED . "Could not validate your minecraftpocket-servers.com API key!"; $err .= " Server response was '" . TextFormat::YELLOW . $response_raw . "'"; $err .= TextFormat::YELLOW . " key was " . $votingAPIKey; $this->plugin->getLogger()->warning($err); $this->validatedKey = false; return false; } if (!isset($response->name)) { $err = TextFormat::RED . "Could not validate your minecraftpocket-servers.com API key!"; $err .= " Server response was '" . TextFormat::YELLOW . $response_raw . "'"; $this->plugin->getLogger()->warning($err); $this->validatedKey = false; return false; } $infoMessage = "Voting enabled for " . $response->name; $this->plugin->getLogger()->info(TextFormat::GREEN . $infoMessage); $this->validatedKey = true; return true; }
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"); } }