Fixing debug + Fixing positions bugs
This commit is contained in:
parent
dcd26a0fbf
commit
f86a9437c3
3 changed files with 42 additions and 2 deletions
|
@ -87,7 +87,7 @@ class DataBase extends SQLite3 {
|
|||
@return SQLite3Result|bool
|
||||
*/
|
||||
public function query($qry) {
|
||||
echo $qry . ";;";
|
||||
$this->getLogger()->debug($qry);
|
||||
$res = parent::query($qry);
|
||||
if($res instanceof \SQLite3Result) self::setNumRows($res);
|
||||
return $res;
|
||||
|
|
|
@ -214,6 +214,7 @@ class Game extends PluginTask /* Allows easy game running */ implements Listener
|
|||
public function getSpawn() : Vector3 {
|
||||
$data = $this->getMain()->getDatabase()->get("spawnpoint", ["table" => "Games", "name" => $this->getName()])->fetchArray()[0];
|
||||
$data = explode(",", $data);
|
||||
if(!isset($data[1])) return $this->getLevel()->getSafeSpawn();
|
||||
return new Vector3($data[0], $data[1], $data[2]);
|
||||
}
|
||||
|
||||
|
@ -225,6 +226,7 @@ class Game extends PluginTask /* Allows easy game running */ implements Listener
|
|||
public function getSeekerSpawn() : Vector3 {
|
||||
$data = $this->getMain()->getDatabase()->get("seekerspawn", ["table" => "Games", "name" => $this->getName()])->fetchArray()[0];
|
||||
$data = explode(",", $data);
|
||||
if(!isset($data[1])) return $this->getLevel()->getSafeSpawn();
|
||||
return new Vector3($data[0], $data[1], $data[2]);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,9 @@ namespace Ad5001\HideAndSeek\tasks;
|
|||
use pocketmine\Server;
|
||||
use pocketmine\scheduler\PluginTask;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\tile\Sign;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
|
||||
use Ad5001\HideAndSeek\Main;
|
||||
|
||||
|
@ -32,7 +35,42 @@ class Task1 extends PluginTask {
|
|||
|
||||
|
||||
public function onRun($tick) {
|
||||
$this->main->getLogger()->debug('Task ' . get_class($this) . ' is running on $tick');
|
||||
foreach($this->server->getLevels() as $lvl) {
|
||||
foreach($lvl->getTiles() as $t) {
|
||||
if($t instanceof Sign) {
|
||||
if(isset($t->namedtag->hideAndSeekSignData)) {
|
||||
if(!isset($t->namedtag->hideAndSeekSignData->model)) {
|
||||
$t->namedtag->hideAndSeekSignData->model = new ListTag("model", [
|
||||
1 => $t->namedtag->Text1,
|
||||
2 => $t->namedtag->Text2,
|
||||
3 => $t->namedtag->Text3,
|
||||
4 => $t->namedtag->Text4
|
||||
]);
|
||||
}
|
||||
$line1 = $this->parse((string) $t->namedtag->hideAndSeekSignData->model[1], $t);
|
||||
$line2 = $this->parse((string) $t->namedtag->hideAndSeekSignData->model[2], $t);
|
||||
$line3 = $this->parse((string) $t->namedtag->hideAndSeekSignData->model[3], $t);
|
||||
$line4 = $this->parse((string) $t->namedtag->hideAndSeekSignData->model[4], $t);
|
||||
$t->setText($line1, $line2, $line3, $line4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Parses the text of the sign
|
||||
@param $string string
|
||||
@param $sign \pocketmine\tile\Sign
|
||||
@return string
|
||||
*/
|
||||
public function parse(string $string, Sign $sign) : string {
|
||||
$game = $this->main->getGameManager()->getGameByName($sign->namedtag->hideAndSeekSignData->level);
|
||||
$str = str_ireplace("{world}", $sign->namedtag->hideAndSeekSignData->level);
|
||||
$str = str_ireplace("{maxp}", $game->getMaxPlayers());
|
||||
$str = str_ireplace("{pls}", count($game->getPlayers()));
|
||||
$str = str_ireplace("{world}", $sign->namedtag->hideAndSeekSignData->level);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue