Skip to content

Commit e29aa2f

Browse files
authored
Added resin material color (#6622)
1 parent 9b3b452 commit e29aa2f

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/utils/Terminal.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ abstract class Terminal{
6969
public static string $COLOR_MATERIAL_DIAMOND = "";
7070
public static string $COLOR_MATERIAL_LAPIS = "";
7171
public static string $COLOR_MATERIAL_AMETHYST = "";
72+
public static string $COLOR_MATERIAL_RESIN = "";
7273

7374
private static ?bool $formattingCodes = null;
7475

@@ -131,6 +132,7 @@ protected static function getFallbackEscapeCodes() : void{
131132
self::$COLOR_MATERIAL_DIAMOND = $color(37);
132133
self::$COLOR_MATERIAL_LAPIS = $color(24);
133134
self::$COLOR_MATERIAL_AMETHYST = $color(98);
135+
self::$COLOR_MATERIAL_RESIN = $color(208);
134136
}
135137

136138
protected static function getEscapeCodes() : void{
@@ -174,11 +176,12 @@ protected static function getEscapeCodes() : void{
174176
self::$COLOR_MATERIAL_DIAMOND = $colors >= 256 ? $setaf(37) : $setaf(14);
175177
self::$COLOR_MATERIAL_LAPIS = $colors >= 256 ? $setaf(24) : $setaf(12);
176178
self::$COLOR_MATERIAL_AMETHYST = $colors >= 256 ? $setaf(98) : $setaf(13);
179+
self::$COLOR_MATERIAL_RESIN = $colors >= 256 ? $setaf(208) : $setaf(11);
177180
}else{
178181
self::$COLOR_BLACK = self::$COLOR_DARK_GRAY = self::$COLOR_MATERIAL_NETHERITE = $setaf(0);
179182
self::$COLOR_RED = self::$COLOR_DARK_RED = self::$COLOR_MATERIAL_REDSTONE = self::$COLOR_MATERIAL_COPPER = $setaf(1);
180183
self::$COLOR_GREEN = self::$COLOR_DARK_GREEN = self::$COLOR_MATERIAL_EMERALD = $setaf(2);
181-
self::$COLOR_YELLOW = self::$COLOR_GOLD = self::$COLOR_MINECOIN_GOLD = self::$COLOR_MATERIAL_GOLD = $setaf(3);
184+
self::$COLOR_YELLOW = self::$COLOR_GOLD = self::$COLOR_MINECOIN_GOLD = self::$COLOR_MATERIAL_GOLD = self::$COLOR_MATERIAL_RESIN = $setaf(3);
182185
self::$COLOR_BLUE = self::$COLOR_DARK_BLUE = self::$COLOR_MATERIAL_LAPIS = $setaf(4);
183186
self::$COLOR_LIGHT_PURPLE = self::$COLOR_PURPLE = self::$COLOR_MATERIAL_AMETHYST = $setaf(5);
184187
self::$COLOR_AQUA = self::$COLOR_DARK_AQUA = self::$COLOR_MATERIAL_DIAMOND = $setaf(6);
@@ -253,6 +256,7 @@ public static function toANSI(string $string) : string{
253256
TextFormat::MATERIAL_DIAMOND => Terminal::$COLOR_MATERIAL_DIAMOND,
254257
TextFormat::MATERIAL_LAPIS => Terminal::$COLOR_MATERIAL_LAPIS,
255258
TextFormat::MATERIAL_AMETHYST => Terminal::$COLOR_MATERIAL_AMETHYST,
259+
TextFormat::MATERIAL_RESIN => Terminal::$COLOR_MATERIAL_RESIN,
256260
default => $token,
257261
};
258262
}

src/utils/TextFormat.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ abstract class TextFormat{
7373
public const MATERIAL_DIAMOND = TextFormat::ESCAPE . "s";
7474
public const MATERIAL_LAPIS = TextFormat::ESCAPE . "t";
7575
public const MATERIAL_AMETHYST = TextFormat::ESCAPE . "u";
76+
public const MATERIAL_RESIN = TextFormat::ESCAPE . "v";
7677

7778
public const COLORS = [
7879
self::BLACK => self::BLACK,
@@ -102,6 +103,7 @@ abstract class TextFormat{
102103
self::MATERIAL_DIAMOND => self::MATERIAL_DIAMOND,
103104
self::MATERIAL_LAPIS => self::MATERIAL_LAPIS,
104105
self::MATERIAL_AMETHYST => self::MATERIAL_AMETHYST,
106+
self::MATERIAL_RESIN => self::MATERIAL_RESIN,
105107
];
106108

107109
public const OBFUSCATED = TextFormat::ESCAPE . "k";
@@ -150,7 +152,7 @@ private static function preg_replace(string $pattern, string $replacement, strin
150152
* @return string[]
151153
*/
152154
public static function tokenize(string $string) : array{
153-
$result = preg_split("/(" . TextFormat::ESCAPE . "[0-9a-u])/u", $string, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
155+
$result = preg_split("/(" . TextFormat::ESCAPE . "[0-9a-v])/u", $string, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
154156
if($result === false) throw self::makePcreError();
155157
return $result;
156158
}
@@ -164,7 +166,7 @@ public static function clean(string $string, bool $removeFormat = true) : string
164166
$string = mb_scrub($string, 'UTF-8');
165167
$string = self::preg_replace("/[\x{E000}-\x{F8FF}]/u", "", $string); //remove unicode private-use-area characters (they might break the console)
166168
if($removeFormat){
167-
$string = str_replace(TextFormat::ESCAPE, "", self::preg_replace("/" . TextFormat::ESCAPE . "[0-9a-u]/u", "", $string));
169+
$string = str_replace(TextFormat::ESCAPE, "", self::preg_replace("/" . TextFormat::ESCAPE . "[0-9a-v]/u", "", $string));
168170
}
169171
return str_replace("\x1b", "", self::preg_replace("/\x1b[\\(\\][[0-9;\\[\\(]+[Bm]/u", "", $string));
170172
}
@@ -175,7 +177,7 @@ public static function clean(string $string, bool $removeFormat = true) : string
175177
* @param string $placeholder default "&"
176178
*/
177179
public static function colorize(string $string, string $placeholder = "&") : string{
178-
return self::preg_replace('/' . preg_quote($placeholder, "/") . '([0-9a-u])/u', TextFormat::ESCAPE . '$1', $string);
180+
return self::preg_replace('/' . preg_quote($placeholder, "/") . '([0-9a-v])/u', TextFormat::ESCAPE . '$1', $string);
179181
}
180182

181183
/**
@@ -252,6 +254,7 @@ public static function toHTML(string $string) : string{
252254
TextFormat::MATERIAL_DIAMOND => "color:#2cb9a8",
253255
TextFormat::MATERIAL_LAPIS => "color:#20487a",
254256
TextFormat::MATERIAL_AMETHYST => "color:#9a5cc5",
257+
TextFormat::MATERIAL_RESIN => "color:#fc7812",
255258
TextFormat::BOLD => "font-weight:bold",
256259
TextFormat::ITALIC => "font-style:italic",
257260
default => null

0 commit comments

Comments
 (0)