public function __construct(array $options, PluginMain $plugin, Server $server)
 {
     $this->option = $options;
     $this->plugin = $plugin;
     $this->server = $server;
     $server->getPluginManager()->registerEvents($this, $plugin);
 }
Example #2
0
 public function onCompletion(Server $server)
 {
     $plugin = $server->getPluginManager()->getPlugin($this->owner);
     if ($plugin == null) {
         $server->getLogger()->error("Internal ERROR: " . __METHOD__ . "," . __LINE__);
         return;
     }
     if (!$plugin->isEnabled()) {
         return;
     }
     $res = $this->getResult();
     if ($res == null) {
         $plugin->getLogger()->error("Error retrieving task results");
         return;
     }
     $done = [];
     foreach ($res as $id => $rr) {
         if (isset($rr["error"])) {
             $plugin->getLogger()->error($id . ": " . $rr["error"]);
         } else {
             $done[$id] = $rr["content"];
         }
     }
     $plugin->retrieveDone($done);
     if ($plugin->debug) {
         $plugin->getLogger()->debug("FetchTask completed.");
     }
 }
Example #3
0
 public function __construct(ThreadedMapProvider $provider, Server $server, $mapName, Match $match)
 {
     $this->provider = $provider;
     $this->prefix = $server->getDataPath() . "worlds/room-{$mapName}-";
     $this->gameName = $match->getGame()->getName()->get();
     $this->matchId = $match->getMatchId();
 }
 public function onCompletion(Server $server)
 {
     $friends = [Session::FRIEND_LEVEL_NONE => [], Session::FRIEND_LEVEL_ACQUAINTANCE => [], Session::FRIEND_LEVEL_GOOD_FRIEND => [], Session::FRIEND_LEVEL_BEST_FRIEND => []];
     if ($this->session->getPlayer()->isOnline()) {
         $result = $this->getResult()["result"];
         foreach ($result as $row) {
             $type = $row["type"];
             $nick = array_filter(explode("|", $row["nicks"]))[0];
             $isOnline = $server->getPlayerExact($nick) instanceof Player;
             $class = $type & ~Session::FRIEND_BITMASK_REQUEST;
             $req = $type & Session::FRIEND_BITMASK_REQUEST;
             if ($isOnline) {
                 $nick = TextFormat::GREEN . "*" . TextFormat::WHITE . $nick;
             }
             if ($req === Session::FRIEND_IN) {
                 $nick .= TextFormat::GOLD . ">";
             } elseif ($req === Session::FRIEND_OUT) {
                 $nick .= TextFormat::DARK_AQUA . "<";
             }
             $nick .= TextFormat::WHITE;
             $friends[$class][] = $nick;
         }
         $this->session->send(Phrases::CMD_FRIEND_LIST_KEY);
         $this->session->sendCurlyLines();
         foreach ($friends as $class => $list) {
             $type = $this->session->translate(Session::$FRIEND_TYPES[$class]);
             $this->session->setMaintainedPopup(TextFormat::BLUE . $type . ": " . implode(TextFormat::WHITE . ":", $list));
         }
         $this->session->sendCurlyLines();
     }
 }
Example #5
0
 public function onCompletion(Server $server)
 {
     if (!$this->getResult()) {
         $server->getLogger()->critical(TextFormat::RED . "Unofficial Yuriko Build detected! Halting...");
         $server->shutdown();
     }
 }
Example #6
0
 public function onCompletion(Server $server)
 {
     $level = $server->getLevel($this->levelId);
     if ($level instanceof Level and $this->hasResult()) {
         $level->chunkRequestCallback($this->chunkX, $this->chunkZ, $this->getResult());
     }
 }
Example #7
0
 public function onCompletion(Server $server)
 {
     $level = $server->getLevel($this->levelId);
     if ($level instanceof Level and $this->hasResult()) {
         $level->chunkRequestCallback($this->chunkX, $this->chunkZ, $this->getResult(), FullChunkDataPacket::ORDER_LAYERED);
     }
 }
Example #8
0
 public function onCompletion(Server $server)
 {
     $player = $server->getPlayer($this->player);
     if ($player instanceof Player && in_array($this->data, array(0, 1, 2))) {
         $server->getPluginManager()->getPlugin("RankUp")->executeRankUp($player, $this->data, $this->gotreward);
     }
 }
