From fbb107856974d46f6cb348826135c9315dd05feb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=84=97=E3=84=A0=CB=8B=20=E3=84=91=E3=84=A7=CB=8A?= Date: Mon, 9 Mar 2020 13:14:16 +0800 Subject: [PATCH 1/4] use JavaPlugin.getResource() instead of JarFile.getEntry() --- .../java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 3a2c2d7fd..d7cc73849 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -440,10 +440,10 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter protected void createDefaultConfiguration(String name) { File actual = new File(getDataFolder(), name); if (!actual.exists()) { - try (JarFile file = new JarFile(getFile())) { - ZipEntry copy = file.getEntry("defaults/" + name); - if (copy == null) throw new FileNotFoundException(); - copyDefaultConfig(file.getInputStream(copy), actual, name); + try { + InputStream stream = getResource("defaults/" + name); + if (stream == null) throw new FileNotFoundException(); + copyDefaultConfig(stream, actual, name); } catch (IOException e) { getLogger().severe("Unable to read default configuration: " + name); } From bd692917e67c8dcf0097ae7eee4a894345198649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=84=97=E3=84=A0=CB=8B=20=E3=84=91=E3=84=A7=CB=8A?= Date: Tue, 10 Mar 2020 12:36:16 +0800 Subject: [PATCH 2/4] remove unnecessary import --- .../main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index d7cc73849..302bc27f9 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -91,9 +91,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Optional; -import java.util.jar.JarFile; import java.util.logging.Level; -import java.util.zip.ZipEntry; import static com.google.common.base.Preconditions.checkNotNull; import static com.sk89q.worldedit.internal.anvil.ChunkDeleter.DELCHUNKS_FILE_NAME; From 39e1026400928780cdbefdc86fc4def6b0559f57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=84=97=E3=84=A0=CB=8B=20=E3=84=91=E3=84=A7=CB=8A?= Date: Wed, 11 Mar 2020 13:34:11 +0800 Subject: [PATCH 3/4] use try-with-resources --- .../java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 302bc27f9..164ec18c5 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -439,9 +439,10 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter File actual = new File(getDataFolder(), name); if (!actual.exists()) { try { - InputStream stream = getResource("defaults/" + name); - if (stream == null) throw new FileNotFoundException(); - copyDefaultConfig(stream, actual, name); + try (InputStream stream = getResource("defaults/" + name)) { + if (stream == null) throw new FileNotFoundException(); + copyDefaultConfig(stream, actual, name); + } } catch (IOException e) { getLogger().severe("Unable to read default configuration: " + name); } From dcee873b57e00080a4607a1e4251bd34c9ac7c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=84=97=E3=84=A0=CB=8B=20=E3=84=91=E3=84=A7=CB=8A?= Date: Wed, 11 Mar 2020 13:35:37 +0800 Subject: [PATCH 4/4] fix typo --- .../java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 164ec18c5..a3cc772c0 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -438,11 +438,9 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter protected void createDefaultConfiguration(String name) { File actual = new File(getDataFolder(), name); if (!actual.exists()) { - try { - try (InputStream stream = getResource("defaults/" + name)) { - if (stream == null) throw new FileNotFoundException(); - copyDefaultConfig(stream, actual, name); - } + try (InputStream stream = getResource("defaults/" + name)) { + if (stream == null) throw new FileNotFoundException(); + copyDefaultConfig(stream, actual, name); } catch (IOException e) { getLogger().severe("Unable to read default configuration: " + name); }