diff --git a/plugin/src/main/java/me/libraryaddict/disguise/LibsDisguises.java b/plugin/src/main/java/me/libraryaddict/disguise/LibsDisguises.java index 056eb30a6a..7f042a9b1d 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/LibsDisguises.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/LibsDisguises.java @@ -174,6 +174,8 @@ public void onLoad() { commandConfig.load(); } } catch (Throwable throwable) { + ClassMappings.deleteMappingsCache(getDataFolder()); + try { if (isJenkins() && DisguiseConfig.isAutoUpdate()) { getUpdateChecker().doUpdate(); @@ -237,6 +239,8 @@ public void onEnable() { new MetricsInitalizer(); } catch (Throwable throwable) { + ClassMappings.deleteMappingsCache(getDataFolder()); + try { if (isJenkins() && DisguiseConfig.isAutoUpdate()) { getUpdateChecker().doUpdate(); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/reflection/ClassMappings.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/reflection/ClassMappings.java index e1146203b2..5a9672336c 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/reflection/ClassMappings.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/reflection/ClassMappings.java @@ -94,6 +94,14 @@ private static String getVersion() { return "Built for: " + Bukkit.getVersion() + "\t" + LibsDisguises.getInstance().getDescription().getVersion(); } + private static File getFile(File dataFolder) { + return new File(dataFolder, "mappings_cache"); + } + + public static void deleteMappingsCache(File folder) { + getFile(folder).delete(); + } + public static void saveMappingsCache(File dataFolder) { synchronized (classLocations) { if (!updatingCache) { @@ -103,7 +111,7 @@ public static void saveMappingsCache(File dataFolder) { updatingCache = false; } - File mappingsCache = new File(dataFolder, "mappings_cache"); + File mappingsCache = getFile(dataFolder); try (BufferedWriter writer = new BufferedWriter(new FileWriter(mappingsCache))) { writer.write(getVersion() + "\n"); @@ -116,7 +124,8 @@ public static void saveMappingsCache(File dataFolder) { } public static void loadMappingsCache(File dataFolder) { - File mappingsCache = new File(dataFolder, "mappings_cache"); + File mappingsCache = getFile(dataFolder); + if (!mappingsCache.exists()) { return; }