feat: do not cache skin reset
This commit is contained in:
parent
aba24384d5
commit
690aeadf67
7 changed files with 31 additions and 15 deletions
|
@ -69,13 +69,17 @@ public class AppearanceManager {
|
|||
final String defaultName = instance.getDataStore().getStoredName(player);
|
||||
this.profile.setName(defaultName);
|
||||
this.profile.setSkin(defaultName);
|
||||
final ActionResult actionResult = updatePlayer(true);
|
||||
final ActionResult actionResult = resetPlayer();
|
||||
this.profile.setSkin(null);
|
||||
this.profile.setName(null);
|
||||
return actionResult;
|
||||
}
|
||||
|
||||
public ActionResult resetPlayer() {
|
||||
return NickoBukkit.getInstance().getInternals().updateProfile(player, profile, true, true);
|
||||
}
|
||||
|
||||
public ActionResult updatePlayer(boolean skinChange) {
|
||||
return NickoBukkit.getInstance().getInternals().updateProfile(player, profile, skinChange);
|
||||
return NickoBukkit.getInstance().getInternals().updateProfile(player, profile, skinChange, false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,5 +9,5 @@ public interface Internals {
|
|||
|
||||
void updateOthers(Player player);
|
||||
|
||||
ActionResult updateProfile(Player player, NickoProfile profile, boolean skinChange);
|
||||
ActionResult updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset);
|
||||
}
|
||||
|
|
|
@ -46,6 +46,10 @@ public class MojangAPI {
|
|||
return cache.get(uuid);
|
||||
}
|
||||
|
||||
public Optional<MojangSkin> getSkinWithoutCaching(String uuid) throws IOException {
|
||||
return getSkinFromMojang(uuid);
|
||||
}
|
||||
|
||||
public Optional<String> getUUID(String name) throws IOException {
|
||||
final String parametrizedUrl = URL_NAME.replace("{name}", name);
|
||||
final JsonObject object = getRequestToUrl(parametrizedUrl);
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.artelnatif.nicko.NickoBukkit;
|
|||
import net.artelnatif.nicko.disguise.NickoProfile;
|
||||
import net.artelnatif.nicko.disguise.ActionResult;
|
||||
import net.artelnatif.nicko.i18n.I18NDict;
|
||||
import net.artelnatif.nicko.mojang.MojangAPI;
|
||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
||||
import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
|
@ -82,7 +83,7 @@ public class v1_17_R1 implements Internals {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult updateProfile(Player player, NickoProfile profile, boolean skinChange) {
|
||||
public ActionResult updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) {
|
||||
final CraftPlayer craftPlayer = (CraftPlayer) player;
|
||||
final EntityPlayer entityPlayer = craftPlayer.getHandle();
|
||||
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
|
||||
|
@ -95,9 +96,10 @@ public class v1_17_R1 implements Internals {
|
|||
|
||||
if (skinChange || changeOnlyName) {
|
||||
try {
|
||||
final Optional<String> uuid = NickoBukkit.getInstance().getMojangAPI().getUUID(profile.getSkin());
|
||||
final MojangAPI mojang = NickoBukkit.getInstance().getMojangAPI();
|
||||
final Optional<String> uuid = mojang.getUUID(profile.getSkin());
|
||||
if (uuid.isPresent()) {
|
||||
skin = NickoBukkit.getInstance().getMojangAPI().getSkin(uuid.get());
|
||||
skin = (reset ? mojang.getSkinWithoutCaching(uuid.get()) : mojang.getSkin(uuid.get()));
|
||||
if (skin.isPresent()) {
|
||||
final PropertyMap properties = gameProfile.getProperties();
|
||||
properties.put("textures", new Property("textures", skin.get().value(), skin.get().signature()));
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.artelnatif.nicko.NickoBukkit;
|
|||
import net.artelnatif.nicko.disguise.NickoProfile;
|
||||
import net.artelnatif.nicko.disguise.ActionResult;
|
||||
import net.artelnatif.nicko.i18n.I18NDict;
|
||||
import net.artelnatif.nicko.mojang.MojangAPI;
|
||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
||||
import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
|
@ -84,7 +85,7 @@ public class v1_18_R1 implements Internals {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult updateProfile(Player player, NickoProfile profile, boolean skinChange) {
|
||||
public ActionResult updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) {
|
||||
final CraftPlayer craftPlayer = (CraftPlayer) player;
|
||||
final EntityPlayer entityPlayer = craftPlayer.getHandle();
|
||||
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
|
||||
|
@ -97,9 +98,10 @@ public class v1_18_R1 implements Internals {
|
|||
|
||||
if (skinChange || changeOnlyName) {
|
||||
try {
|
||||
final Optional<String> uuid = NickoBukkit.getInstance().getMojangAPI().getUUID(profile.getSkin());
|
||||
final MojangAPI mojang = NickoBukkit.getInstance().getMojangAPI();
|
||||
final Optional<String> uuid = mojang.getUUID(profile.getSkin());
|
||||
if (uuid.isPresent()) {
|
||||
skin = NickoBukkit.getInstance().getMojangAPI().getSkin(uuid.get());
|
||||
skin = (reset ? mojang.getSkinWithoutCaching(uuid.get()) : mojang.getSkin(uuid.get()));
|
||||
if (skin.isPresent()) {
|
||||
final PropertyMap properties = gameProfile.getProperties();
|
||||
properties.put("textures", new Property("textures", skin.get().value(), skin.get().signature()));
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.artelnatif.nicko.NickoBukkit;
|
|||
import net.artelnatif.nicko.disguise.NickoProfile;
|
||||
import net.artelnatif.nicko.disguise.ActionResult;
|
||||
import net.artelnatif.nicko.i18n.I18NDict;
|
||||
import net.artelnatif.nicko.mojang.MojangAPI;
|
||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.network.chat.IChatBaseComponent;
|
||||
|
@ -84,7 +85,7 @@ public class v1_18_R2 implements Internals {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult updateProfile(Player player, NickoProfile profile, boolean skinChange) {
|
||||
public ActionResult updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) {
|
||||
final CraftPlayer craftPlayer = (CraftPlayer) player;
|
||||
final EntityPlayer entityPlayer = craftPlayer.getHandle();
|
||||
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
|
||||
|
@ -97,9 +98,10 @@ public class v1_18_R2 implements Internals {
|
|||
|
||||
if (skinChange || changeOnlyName) {
|
||||
try {
|
||||
final Optional<String> uuid = NickoBukkit.getInstance().getMojangAPI().getUUID(profile.getSkin());
|
||||
final MojangAPI mojang = NickoBukkit.getInstance().getMojangAPI();
|
||||
final Optional<String> uuid = mojang.getUUID(profile.getSkin());
|
||||
if (uuid.isPresent()) {
|
||||
skin = NickoBukkit.getInstance().getMojangAPI().getSkin(uuid.get());
|
||||
skin = (reset ? mojang.getSkinWithoutCaching(uuid.get()) : mojang.getSkin(uuid.get()));
|
||||
if (skin.isPresent()) {
|
||||
final PropertyMap properties = gameProfile.getProperties();
|
||||
properties.put("textures", new Property("textures", skin.get().value(), skin.get().signature()));
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.artelnatif.nicko.NickoBukkit;
|
|||
import net.artelnatif.nicko.disguise.NickoProfile;
|
||||
import net.artelnatif.nicko.disguise.ActionResult;
|
||||
import net.artelnatif.nicko.i18n.I18NDict;
|
||||
import net.artelnatif.nicko.mojang.MojangAPI;
|
||||
import net.artelnatif.nicko.mojang.MojangSkin;
|
||||
import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
|
@ -86,7 +87,7 @@ public class v1_19_R1 implements Internals {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ActionResult updateProfile(Player player, NickoProfile profile, boolean skinChange) {
|
||||
public ActionResult updateProfile(Player player, NickoProfile profile, boolean skinChange, boolean reset) {
|
||||
final CraftPlayer craftPlayer = (CraftPlayer) player;
|
||||
final EntityPlayer entityPlayer = craftPlayer.getHandle();
|
||||
final boolean changeOnlyName = profile.getSkin() != null && !profile.getSkin().equalsIgnoreCase(player.getName());
|
||||
|
@ -102,9 +103,10 @@ public class v1_19_R1 implements Internals {
|
|||
|
||||
if (skinChange || changeOnlyName) {
|
||||
try {
|
||||
final Optional<String> uuid = NickoBukkit.getInstance().getMojangAPI().getUUID(profile.getSkin());
|
||||
final MojangAPI mojang = NickoBukkit.getInstance().getMojangAPI();
|
||||
final Optional<String> uuid = mojang.getUUID(profile.getSkin());
|
||||
if (uuid.isPresent()) {
|
||||
skin = NickoBukkit.getInstance().getMojangAPI().getSkin(uuid.get());
|
||||
skin = (reset ? mojang.getSkinWithoutCaching(uuid.get()) : mojang.getSkin(uuid.get()));
|
||||
if (skin.isPresent()) {
|
||||
final PropertyMap properties = gameProfile.getProperties();
|
||||
properties.put("textures", new Property("textures", skin.get().value(), skin.get().signature()));
|
||||
|
|
Loading…
Reference in a new issue