From d86107e22ad49dd75fa4c8a867253f73f0095691 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 78562da77..df749f3c9 100644 --- a/src/pocketmine/utils/MainLogger.php +++ b/src/pocketmine/utils/MainLogger.php @@ -280,7 +280,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 f7c52a974..23c05be8a 100644 --- a/src/pocketmine/utils/Terminal.php +++ b/src/pocketmine/utils/Terminal.php @@ -256,4 +256,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; + } }