-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use api.ashcon.app only for uuid resolve, for skins use a mojang api
- Loading branch information
Showing
6 changed files
with
123 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package ru.leymooo.simpleskins; | ||
|
||
import com.google.common.cache.Cache; | ||
import com.google.common.cache.CacheBuilder; | ||
import java.util.HashSet; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.UUID; | ||
import java.util.concurrent.TimeUnit; | ||
import ru.leymooo.simpleskins.utils.SkinUtils.FetchResult; | ||
|
||
public class UuidFetchCache { | ||
|
||
private final Set<UUID> working = new HashSet<>(); | ||
private final Cache<UUID, FetchResult> cache = CacheBuilder.newBuilder() | ||
.concurrencyLevel(Runtime.getRuntime().availableProcessors()) | ||
.expireAfterWrite(1, TimeUnit.MINUTES) | ||
.build(); | ||
|
||
public boolean isWorking(UUID id) { | ||
return working.contains(id); | ||
} | ||
|
||
public void addWorking(UUID id) { | ||
working.add(id); | ||
} | ||
|
||
public void removeWorking(UUID id) { | ||
working.remove(id); | ||
} | ||
|
||
public Optional<FetchResult> getIfCached(UUID id) { | ||
return Optional.ofNullable(cache.getIfPresent(id)); | ||
} | ||
|
||
public void cache(FetchResult result) { | ||
if (result.getId() != null) { | ||
cache.put(result.getId(), result); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters