Merge branch '1.0.0'
This commit is contained in:
@@ -41,10 +41,23 @@ public final class CoreBungeeCordUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Configuration getPluginConfig(@NotNull Plugin plugin, @NotNull String filename) {
|
||||
File configFile = new File(plugin.getDataFolder(), filename);
|
||||
if (!configFile.exists()) {
|
||||
return saveDefaultConfig(plugin, filename);
|
||||
}
|
||||
try {
|
||||
return ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Configuration saveDefaultConfig(@NotNull Plugin plugin) {
|
||||
if (plugin.getDataFolder().mkdir()) {
|
||||
plugin.getLogger().info("创建插件文件夹...");
|
||||
plugin.getLogger().info("已生成插件存档文件夹...");
|
||||
}
|
||||
File configFile = new File(plugin.getDataFolder(), "config.yml");
|
||||
try {
|
||||
@@ -55,4 +68,19 @@ public final class CoreBungeeCordUtils {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Configuration saveDefaultConfig(@NotNull Plugin plugin, @NotNull String filename) {
|
||||
if (plugin.getDataFolder().mkdir()) {
|
||||
plugin.getLogger().info("已生成插件存档文件夹...");
|
||||
}
|
||||
File configFile = new File(plugin.getDataFolder(), filename);
|
||||
try {
|
||||
InputStream in = plugin.getResourceAsStream(filename);
|
||||
Files.copy(in, configFile.toPath());
|
||||
return ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user