Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add of new minecraft colours #5838

Open
wants to merge 7 commits into
base: minor-next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 48 additions & 8 deletions src/utils/Terminal.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ abstract class Terminal{
public static string $COLOR_YELLOW = "";
public static string $COLOR_WHITE = "";
public static string $COLOR_MINECOIN_GOLD = "";
public static string $COLOR_MATERIAL_QUARTZ = "";
public static string $COLOR_MATERIAL_IRON = "";
public static string $COLOR_MATERIAL_NETHERITE = "";
public static string $COLOR_MATERIAL_REDSTONE = "";
public static string $COLOR_MATERIAL_COPPER = "";
public static string $COLOR_MATERIAL_GOLD = "";
public static string $COLOR_MATERIAL_EMERALD = "";
public static string $COLOR_MATERIAL_DIAMOND = "";
public static string $COLOR_MATERIAL_LAPIS = "";
public static string $COLOR_MATERIAL_AMETHYST = "";

private static ?bool $formattingCodes = null;

Expand Down Expand Up @@ -111,6 +121,16 @@ protected static function getFallbackEscapeCodes() : void{
self::$COLOR_YELLOW = $color(227);
self::$COLOR_WHITE = $color(231);
self::$COLOR_MINECOIN_GOLD = $color(184);
self::$COLOR_MATERIAL_QUARTZ = $color(188);
self::$COLOR_MATERIAL_IRON = $color(188);
roimee6 marked this conversation as resolved.
Show resolved Hide resolved
self::$COLOR_MATERIAL_NETHERITE = $color(59);
self::$COLOR_MATERIAL_REDSTONE = $color(124);
self::$COLOR_MATERIAL_COPPER = $color(174);
self::$COLOR_MATERIAL_GOLD = $color(179);
self::$COLOR_MATERIAL_EMERALD = $color(35);
self::$COLOR_MATERIAL_DIAMOND = $color(79);
self::$COLOR_MATERIAL_LAPIS = $color(60);
self::$COLOR_MATERIAL_AMETHYST = $color(140);
}

protected static function getEscapeCodes() : void{
Expand Down Expand Up @@ -144,15 +164,25 @@ protected static function getEscapeCodes() : void{
self::$COLOR_YELLOW = $colors >= 256 ? $setaf(227) : $setaf(11);
self::$COLOR_WHITE = $colors >= 256 ? $setaf(231) : $setaf(15);
self::$COLOR_MINECOIN_GOLD = $colors >= 256 ? $setaf(184) : $setaf(11);
self::$COLOR_MATERIAL_QUARTZ = $colors >= 256 ? $setaf(188) : $setaf(14);
self::$COLOR_MATERIAL_IRON = $colors >= 256 ? $setaf(188) : $setaf(7);
roimee6 marked this conversation as resolved.
Show resolved Hide resolved
self::$COLOR_MATERIAL_NETHERITE = $colors >= 256 ? $setaf(59) : $setaf(8);
self::$COLOR_MATERIAL_REDSTONE = $colors >= 256 ? $setaf(124) : $setaf(9);
self::$COLOR_MATERIAL_COPPER = $colors >= 256 ? $setaf(174) : $setaf(3);
self::$COLOR_MATERIAL_GOLD = $colors >= 256 ? $setaf(179) : $setaf(3);
self::$COLOR_MATERIAL_EMERALD = $colors >= 256 ? $setaf(35) : $setaf(2);
self::$COLOR_MATERIAL_DIAMOND = $colors >= 256 ? $setaf(79) : $setaf(6);
self::$COLOR_MATERIAL_LAPIS = $colors >= 256 ? $setaf(60) : $setaf(12);
self::$COLOR_MATERIAL_AMETHYST = $colors >= 256 ? $setaf(140) : $setaf(5);
}else{
self::$COLOR_BLACK = self::$COLOR_DARK_GRAY = $setaf(0);
self::$COLOR_RED = self::$COLOR_DARK_RED = $setaf(1);
self::$COLOR_GREEN = self::$COLOR_DARK_GREEN = $setaf(2);
self::$COLOR_YELLOW = self::$COLOR_GOLD = self::$COLOR_MINECOIN_GOLD = $setaf(3);
self::$COLOR_BLUE = self::$COLOR_DARK_BLUE = $setaf(4);
self::$COLOR_LIGHT_PURPLE = self::$COLOR_PURPLE = $setaf(5);
self::$COLOR_AQUA = self::$COLOR_DARK_AQUA = $setaf(6);
self::$COLOR_GRAY = self::$COLOR_WHITE = $setaf(7);
self::$COLOR_BLACK = self::$COLOR_DARK_GRAY = self::$COLOR_MATERIAL_NETHERITE = $setaf(0);
self::$COLOR_RED = self::$COLOR_DARK_RED = self::$COLOR_MATERIAL_REDSTONE = self::$COLOR_MATERIAL_COPPER = $setaf(1);
self::$COLOR_GREEN = self::$COLOR_DARK_GREEN = self::$COLOR_MATERIAL_EMERALD = $setaf(2);
self::$COLOR_YELLOW = self::$COLOR_GOLD = self::$COLOR_MINECOIN_GOLD = self::$COLOR_MATERIAL_GOLD = $setaf(3);
self::$COLOR_BLUE = self::$COLOR_DARK_BLUE = self::$COLOR_MATERIAL_LAPIS = $setaf(4);
self::$COLOR_LIGHT_PURPLE = self::$COLOR_PURPLE = self::$COLOR_MATERIAL_AMETHYST = $setaf(5);
self::$COLOR_AQUA = self::$COLOR_DARK_AQUA = self::$COLOR_MATERIAL_DIAMOND = $setaf(6);
self::$COLOR_GRAY = self::$COLOR_WHITE = self::$COLOR_MATERIAL_QUARTZ = self::$COLOR_MATERIAL_IRON = $setaf(7);
}
}

Expand Down Expand Up @@ -215,6 +245,16 @@ public static function toANSI(string $string) : string{
TextFormat::YELLOW => Terminal::$COLOR_YELLOW,
TextFormat::WHITE => Terminal::$COLOR_WHITE,
TextFormat::MINECOIN_GOLD => Terminal::$COLOR_MINECOIN_GOLD,
TextFormat::MATERIAL_QUARTZ => Terminal::$COLOR_MATERIAL_QUARTZ,
TextFormat::MATERIAL_IRON => Terminal::$COLOR_MATERIAL_IRON,
TextFormat::MATERIAL_NETHERITE => Terminal::$COLOR_MATERIAL_NETHERITE,
TextFormat::MATERIAL_REDSTONE => Terminal::$COLOR_MATERIAL_REDSTONE,
TextFormat::MATERIAL_COPPER => Terminal::$COLOR_MATERIAL_COPPER,
TextFormat::MATERIAL_GOLD => Terminal::$COLOR_MATERIAL_GOLD,
TextFormat::MATERIAL_EMERALD => Terminal::$COLOR_MATERIAL_EMERALD,
TextFormat::MATERIAL_DIAMOND => Terminal::$COLOR_MATERIAL_DIAMOND,
TextFormat::MATERIAL_LAPIS => Terminal::$COLOR_MATERIAL_LAPIS,
TextFormat::MATERIAL_AMETHYST => Terminal::$COLOR_MATERIAL_AMETHYST,
default => $token,
};
}
Expand Down
26 changes: 24 additions & 2 deletions src/utils/TextFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ abstract class TextFormat{
public const YELLOW = TextFormat::ESCAPE . "e";
public const WHITE = TextFormat::ESCAPE . "f";
public const MINECOIN_GOLD = TextFormat::ESCAPE . "g";
public const MATERIAL_QUARTZ = TextFormat::ESCAPE . "h";
public const MATERIAL_IRON = TextFormat::ESCAPE . "i";
public const MATERIAL_NETHERITE = TextFormat::ESCAPE . "j";
public const MATERIAL_REDSTONE = TextFormat::ESCAPE . "m";
public const MATERIAL_COPPER = TextFormat::ESCAPE . "n";
public const MATERIAL_GOLD = TextFormat::ESCAPE . "p";
public const MATERIAL_EMERALD = TextFormat::ESCAPE . "q";
public const MATERIAL_DIAMOND = TextFormat::ESCAPE . "s";
public const MATERIAL_LAPIS = TextFormat::ESCAPE . "t";
public const MATERIAL_AMETHYST = TextFormat::ESCAPE . "u";

public const COLORS = [
self::BLACK => self::BLACK,
Expand All @@ -82,12 +92,24 @@ abstract class TextFormat{
self::YELLOW => self::YELLOW,
self::WHITE => self::WHITE,
self::MINECOIN_GOLD => self::MINECOIN_GOLD,
self::MATERIAL_QUARTZ => self::MATERIAL_QUARTZ,
self::MATERIAL_IRON => self::MATERIAL_IRON,
self::MATERIAL_NETHERITE => self::MATERIAL_NETHERITE,
self::MATERIAL_REDSTONE => self::MATERIAL_REDSTONE,
self::MATERIAL_COPPER => self::MATERIAL_COPPER,
self::MATERIAL_GOLD => self::MATERIAL_GOLD,
self::MATERIAL_EMERALD => self::MATERIAL_EMERALD,
self::MATERIAL_DIAMOND => self::MATERIAL_DIAMOND,
self::MATERIAL_LAPIS => self::MATERIAL_LAPIS,
self::MATERIAL_AMETHYST => self::MATERIAL_AMETHYST,
];

public const OBFUSCATED = TextFormat::ESCAPE . "k";
public const BOLD = TextFormat::ESCAPE . "l";
public const STRIKETHROUGH = TextFormat::ESCAPE . "m";
public const UNDERLINE = TextFormat::ESCAPE . "n";
/** @deprecated */
roimee6 marked this conversation as resolved.
Show resolved Hide resolved
public const STRIKETHROUGH = "";
/** @deprecated */
public const UNDERLINE = "";
public const ITALIC = TextFormat::ESCAPE . "o";

public const FORMATS = [
Expand Down