use JavaPlugin.getResource() instead of JarFile.getEntry()

This commit is contained in:
ㄗㄠˋ ㄑㄧˊ 2020-03-09 13:14:16 +08:00 committed by GitHub
parent c1fe16b0e9
commit fbb1078569
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -440,10 +440,10 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
protected void createDefaultConfiguration(String name) { protected void createDefaultConfiguration(String name) {
File actual = new File(getDataFolder(), name); File actual = new File(getDataFolder(), name);
if (!actual.exists()) { if (!actual.exists()) {
try (JarFile file = new JarFile(getFile())) { try {
ZipEntry copy = file.getEntry("defaults/" + name); InputStream stream = getResource("defaults/" + name);
if (copy == null) throw new FileNotFoundException(); if (stream == null) throw new FileNotFoundException();
copyDefaultConfig(file.getInputStream(copy), actual, name); copyDefaultConfig(stream, actual, name);
} catch (IOException e) { } catch (IOException e) {
getLogger().severe("Unable to read default configuration: " + name); getLogger().severe("Unable to read default configuration: " + name);
} }