mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 00:39:45 +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 assert;
|
||||
use function floor;
|
||||
use function strlen;
|
||||
|
||||
class Sign extends Transparent{
|
||||
/** @var BlockIdentifierFlattened */
|
||||
@ -151,8 +152,16 @@ class Sign extends Transparent{
|
||||
* @param SignText $text
|
||||
*
|
||||
* @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{
|
||||
$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();
|
||||
$ev = new SignChangeEvent($this, $author, new SignText(array_map(function(string $line) use ($removeFormat){
|
||||
return TextFormat::clean($line, $removeFormat);
|
||||
|
@ -115,8 +115,12 @@ class WhitelistCommand extends VanillaCommand{
|
||||
return true;
|
||||
}
|
||||
|
||||
private function badPerm(CommandSender $sender, string $perm) : bool{
|
||||
if(!$sender->hasPermission("pocketmine.command.whitelist.$perm")){
|
||||
private function badPerm(CommandSender $sender, string $subcommand) : bool{
|
||||
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"));
|
||||
|
||||
return true;
|
||||
|
@ -464,8 +464,12 @@ class SimpleSessionHandler extends SessionHandler{
|
||||
throw new BadPacketException("Invalid sign text update: " . $e->getMessage(), 0, $e);
|
||||
}
|
||||
|
||||
if(!$block->updateText($this->player, $text)){
|
||||
$this->player->getLevel()->sendBlocks([$this->player], [$block]);
|
||||
try{
|
||||
if(!$block->updateText($this->player, $text)){
|
||||
$this->player->getLevel()->sendBlocks([$this->player], [$block]);
|
||||
}
|
||||
}catch(\UnexpectedValueException $e){
|
||||
throw new BadPacketException($e->getMessage(), 0, $e);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user