From 49aeffb25ad586866758520b9b9e49b06e4422b4 Mon Sep 17 00:00:00 2001 From: Ryder Belserion Date: Mon, 3 Jun 2024 16:19:12 -0400 Subject: [PATCH] Fix an issue with FileNotFoundException if you deleted a file from `crates` folder (#732) * bump vital api * extend new vital class, make use of verbose logging * update CHANGELOG.md * bump version * Nuke and repopulate custom files every time on reload --- CHANGELOG.md | 3 ++- buildSrc/src/main/kotlin/java-plugin.gradle.kts | 1 + .../java/com/badbones69/crazycrates/Server.java | 14 ++++++++++---- .../crazycrates/config/ConfigManager.java | 6 +++--- gradle.properties | 2 +- gradle/libs.versions.toml | 2 +- paper/run/server.properties | 2 +- .../crazycrates/tasks/crates/CrateManager.java | 2 ++ 8 files changed, 21 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d01e10ba..590443c9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## Fixes: -* Updates how lore is handled when using /cc additem +* Fixed an issue where if you removed a file and ran /crazycrates reload, It would tell about file not found + * I didn't remove the file from the cache... It should now. ## Other: * [Feature Requests](https://github.com/Crazy-Crew/CrazyCrates/discussions/categories/features) diff --git a/buildSrc/src/main/kotlin/java-plugin.gradle.kts b/buildSrc/src/main/kotlin/java-plugin.gradle.kts index 3bb80d9a1..fbd602dbe 100644 --- a/buildSrc/src/main/kotlin/java-plugin.gradle.kts +++ b/buildSrc/src/main/kotlin/java-plugin.gradle.kts @@ -15,6 +15,7 @@ repositories { flatDir { dirs("libs") } mavenCentral() + //mavenLocal() } dependencies { diff --git a/core/src/main/java/com/badbones69/crazycrates/Server.java b/core/src/main/java/com/badbones69/crazycrates/Server.java index bf84902eb..e17f229e7 100644 --- a/core/src/main/java/com/badbones69/crazycrates/Server.java +++ b/core/src/main/java/com/badbones69/crazycrates/Server.java @@ -1,6 +1,7 @@ package com.badbones69.crazycrates; -import com.ryderbelserion.vital.core.AbstractPlugin; +import com.badbones69.crazycrates.config.impl.ConfigKeys; +import com.ryderbelserion.vital.core.Vital; import com.ryderbelserion.vital.core.util.FileUtil; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; @@ -13,7 +14,7 @@ import java.util.List; import java.util.logging.Logger; -public class Server extends AbstractPlugin implements IServer { +public class Server extends Vital implements IServer { private final File directory; private final Logger logger; @@ -26,6 +27,8 @@ public Server(@NotNull final File directory, @NotNull final Logger logger) { this.directory = directory; this.crates = new File(this.directory, "crates"); this.logger = logger; + + ConfigManager.load(this.directory); } /** @@ -33,8 +36,6 @@ public Server(@NotNull final File directory, @NotNull final Logger logger) { */ @ApiStatus.Internal public void apply() { - ConfigManager.load(this.directory); - this.settings = new Settings(); // Register default provider. @@ -112,4 +113,9 @@ public void reload() { public @NotNull final Logger getLogger() { return this.logger; } + + @Override + public boolean isLogging() { + return ConfigManager.getConfig().getProperty(ConfigKeys.verbose_logging); + } } \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazycrates/config/ConfigManager.java b/core/src/main/java/com/badbones69/crazycrates/config/ConfigManager.java index d28b06868..ab095b35a 100644 --- a/core/src/main/java/com/badbones69/crazycrates/config/ConfigManager.java +++ b/core/src/main/java/com/badbones69/crazycrates/config/ConfigManager.java @@ -59,11 +59,11 @@ public static void refresh() { config.reload(); messages.reload(); + // Refresh custom files. + getYamlManager().init(); + // Refresh static files. getYamlManager().reloadFiles(); - - // Refresh custom files. - getYamlManager().reloadCustomFiles(); } /** diff --git a/gradle.properties b/gradle.properties index 9b88e772c..09c8a9018 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,4 +7,4 @@ authors=["ryderbelserion", "BadBones69", "TDL"] description=Create unlimited crates with multiple crate types to choose from! website=https://modrinth.com/plugin/crazycrates -version=3.0.1 \ No newline at end of file +version=3.0.2 \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a3bb92c5a..d9a2e951a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,7 +13,7 @@ oraxen = "1.171.0" annotations = "24.1.0" crazycrates = "0.6" gson = "2.10.1" -vital = "1.2" +vital = "1.5.1" decentholograms = "2.8.8" fancyholograms = "2.0.6" diff --git a/paper/run/server.properties b/paper/run/server.properties index 3706d7e29..3c3be1400 100644 --- a/paper/run/server.properties +++ b/paper/run/server.properties @@ -1,5 +1,5 @@ #Minecraft server properties -#Mon Jun 03 12:01:59 EDT 2024 +#Mon Jun 03 15:51:13 EDT 2024 accepts-transfers=false allow-flight=false allow-nether=false diff --git a/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/CrateManager.java b/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/CrateManager.java index 824b8e55a..d9fd06ff0 100644 --- a/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/CrateManager.java +++ b/paper/src/main/java/com/badbones69/crazycrates/tasks/crates/CrateManager.java @@ -247,6 +247,8 @@ public void loadCrates() { final CrateType crateType = CrateType.getFromName(file.getString("Crate.CrateType", "CSGO")); + this.plugin.getLogger().warning("Type: " + crateType.getName()); + final ArrayList prizes = new ArrayList<>(); final List tiers = new ArrayList<>();