Skip to content

Commit

Permalink
feat: add test for player.skin property
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Jul 10, 2024
1 parent 11e5797 commit 7739c43
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ build-backend = "hatchling.build"
name = "endstone-test"
version = "0.0.1"
dependencies = [
"babel"
"babel",
"pillow"
]
authors = [
{ name = "Vincent Wu", email = "[email protected]" },
Expand Down
11 changes: 11 additions & 0 deletions src/endstone_test/event_listener.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import datetime
from functools import partial
from pathlib import Path

from PIL import Image
from babel import Locale
from endstone import ColorFormat, Server, Translatable
from endstone.event import *
Expand Down Expand Up @@ -74,6 +76,15 @@ def send_welcome_message(player_name: str) -> None:

assert Locale.parse(event.player.locale) is not None, event.player.locale

skin = event.player.skin
self._plugin.logger.info(f"Skin Id: {skin.skin_id}, Cape Id: {skin.cape_id}")
assert skin.skin_data.shape[2] == 4
skin_path = Path(self._plugin.data_folder) / "skins"
skin_path.mkdir(parents=True, exist_ok=True)
Image.fromarray(skin.skin_data).save(skin_path / f"{event.player.name}.png")
if skin.cape_data is not None:
Image.fromarray(skin.cape_data).save(skin_path / f"{event.player.name}_cape.png")

@event_handler
def on_player_death(self, event: PlayerDeathEvent):
# TODO: add player.is_dead check
Expand Down

0 comments on commit 7739c43

Please sign in to comment.