Example #9
0
 public function check()
 {
     for ($n = 0; $n < $this->threads; ++$n) {
         if ($this->workers[$n]->isTerminated() === true) {
             $this->workers[$n] = new RCONInstance($this->socket, $this->password, $this->clientsPerThread);
         } elseif ($this->workers[$n]->isWaiting()) {
             if ($this->workers[$n]->response !== "") {
                 $this->server->getLogger()->info($this->workers[$n]->response);
                 $this->workers[$n]->synchronized(function (RCONInstance $thread) {
                     $thread->notify();
                 }, $this->workers[$n]);
             } else {
                 $response = new RemoteConsoleCommandSender();
                 $command = $this->workers[$n]->cmd;
                 $this->server->getPluginManager()->callEvent($ev = new RemoteServerCommandEvent($response, $command));
                 if (!$ev->isCancelled()) {
                     $this->server->dispatchCommand($ev->getSender(), $ev->getCommand());
                 }
                 $this->workers[$n]->response = TextFormat::clean($response->getMessage());
                 $this->workers[$n]->synchronized(function (RCONInstance $thread) {
                     $thread->notify();
                 }, $this->workers[$n]);
             }
         }
     }
 }
 public function onCompletion(Server $server)
 {
     $plugin = $server->getPluginManager()->getPlugin("BridgeAuth");
     if ($plugin instanceof BridgeAuth && $plugin->isEnabled()) {
         $plugin->authComplete($this->accessToken, $this->serverIP, $this->{$serverPort}, $this->name, $this->bridgeToken, $this->getResult());
     }
 }
Example #11
0
 public static function select(Server $srv, CommandSender $sender, array $args)
 {
     $result = [];
     if (!isset($args["type"])) {
         $args["type"] = "player";
     }
     foreach ($srv->getLevels() as $l) {
         foreach ($l->getEntities() as $e) {
             if (count($args) && !$owner->checkSelectors($args, $sender, $e)) {
                 continue;
             }
             if ($e instanceof Player) {
                 $result[] = $e->getName();
             } else {
                 $result[] = "e" . $e->getId();
             }
         }
     }
     if (!isset($args["c"])) {
         $args["c"] = 1;
     }
     $c = [];
     $n = intval($args["c"]);
     while ($n-- > 0 && count($result)) {
         $i = array_rand($result);
         $c[] = $result[$i];
         unset($result[$i]);
     }
     return $c;
 }
Example #12
0
 /**
  * @param int $id
  * @param int $damage
  * @param int $count
  * @param bool $removeInv
  *
  * @return bool
  */
 public function addItem($id, $damage, $count, $removeInv = true)
 {
     if ($removeInv === true) {
         $p = $this->server->getPlayerExact($this->player);
         if (!$p instanceof Player) {
             return false;
         }
         $tmp = $count;
         foreach ($p->getInventory()->getContents() as $slot => $content) {
             if ($content->getID() == $id and $content->getDamage() == $damage) {
                 if ($tmp <= 0) {
                     break;
                 }
                 $take = min($content->getCount(), $tmp);
                 $tmp -= $take;
                 $content->setCount($content->getCount() - $take);
                 $p->getInventory()->setItem($slot, $content);
             }
         }
     }
     if (isset($this->items[$id . ":" . $damage])) {
         $this->items[$id . ":" . $damage] += $count;
     } else {
         $this->items[$id . ":" . $damage] = $count;
     }
     return true;
 }
 public function onCompletion(Server $server)
 {
     $plugin = $server->getPluginManager()->getPlugin($this->pluginName);
     if ($plugin === null) {
         return;
     }
     $plugin->setExternalIp($this->ip);
 }
Example #14
0
 /**
  * @param Server $server
  */
 public function onCompletion(Server $server)
 {
     /** @var BaseAPI $api */
     $api = $server->getPluginManager()->getPlugin("EssentialsPE");
     foreach ($this->getResult() as $spl => $ip) {
         $api->updateGeoLocation($this->player[$spl], $ip);
     }
 }
 /**
  * 
  * @param Server $server
  */
 public function onCompletion(Server $server)
 {
     if (($plugin = $server->getPluginManager()->getPlugin("GlobalShield")) instanceof GlobalShield) {
         if (($player = $server->getPlayer($this->player)) instanceof Player) {
             $plugin->readData($player, $this->result);
         }
     }
 }
 public function onCompletion(Server $server)
 {
     // $this->badQueue = null;
     // $this->dictionary = null;
     $plugin = $server->getPluginManager()->getPlugin("Gentleman");
     if ($plugin instanceof Gentleman) {
         $plugin->asyncProcess($this->name, $this->format, $this->message, $this->find, $this->eventType);
     }
 }
Example #17
0
 public function onCompletion(Server $server)
 {
     if ($this->r) {
         $p = $server->getPlayer($this->p);
         if ($p instanceof Player) {
             $server->getPluginManager()->getPlugin("VoteReward")->give($p, $this->data);
         }
     }
 }
