Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Falkirks
committed
Sep 20, 2014
1 parent
2268cd0
commit 6f0836d
Showing
4 changed files
with
53 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: BuyCraft | ||
main: buycraft\BuyCraft | ||
version: 0.6.1 | ||
version: 0.7 | ||
author: Falk | ||
api: [1.0.0] | ||
load: POSTWORLD | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
namespace buycraft\task; | ||
|
||
|
||
use buycraft\api\Actions; | ||
use buycraft\api\ApiAsyncTask; | ||
use buycraft\BuyCraft; | ||
use pocketmine\Player; | ||
/* | ||
* This is an Async task which allows PendingPlayerCheckerTask to | ||
* send requests outside the main thread. | ||
*/ | ||
class PendingUsersTask extends ApiAsyncTask{ | ||
public function onConfig(BuyCraft $plugin){ | ||
$data = $this->getData(); | ||
$data["action"] = Actions::PENDING_PLAYERS; | ||
$this->setData($data); | ||
} | ||
public function onRun(){ | ||
$this->send(); | ||
} | ||
public function onOutput(BuyCraft $main, Player $player = null){ | ||
$res = $this->getOutput(); | ||
if($res !== false && is_array($res["payload"]["pendingPlayers"])){ | ||
$playersToFetch = []; | ||
foreach($res["payload"]["pendingPlayers"] as $player){ | ||
$p = $main->getServer()->getPlayerExact($player); | ||
if($p !== null && $p->isOnline()){ | ||
$playersToFetch[] = $p->getName(); | ||
} | ||
else{ | ||
$main->getPendingPlayerCheckerTask()->addPendingPlayer($player); | ||
} | ||
} | ||
if($res["payload"]["offlineCommands"] || count($playersToFetch) > 0){ | ||
$fetch = new CommandFetchTask($main, ["users" => $playersToFetch, "offlineCommands" => $res["payload"]["offlineCommands"]]); | ||
$fetch->call(); | ||
} | ||
} | ||
} | ||
} |