PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
DyeColor.php
1<?php
2
3/*
4 *
5 * ____ _ _ __ __ _ __ __ ____
6 * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8 * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9 * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * @author PocketMine Team
17 * @link http://www.pocketmine.net/
18 *
19 *
20 */
21
22declare(strict_types=1);
23
24namespace pocketmine\block\utils;
25
27use pocketmine\utils\LegacyEnumShimTrait;
28use function spl_object_id;
29
53enum DyeColor{
54 use LegacyEnumShimTrait;
55
56 case WHITE;
57 case ORANGE;
58 case MAGENTA;
59 case LIGHT_BLUE;
60 case YELLOW;
61 case LIME;
62 case PINK;
63 case GRAY;
64 case LIGHT_GRAY;
65 case CYAN;
66 case PURPLE;
67 case BLUE;
68 case BROWN;
69 case GREEN;
70 case RED;
71 case BLACK;
72
78 private static function meta(string $displayName, Color $rgbValue) : array{
79 return [$displayName, $rgbValue];
80 }
81
85 private function getMetadata() : array{
87 static $cache = [];
88
89 return $cache[spl_object_id($this)] ??= match($this){
90 self::WHITE => self::meta("White", new Color(0xf0, 0xf0, 0xf0)),
91 self::ORANGE => self::meta("Orange", new Color(0xf9, 0x80, 0x1d)),
92 self::MAGENTA => self::meta("Magenta", new Color(0xc7, 0x4e, 0xbd)),
93 self::LIGHT_BLUE => self::meta("Light Blue", new Color(0x3a, 0xb3, 0xda)),
94 self::YELLOW => self::meta("Yellow", new Color(0xfe, 0xd8, 0x3d)),
95 self::LIME => self::meta("Lime", new Color(0x80, 0xc7, 0x1f)),
96 self::PINK => self::meta("Pink", new Color(0xf3, 0x8b, 0xaa)),
97 self::GRAY => self::meta("Gray", new Color(0x47, 0x4f, 0x52)),
98 self::LIGHT_GRAY => self::meta("Light Gray", new Color(0x9d, 0x9d, 0x97)),
99 self::CYAN => self::meta("Cyan", new Color(0x16, 0x9c, 0x9c)),
100 self::PURPLE => self::meta("Purple", new Color(0x89, 0x32, 0xb8)),
101 self::BLUE => self::meta("Blue", new Color(0x3c, 0x44, 0xaa)),
102 self::BROWN => self::meta("Brown", new Color(0x83, 0x54, 0x32)),
103 self::GREEN => self::meta("Green", new Color(0x5e, 0x7c, 0x16)),
104 self::RED => self::meta("Red", new Color(0xb0, 0x2e, 0x26)),
105 self::BLACK => self::meta("Black", new Color(0x1d, 0x1d, 0x21)),
106 };
107 }
108
109 public function getDisplayName() : string{
110 return $this->getMetadata()[0];
111 }
112
113 public function getRgbValue() : Color{
114 return $this->getMetadata()[1];
115 }
116}