mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Sign: remove non-standard broken bad solution for editing
this never really worked properly and is a bad idea anyway. This was the cause of many sign-going-blank bugs before it was broken (by me), and since it's broken it's now useless. I don't think there's any practical way to make this work properly, so I leave it up to plugins to decide whether or not they want to cancel sign editing in protected areas. PocketMine-MP built-in spawn protection will already block this by default anyway.
This commit is contained in:
parent
b1cb63ebd6
commit
b6317fa7ce
@ -24,9 +24,7 @@ declare(strict_types=1);
|
||||
namespace pocketmine\tile;
|
||||
|
||||
use pocketmine\event\block\SignChangeEvent;
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\level\Level;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\Player;
|
||||
@ -35,7 +33,6 @@ use pocketmine\utils\TextFormat;
|
||||
class Sign extends Spawnable{
|
||||
public const TAG_TEXT_BLOB = "Text";
|
||||
public const TAG_TEXT_LINE = "Text%d"; //sprintf()able
|
||||
public const TAG_CREATOR = "Creator";
|
||||
|
||||
/** @var string[] */
|
||||
protected $text = ["", "", "", ""];
|
||||
@ -66,8 +63,6 @@ class Sign extends Spawnable{
|
||||
$textKey = sprintf(self::TAG_TEXT_LINE, $i);
|
||||
$this->namedtag->setString($textKey, $this->getLine($i - 1));
|
||||
}
|
||||
|
||||
$this->namedtag->removeTag(self::TAG_CREATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -154,11 +149,6 @@ class Sign extends Spawnable{
|
||||
$removeFormat = $player->getRemoveFormat();
|
||||
|
||||
$ev = new SignChangeEvent($this->getBlock(), $player, array_map(function(string $line) use ($removeFormat){ return TextFormat::clean($line, $removeFormat); }, $lines));
|
||||
|
||||
if($this->namedtag->hasTag(self::TAG_CREATOR, StringTag::class) and $this->namedtag->getString(self::TAG_CREATOR) !== $player->getRawUniqueId()){
|
||||
$ev->setCancelled();
|
||||
}
|
||||
|
||||
$this->level->getServer()->getPluginManager()->callEvent($ev);
|
||||
|
||||
if(!$ev->isCancelled()){
|
||||
@ -169,10 +159,4 @@ class Sign extends Spawnable{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected static function createAdditionalNBT(CompoundTag $nbt, Vector3 $pos, ?int $face = null, ?Item $item = null, ?Player $player = null) : void{
|
||||
if($player !== null){
|
||||
$nbt->setString(self::TAG_CREATOR, $player->getRawUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user