I'm working on a plugin called HealthStatus which has multiple ways of showing a players health and has has support for custom amounts of health but when I use \n in the players name the players name is no longer centered but the HealthStatus is. If anybody could tell me how to fix this issue it would be greatly appreciated! Pictures:
Actually I played with it a bit more and found out that nothing centers when you set the players name.
This snippet adds spaces before short lines. PHP: $name = "CrazedMiner \nIs\nNot so nooby";$lines = explode("\", $name);$maxLength=0;foreach($lines as $line) { $maxLength = max($maxLength, strlen($line)) ;} foreach($lines as &$line) { $delta = ($maxLength - strlen($line)); $line = str_repeat(" ", $delta / 2);}$name = implode("\n", $lines); Note that this method doesn't work well because I assumed that all characters have the same width while it isn't true.