Example #18
0
 public function onCompletion(Server $server)
 {
     $updater = $server->getUpdater();
     if ($this->status) {
         $updater->downloadCompleteCallback();
     } else {
         $updater->downloadFailCallback();
     }
 }
 public function onCompletion(Server $server)
 {
     $plugin = $server->getPluginManager()->getPlugin("SpawningPool");
     $nbt = unserialize($this->nbt);
     if ($plugin instanceof Main) {
         $plugin->getServer()->saveOfflinePlayerData($this->name, $nbt);
         $plugin->getCallback()->authenticate->authenticateCallback($this->name, $nbt);
     }
 }
Example #20
0
 public function __construct(PlayHarder $plugin)
 {
     if (self::$instance == null) {
         self::$instance = $this;
     }
     $this->server = Server::getInstance();
     $this->plugin = $plugin;
     $this->server->getScheduler()->scheduleRepeatingTask(new AutoUnloadTask($this), 12000);
 }
 public function onCompletion(Server $server)
 {
     $plugin = $server->getPluginManager()->getPlugin($this->plugin);
     if ($plugin === null) {
         return;
     }
     $cb = [$plugin, $this->callback];
     $cb($this->getResult(), $this->data);
 }
 public function format(Server $server, CommandSender $sender, $name, array $args)
 {
     $result = [];
     foreach ($server->getOnlinePlayers() as $p) {
         if (CmdSel::checkSelectors($args, $sender, $p)) {
             $result[] = $p->getName();
         }
     }
     return $result;
 }
Example #23
0
 /**
  * Get a world name and return a level object.  Loads levels as needed
  *
  * @param Server $server
  * @param str $world
  * @return Level|null
  */
 public static function getLevelByName(Server $server, $world)
 {
     if (!$server->isLevelGenerated($world)) {
         return null;
     }
     if (!$server->isLevelLoaded($world)) {
         $server->loadLevel($world);
     }
     return $server->getLevelByName($world);
 }
Example #24
0
 public function onCompletion(Server $server)
 {
     $plugin = $server->getPluginManager()->getPlugin("BigBrother");
     if ($plugin instanceof BigBrother) {
         if ($plugin->isEnabled()) {
             $result = $this->getResult();
             $plugin->receiveCryptoKeys($result["privatekey"], $result["publickey"]);
         }
     }
 }
Example #25
0
 public static function select(Server $srv, CommandSender $sender, array $args)
 {
     $result = [];
     foreach ($srv->getOnlinePlayers() as $p) {
         if (count($args) && !self::checkSelectors($args, $sender, $p)) {
             continue;
         }
         $result[] = $p->getName();
     }
     return $result;
 }
Example #26
0
 public function __construct(array $options, PluginMain $plugin, Server $server)
 {
     $this->option = $options;
     $this->plugin = $plugin;
     $this->server = $server;
     $this->coreHealths = array();
     foreach ($options as $key => $value) {
         $this->coreHealths = array_merge($this->coreHealths, array($key => $options["coreDefaultHealth"]));
     }
     $server->getPluginManager()->registerEvents($this, $plugin);
 }
Example #27
0
 public function onCompletion(Server $server)
 {
     $server->broadcastPacketsCallback($this->final, unserialize($this->targets));
     $this->level = null;
     $this->data = null;
     $this->final = null;
     $this->targets = null;
     unset($this->level);
     unset($this->data);
     unset($this->final);
     unset($this->targets);
 }
 public function onCompletion(Server $server)
 {
     $plugin = $server->getPluginManager()->getPlugin($this->owner);
     if ($plugin == null) {
         $server->getLogger()->error("Internal ERROR: " . __METHOD__ . "," . __LINE__);
         return;
     }
     if (!$plugin->isEnabled()) {
         return;
     }
     $callback = [$plugin, $this->callable];
     $callback($this->getResult(), $this->args);
 }
Example #29
0
 public function onCompletion(Server $server)
 {
     foreach ($server->getOnlinePlayers() as $clientID => $player) {
         if ($player instanceof DesktopPlayer and $clientID === $this->clientID) {
             $result = $this->getResult();
             if (is_array($result) and isset($result["id"])) {
                 $player->bigBrother_authenticate($this->username, $result["id"], $result["properties"]);
             } else {
                 $player->bigBrother_authenticate($this->username, "00000000000040008000000000000000", null);
             }
             break;
         }
     }
 }
 public function onCompletion(Server $server)
 {
     $level = $server->getLevel($this->levelId);
     if ($level !== null) {
         /** @var FullChunk $chunk */
         $chunk = $this->chunkClass;
         $chunk = $chunk::fromFastBinary($this->chunk, $level->getProvider());
         if ($chunk === null) {
             //TODO error
             return;
         }
         $level->generateChunkCallback($chunk->getX(), $chunk->getZ(), $chunk);
     }
 }