Skip to content
This repository was archived by the owner on Jul 11, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions LiveSigns/src/aliuly/livesigns/FetchTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
class FetchTask extends AsyncTask {
public $started;
public $owner;
public $re;
protected $pkgs;
protected $cf;
public function __construct($plugin,$cfg,$pkgs) {
Expand Down Expand Up @@ -56,7 +57,8 @@ private function fetchJob($dat) {
}

public function onRun() {
$this->setResult(null);
//$this->setResult(null);
$this->re = json_encode(null);
$restab = [];
foreach ($this->pkgs as $job) {
list($id,$dat) = $job;
Expand All @@ -67,7 +69,8 @@ public function onRun() {
$restab[$id] = [ "error" => $res ];
}
}
$this->setResult($restab);
//$this->setResult($restab);
$this->re = json_encode($restab);
}
public function onCompletion(Server $server) {
$plugin = $server->getPluginManager()->getPlugin($this->owner);
Expand All @@ -77,7 +80,14 @@ public function onCompletion(Server $server) {
return;
}
if (!$plugin->isEnabled()) return;
$res = $this->getResult();
//$res = $this->getResult();
if(!is_string($this->re)) {
$plugin->getLogger()->error("Error retrieving task results - no array in re");
return;
}


$res = json_decode($this->re, true);
if ($res == null) {
$plugin->getLogger()->error("Error retrieving task results");
return;
Expand Down
11 changes: 10 additions & 1 deletion LiveSigns/src/aliuly/livesigns/LsCmds.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,16 @@ private function cmdShow(CommandSender $c,array $args){
++$count;
$txt[] = TextFormat::AQUA.mc::_("LiveSign: ").TextFormat::WHITE.$id;
foreach ($stx[$id]["text"] as $k) {
$txt[] = TextFormat::AQUA."- -".TextFormat::WHITE.$k;
if(is_array($k)) {
$i = 0;
foreach ($k as $k_line) {
$txt[] = TextFormat::AQUA."- -".TextFormat::WHITE.$k[$i];
$i++;
}
unset($i,$k_line);
} else {
$txt[] = TextFormat::AQUA."- -".TextFormat::WHITE.$k;
}
}
if (isset($stx[$id]["datetime"])) {
$txt[] = TextFormat::AQUA.mc::_("- tstamp: ").
Expand Down
6 changes: 5 additions & 1 deletion LiveSigns/src/aliuly/livesigns/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,11 @@ private function getText($id) {
$text = $this->signsTxt[$id]["text"];
}
if(isset($this->signsCfg[$id]["no-vars"])) return $text;
return explode("\n",strtr(implode("\n",$text),$this->vars));
//return explode("\n",strtr(implode("\n",$text),$this->vars));
if(is_array($text[0]))
return explode("\n",strtr(implode("\n",$text[0]),$this->vars));
else
return explode("\n",strtr(implode("\n",$text),$this->vars));
}
public function getLiveText($id,$opts) {
if (!isset($this->signsTxt[$id])) return null;
Expand Down
6 changes: 4 additions & 2 deletions LiveSigns/src/aliuly/livesigns/TileUpdTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
use pocketmine\scheduler\PluginTask;
use pocketmine\plugin\Plugin;
use pocketmine\tile\Sign;
use pocketmine\network\protocol\TileEntityDataPacket;
//use pocketmine\network\protocol\TileEntityDataPacket;
use pocketmine\network\protocol\BlockEntityDataPacket;
use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\StringTag;
Expand All @@ -20,12 +21,13 @@ public function onRun($currentTicks){
$this->getOwner()->updateVars();
foreach ($this->getOwner()->getServer()->getLevels() as $lv) {
if (count($lv->getPlayers()) == 0) continue;
if ($lv === null) continue; // Skip all if level is not loaded
foreach ($lv->getTiles() as $tile) {
if (!($tile instanceof Sign)) continue;
$sign = $tile->getText();
$text = $this->getOwner()->getLiveSign($sign);
if ($text == null) continue;
$pk = new TileEntityDataPacket();
$pk = new BlockEntityDataPacket();
$data = $tile->getSpawnCompound();
$data->Text1 = new StringTag("Text1",$text[0]);
$data->Text2 = new StringTag("Text2",$text[1]);
Expand Down