Terminal: Added write() and writeLine() to allow easily emitting Minecraft-formatted text to the console

This commit is contained in:
Dylan K. Taylor 2018-12-29 11:28:25 +00:00
parent 4e5a80c481
commit eedea4998b
2 changed files with 20 additions and 1 deletions

View File

@ -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);

View File

@ -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;
}
}