3
0
Fork 0
This repository has been archived on 2024-11-14. You can view files and clone it, but cannot push or open issues or pull requests.
ThemeParkPlus-Panel/app/Color/MinecraftColor.php

53 lines
1.1 KiB
PHP
Raw Permalink Normal View History

<?php
namespace App\Color;
class MinecraftColor {
private static $array = [
2021-06-29 20:05:00 +00:00
"&0" => "#000000",
"&1" => "#0000AA",
"&2" => "#00AA00",
"&3" => "#00AAAA",
"&4" => "#AA0000",
"&5" => "#AA00AA",
"&6" => "#FFAA00",
"&7" => "#AAAAAA",
"&8" => "#555555",
"&9" => "#5555FF",
"&a" => "#55FF55",
"&b" => "#55FFFF",
"&c" => "#FF5555",
"&d" => "#FF55FF",
"&e" => "#FFFF55",
"&f" => "#FFFFFF"
];
private static $none = [
2021-06-29 20:05:00 +00:00
"&k", "&l", "&m", "&n", "&o", "&r",
];
public static function color($text) {
foreach(self::$array as $key => $value) {
$str = str_replace($key, $value, $text);
if($str !== $text) {
return $value;
}
}
return "";
}
public static function stripColor($text) {
foreach(self::$array as $key => $value) {
$text = str_replace($key, "", $text);
}
foreach(self::$none as $key) {
$text = str_replace($key, "", $text);
}
return $text;
}
}