Skip to content

Commit

Permalink
cache skins from old system
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverSchlueter committed Sep 4, 2024
1 parent 7211688 commit 5704d20
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/main/java/de/oliver/fancynpcs/NpcManagerImpl.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package de.oliver.fancynpcs;

import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.NpcAttribute;
import de.oliver.fancynpcs.api.NpcData;
import de.oliver.fancynpcs.api.NpcManager;
import de.oliver.fancynpcs.api.*;
import de.oliver.fancynpcs.api.utils.NpcEquipmentSlot;
import de.oliver.fancynpcs.api.utils.SkinFetcher;
import net.kyori.adventure.text.format.NamedTextColor;
Expand Down Expand Up @@ -249,6 +246,18 @@ public void loadNpcs() {
skin = new SkinFetcher.SkinData(skinIdentifier, "", "");
}

if (npcConfig.isSet("npcs." + id + ".skin.value") && npcConfig.isSet("npcs." + id + ".skin.signature")) {
String value = npcConfig.getString("npcs." + id + ".skin.value");
String signature = npcConfig.getString("npcs." + id + ".skin.signature");

if (value != null && !value.isEmpty() && signature != null && !signature.isEmpty()) {
skin = new SkinFetcher.SkinData(skinIdentifier, value, signature);
SkinFetcher.SkinData oldSkinData = new SkinFetcher.SkinData(skinIdentifier, value, signature);
SkinFetcher.skinCache.put(skinIdentifier, oldSkinData);
FancyNpcsPlugin.get().getSkinCache().upsert(new SkinFetcher.SkinCacheData(oldSkinData, System.currentTimeMillis(), 1000 * 60 * 60 * 24));
}
}

boolean oldMirrorSkin = npcConfig.getBoolean("npcs." + id + ".mirrorSkin"); //TODO: remove in next version
boolean mirrorSkin = oldMirrorSkin || npcConfig.getBoolean("npcs." + id + ".skin.mirrorSkin");

Expand Down

0 comments on commit 5704d20

Please sign in to comment.