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) {
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);
}