From d7a482b2888bb56a5fa44b25f6c68089d6f88d45 Mon Sep 17 00:00:00 2001 From: Lucino772 Date: Sat, 13 Nov 2021 17:59:01 +0100 Subject: [PATCH] Added id & state to Skin & Cape --- mojang/account/session.py | 11 ++++++-- mojang/account/structures/session.py | 42 +++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/mojang/account/session.py b/mojang/account/session.py index a278aee9..002a2d03 100644 --- a/mojang/account/session.py +++ b/mojang/account/session.py @@ -180,11 +180,18 @@ def get_profile(access_token: str): if len(data["skins"]) > 0: _dict["skin"] = Skin( - data["skins"][0]["url"], data["skins"][0]["variant"] + data["skins"][0]["url"], + data["skins"][0]["variant"], + id=data["skins"][0]["id"], + state=data["skins"][0]["state"], ) if len(data["capes"]) > 0: - _dict["cape"] = Cape(data["capes"][0]["url"]) + _dict["cape"] = Cape( + data["capes"][0]["url"], + id=data["capes"][0]["id"], + state=data["capes"][0]["state"], + ) _dict["is_legacy"] = False _dict["is_demo"] = False diff --git a/mojang/account/structures/session.py b/mojang/account/structures/session.py index 27234238..6330e9b5 100644 --- a/mojang/account/structures/session.py +++ b/mojang/account/structures/session.py @@ -111,14 +111,31 @@ class Skin(_Resource): variant (str): The variant of skin (default to 'classic') """ - def __init__(self, source: str, variant: str, load: bool = True) -> None: + def __init__( + self, + source: str, + variant: str, + id: str = None, + state: str = None, + load: bool = True, + ) -> None: super().__init__(source, load=load) self.__variant = variant + self.__id = id + self.__state = state @property def variant(self): return self.__variant + @property + def id(self): + return self.__id + + @property + def state(self): + return self.__state + def __hash__(self) -> int: return hash((self.source, self.variant, self.data)) @@ -129,15 +146,32 @@ def __eq__(self, o: object) -> bool: return False def __repr__(self) -> str: - return f"Skin(source='{self.source}', variant='{self.variant}')" + return f"Skin(source='{self.source}', variant='{self.variant}', id='{self.id}', state='{self.state}')" __str__ = __repr__ + class Cape(_Resource): """ Attributes: source (str): The source where the cape is located """ + + def __init__( + self, source: str, id: str = None, state: str = None, load: bool = True + ) -> None: + super().__init__(source, load=load) + self.__id = id + self.__state = state + + @property + def id(self): + return self.__id + + @property + def state(self): + return self.__state + def __hash__(self) -> int: return hash((self.source, self.data)) @@ -148,6 +182,6 @@ def __eq__(self, o: object) -> bool: return False def __repr__(self) -> str: - return f"Cape(source='{self.source}'')" + return f"Cape(source='{self.source}', id='{self.id}', state='{self.state}')" - __str__ = __repr__ \ No newline at end of file + __str__ = __repr__