Skip to content

Commit

Permalink
Add Color.drop_shadow
Browse files Browse the repository at this point in the history
  • Loading branch information
duhby committed Oct 13, 2023
1 parent a795884 commit 7b0bd82
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 68 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Color.drop_shadow.

### Fixed

- publish.sh twine command.
Expand Down
157 changes: 89 additions & 68 deletions hypixel/color.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing import Optional

__all__ = [
'Color',
"Color",
]


Expand All @@ -27,11 +27,15 @@ class Color:
The Minecraft chat formatting code for the color.
hexadecimal: :class:`str`
The hexadecimal value of the color.
drop_shadow: :class:`str`
The hexadecimal value of the drop shadow.
"""

type_name: str
clean_name: str
chat_code: str
hexadecimal: str
drop_shadow: str

@classmethod
@functools.lru_cache()
Expand All @@ -49,108 +53,125 @@ def from_type(cls, type_name: str) -> Optional[Color]:
The constructed color object, or ``None`` if the type name
is invalid.
"""
data = next((
item for item in COLOR_TYPES if item['type_name'] == type_name
), None)
data = next(
(item for item in COLOR_TYPES if item["type_name"] == type_name), None
)
if not data:
return None
return cls(**data)


COLOR_TYPES = [
{
'type_name': 'DARK_RED',
'clean_name': 'Dark Red',
'chat_code': '§4',
'hexadecimal': 'AA0000',
"type_name": "DARK_RED",
"clean_name": "Dark Red",
"chat_code": "§4",
"hexadecimal": "AA0000",
"drop_shadow": "2A0102",
},
{
'type_name': 'RED',
'clean_name': 'Red',
'chat_code': '§c',
'hexadecimal': 'FF5555',
"type_name": "RED",
"clean_name": "Red",
"chat_code": "§c",
"hexadecimal": "FF5555",
"drop_shadow": "3E1616",
},
{
'type_name': 'GOLD',
'clean_name': 'Gold',
'chat_code': '§6',
'hexadecimal': 'FFAA00',
"type_name": "GOLD",
"clean_name": "Gold",
"chat_code": "§6",
"hexadecimal": "FFAA00",
"drop_shadow": "2A2A02",
},
{
'type_name': 'YELLOW',
'clean_name': 'Yellow',
'chat_code': '§e',
'hexadecimal': 'FFFF55',
"type_name": "YELLOW",
"clean_name": "Yellow",
"chat_code": "§e",
"hexadecimal": "FFFF55",
"drop_shadow": "313322",
},
{
'type_name': 'DARK_GREEN',
'clean_name': 'Dark Green',
'chat_code': '§2',
'hexadecimal': '00AA00',
"type_name": "DARK_GREEN",
"clean_name": "Dark Green",
"chat_code": "§2",
"hexadecimal": "00AA00",
"drop_shadow": "002A01",
},
{
'type_name': 'GREEN',
'clean_name': 'Green',
'chat_code': '§a',
'hexadecimal': '55FF55',
"type_name": "GREEN",
"clean_name": "Green",
"chat_code": "§a",
"hexadecimal": "55FF55",
"drop_shadow": "153F15",
},
{
'type_name': 'AQUA',
'clean_name': 'Aqua',
'chat_code': '§b',
'hexadecimal': '55FFFF',
"type_name": "AQUA",
"clean_name": "Aqua",
"chat_code": "§b",
"hexadecimal": "55FFFF",
"drop_shadow": "163E3E",
},
{
'type_name': 'DARK_AQUA',
'clean_name': 'Dark Aqua',
'chat_code': '§3',
'hexadecimal': '00AAAA',
"type_name": "DARK_AQUA",
"clean_name": "Dark Aqua",
"chat_code": "§3",
"hexadecimal": "00AAAA",
"drop_shadow": "012A2A",
},
{
'type_name': 'DARK_BLUE',
'clean_name': 'Dark Blue',
'chat_code': '§1',
'hexadecimal': '0000AA',
"type_name": "DARK_BLUE",
"clean_name": "Dark Blue",
"chat_code": "§1",
"hexadecimal": "0000AA",
"drop_shadow": "01012A",
},
{
'type_name': 'BLUE',
'clean_name': 'Blue',
'chat_code': '§9',
'hexadecimal': '5555FF',
"type_name": "BLUE",
"clean_name": "Blue",
"chat_code": "§9",
"hexadecimal": "5555FF",
"drop_shadow": "16153E",
},
{
'type_name': 'LIGHT_PURPLE',
'clean_name': 'Light Purple',
'chat_code': '§d',
'hexadecimal': 'FF55FF',
"type_name": "LIGHT_PURPLE",
"clean_name": "Light Purple",
"chat_code": "§d",
"hexadecimal": "FF55FF",
"drop_shadow": "3E153E",
},
{
'type_name': 'DARK_PURPLE',
'clean_name': 'Dark Purple',
'chat_code': '§5',
'hexadecimal': 'AA00AA',
"type_name": "DARK_PURPLE",
"clean_name": "Dark Purple",
"chat_code": "§5",
"hexadecimal": "AA00AA",
"drop_shadow": "29012A",
},
{
'type_name': 'WHITE',
'clean_name': 'White',
'chat_code': '§f',
'hexadecimal': 'FFFFFF',
"type_name": "WHITE",
"clean_name": "White",
"chat_code": "§f",
"hexadecimal": "FFFFFF",
"drop_shadow": "3E3E3E",
},
{
'type_name': 'GRAY',
'clean_name': 'Gray',
'chat_code': '§7',
'hexadecimal': 'AAAAAA',
"type_name": "GRAY",
"clean_name": "Gray",
"chat_code": "§7",
"hexadecimal": "AAAAAA",
"drop_shadow": "292A2A",
},
{
'type_name': 'DARK_GRAY',
'clean_name': 'Dark Gray',
'chat_code': '§8',
'hexadecimal': '555555',
"type_name": "DARK_GRAY",
"clean_name": "Dark Gray",
"chat_code": "§8",
"hexadecimal": "555555",
"drop_shadow": "151515",
},
{
'type_name': 'BLACK',
'clean_name': 'Black',
'chat_code': '§0',
'hexadecimal': '000000',
"type_name": "BLACK",
"clean_name": "Black",
"chat_code": "§0",
"hexadecimal": "000000",
"drop_shadow": "010101",
},
]

0 comments on commit 7b0bd82

Please sign in to comment.