From eedea4998bf77d9d6436e7f000de37596fe8d91e Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sat, 29 Dec 2018 11:28:25 +0000 Subject: [PATCH] Terminal: Added write() and writeLine() to allow easily emitting Minecraft-formatted text to the console --- src/pocketmine/utils/MainLogger.php | 2 +- src/pocketmine/utils/Terminal.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/pocketmine/utils/MainLogger.php b/src/pocketmine/utils/MainLogger.php index 83d0f379b..06d11da64 100644 --- a/src/pocketmine/utils/MainLogger.php +++ b/src/pocketmine/utils/MainLogger.php @@ -307,7 +307,7 @@ class MainLogger extends \AttachableThreadedLogger{ } $this->synchronized(function() use ($message, $level, $time) : void{ - echo Terminal::toANSI($message) . PHP_EOL; + Terminal::writeLine($message); foreach($this->attachments as $attachment){ $attachment->call($level, $message); diff --git a/src/pocketmine/utils/Terminal.php b/src/pocketmine/utils/Terminal.php index dd52d6951..a3f6058c9 100644 --- a/src/pocketmine/utils/Terminal.php +++ b/src/pocketmine/utils/Terminal.php @@ -263,4 +263,23 @@ abstract class Terminal{ return $newString; } + + /** + * Emits a string containing Minecraft colour codes to the console formatted with native colours. + * + * @param string $line + */ + public static function write(string $line) : void{ + echo self::toANSI($line); + } + + /** + * Emits a string containing Minecraft colour codes to the console formatted with native colours, followed by a + * newline character. + * + * @param string $line + */ + public static function writeLine(string $line) : void{ + echo self::toANSI($line) . PHP_EOL; + } }