mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-03 16:45:13 +00:00
Better BlockEntityDataPacket handling
This commit is contained in:
@ -2,11 +2,11 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
@ -15,16 +15,19 @@
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\tile;
|
||||
|
||||
use pocketmine\event\block\SignChangeEvent;
|
||||
use pocketmine\level\format\Chunk;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\utils\TextFormat;
|
||||
|
||||
class Sign extends Spawnable{
|
||||
|
||||
@ -82,4 +85,30 @@ class Sign extends Spawnable{
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateCompoundTag(CompoundTag $nbt, Player $player) : bool{
|
||||
if($nbt["id"] !== Tile::SIGN){
|
||||
return false;
|
||||
}
|
||||
|
||||
$ev = new SignChangeEvent($this->getBlock(), $player, [
|
||||
TextFormat::clean($nbt["Text1"], ($removeFormat = $player->getRemoveFormat())),
|
||||
TextFormat::clean($nbt["Text2"], $removeFormat),
|
||||
TextFormat::clean($nbt["Text3"], $removeFormat),
|
||||
TextFormat::clean($nbt["Text4"], $removeFormat)
|
||||
]);
|
||||
|
||||
if(!isset($this->namedtag->Creator) or $this->namedtag["Creator"] !== $player->getRawUniqueId()){
|
||||
$ev->setCancelled();
|
||||
}
|
||||
|
||||
$this->level->getServer()->getPluginManager()->callEvent($ev);
|
||||
|
||||
if(!$ev->isCancelled()){
|
||||
$this->setText(...$ev->getLines());
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user