PocketMine-MP 5.21.2 git-a6534ecbbbcf369264567d27e5ed70f7f5be9816
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 function spl_object_id;
28
32enum DyeColor{
33 case WHITE;
34 case ORANGE;
35 case MAGENTA;
36 case LIGHT_BLUE;
37 case YELLOW;
38 case LIME;
39 case PINK;
40 case GRAY;
41 case LIGHT_GRAY;
42 case CYAN;
43 case PURPLE;
44 case BLUE;
45 case BROWN;
46 case GREEN;
47 case RED;
48 case BLACK;
49
55 private static function meta(string $displayName, Color $rgbValue) : array{
56 return [$displayName, $rgbValue];
57 }
58
62 private function getMetadata() : array{
64 static $cache = [];
65
66 return $cache[spl_object_id($this)] ??= match($this){
67 self::WHITE => self::meta("White", new Color(0xf0, 0xf0, 0xf0)),
68 self::ORANGE => self::meta("Orange", new Color(0xf9, 0x80, 0x1d)),
69 self::MAGENTA => self::meta("Magenta", new Color(0xc7, 0x4e, 0xbd)),
70 self::LIGHT_BLUE => self::meta("Light Blue", new Color(0x3a, 0xb3, 0xda)),
71 self::YELLOW => self::meta("Yellow", new Color(0xfe, 0xd8, 0x3d)),
72 self::LIME => self::meta("Lime", new Color(0x80, 0xc7, 0x1f)),
73 self::PINK => self::meta("Pink", new Color(0xf3, 0x8b, 0xaa)),
74 self::GRAY => self::meta("Gray", new Color(0x47, 0x4f, 0x52)),
75 self::LIGHT_GRAY => self::meta("Light Gray", new Color(0x9d, 0x9d, 0x97)),
76 self::CYAN => self::meta("Cyan", new Color(0x16, 0x9c, 0x9c)),
77 self::PURPLE => self::meta("Purple", new Color(0x89, 0x32, 0xb8)),
78 self::BLUE => self::meta("Blue", new Color(0x3c, 0x44, 0xaa)),
79 self::BROWN => self::meta("Brown", new Color(0x83, 0x54, 0x32)),
80 self::GREEN => self::meta("Green", new Color(0x5e, 0x7c, 0x16)),
81 self::RED => self::meta("Red", new Color(0xb0, 0x2e, 0x26)),
82 self::BLACK => self::meta("Black", new Color(0x1d, 0x1d, 0x21)),
83 };
84 }
85
86 public function getDisplayName() : string{
87 return $this->getMetadata()[0];
88 }
89
90 public function getRgbValue() : Color{
91 return $this->getMetadata()[1];
92 }
93}