diff --git a/build.gradle.kts b/build.gradle.kts index b934bee8..e8b56d75 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -103,6 +103,7 @@ dependencies { implementation("dev.jorel", "commandapi-bukkit-shade-mojang-mapped", "9.5.3") implementation("net.lingala.zip4j", "zip4j", "2.11.5") implementation("com.github.EsotericFoundation:utility.kt:0.1.0") + implementation("com.github.EsotericFoundation:plugin-library:0.1.0") } tasks { diff --git a/src/main/java/org/esoteric/minecraft/plugins/template/PaperTemplatePlugin.java b/src/main/java/org/esoteric/minecraft/plugins/template/PaperTemplatePlugin.java index 3c0dd424..1d1eabbe 100644 --- a/src/main/java/org/esoteric/minecraft/plugins/template/PaperTemplatePlugin.java +++ b/src/main/java/org/esoteric/minecraft/plugins/template/PaperTemplatePlugin.java @@ -2,6 +2,8 @@ import dev.jorel.commandapi.CommandAPI; import dev.jorel.commandapi.CommandAPIBukkitConfig; +import foundation.esoteric.minecraft.plugins.library.file.FileManagedPlugin; +import foundation.esoteric.minecraft.plugins.library.file.FileManager; import org.bukkit.NamespacedKey; import org.bukkit.plugin.java.JavaPlugin; import org.esoteric.minecraft.plugins.template.commands.GiveCustomItemCommand; @@ -15,13 +17,12 @@ import org.esoteric.minecraft.plugins.template.custom.multientities.CustomMultientity; import org.esoteric.minecraft.plugins.template.custom.multientities.CustomMultientityManager; import org.esoteric.minecraft.plugins.template.data.player.PlayerDataManager; -import org.esoteric.minecraft.plugins.template.file.FileManager; import org.esoteric.minecraft.plugins.template.http.server.HttpServerManager; import org.esoteric.minecraft.plugins.template.language.LanguageManager; import org.esoteric.minecraft.plugins.template.language.Message; import org.esoteric.minecraft.plugins.template.resourcepack.ResourcePackManager; -public final class PaperTemplatePlugin extends JavaPlugin { +public final class PaperTemplatePlugin extends JavaPlugin implements FileManagedPlugin { private FileManager fileManager; private PlayerDataManager playerDataManager; diff --git a/src/main/java/org/esoteric/minecraft/plugins/template/file/FileManager.java b/src/main/java/org/esoteric/minecraft/plugins/template/file/FileManager.java deleted file mode 100644 index fa64c4ca..00000000 --- a/src/main/java/org/esoteric/minecraft/plugins/template/file/FileManager.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.esoteric.minecraft.plugins.template.file; - -import foundation.esoteric.utility.resource.ResourceUtility; -import org.esoteric.minecraft.plugins.template.PaperTemplatePlugin; - -import java.io.File; - -public class FileManager { - - private final PaperTemplatePlugin plugin; - - public FileManager(PaperTemplatePlugin plugin) { - this.plugin = plugin; - } - - public File saveResourceFileFolder(String resourceFileFolderPath, boolean shouldReplaceExistingFiles) { - ResourceUtility.Companion.getResourceFilePaths(resourceFileFolderPath).forEach((resourceFilePath) -> plugin.saveResource(resourceFilePath.toString(), shouldReplaceExistingFiles)); - return new File(plugin.getDataPath() + File.separator + resourceFileFolderPath); - } - - public File saveResourceFileFolder(String resourceFileFolderPath) { - return saveResourceFileFolder(resourceFileFolderPath, true); - } -} diff --git a/src/main/java/org/esoteric/minecraft/plugins/template/language/LanguageManager.java b/src/main/java/org/esoteric/minecraft/plugins/template/language/LanguageManager.java index d0078342..517e626b 100644 --- a/src/main/java/org/esoteric/minecraft/plugins/template/language/LanguageManager.java +++ b/src/main/java/org/esoteric/minecraft/plugins/template/language/LanguageManager.java @@ -54,7 +54,7 @@ public LanguageManager(@NotNull PaperTemplatePlugin plugin) { private void saveLanguageFiles() { String languagesResourceFolderName = languagesFolderName; - plugin.getFileManager().saveResourceFileFolder(languagesResourceFolderName, !plugin.getConfig().getBoolean("language.use-custom-messages")); + plugin.getFileManager().saveResourceFolder(languagesResourceFolderName, !plugin.getConfig().getBoolean("language.use-custom-messages")); } private void loadLanguageMessages() { diff --git a/src/main/java/org/esoteric/minecraft/plugins/template/resourcepack/ResourcePackManager.java b/src/main/java/org/esoteric/minecraft/plugins/template/resourcepack/ResourcePackManager.java index 7ff792db..12ee2bbe 100644 --- a/src/main/java/org/esoteric/minecraft/plugins/template/resourcepack/ResourcePackManager.java +++ b/src/main/java/org/esoteric/minecraft/plugins/template/resourcepack/ResourcePackManager.java @@ -54,8 +54,7 @@ public ResourcePackManager(PaperTemplatePlugin plugin) { } private void saveResourcepackZipFile() { - assert plugin.getFileManager() != null; - File resourcePackFolder = plugin.getFileManager().saveResourceFileFolder(resourcePackResourceFolderName); + File resourcePackFolder = plugin.getFileManager().saveResourceFolder(resourcePackResourceFolderName, true); String[] resourcePackFiles = resourcePackFolder.list(); if (resourcePackFiles == null || resourcePackFiles.length == 0) {