Files
PocketMine-MP/src/event/block/SignChangeEvent.php
Dylan T. b2d0be5b75 Support editing the back side of signs (#6774)
* Deprecate BaseSign get/set/updateText(), add get/set/updateFaceText() which accepts true/false for front/back
* add isFrontFace() to SignChangeEvent
* add optional frontFace to Player::openSignEditor()
* add BaseSign::getFacingDegrees() and getHitboxCenter() which need to be implemented by subclasses
2025-09-01 17:15:29 +01:00

81 lines
1.9 KiB
PHP

<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\block;
use pocketmine\block\BaseSign;
use pocketmine\block\utils\SignText;
use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait;
use pocketmine\player\Player;
/**
* Called when a sign's text is changed by a player.
*/
class SignChangeEvent extends BlockEvent implements Cancellable{
use CancellableTrait;
private SignText $oldText;
public function __construct(
private BaseSign $sign,
private Player $player,
private SignText $text,
private bool $frontFace = true
){
$this->oldText = $this->sign->getFaceText($this->frontFace);
parent::__construct($sign);
}
public function getSign() : BaseSign{
return $this->sign;
}
public function getPlayer() : Player{
return $this->player;
}
/**
* Returns the text currently on the sign.
*/
public function getOldText() : SignText{
return $this->oldText;
}
/**
* Returns the text which will be on the sign after the event.
*/
public function getNewText() : SignText{
return $this->text;
}
/**
* Sets the text to be written on the sign after the event.
*/
public function setNewText(SignText $text) : void{
$this->text = $text;
}
public function isFrontFace() : bool{ return $this->frontFace; }
}