Skip to content

Commit

Permalink
Fix cache image task from last commit and make it work with reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
Camotoy committed Jan 31, 2022
1 parent 36afd3f commit 7853e8c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 2 additions & 1 deletion core/src/main/java/org/geysermc/geyser/GeyserImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ private GeyserImpl(PlatformType platformType, GeyserBootstrap bootstrap) {
ItemTranslator.init();
MessageTranslator.init();
MinecraftLocale.init();
SkinProvider.init();

start();

Expand Down Expand Up @@ -197,6 +196,8 @@ private void start() {

ScoreboardUpdater.init();

SkinProvider.registerCacheImageTask(this);

ResourcePack.loadPacks();

if (platformType != PlatformType.STANDALONE && config.getRemote().getAddress().equals("auto")) {
Expand Down
10 changes: 4 additions & 6 deletions core/src/main/java/org/geysermc/geyser/skin/SkinProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ public class SkinProvider {
WEARING_CUSTOM_SKULL = new SkinGeometry("{\"geometry\" :{\"default\" :\"geometry.humanoid.wearingCustomSkull\"}}", wearingCustomSkull, false);
String wearingCustomSkullSlim = new String(FileUtils.readAllBytes("bedrock/skin/geometry.humanoid.wearingCustomSkullSlim.json"), StandardCharsets.UTF_8);
WEARING_CUSTOM_SKULL_SLIM = new SkinGeometry("{\"geometry\" :{\"default\" :\"geometry.humanoid.wearingCustomSkullSlim\"}}", wearingCustomSkullSlim, false);
}

public static void registerCacheImageTask(GeyserImpl geyser) {
// Schedule Daily Image Expiry if we are caching them
if (GeyserImpl.getInstance().getConfig().getCacheImages() > 0) {
GeyserImpl.getInstance().getScheduledThread().scheduleAtFixedRate(() -> {
if (geyser.getConfig().getCacheImages() > 0) {
geyser.getScheduledThread().scheduleAtFixedRate(() -> {
File cacheFolder = GeyserImpl.getInstance().getBootstrap().getConfigFolder().resolve("cache").resolve("images").toFile();
if (!cacheFolder.exists()) {
return;
Expand Down Expand Up @@ -819,8 +821,4 @@ public static String toRequestedType(CapeUrlType type, UUID uuid, String usernam
};
}
}

public static void init() {
// no-op
}
}

0 comments on commit 7853e8c

Please sign in to comment.