Skip to content

Commit

Permalink
Merge branch 'dev/4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
fuyutsuki committed Mar 26, 2021
2 parents a2382db + 5e376ad commit de42c3b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/readme/ja_jp.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ Texterは複数ワールドに対応した、FloatingText(浮き文字)の追加

#### 変数

[Mineflow >= 1.3](https://poggit.pmmp.io/p/Mineflow)を導入している場合、浮き文字に変数を適用することが出来ます。
[Mineflow >= 2.0](https://poggit.pmmp.io/p/Mineflow)を導入している場合、浮き文字に変数を適用することが出来ます。

|変数名||使用できるプロパティ|
|:----|:-|:----------------|
|`server_name`|string||
|`microtime`|number||
|`time`|string||
|`date`|string||
|`default_level`|string||
|`default_world`|string||
|`player`|Player|[Mineflow#Player](https://github.com/aieuo/Mineflow#player)|
|`ft`|FloatingText|`name(string), pos(Position), spacing(Position)`|

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ All commands have permissions set to `texter.command.txt` (OP only).

#### Variables

If you have installed [Mineflow >= 1.3](https://poggit.pmmp.io/p/Mineflow), you can apply variables to floating characters.
If you have installed [Mineflow >= 2.0](https://poggit.pmmp.io/p/Mineflow), you can apply variables to floating characters.

|name|type|available properties|
|:----|:-|:----------------|
|`server_name`|string||
|`microtime`|number||
|`time`|string||
|`date`|string|||`default_level`|string
|`default_level`|string||||`player`|Player
|`date`|string||
|`default_world`|string||
|`player`|Player|[Mineflow#Player](https://github.com/aieuo/Mineflow#player)|
|`ft`|FloatingText|`name(string), pos(Position without world), spacing(Position without world)`|

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
namespace jp\mcbe\fuyutsuki\Texter\mineflow\variable;

use aieuo\mineflow\variable\DummyVariable;
use aieuo\mineflow\variable\object\PositionObjectVariable;
use aieuo\mineflow\variable\ListVariable;
use aieuo\mineflow\variable\object\Vector3ObjectVariable;
use aieuo\mineflow\variable\ObjectVariable;
use aieuo\mineflow\variable\StringVariable;
use aieuo\mineflow\variable\Variable;
use jp\mcbe\fuyutsuki\Texter\text\FloatingTextCluster;
use pocketmine\level\Position;

/**
* Class FloatingTextObjectVariable
Expand All @@ -20,25 +20,33 @@ class FloatingTextObjectVariable extends ObjectVariable {

public const DEFAULT_NAME = "ft";

public const PROPERTY_NAME = "name";
public const PROPERTY_POSITION = "pos";
public const PROPERTY_NAME = "name";
public const PROPERTY_SPACING = "spacing";
public const PROPERTY_TEXTS = "texts";

public function __construct(FloatingTextCluster $floatingText, string $name = self::DEFAULT_NAME, ?string $str = null) {
parent::__construct($floatingText, $name, $str);
public function __construct(FloatingTextCluster $floatingTextCluster, ?string $str = null) {
parent::__construct($floatingTextCluster, $str);
}

public function getValueFromIndex(string $index): ?Variable {
$floatingText = $this->floatingText();
$floatingTextCluster = $this->floatingText();
switch ($index) {
case self::PROPERTY_POSITION:
$variable = new Vector3ObjectVariable($floatingTextCluster->position(), self::PROPERTY_POSITION);
break;
case self::PROPERTY_NAME:
$variable = new StringVariable($floatingText->name(), self::PROPERTY_NAME);
$variable = new StringVariable($floatingTextCluster->name());
break;
case self::PROPERTY_POSITION:// TODO: Mineflow should implements Vector3ObjectVariable
$variable = new PositionObjectVariable(Position::fromObject($floatingText->position()), self::PROPERTY_POSITION);
case self::PROPERTY_SPACING:
$variable = new Vector3ObjectVariable($floatingTextCluster->spacing(), self::PROPERTY_SPACING);
break;
case self::PROPERTY_SPACING:// TODO: Mineflow should implements Vector3ObjectVariable
$variable = new PositionObjectVariable(Position::fromObject($floatingText->spacing()), self::PROPERTY_SPACING);
case self::PROPERTY_TEXTS:
$texts = [];
foreach ($floatingTextCluster->all() as $floatingText) {
$texts[] = new StringVariable($floatingText->text());
}
$variable = new ListVariable($texts, self::PROPERTY_TEXTS);
break;
default:
$variable = null;
Expand All @@ -52,11 +60,12 @@ public function floatingText(): FloatingTextCluster {
return $value;
}

public static function getValuesDummy(string $name): array {
public static function getValuesDummy(): array {
return [
new DummyVariable("{$name}." . self::PROPERTY_NAME, DummyVariable::STRING),
new DummyVariable("{$name}." . self::PROPERTY_POSITION, DummyVariable::POSITION),
new DummyVariable("{$name}." . self::PROPERTY_SPACING, DummyVariable::POSITION)
self::PROPERTY_POSITION => new DummyVariable(DummyVariable::VECTOR3),
self::PROPERTY_NAME => new DummyVariable(DummyVariable::STRING),
self::PROPERTY_SPACING => new DummyVariable(DummyVariable::VECTOR3),
self::PROPERTY_TEXTS => new DummyVariable(DummyVariable::LIST),
];
}

Expand Down

0 comments on commit de42c3b

Please sign in to comment.