Skip to content

Commit

Permalink
Added id & state to Skin & Cape
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucino772 committed Nov 13, 2021
1 parent 969c5c4 commit d7a482b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 6 deletions.
11 changes: 9 additions & 2 deletions mojang/account/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 38 additions & 4 deletions mojang/account/structures/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand All @@ -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))

Expand All @@ -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__
__str__ = __repr__

0 comments on commit d7a482b

Please sign in to comment.