From ab10a6f4a128bdc4c28f6847a994898d973ce08e Mon Sep 17 00:00:00 2001 From: Alberto Migliorato Date: Thu, 31 Aug 2023 16:14:32 +0200 Subject: [PATCH] idk what's changed but now full recursive getResourceAsStream works --- README.md | 6 ++--- all/pom.xml | 2 +- bukkit-plugin/pom.xml | 2 +- bukkit-plugin/src/main/resources/config.yml | 2 +- bukkit-plugin/src/main/resources/plugin.yml | 2 +- bukkit/pom.xml | 2 +- .../bukkit/config/BukkitConfigManager.java | 24 ++++++++++++------- bungee-plugin/pom.xml | 2 +- bungee-plugin/src/main/resources/bungee.yml | 2 +- bungee-plugin/src/main/resources/config.yml | 2 +- bungee/pom.xml | 2 +- common/pom.xml | 2 +- pom.xml | 2 +- velocity-plugin/pom.xml | 2 +- .../powerlib/velocity/PowerLibPlugin.java | 2 +- .../src/main/resources/velocity-plugin.json | 2 +- velocity/pom.xml | 2 +- 17 files changed, 33 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 52d3715..9d9b553 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Development builds are always available at: **https://ci.codemc.io/job/AlbeMigli it.mycraft powerlib- - 1.2.9 + 1.2.10 provided @@ -61,7 +61,7 @@ repositories { } dependencies { - compileOnly 'it.mycraft:powerlib-:1.2.9' + compileOnly 'it.mycraft:powerlib-:1.2.10' } ``` @@ -82,7 +82,7 @@ your plugin and rename its packages: it.mycraft powerlib- - 1.2.9 + 1.2.10 compile diff --git a/all/pom.xml b/all/pom.xml index 0c2013e..b88b359 100644 --- a/all/pom.xml +++ b/all/pom.xml @@ -5,7 +5,7 @@ powerlib it.mycraft - 1.2.9 + 1.2.10 4.0.0 diff --git a/bukkit-plugin/pom.xml b/bukkit-plugin/pom.xml index 3c32c73..1d41f12 100644 --- a/bukkit-plugin/pom.xml +++ b/bukkit-plugin/pom.xml @@ -5,7 +5,7 @@ it.mycraft powerlib - 1.2.9 + 1.2.10 4.0.0 jar diff --git a/bukkit-plugin/src/main/resources/config.yml b/bukkit-plugin/src/main/resources/config.yml index 0e0360f..f4c610a 100644 --- a/bukkit-plugin/src/main/resources/config.yml +++ b/bukkit-plugin/src/main/resources/config.yml @@ -1,4 +1,4 @@ # -# PowerLib v1.2.9 +# PowerLib v1.2.10 # check-for-updates: true \ No newline at end of file diff --git a/bukkit-plugin/src/main/resources/plugin.yml b/bukkit-plugin/src/main/resources/plugin.yml index 579a080..7d0b411 100644 --- a/bukkit-plugin/src/main/resources/plugin.yml +++ b/bukkit-plugin/src/main/resources/plugin.yml @@ -1,4 +1,4 @@ name: PowerLib authors: [AlbeMiglio, FranFrau] main: it.mycraft.powerlib.bukkit.PowerLibPlugin -version: 1.2.9 \ No newline at end of file +version: 1.2.10 \ No newline at end of file diff --git a/bukkit/pom.xml b/bukkit/pom.xml index f680c81..927e6b0 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -5,7 +5,7 @@ it.mycraft powerlib - 1.2.9 + 1.2.10 4.0.0 diff --git a/bukkit/src/main/java/it/mycraft/powerlib/bukkit/config/BukkitConfigManager.java b/bukkit/src/main/java/it/mycraft/powerlib/bukkit/config/BukkitConfigManager.java index 18346d6..a919df1 100644 --- a/bukkit/src/main/java/it/mycraft/powerlib/bukkit/config/BukkitConfigManager.java +++ b/bukkit/src/main/java/it/mycraft/powerlib/bukkit/config/BukkitConfigManager.java @@ -1,5 +1,6 @@ package it.mycraft.powerlib.bukkit.config; +import it.mycraft.powerlib.common.chat.Message; import it.mycraft.powerlib.common.configuration.ConfigManager; import it.mycraft.powerlib.common.configuration.Configuration; import it.mycraft.powerlib.common.configuration.ConfigurationProvider; @@ -62,7 +63,7 @@ public Configuration get(String file) { * @return The new file */ public Configuration create(String file, String source) { - File resourcePath = new File(folder + "/" + file); + File resourcePath = new File(folder + File.separator + file); if (!resourcePath.exists()) { createYAML(file, source, false); } @@ -86,7 +87,7 @@ public void save(String file) { } try { ConfigurationProvider.getProvider(YamlConfiguration.class) - .save(config, new File(folder + "/" + file)); + .save(config, new File(folder + File.separator + file)); } catch (IOException ex) { Bukkit.getLogger().log(Level.SEVERE, "Exception encountered while saving a yaml file! Please contact an administrator!"); } @@ -123,7 +124,7 @@ public void reloadAll() { private Configuration load(String file) { try { return ConfigurationProvider.getProvider(YamlConfiguration.class) - .load(new File(folder + "/" + file)); + .load(new File(folder + File.separator + file)); } catch (IOException ex) { Bukkit.getLogger().log(Level.SEVERE, "Exception encountered while loading a yaml file! Please contact an administrator!"); return null; @@ -149,9 +150,9 @@ private void put(String file, Configuration config) { */ private void createYAML(String resourcePath, String source, boolean replace) { try { - File file = new File(folder + "/" + resourcePath); + File file = new File(folder + File.separator + resourcePath); if (!file.getParentFile().exists() || !file.exists()) { - file.getParentFile().mkdir(); + file.getParentFile().mkdirs(); if (file.createNewFile()) { replace = true; } @@ -159,12 +160,14 @@ private void createYAML(String resourcePath, String source, boolean replace) { replace = true; } if (replace) { - Files.copy(getResourceAsStream(source), - file.toPath(), StandardCopyOption.REPLACE_EXISTING); + Files.copy(getResourceAsStream(source), file.toPath(), StandardCopyOption.REPLACE_EXISTING); } else Files.copy(getResourceAsStream(source), file.toPath()); } } catch (IOException | ClassNotFoundException | URISyntaxException e) { - Bukkit.getLogger().log(Level.SEVERE, "Exception encountered while creating a yaml file! Please contact an administrator!"); + new Message("&cException encountered while creating a yaml file! Please contact an administrator!", + "&cError message: %msg") + .addPlaceHolder("%msg", e.getMessage()) + .sendConsole(); } } @@ -174,6 +177,7 @@ private void createYAML(String resourcePath, boolean replace) { private InputStream getResourceAsStream(String name) throws ClassNotFoundException, URISyntaxException, IOException { + try (ZipFile file = new ZipFile(pluginJar); ZipInputStream zip = new ZipInputStream(pluginJar.toURL().openStream())) { boolean stop = false; @@ -181,7 +185,9 @@ private InputStream getResourceAsStream(String name) throws ClassNotFoundExcepti ZipEntry e = zip.getNextEntry(); if (e == null) { stop = true; - } else if (e.getName().equals(name)) { + continue; + } + if (e.getName().equals(name)) { return cloneInputStream(file.getInputStream(e)); } } diff --git a/bungee-plugin/pom.xml b/bungee-plugin/pom.xml index e1a5a21..c8f12b1 100644 --- a/bungee-plugin/pom.xml +++ b/bungee-plugin/pom.xml @@ -5,7 +5,7 @@ powerlib it.mycraft - 1.2.9 + 1.2.10 4.0.0 diff --git a/bungee-plugin/src/main/resources/bungee.yml b/bungee-plugin/src/main/resources/bungee.yml index 441749e..07516bd 100644 --- a/bungee-plugin/src/main/resources/bungee.yml +++ b/bungee-plugin/src/main/resources/bungee.yml @@ -2,4 +2,4 @@ name: PowerLib author: AlbeMiglio authors: [AlbeMiglio, FranFrau] main: it.mycraft.powerlib.bungee.PowerLibPlugin -version: 1.2.9 \ No newline at end of file +version: 1.2.10 \ No newline at end of file diff --git a/bungee-plugin/src/main/resources/config.yml b/bungee-plugin/src/main/resources/config.yml index 0e0360f..f4c610a 100644 --- a/bungee-plugin/src/main/resources/config.yml +++ b/bungee-plugin/src/main/resources/config.yml @@ -1,4 +1,4 @@ # -# PowerLib v1.2.9 +# PowerLib v1.2.10 # check-for-updates: true \ No newline at end of file diff --git a/bungee/pom.xml b/bungee/pom.xml index 86c36f5..2f4841d 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -5,7 +5,7 @@ powerlib it.mycraft - 1.2.9 + 1.2.10 4.0.0 diff --git a/common/pom.xml b/common/pom.xml index bf7438d..6de49bd 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ powerlib it.mycraft - 1.2.9 + 1.2.10 4.0.0 diff --git a/pom.xml b/pom.xml index 1c703b2..c62fc0c 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ it.mycraft powerlib pom - 1.2.9 + 1.2.10 MIT License diff --git a/velocity-plugin/pom.xml b/velocity-plugin/pom.xml index 5366ef5..4acf692 100644 --- a/velocity-plugin/pom.xml +++ b/velocity-plugin/pom.xml @@ -5,7 +5,7 @@ powerlib it.mycraft - 1.2.9 + 1.2.10 4.0.0 diff --git a/velocity-plugin/src/main/java/it/mycraft/powerlib/velocity/PowerLibPlugin.java b/velocity-plugin/src/main/java/it/mycraft/powerlib/velocity/PowerLibPlugin.java index b4ae14d..906fcfd 100644 --- a/velocity-plugin/src/main/java/it/mycraft/powerlib/velocity/PowerLibPlugin.java +++ b/velocity-plugin/src/main/java/it/mycraft/powerlib/velocity/PowerLibPlugin.java @@ -24,7 +24,7 @@ import java.nio.file.Path; @Getter -@Plugin(id = "powerlib", name = "PowerLib", version = "1.2.9", authors = {"AlbeMiglio", "FranFrau"}) +@Plugin(id = "powerlib", name = "PowerLib", version = "1.2.10", authors = {"AlbeMiglio", "FranFrau"}) public class PowerLibPlugin { private ProxyServer proxy; diff --git a/velocity-plugin/src/main/resources/velocity-plugin.json b/velocity-plugin/src/main/resources/velocity-plugin.json index 4f6ede7..66f04ff 100644 --- a/velocity-plugin/src/main/resources/velocity-plugin.json +++ b/velocity-plugin/src/main/resources/velocity-plugin.json @@ -1,2 +1,2 @@ -{"id":"powerlib","name":"PowerLib","version":"1.2.9","authors":["AlbeMiglio","FranFrau"], +{"id":"powerlib","name":"PowerLib","version":"1.2.10","authors":["AlbeMiglio","FranFrau"], "dependencies":[],"main":"it.mycraft.powerlib.velocity.PowerLibPlugin"} \ No newline at end of file diff --git a/velocity/pom.xml b/velocity/pom.xml index 23de84c..15581ed 100644 --- a/velocity/pom.xml +++ b/velocity/pom.xml @@ -5,7 +5,7 @@ powerlib it.mycraft - 1.2.9 + 1.2.10 4.0.0