From 46cd26ffae33c6b2cdad66347b4bcdbd4400bbd7 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Sun, 25 Jul 2021 10:11:53 -0400 Subject: [PATCH] Don't cache non-locale assets in the LocaleUtils asset cache Previously Geyser was storing a reference of every single asset hash provided by the server, including things like sound files. We never used this files, and their existence caused the amount of Asset classes present in Geyser to be over 3000. With this change, we only cache the 118 language files. --- .../main/java/org/geysermc/connector/utils/LocaleUtils.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/connector/src/main/java/org/geysermc/connector/utils/LocaleUtils.java b/connector/src/main/java/org/geysermc/connector/utils/LocaleUtils.java index bd2bb9370..533e95d4a 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/LocaleUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/LocaleUtils.java @@ -98,6 +98,11 @@ public class LocaleUtils { Iterator> assetIterator = assets.fields(); while (assetIterator.hasNext()) { Map.Entry entry = assetIterator.next(); + if (!entry.getKey().startsWith("minecraft/lang/")) { + // No need to cache non-language assets as we don't use them + continue; + } + Asset asset = GeyserConnector.JSON_MAPPER.treeToValue(entry.getValue(), Asset.class); ASSET_MAP.put(entry.getKey(), asset); }