mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-03 16:45:13 +00:00
Make use of CompoundTag->hasTag()
This commit is contained in:
@ -41,14 +41,14 @@ class Sign extends Spawnable{
|
||||
protected $text = ["", "", "", ""];
|
||||
|
||||
public function __construct(Level $level, CompoundTag $nbt){
|
||||
if($nbt->getTag(self::TAG_TEXT_BLOB) instanceof StringTag){ //MCPE 1.2 save format
|
||||
if($nbt->hasTag(self::TAG_TEXT_BLOB, StringTag::class)){ //MCPE 1.2 save format
|
||||
$this->text = explode("\n", $nbt->getString(self::TAG_TEXT_BLOB));
|
||||
assert(count($this->text) === 4, "Too many lines!");
|
||||
$nbt->removeTag(self::TAG_TEXT_BLOB);
|
||||
}else{
|
||||
for($i = 1; $i <= 4; ++$i){
|
||||
$textKey = sprintf(self::TAG_TEXT_LINE, $i);
|
||||
if($nbt->getTag($textKey) instanceof StringTag){
|
||||
if($nbt->hasTag($textKey, StringTag::class)){
|
||||
$this->text[$i - 1] = $nbt->getString($textKey);
|
||||
$nbt->removeTag($textKey);
|
||||
}
|
||||
@ -140,8 +140,8 @@ class Sign extends Spawnable{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(($blob = $nbt->getString(self::TAG_TEXT_BLOB)) !== null){
|
||||
$lines = array_pad(explode("\n", $blob), 4, "");
|
||||
if($nbt->hasTag(self::TAG_TEXT_BLOB, StringTag::class)){
|
||||
$lines = array_pad(explode("\n", $nbt->getString(self::TAG_TEXT_BLOB)), 4, "");
|
||||
}else{
|
||||
$lines = [
|
||||
$nbt->getString(sprintf(self::TAG_TEXT_LINE, 1)),
|
||||
|
Reference in New Issue
Block a user