Skip to content

Commit 643fd7e

Browse files
committed
Fix: Config reloading and allow paths for resource order
1 parent f21081f commit 643fd7e

File tree

5 files changed

+182
-180
lines changed

5 files changed

+182
-180
lines changed

abstraction/src/main/java/com/loohp/multichatdiscordsrvaddon/config/Config.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ public record Resources(
300300
)
301301
String serverResourcePackProvider,
302302
@Comment("Set this option if you want a separate URL as the server resource pack.\nIf the URL is empty, the URL and hash from server.properties will be used.\nIf the hash is empty but URL is not, the resource pack hash will not be checked") ResourcesAlternateServerResourcePack alternateServerResourcePack,
303-
@Comment("Set which resource pack should be installed and in what order.\nVisit this page for more info:\nhttps://github.com/LOOHP/InteractiveChat-DiscordSRV-Addon/wiki/Resource-Pack") List<String> order,
303+
@Comment("Set which resource pack should be installed and in what order.\nVisit this page for more info:\nhttps://github.com/LOOHP/InteractiveChat-DiscordSRV-Addon/wiki/Resource-Pack\nIf you have a pack that is in another location, start the entry with \"path:\" and specify a path to the file (starts from this plugin's config folder).") List<String> order,
304304
@Comment("Enable (Partial) Optifine Custom Texture CIT support") boolean optifineCustomTextures,
305305
@Comment("Enable (Partial) Chime Custom Model Override support (1.16+)") boolean chimeOverrideModels
306306
) {}
@@ -762,7 +762,7 @@ public void saveConfig() {
762762
YamlConfigurations.save(new File(LoaderUtils.getPlugin().getDataFolder(), "config.yml").toPath(), Config.class, this, properties);
763763
}
764764

765-
public void reload() {
765+
public static void reload() {
766766
instance = YamlConfigurations.load(new File(LoaderUtils.getPlugin().getDataFolder(), "config.yml").toPath(), Config.class, properties);
767767
}
768768
}

common/src/main/java/com/loohp/multichatdiscordsrvaddon/MultiChatDiscordSrvAddon.java

+7
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,13 @@ public void reloadTextures(boolean redownload, boolean clean, CommandSender... r
512512
try {
513513
ChatUtils.sendMessage("<yellow>Loading \"" + resourceName + "\" resources...", senders);
514514
File resourcePackFile = new File(getDataFolder(), "resourcepacks/" + resourceName);
515+
if (resourceName.startsWith("path:")) {
516+
resourcePackFile = getDataFolder().toPath().resolve(resourceName.replace("path:", ""))
517+
.normalize()
518+
.toFile();
519+
}
520+
521+
515522
ResourcePackInfo info = resourceManager.loadResources(resourcePackFile, ResourcePackType.LOCAL);
516523
if (info.getStatus()) {
517524
if (info.compareServerPackFormat(ResourceRegistry.RESOURCE_PACK_VERSION) > 0) {

common/src/main/java/com/loohp/multichatdiscordsrvaddon/command/subcommand/ReloadConfigCommand.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void execute(
2626
try {
2727
if (plugin.resourceReloadLock.tryLock(0, TimeUnit.MILLISECONDS)) {
2828
try {
29-
Config.i().reload();
29+
Config.reload();
3030
ImageGeneration.onConfigReload();
3131
Bukkit.getPluginManager().callEvent(new MultiChatDiscordSRVConfigReloadEvent());
3232
ChatUtils.sendMessage(Config.i().getMessages().reloadConfig(), sender);

0 commit comments

Comments
 (0)