fix: reset
This commit is contained in:
parent
03a8eb9b7d
commit
1a45ca186a
1 changed files with 21 additions and 2 deletions
|
@ -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());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue