From 436fc91556aeba208234e646def8705292cfb65d Mon Sep 17 00:00:00 2001 From: ineanto Date: Sun, 29 Jun 2025 14:04:20 +0200 Subject: [PATCH] fix: reset --- TODO | 2 -- .../nicko/appearance/AppearanceManager.java | 23 +++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/TODO b/TODO index 6d5f383..4d14540 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,3 @@ -la fonctionnalité pour retirer les déguisements fonctionne pas (admin comme via la tnt côté utilisateur) l'item favori explose si skin == null -les messages d'erreurs ne contiennent pas la raison (est affiché null en raison, pb de trad ?) impossible de s'équiper d'un favori les chat session sont baisées (https://github.com/retrooper/packetevents/issues/1271) \ No newline at end of file diff --git a/src/main/java/xyz/ineanto/nicko/appearance/AppearanceManager.java b/src/main/java/xyz/ineanto/nicko/appearance/AppearanceManager.java index f754a29..0eece57 100644 --- a/src/main/java/xyz/ineanto/nicko/appearance/AppearanceManager.java +++ b/src/main/java/xyz/ineanto/nicko/appearance/AppearanceManager.java @@ -33,11 +33,16 @@ public class AppearanceManager { final PlayerResetDisguiseEvent event = new PlayerResetDisguiseEvent(player); Bukkit.getPluginManager().callEvent(event); + final String playerName = nameStore.getStoredName(player); + profile.setName(playerName); + profile.setSkin(playerName); + final ActionResult resetSkinUpdate = update(true); + profile.setName(null); profile.setSkin(null); dataStore.getCache().cache(player.getUniqueId(), profile); - return ActionResult.ok(); + return resetSkinUpdate; } public ActionResult update(boolean skinChange) { @@ -50,7 +55,7 @@ public class AppearanceManager { final ActionResult propertiesUpdateResult = packetSender.updatePlayerProfileProperties(); if (propertiesUpdateResult.isError()) { - return reset(); + return resetWithoutUpdate(); } } @@ -63,6 +68,20 @@ public class AppearanceManager { return result; } + private ActionResult resetWithoutUpdate() { + final NickoProfile profile = getNickoProfile(); + + // Call the event. + final PlayerResetDisguiseEvent event = new PlayerResetDisguiseEvent(player); + Bukkit.getPluginManager().callEvent(event); + + profile.setName(null); + profile.setSkin(null); + dataStore.getCache().cache(player.getUniqueId(), profile); + + return ActionResult.ok(); + } + private NickoProfile getNickoProfile() { final Optional optionalProfile = dataStore.getData(player.getUniqueId()); return optionalProfile.orElse(NickoProfile.EMPTY_PROFILE.clone());