fix(core-bukkit): 修复启动时不自动初始化配置文件的问题
This commit is contained in:
@@ -24,6 +24,9 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.Objects;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@SuppressWarnings("CallToPrintStackTrace")
|
||||
@@ -68,8 +71,15 @@ public class HamsterCorePlugin extends JavaPlugin {
|
||||
if (dataFolder.mkdir()) {
|
||||
logger.info("已生成插件存档文件夹");
|
||||
}
|
||||
File file = new File(dataFolder, "config.yml");
|
||||
CoreBukkitAPI.init(file);
|
||||
File configFile = new File(dataFolder, "config.yml");
|
||||
if (!configFile.exists()) {
|
||||
Files.copy(
|
||||
Objects.requireNonNull(getResource("config.yml")),
|
||||
configFile.toPath(),
|
||||
StandardCopyOption.REPLACE_EXISTING
|
||||
);
|
||||
}
|
||||
CoreBukkitAPI.init(configFile);
|
||||
logger.info("已初始化 CoreAPI");
|
||||
} catch (Exception e) {
|
||||
logger.warning("初始化 CoreAPI 出错");
|
||||
|
Reference in New Issue
Block a user