Skip to content

Commit

Permalink
cache player skin on join
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverSchlueter committed Aug 20, 2024
1 parent eaf0ea4 commit f241dbb
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package de.oliver.fancynpcs.listeners;

import com.destroystokyo.paper.profile.ProfileProperty;
import de.oliver.fancynpcs.FancyNpcs;
import de.oliver.fancynpcs.api.Npc;
import de.oliver.fancynpcs.api.utils.SkinFetcher;
import de.oliver.fancynpcs.v1_19_4.PacketReader_1_19_4;
import de.oliver.fancynpcs.v1_20.PacketReader_1_20;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -35,5 +37,23 @@ public void onPlayerJoin(PlayerJoinEvent event) {
() -> FancyNpcs.getInstance().getVersionConfig().checkVersionAndDisplay(event.getPlayer(), true)
);
}

for (ProfileProperty property : event.getPlayer().getPlayerProfile().getProperties()) {
if (property.getName().equals("textures")) {
SkinFetcher.SkinData skinData = new SkinFetcher.SkinData(
event.getPlayer().getUniqueId().toString(),
property.getValue(),
property.getSignature()
);

SkinFetcher.skinCache.put(event.getPlayer().getUniqueId().toString(), skinData);

FancyNpcs.getInstance().getSkinCache().upsert(new SkinFetcher.SkinCacheData(
skinData,
System.currentTimeMillis(),
1000L * 60 * 60 * 24 * 30 * 6
));
}
}
}
}

0 comments on commit f241dbb

Please sign in to comment.