feat: 修复 getPluginConfig 可能的报错
This commit is contained in:
@@ -217,15 +217,15 @@ public final class CoreBukkitUtils {
|
||||
|
||||
@NotNull
|
||||
public static YamlConfiguration getPluginConfig(@NotNull Plugin plugin, @NotNull String filename) {
|
||||
File dataFolder = plugin.getDataFolder();
|
||||
if (dataFolder.mkdirs()) {
|
||||
plugin.getLogger().info("已生成插件存档文件夹...");
|
||||
File file = new File(plugin.getDataFolder(), filename);
|
||||
File parentFile = file.getParentFile();
|
||||
if (parentFile.mkdirs()) {
|
||||
plugin.getLogger().info("已生成插件存档文件夹 " + parentFile.getName());
|
||||
}
|
||||
File file = new File(dataFolder, filename);
|
||||
if (!file.exists()) {
|
||||
try (InputStream stream = plugin.getResource(filename)) {
|
||||
if (stream == null) {
|
||||
throw new IllegalArgumentException("在插件 " + plugin.getName() + " 的文件内部未找到 " + filename + " !");
|
||||
throw new NullPointerException("在插件 " + plugin.getName() + " 的文件内部未找到 " + filename + " !");
|
||||
}
|
||||
Files.copy(stream, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
} catch (IOException e) {
|
||||
|
Reference in New Issue
Block a user