Skip to content

Commit

Permalink
Mark the current skin system as deprecated
Browse files Browse the repository at this point in the history
It will be replaced with a slightly different system in the near future
  • Loading branch information
OliverSchlueter committed Nov 23, 2024
1 parent 78eaff0 commit 0ead36c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
12 changes: 10 additions & 2 deletions api/src/main/java/de/oliver/fancynpcs/api/NpcData.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class NpcData {
private final String name;
private final UUID creator;
private String displayName;
private SkinFetcher.SkinData skin;
@Deprecated private SkinFetcher.SkinData skin;
private boolean mirrorSkin;
private Location location;
private boolean showInTab;
Expand All @@ -46,7 +46,7 @@ public NpcData(
String name,
UUID creator,
String displayName,
SkinFetcher.SkinData skin,
@Deprecated SkinFetcher.SkinData skin,
Location location,
boolean showInTab,
boolean spawnEntity,
Expand Down Expand Up @@ -135,10 +135,18 @@ public NpcData setDisplayName(String displayName) {
return this;
}

/**
* The skin system is deprecated and will be replaced with a slightly different system in the near future.
*/
@Deprecated
public SkinFetcher.SkinData getSkin() {
return skin;
}

/**
* The skin system is deprecated and will be replaced with a slightly different system in the near future.
*/
@Deprecated
public NpcData setSkin(SkinFetcher.SkinData skin) {
this.skin = skin;
isDirty = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@

import java.util.List;

/**
* The skin system is deprecated and will be replaced with a slightly different system in the near future.
*/
@Deprecated
public interface SkinCache {

/**
* Load all cached skins from the cache and removes all expired skins
*
* @return List of cached skins
*/
@Deprecated
List<SkinFetcher.SkinCacheData> load();

/**
Expand All @@ -17,8 +22,10 @@ public interface SkinCache {
* @param skinCacheData Skin data to save
* @param onlyIfExists If true, the skin will only be replaced/updated if it already exists in the cache
*/
@Deprecated
void upsert(SkinFetcher.SkinCacheData skinCacheData, boolean onlyIfExists);

@Deprecated
default void upsert(SkinFetcher.SkinCacheData skinCacheData) {
upsert(skinCacheData, false);
}
Expand Down
11 changes: 11 additions & 0 deletions api/src/main/java/de/oliver/fancynpcs/api/utils/SkinFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;

/**
* The skin system is deprecated and will be replaced with a slightly different system in the near future.
*/
@Deprecated
public final class SkinFetcher {
@Deprecated
public static final Map<String, SkinData> skinCache = new ConcurrentHashMap<>(); // identifier -> skinData

private SkinFetcher() {
Expand All @@ -38,6 +43,7 @@ private SkinFetcher() {
* @param identifier The identifier of the skin. This can be a UUID, username, URL or a placeholder by PAPI.
* @return A CompletableFuture that will contain the SkinData.
*/
@Deprecated
public static CompletableFuture<SkinData> fetchSkin(String identifier) {
return CompletableFuture.supplyAsync(() -> {
String parsedIdentifier = ChatColorHandler.translate(identifier, ParserTypes.placeholder());
Expand Down Expand Up @@ -104,6 +110,7 @@ public static CompletableFuture<SkinData> fetchSkin(String identifier) {
* @param player The player.
* @return The SkinData or {@code null} if the skin data could not be fetched.
*/
@Deprecated
public static SkinData getSkinByOnlinePlayer(Player player) {
if (player == null) {
return null;
Expand All @@ -124,6 +131,7 @@ public static SkinData getSkinByOnlinePlayer(Player player) {
* @param uuid The UUID of the player.
* @return A CompletableFuture that will contain the SkinData.
*/
@Deprecated
public static CompletableFuture<SkinData> fetchSkinByUUID(String uuid) {
return CompletableFuture.supplyAsync(() -> {
try {
Expand Down Expand Up @@ -157,6 +165,7 @@ public static CompletableFuture<SkinData> fetchSkinByUUID(String uuid) {
* @param skinURL The URL of the skin.
* @return A CompletableFuture that will contain the SkinData.
*/
@Deprecated
public static CompletableFuture<SkinData> fetchSkinByURL(String skinURL) {
return CompletableFuture.supplyAsync(() -> {
try {
Expand Down Expand Up @@ -211,6 +220,7 @@ private static long randomFromTo(long from, long to) {
* @param value The value of the skin. If {@code null}, the skin will be fetched from the Mojang API.
* @param signature The signature of the skin. If {@code null}, the skin will be fetched from the Mojang API.
*/
@Deprecated
public record SkinData(@NotNull String identifier, @Nullable String value, @Nullable String signature) {

/**
Expand Down Expand Up @@ -261,6 +271,7 @@ public String signature() {
* @param lastUpdated The timestamp when the skin data was last updated.
* @param timeToLive The time to live of the skin data in milliseconds.
*/
@Deprecated
@ApiStatus.Internal
public record SkinCacheData(@NotNull SkinData skinData, long lastUpdated, long timeToLive) {
public boolean isExpired() {
Expand Down

0 comments on commit 0ead36c

Please sign in to comment.