|
5 | 5 | import com.google.gson.JsonObject;
|
6 | 6 | import com.google.gson.JsonParser;
|
7 | 7 | import com.google.gson.reflect.TypeToken;
|
| 8 | + |
8 | 9 | import lombok.Getter;
|
| 10 | + |
9 | 11 | import org.bukkit.Bukkit;
|
10 | 12 | import org.bukkit.entity.Player;
|
11 | 13 | import org.bukkit.plugin.java.JavaPlugin;
|
|
15 | 17 | import xyz.refinedev.api.skin.player.impl.CarbonAdapter;
|
16 | 18 | import xyz.refinedev.api.skin.player.impl.LegacyAdapter;
|
17 | 19 | import xyz.refinedev.api.skin.player.impl.ModernAdapter;
|
18 |
| -import xyz.refinedev.api.storage.JsonStorage; |
| 20 | +import xyz.refinedev.api.storage.json.JsonStorage; |
19 | 21 |
|
20 | 22 | import java.io.BufferedReader;
|
21 | 23 | import java.io.IOException;
|
22 | 24 | import java.io.InputStreamReader;
|
23 | 25 | import java.lang.reflect.Type;
|
24 | 26 | import java.net.HttpURLConnection;
|
25 | 27 | import java.net.URL;
|
26 |
| -import java.util.Collection; |
27 |
| -import java.util.Map; |
| 28 | +import java.util.*; |
28 | 29 | import java.util.concurrent.CompletableFuture;
|
29 | 30 | import java.util.concurrent.ConcurrentHashMap;
|
30 | 31 | import java.util.function.Consumer;
|
@@ -211,8 +212,13 @@ public void registerSkin(String name, CachedSkin skin) {
|
211 | 212 | public void registerPlayer(Player player) {
|
212 | 213 | if (this.skinCache.containsKey(player.getName())) return;
|
213 | 214 |
|
214 |
| - CachedSkin skin = this.getByPlayer(player); |
215 |
| - this.temporaryCache.put(player.getName(), skin); |
| 215 | + CompletableFuture<CachedSkin> future = CompletableFuture.supplyAsync(() -> fetchSkin(player.getName())); |
| 216 | + this.skinFutures.put(player.getName(), future); |
| 217 | + |
| 218 | + future.whenComplete((skin, throwable) -> { |
| 219 | + this.registerSkin(player.getName(), skin); |
| 220 | + this.skinFutures.remove(player.getName()); |
| 221 | + }); |
216 | 222 | }
|
217 | 223 |
|
218 | 224 | /**
|
|
0 commit comments