9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-23 17:09:21 +00:00
This commit is contained in:
Xiao-MoMi
2022-06-14 14:51:37 +08:00
parent a1f53c4ad7
commit bea7e823b6
9 changed files with 142 additions and 145 deletions

View File

@@ -163,35 +163,39 @@ public class ConfigManager {
YamlConfiguration cropConfig = getConfig("crops.yml");
Set<String> keys = cropConfig.getConfigurationSection("crops").getKeys(false);
keys.forEach(key -> {
double chance = cropConfig.getDouble("crops."+key+".grow-chance");
Crop crop = new Crop(key, chance);
if(cropConfig.getConfigurationSection("crops."+key).contains("return")){
crop.setWillReturn(true);
crop.setReturnStage(cropConfig.getString("crops."+key+".return"));
}else {
crop.setWillReturn(false);
}
if(Config.season){
if(cropConfig.getConfigurationSection("crops."+key).contains("season")){
crop.setSeasons(StringUtils.split( cropConfig.getString("crops."+key+".season"), ","));
if(cropConfig.getConfigurationSection("crops."+key).contains("grow-chance")){
double chance = cropConfig.getDouble("crops."+key+".grow-chance");
Crop crop = new Crop(key, chance);
if(cropConfig.getConfigurationSection("crops."+key).contains("return")){
crop.setWillReturn(true);
crop.setReturnStage(cropConfig.getString("crops."+key+".return"));
}else {
MessageManager.consoleMessage("&c[CustomCrops] 错误!在启用季节模式的情况下未设置农作物 &f"+ key +" &c的生长季节!", Bukkit.getConsoleSender());
return;
crop.setWillReturn(false);
}
}
if(cropConfig.getConfigurationSection("crops."+key).contains("gigantic")){
crop.setWillGiant(true);
crop.setGiant(cropConfig.getString("crops."+key+".gigantic"));
if(cropConfig.getConfigurationSection("crops."+key).contains("gigantic-chance")){
crop.setGiantChance(cropConfig.getDouble("crops."+key+".gigantic-chance"));
if(Config.season){
if(cropConfig.getConfigurationSection("crops."+key).contains("season")){
crop.setSeasons(StringUtils.split( cropConfig.getString("crops."+key+".season"), ","));
}else {
MessageManager.consoleMessage("&c[CustomCrops] 错误!在启用季节模式的情况下未设置农作物 &f"+ key +" &c的生长季节!", Bukkit.getConsoleSender());
return;
}
}
if(cropConfig.getConfigurationSection("crops."+key).contains("gigantic")){
crop.setWillGiant(true);
crop.setGiant(cropConfig.getString("crops."+key+".gigantic"));
if(cropConfig.getConfigurationSection("crops."+key).contains("gigantic-chance")){
crop.setGiantChance(cropConfig.getDouble("crops."+key+".gigantic-chance"));
}else {
MessageManager.consoleMessage("&c[CustomCrops] 错误!未设置农作物 &f"+ key +" &c的巨大化概率!", Bukkit.getConsoleSender());
return;
}
}else {
MessageManager.consoleMessage("&c[CustomCrops] 错误!未设置农作物 &f"+ key +" &c的巨大化概率!", Bukkit.getConsoleSender());
return;
crop.setWillGiant(false);
}
CONFIG.put(key, crop);
}else {
crop.setWillGiant(false);
MessageManager.consoleMessage("&c[CustomCrops] 错误!未设置农作物 &f"+ key +" &c的生长概率!", Bukkit.getConsoleSender());
}
CONFIG.put(key, crop);
});
if(keys.size() == CONFIG.size()){
MessageManager.consoleMessage("&#ccfbff-#ef96c5&[CustomCrops] &f成功载入 &a" + CONFIG.size() + " &f种农作物", Bukkit.getConsoleSender());