fix: reset

This commit is contained in:
ineanto 2025-06-29 14:04:20 +02:00
parent 03a8eb9b7d
commit 1a45ca186a
Signed by: ineanto
GPG key ID: E511F9CAA2F9CE84

View file

@ -33,11 +33,16 @@ public class AppearanceManager {
final PlayerResetDisguiseEvent event = new PlayerResetDisguiseEvent(player); final PlayerResetDisguiseEvent event = new PlayerResetDisguiseEvent(player);
Bukkit.getPluginManager().callEvent(event); 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.setName(null);
profile.setSkin(null); profile.setSkin(null);
dataStore.getCache().cache(player.getUniqueId(), profile); dataStore.getCache().cache(player.getUniqueId(), profile);
return ActionResult.ok(); return resetSkinUpdate;
} }
public ActionResult update(boolean skinChange) { public ActionResult update(boolean skinChange) {
@ -50,7 +55,7 @@ public class AppearanceManager {
final ActionResult propertiesUpdateResult = packetSender.updatePlayerProfileProperties(); final ActionResult propertiesUpdateResult = packetSender.updatePlayerProfileProperties();
if (propertiesUpdateResult.isError()) { if (propertiesUpdateResult.isError()) {
return reset(); return resetWithoutUpdate();
} }
} }
@ -63,6 +68,20 @@ public class AppearanceManager {
return result; 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() { private NickoProfile getNickoProfile() {
final Optional<NickoProfile> optionalProfile = dataStore.getData(player.getUniqueId()); final Optional<NickoProfile> optionalProfile = dataStore.getData(player.getUniqueId());
return optionalProfile.orElse(NickoProfile.EMPTY_PROFILE.clone()); return optionalProfile.orElse(NickoProfile.EMPTY_PROFILE.clone());