mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 09:49:50 +00:00
Merge branch 'stable'
This commit is contained in:
commit
209ae51a67
@ -36,6 +36,7 @@ use pocketmine\utils\TextFormat;
|
|||||||
use function array_map;
|
use function array_map;
|
||||||
use function assert;
|
use function assert;
|
||||||
use function floor;
|
use function floor;
|
||||||
|
use function strlen;
|
||||||
|
|
||||||
class Sign extends Transparent{
|
class Sign extends Transparent{
|
||||||
/** @var BlockIdentifierFlattened */
|
/** @var BlockIdentifierFlattened */
|
||||||
@ -151,8 +152,16 @@ class Sign extends Transparent{
|
|||||||
* @param SignText $text
|
* @param SignText $text
|
||||||
*
|
*
|
||||||
* @return bool if the sign update was successful.
|
* @return bool if the sign update was successful.
|
||||||
|
* @throws \UnexpectedValueException if the text payload is too large
|
||||||
*/
|
*/
|
||||||
public function updateText(Player $author, SignText $text) : bool{
|
public function updateText(Player $author, SignText $text) : bool{
|
||||||
|
$size = 0;
|
||||||
|
foreach($text->getLines() as $line){
|
||||||
|
$size += strlen($line);
|
||||||
|
}
|
||||||
|
if($size > 1000){
|
||||||
|
throw new \UnexpectedValueException($author->getName() . " tried to write $size bytes of text onto a sign (bigger than max 1000)");
|
||||||
|
}
|
||||||
$removeFormat = $author->getRemoveFormat();
|
$removeFormat = $author->getRemoveFormat();
|
||||||
$ev = new SignChangeEvent($this, $author, new SignText(array_map(function(string $line) use ($removeFormat){
|
$ev = new SignChangeEvent($this, $author, new SignText(array_map(function(string $line) use ($removeFormat){
|
||||||
return TextFormat::clean($line, $removeFormat);
|
return TextFormat::clean($line, $removeFormat);
|
||||||
|
@ -115,8 +115,12 @@ class WhitelistCommand extends VanillaCommand{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function badPerm(CommandSender $sender, string $perm) : bool{
|
private function badPerm(CommandSender $sender, string $subcommand) : bool{
|
||||||
if(!$sender->hasPermission("pocketmine.command.whitelist.$perm")){
|
static $map = [
|
||||||
|
"on" => "enable",
|
||||||
|
"off" => "disable"
|
||||||
|
];
|
||||||
|
if(!$sender->hasPermission("pocketmine.command.whitelist." . ($map[$subcommand] ?? $subcommand))){
|
||||||
$sender->sendMessage($sender->getServer()->getLanguage()->translateString(TextFormat::RED . "%commands.generic.permission"));
|
$sender->sendMessage($sender->getServer()->getLanguage()->translateString(TextFormat::RED . "%commands.generic.permission"));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -464,9 +464,13 @@ class SimpleSessionHandler extends SessionHandler{
|
|||||||
throw new BadPacketException("Invalid sign text update: " . $e->getMessage(), 0, $e);
|
throw new BadPacketException("Invalid sign text update: " . $e->getMessage(), 0, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
if(!$block->updateText($this->player, $text)){
|
if(!$block->updateText($this->player, $text)){
|
||||||
$this->player->getLevel()->sendBlocks([$this->player], [$block]);
|
$this->player->getLevel()->sendBlocks([$this->player], [$block]);
|
||||||
}
|
}
|
||||||
|
}catch(\UnexpectedValueException $e){
|
||||||
|
throw new BadPacketException($e->getMessage(), 0, $e);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user