From 18d73224067a2a205f04f582307cbe2b7e53aa57 Mon Sep 17 00:00:00 2001 From: ineanto Date: Sat, 1 Jul 2023 17:55:53 +0200 Subject: [PATCH] feat: don't cache reset skin --- .../xyz/atnrch/nicko/disguise/AppearanceManager.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/xyz/atnrch/nicko/disguise/AppearanceManager.java b/src/main/java/xyz/atnrch/nicko/disguise/AppearanceManager.java index a8c4645..839aeb9 100644 --- a/src/main/java/xyz/atnrch/nicko/disguise/AppearanceManager.java +++ b/src/main/java/xyz/atnrch/nicko/disguise/AppearanceManager.java @@ -79,14 +79,14 @@ public class AppearanceManager { public void setNameAndSkin(String name, String skin) { this.profile.setName(name); this.profile.setSkin(skin); - updatePlayer(true); + updatePlayer(true, false); } public ActionResult reset() { final String defaultName = nameStore.getStoredName(player); this.profile.setName(defaultName); this.profile.setSkin(defaultName); - final ActionResult actionResult = updatePlayer(true); + final ActionResult actionResult = updatePlayer(true, true); if (!actionResult.isError()) { this.profile.setSkin(null); this.profile.setName(null); @@ -94,11 +94,11 @@ public class AppearanceManager { return actionResult; } - public ActionResult updatePlayer(boolean skinChange) { + public ActionResult updatePlayer(boolean skinChange, boolean reset) { final String displayName = profile.getName() == null ? player.getName() : profile.getName(); final WrappedGameProfile gameProfile = WrappedGameProfile.fromPlayer(player).withName(displayName); - final ActionResult result = updateGameProfileSkin(gameProfile, skinChange); + final ActionResult result = updateGameProfileSkin(gameProfile, skinChange, reset); final boolean wasFlying = player.isFlying(); if (!result.isError()) { updateMetadata(); @@ -126,7 +126,7 @@ public class AppearanceManager { } - private ActionResult updateGameProfileSkin(WrappedGameProfile gameProfile, boolean skinChange) { + private ActionResult updateGameProfileSkin(WrappedGameProfile gameProfile, boolean skinChange, boolean reset) { final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName()); if (skinChange || changeOnlyName) { @@ -135,7 +135,7 @@ public class AppearanceManager { final MojangAPI mojang = NickoBukkit.getInstance().getMojangAPI(); final Optional uuid = mojang.getUUID(profile.getSkin()); if (uuid.isPresent()) { - skin = mojang.getSkin(uuid.get()); + skin = reset ? mojang.getSkinWithoutCaching(uuid.get()) : mojang.getSkin(uuid.get()); if (skin.isPresent()) { final MojangSkin skinResult = skin.get(); final Multimap properties = gameProfile.getProperties();