mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Added proper TextWrap width
This commit is contained in:
parent
24c76acf30
commit
afdf7bc2b9
@ -2240,7 +2240,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;git
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2250,14 +2250,14 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
*/
|
||||
public function sendMessage($message){
|
||||
if($this->removeFormat !== false){
|
||||
$message = TextWrapper::wrap($message);
|
||||
$message = TextWrapper::wrap(TextFormat::clean($message));
|
||||
}
|
||||
$mes = explode("\n", $message);
|
||||
foreach($mes as $m){
|
||||
if($m !== ""){
|
||||
$pk = new MessagePacket;
|
||||
$pk->source = ""; //Do not use this ;)
|
||||
$pk->message = $this->removeFormat === false ? $m : TextFormat::clean($m);
|
||||
$pk->message = $m;
|
||||
$this->dataPacket($pk);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ abstract class TextWrapper{
|
||||
6, 6, 6, 4, 6, 6, 6, 6, 6, 6, 5, 2, 5, 7
|
||||
];
|
||||
|
||||
const CHAT_WINDOW_WIDTH = 320;
|
||||
const CHAT_WINDOW_WIDTH = 240;
|
||||
const CHAT_STRING_LENGTH = 119;
|
||||
|
||||
private static $allowedChars = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_abcdefghijklmnopqrstuvwxyz{|}~";
|
||||
@ -57,7 +57,6 @@ abstract class TextWrapper{
|
||||
$char = $text{$i};
|
||||
|
||||
if($char === "\n"){
|
||||
$result .= "\n";
|
||||
$lineLength = 0;
|
||||
$lineWidth = 0;
|
||||
}elseif(isset(self::$allowedCharsArray[$char])){
|
||||
@ -71,10 +70,9 @@ abstract class TextWrapper{
|
||||
|
||||
++$lineLength;
|
||||
$lineWidth += $width;
|
||||
$result .= $char;
|
||||
}else{
|
||||
$result .= "\n";
|
||||
}
|
||||
|
||||
$result .= $char;
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
Loading…
x
Reference in New Issue
Block a user