111
This commit is contained in:
parent
9c23f5fc3d
commit
ce3d0c1bac
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.yuyu</groupId>
|
<groupId>com.yuyu</groupId>
|
||||||
<artifactId>SrWildEntity</artifactId>
|
<artifactId>SrWildEntity</artifactId>
|
||||||
<version>2.0.1-SNAPSHOT</version>
|
<version>2.0.3-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>SrWildEntity</name>
|
<name>SrWildEntity</name>
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
package com.yuyu.srwildentity.config.condition;
|
package com.yuyu.srwildentity.config.condition;
|
||||||
|
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import javax.swing.text.html.parser.Entity;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @BelongsProject: SrWildEntity
|
* @BelongsProject: SrWildEntity
|
||||||
@ -24,16 +27,16 @@ public class BiomeEntityRefreshSettings {
|
|||||||
//
|
//
|
||||||
// private final HashMap<String,HashMap<String,EntityCondition>> biomeEntityConditionMap;//此集合储存需要刷新的怪物的相关配置
|
// private final HashMap<String,HashMap<String,EntityCondition>> biomeEntityConditionMap;//此集合储存需要刷新的怪物的相关配置
|
||||||
private final List<LevelRefresh> levelRefreshesList;
|
private final List<LevelRefresh> levelRefreshesList;
|
||||||
|
private final HashMap<String,EntityCondition> generalEntityConditions;
|
||||||
|
private int levelMax;
|
||||||
|
|
||||||
|
|
||||||
public BiomeEntityRefreshSettings(Plugin plugin,int levelMax) {
|
public BiomeEntityRefreshSettings(Plugin plugin,int levelMax) {
|
||||||
// this.biomeEntityMap = new HashMap<>();
|
|
||||||
// this.biomeEntityConditionMap = new HashMap<>();
|
|
||||||
this.levelRefreshesList = new ArrayList<>();
|
|
||||||
|
|
||||||
// this.loadBiomeEntitiesConfig(plugin,levelMax);
|
this.levelRefreshesList = new ArrayList<>();
|
||||||
//
|
this.levelMax = levelMax;
|
||||||
// this.loadEntityConditionConfig(plugin,levelMax);
|
this.generalEntityConditions = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
this.loadRefreshEntity(plugin,levelMax);
|
this.loadRefreshEntity(plugin,levelMax);
|
||||||
|
|
||||||
@ -47,11 +50,25 @@ public class BiomeEntityRefreshSettings {
|
|||||||
File file = new File(plugin.getDataFolder(), "biomeEntity.yml");
|
File file = new File(plugin.getDataFolder(), "biomeEntity.yml");
|
||||||
config = YamlConfiguration.loadConfiguration(file);
|
config = YamlConfiguration.loadConfiguration(file);
|
||||||
|
|
||||||
|
HashMap<String,HashMap<String,Integer>> riskMap = new HashMap<>();
|
||||||
|
for (int i = 1;i <= levelMax;i++){
|
||||||
|
String risk = config.getString("risk_" + i);
|
||||||
|
String[] split = risk.split("\\|");
|
||||||
|
int min = Integer.parseInt(split[0]);
|
||||||
|
int max = Integer.parseInt(split[1]);
|
||||||
|
HashMap<String,Integer> map = new HashMap<>();
|
||||||
|
map.put("min",min);
|
||||||
|
map.put("max",max);
|
||||||
|
riskMap.put("risk_" + i,map);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//获取所有生物群系
|
//获取所有生物群系
|
||||||
plugin.saveResource("biome.yml",false);
|
plugin.saveResource("biome.yml",false);
|
||||||
FileConfiguration biomeconfig = null;
|
FileConfiguration biomeconfig = null;
|
||||||
File biomeName = new File(plugin.getDataFolder(),"biome.yml");
|
File biomeName = new File(plugin.getDataFolder(),"biome.yml");
|
||||||
biomeconfig = YamlConfiguration.loadConfiguration(biomeName);
|
biomeconfig = YamlConfiguration.loadConfiguration(biomeName);
|
||||||
|
//群系列表
|
||||||
List<String> biomeList = biomeconfig.getStringList("biome");
|
List<String> biomeList = biomeconfig.getStringList("biome");
|
||||||
|
|
||||||
|
|
||||||
@ -77,49 +94,56 @@ public class BiomeEntityRefreshSettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//按level_i 储存刷新的怪物列表
|
||||||
levelBiomeMap.put("level_"+i,biomeMap);
|
levelBiomeMap.put("level_"+i,biomeMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileConfiguration levelConfig = null;
|
||||||
|
File levelFile = new File(plugin.getDataFolder(), "entityCondition.yml");
|
||||||
|
levelConfig = YamlConfiguration.loadConfiguration(levelFile);
|
||||||
for (int i = 1;i <= level;i++){
|
for (int i = 1;i <= level;i++){
|
||||||
|
|
||||||
//读取对应的等级文件
|
|
||||||
// plugin.saveResource("LEVEL_"+i+".yml",false);
|
|
||||||
|
|
||||||
FileConfiguration levelConfig = null;
|
|
||||||
File levelFile = new File(plugin.getDataFolder(), "LEVEL_"+i+".yml");
|
|
||||||
levelConfig = YamlConfiguration.loadConfiguration(levelFile);
|
|
||||||
|
|
||||||
|
//获取对应等级的怪物刷新列表
|
||||||
HashMap<String, List<String>> stringListHashMap = levelBiomeMap.get("level_" + i);
|
HashMap<String, List<String>> stringListHashMap = levelBiomeMap.get("level_" + i);
|
||||||
|
|
||||||
//获取最大,最小危险度
|
//获取最大,最小危险度 todo(这里放到config.yml里面)
|
||||||
int riskMax = levelConfig.getInt("RISK_MAX");
|
// int riskMax = levelConfig.getInt("RISK_MAX");
|
||||||
int riskMin = levelConfig.getInt("RISK_MIN");
|
// int riskMin = levelConfig.getInt("RISK_MIN");
|
||||||
|
// 群系 实体列表
|
||||||
HashMap<String,List<EntityCondition>> listHashMap = new HashMap<>();
|
HashMap<String,HashMap<String,EntityCondition>> listHashMap = new HashMap<>();
|
||||||
|
|
||||||
for (String biome : stringListHashMap.keySet()){
|
for (String biome : stringListHashMap.keySet()){
|
||||||
|
|
||||||
|
|
||||||
List<EntityCondition> entityConditions = new ArrayList<>();
|
// List<EntityCondition> entityConditions = new ArrayList<>();
|
||||||
|
HashMap<String,EntityCondition> entityConditions = new HashMap<>();
|
||||||
|
|
||||||
List<String> strings = stringListHashMap.get(biome);
|
List<String> strings = stringListHashMap.get(biome);
|
||||||
for (String entityName : strings){
|
for (String entityName : strings){
|
||||||
SpawnEntityType spawnEntityType = SpawnEntityType.fromId(levelConfig.getInt(biome + "." + entityName + ".type"));
|
|
||||||
EntitySite entitySite = EntitySite.fromId(levelConfig.getInt(biome + "." + entityName + ".site"));
|
|
||||||
int light = levelConfig.getInt(biome + "." + entityName + ".light");
|
|
||||||
long stime = levelConfig.getLong(biome + "." + entityName + ".startTiming");
|
|
||||||
long etime = levelConfig.getLong(biome + "." + entityName + ".endTiming");
|
|
||||||
int nums = levelConfig.getInt(biome + "." + entityName + ".nums");
|
|
||||||
int yMax = levelConfig.getInt(biome + "." + entityName + ".yMax");
|
|
||||||
int yMin = levelConfig.getInt(biome + "." + entityName + ".yMin");
|
|
||||||
// int riskMax = levelConfig.getInt(biome + "." + entityName + ".riskMax");
|
|
||||||
// int riskMin = levelConfig.getInt(biome + "." + entityName + ".riskMin");
|
|
||||||
double weight = levelConfig.getDouble(biome + "." + entityName + ".weight");
|
|
||||||
EntityCondition entityCondition = new EntityCondition(entityName, biome,
|
|
||||||
spawnEntityType, entitySite, light, stime, etime, nums, yMax, yMin, 50, 0, weight);
|
|
||||||
|
|
||||||
entityConditions.add(entityCondition);
|
String matching_direction = levelConfig.getString(biome + "." + entityName + ".Matching_direction");
|
||||||
plugin.getLogger().info(ChatColor.AQUA +"Level:"+i +"\t"+ entityCondition.toString());
|
if (matching_direction != null){
|
||||||
|
String[] split = matching_direction.split("\\|");
|
||||||
|
String formation = split[0];
|
||||||
|
String entity = split[1];
|
||||||
|
|
||||||
|
EntityCondition entityCondition = makeEntityCondition(entity, formation, levelConfig);
|
||||||
|
entityConditions.put(entityName,entityCondition);
|
||||||
|
plugin.getLogger().info(ChatColor.AQUA +"Level:"+i +"\t"+ entityCondition.toString());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EntityCondition entityCondition = makeEntityCondition(entityName, biome, levelConfig);
|
||||||
|
|
||||||
|
|
||||||
|
entityConditions.put(entityName,entityCondition);
|
||||||
|
if (entityCondition == null){
|
||||||
|
plugin.getLogger().info(ChatColor.AQUA +"Level:"+i +"\t"+ entityCondition);
|
||||||
|
}else {
|
||||||
|
plugin.getLogger().info(ChatColor.AQUA + "Level:" + i + "\t" + entityCondition.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//此处按群系储存list
|
//此处按群系储存list
|
||||||
@ -127,101 +151,79 @@ public class BiomeEntityRefreshSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//此处按等级储存对应等级的LevelRefresh对象
|
//此处按等级储存对应等级的LevelRefresh对象
|
||||||
this.levelRefreshesList.add(new LevelRefresh(riskMax,riskMin,listHashMap));
|
this.levelRefreshesList.add(new LevelRefresh(riskMap.get("risk_"+i).get("max"),riskMap.get("risk_"+i).get("min"),listHashMap,"等级"+i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//循环通用的
|
||||||
|
plugin.saveResource("generalCondition.yml",false);
|
||||||
|
FileConfiguration generalCondition;
|
||||||
|
File generalFile = new File(plugin.getDataFolder(), "generalCondition.yml");
|
||||||
|
generalCondition = YamlConfiguration.loadConfiguration(generalFile);
|
||||||
|
Set<String> keys = generalCondition.getKeys(false);
|
||||||
|
|
||||||
|
for (String key : keys){
|
||||||
|
EntityCondition entityCondition = makeGeneralEntityCondition(key, generalCondition);
|
||||||
|
this.generalEntityConditions.put(key,entityCondition);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// private void loadEntityConditionConfig(Plugin plugin,int levelMax) {
|
public EntityCondition makeEntityCondition(String entityName,String biome,FileConfiguration levelConfig){
|
||||||
//
|
SpawnEntityType spawnEntityType = SpawnEntityType.fromId(levelConfig.getInt(biome + "." + entityName + ".type"));
|
||||||
// //保存文件
|
EntitySite entitySite = EntitySite.fromId(levelConfig.getInt(biome + "." + entityName + ".site"));
|
||||||
// plugin.saveResource("entityCondition.yml",false);
|
int light = levelConfig.getInt(biome + "." + entityName + ".light");
|
||||||
//
|
long stime = levelConfig.getLong(biome + "." + entityName + ".startTiming");
|
||||||
// FileConfiguration config;
|
long etime = levelConfig.getLong(biome + "." + entityName + ".endTiming");
|
||||||
// File file = new File(plugin.getDataFolder(), "entityCondition.yml");
|
int nums = levelConfig.getInt(biome + "." + entityName + ".nums");
|
||||||
// config = YamlConfiguration.loadConfiguration(file);
|
int yMax = levelConfig.getInt(biome + "." + entityName + ".yMax");
|
||||||
//
|
int yMin = levelConfig.getInt(biome + "." + entityName + ".yMin");
|
||||||
//
|
double weight = levelConfig.getDouble(biome + "." + entityName + ".weight");
|
||||||
// for (int i = 1;i<levelMax;i++) {
|
EntityCondition entityCondition = new EntityCondition(entityName, biome,
|
||||||
// for (String biomeName : this.biomeEntityMap.keySet()) {
|
spawnEntityType, entitySite, light, stime, etime, nums, yMax, yMin, 50, 0, weight);
|
||||||
// plugin.getLogger().info(ChatColor.GOLD + biomeName);
|
|
||||||
// HashMap<String, EntityCondition> entityConditionHashMap = new HashMap<>();
|
if (entityCondition.getNums()==0){
|
||||||
//
|
Bukkit.getServer().getPluginManager().getPlugin("SrWildEntity").getLogger().info(ChatColor.RED+biome+"."+entityName+".No_Condition");
|
||||||
// List<String> entities = this.biomeEntityMap.get(biomeName);
|
return null;
|
||||||
// for (String entityName : entities) {
|
}
|
||||||
// SpawnEntityType spawnEntityType = SpawnEntityType.fromId(config.getInt(biomeName + "." + entityName + ".type"));
|
return entityCondition;
|
||||||
// EntitySite entitySite = EntitySite.fromId(config.getInt(biomeName + "." + entityName + ".site"));
|
}
|
||||||
// int light = config.getInt(biomeName + "." + entityName + ".light");
|
|
||||||
// long stime = config.getLong(biomeName + "." + entityName + ".startTiming");
|
public EntityCondition makeGeneralEntityCondition(String entityName,FileConfiguration levelConfig){
|
||||||
// long etime = config.getLong(biomeName + "." + entityName + ".endTiming");
|
SpawnEntityType spawnEntityType = SpawnEntityType.fromId(levelConfig.getInt(entityName + ".type"));
|
||||||
// int nums = config.getInt(biomeName + "." + entityName + ".nums");
|
EntitySite entitySite = EntitySite.fromId(levelConfig.getInt( entityName + ".site"));
|
||||||
// int yMax = config.getInt(biomeName + "." + entityName + ".yMax");
|
int light = levelConfig.getInt( entityName + ".light");
|
||||||
// int yMin = config.getInt(biomeName + "." + entityName + ".yMin");
|
long stime = levelConfig.getLong( entityName + ".startTiming");
|
||||||
// int riskMax = config.getInt(biomeName + "." + entityName + ".riskMax");
|
long etime = levelConfig.getLong(entityName + ".endTiming");
|
||||||
// int riskMin = config.getInt(biomeName + "." + entityName + ".riskMin");
|
int nums = levelConfig.getInt( entityName + ".nums");
|
||||||
// double weight = config.getDouble(biomeName + "." + entityName + ".weight");
|
int yMax = levelConfig.getInt(entityName + ".yMax");
|
||||||
// EntityCondition entityCondition = new EntityCondition(entityName, biomeName,
|
int yMin = levelConfig.getInt( entityName + ".yMin");
|
||||||
// spawnEntityType, entitySite, light, stime, etime, nums, yMax, yMin, riskMax, riskMin, weight);
|
double weight = levelConfig.getDouble( entityName + ".weight");
|
||||||
//
|
EntityCondition entityCondition = new EntityCondition(entityName, null,
|
||||||
// plugin.getLogger().info(ChatColor.AQUA + entityCondition.toString());
|
spawnEntityType, entitySite, light, stime, etime, nums, yMax, yMin, 50, 0, weight);
|
||||||
//
|
|
||||||
// //存入单个群系刷新map
|
if (entityCondition.getNums()==0){
|
||||||
// entityConditionHashMap.put(entityName, entityCondition);
|
Bukkit.getServer().getPluginManager().getPlugin("SrWildEntity").getLogger().info(ChatColor.RED+"."+entityName+".No_Condition");
|
||||||
// }
|
return null;
|
||||||
// //存入记录总群系的map
|
}
|
||||||
// biomeEntityConditionMap.put(biomeName, entityConditionHashMap);
|
return entityCondition;
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
//
|
|
||||||
// plugin.getLogger().info("群系刷新相关文件读取完毕");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void loadBiomeEntitiesConfig(Plugin plugin,int levelMax){
|
|
||||||
// //保存文件
|
|
||||||
// plugin.saveResource("biomeEntity.yml",false);
|
|
||||||
//
|
|
||||||
// FileConfiguration config;
|
|
||||||
// File file = new File(plugin.getDataFolder(), "biomeEntity.yml");
|
|
||||||
// config = YamlConfiguration.loadConfiguration(file);
|
|
||||||
//
|
|
||||||
// //获取所有生物群系
|
|
||||||
// plugin.saveResource("biome.yml",false);
|
|
||||||
// FileConfiguration biomeconfig = null;
|
|
||||||
// File biomeName = new File(plugin.getDataFolder(),"biome.yml");
|
|
||||||
// biomeconfig = YamlConfiguration.loadConfiguration(biomeName);
|
|
||||||
// List<String> biomeList = biomeconfig.getStringList("biome");
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// if (config == null || biomeconfig == null){
|
|
||||||
// plugin.getLogger().info("biomeEntity.yml或者 biome.yml文件读取失败!");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //遍历所有可能的生物群系
|
|
||||||
// for (String section : biomeList){
|
|
||||||
// //判断是否存在
|
|
||||||
// if (config.contains(section)){
|
|
||||||
// List<String> entityList = config.getStringList(section+".ENTITY");
|
|
||||||
// this.biomeEntityMap.put(section,entityList);
|
|
||||||
// plugin.getLogger().info(ChatColor.MAGIC+section+ entityList.toString());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// plugin.getLogger().info("biomeEntity.读取完成");
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public HashMap<String, List<String>> getBiomeEntityMap() {
|
|
||||||
// return biomeEntityMap;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public HashMap<String, HashMap<String, EntityCondition>> getBiomeEntityConditionMap() {
|
|
||||||
// return biomeEntityConditionMap;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public List<LevelRefresh> getLevelRefreshesList() {
|
public List<LevelRefresh> getLevelRefreshesList() {
|
||||||
return levelRefreshesList;
|
return levelRefreshesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HashMap<String, EntityCondition> getGeneralEntityConditions() {
|
||||||
|
return generalEntityConditions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLevelMax() {
|
||||||
|
return levelMax;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLevelMax(int levelMax) {
|
||||||
|
this.levelMax = levelMax;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.yuyu.srwildentity.config.condition;
|
package com.yuyu.srwildentity.config.condition;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @BelongsProject: SrWildEntity
|
* @BelongsProject: SrWildEntity
|
||||||
* @BelongsPackage: com.yuyu.srwildentity.config.condition
|
* @BelongsPackage: com.yuyu.srwildentity.config.condition
|
||||||
@ -20,10 +22,9 @@ public class EntityCondition {
|
|||||||
private final int nums;//刷新的数量
|
private final int nums;//刷新的数量
|
||||||
private final int yMax;
|
private final int yMax;
|
||||||
private final int yMin;
|
private final int yMin;
|
||||||
private final int riskMax;
|
|
||||||
private final int riskMin;
|
|
||||||
private final double weight;
|
private final double weight;
|
||||||
private long refreshTime;
|
private long refreshTime;
|
||||||
|
private List<String> refreshAreas;
|
||||||
|
|
||||||
public EntityCondition(String entityName, String biome, SpawnEntityType spawnEntityType, EntitySite entitySite,
|
public EntityCondition(String entityName, String biome, SpawnEntityType spawnEntityType, EntitySite entitySite,
|
||||||
int light, long startTiming, long endTiming, int nums,
|
int light, long startTiming, long endTiming, int nums,
|
||||||
@ -38,8 +39,6 @@ public class EntityCondition {
|
|||||||
this.nums = nums;
|
this.nums = nums;
|
||||||
this.yMax = yMax;
|
this.yMax = yMax;
|
||||||
this.yMin = yMin;
|
this.yMin = yMin;
|
||||||
this.riskMax = riskMax;
|
|
||||||
this.riskMin = riskMin;
|
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
this.refreshTime = refreshTime;
|
this.refreshTime = refreshTime;
|
||||||
}
|
}
|
||||||
@ -56,8 +55,7 @@ public class EntityCondition {
|
|||||||
this.nums = nums;
|
this.nums = nums;
|
||||||
this.yMax = yMax;
|
this.yMax = yMax;
|
||||||
this.yMin = yMin;
|
this.yMin = yMin;
|
||||||
this.riskMax = riskMax;
|
|
||||||
this.riskMin = riskMin;
|
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,14 +63,6 @@ public class EntityCondition {
|
|||||||
return spawnEntityType;
|
return spawnEntityType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRiskMax() {
|
|
||||||
return riskMax;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRiskMin() {
|
|
||||||
return riskMin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SpawnEntityType getEntityType() {
|
public SpawnEntityType getEntityType() {
|
||||||
return spawnEntityType;
|
return spawnEntityType;
|
||||||
}
|
}
|
||||||
@ -123,6 +113,11 @@ public class EntityCondition {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
|
if (nums == 0){
|
||||||
|
return "EntityName = " + entityName + ", biome = " + biome + ", spawnEntityType = ";
|
||||||
|
}
|
||||||
|
|
||||||
return "EntityCondition{" +
|
return "EntityCondition{" +
|
||||||
"entityName='" + entityName + '\'' +
|
"entityName='" + entityName + '\'' +
|
||||||
", biome='" + biome + '\'' +
|
", biome='" + biome + '\'' +
|
||||||
@ -134,8 +129,6 @@ public class EntityCondition {
|
|||||||
", nums=" + nums +
|
", nums=" + nums +
|
||||||
", yMax=" + yMax +
|
", yMax=" + yMax +
|
||||||
", yMin=" + yMin +
|
", yMin=" + yMin +
|
||||||
", riskMax=" + riskMax +
|
|
||||||
", riskMin=" + riskMin +
|
|
||||||
", weight=" + weight +
|
", weight=" + weight +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,8 @@ public class LevelRefresh {
|
|||||||
private final int riskMax;
|
private final int riskMax;
|
||||||
private final int riskMin;
|
private final int riskMin;
|
||||||
// 群系名
|
// 群系名
|
||||||
private final HashMap<String, List<EntityCondition>> entityConditionHashMap;
|
private final HashMap<String, HashMap<String,EntityCondition>> entityConditionHashMap;
|
||||||
|
private final String levelStr;
|
||||||
|
|
||||||
public int getRiskMax() {
|
public int getRiskMax() {
|
||||||
return riskMax;
|
return riskMax;
|
||||||
@ -26,13 +27,18 @@ public class LevelRefresh {
|
|||||||
return riskMin;
|
return riskMin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<String, List<EntityCondition>> getEntityConditionHashMap() {
|
public HashMap<String, HashMap<String, EntityCondition>> getEntityConditionHashMap() {
|
||||||
return entityConditionHashMap;
|
return entityConditionHashMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LevelRefresh(int riskMax, int riskMin, HashMap<String, List<EntityCondition>> entityConditionHashMap) {
|
public LevelRefresh(int riskMax, int riskMin, HashMap<String, HashMap<String,EntityCondition>> entityConditionHashMap, String levelStr) {
|
||||||
this.riskMax = riskMax;
|
this.riskMax = riskMax;
|
||||||
this.riskMin = riskMin;
|
this.riskMin = riskMin;
|
||||||
this.entityConditionHashMap = entityConditionHashMap;
|
this.entityConditionHashMap = entityConditionHashMap;
|
||||||
|
this.levelStr = levelStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLevelStr() {
|
||||||
|
return levelStr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,8 +130,12 @@ public class PlayerRefreshLintener {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
String levelStr;
|
||||||
|
if (refreshList.getLevelStr().contains("1")){
|
||||||
|
levelStr = "";
|
||||||
|
}else {
|
||||||
|
levelStr = refreshList.getLevelStr();
|
||||||
|
}
|
||||||
|
|
||||||
//获取玩家位置信息
|
//获取玩家位置信息
|
||||||
int blockZ = playerlocation.getBlockZ();
|
int blockZ = playerlocation.getBlockZ();
|
||||||
@ -140,9 +144,9 @@ public class PlayerRefreshLintener {
|
|||||||
Biome biome = world.getBiome(blockX, blockZ);
|
Biome biome = world.getBiome(blockX, blockZ);
|
||||||
String biomeName = biome.name();
|
String biomeName = biome.name();
|
||||||
|
|
||||||
List<EntityCondition> entityConditionList = null;
|
HashMap<String,EntityCondition> entityConditionList = null;
|
||||||
|
|
||||||
HashMap<String, List<EntityCondition>> entityConditionHashMap = refreshList.getEntityConditionHashMap();
|
HashMap<String, HashMap<String,EntityCondition>> entityConditionHashMap = refreshList.getEntityConditionHashMap();
|
||||||
for (String refreshBiome : entityConditionHashMap.keySet()){
|
for (String refreshBiome : entityConditionHashMap.keySet()){
|
||||||
if (biomeName.contains(refreshBiome)){
|
if (biomeName.contains(refreshBiome)){
|
||||||
entityConditionList = entityConditionHashMap.get(refreshBiome);
|
entityConditionList = entityConditionHashMap.get(refreshBiome);
|
||||||
@ -157,8 +161,18 @@ public class PlayerRefreshLintener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (EntityCondition entityCondition : entityConditionList){
|
for (String entityName : entityConditionList.keySet()){
|
||||||
|
EntityCondition entityCondition = entityConditionList.get(entityName);
|
||||||
|
//如果为空,则去通用刷新寻找
|
||||||
|
if (entityCondition == null){
|
||||||
|
HashMap<String, EntityCondition> generalEntityConditions = configManager.getBiomeEntityRefreshSettings().getGeneralEntityConditions();
|
||||||
|
if (generalEntityConditions.containsKey(entityName)){
|
||||||
|
entityCondition = generalEntityConditions.get(entityName);
|
||||||
|
}else {
|
||||||
|
EntityRefreshListener.log.info(ChatColor.RED + "没有配置" + entityName + "的刷新配置");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int yMin = entityCondition.getyMin();
|
int yMin = entityCondition.getyMin();
|
||||||
int yMax = entityCondition.getyMax();
|
int yMax = entityCondition.getyMax();
|
||||||
@ -206,7 +220,7 @@ public class PlayerRefreshLintener {
|
|||||||
}else {
|
}else {
|
||||||
//刷新MM怪物
|
//刷新MM怪物
|
||||||
try {
|
try {
|
||||||
entity = mythicMobs.getAPIHelper().spawnMythicMob(entityCondition.getEntityName(),location,riskLevel);
|
entity = mythicMobs.getAPIHelper().spawnMythicMob(entityCondition.getEntityName()+levelStr,location,riskLevel);
|
||||||
} catch (InvalidMobTypeException e) {
|
} catch (InvalidMobTypeException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@ -251,7 +265,7 @@ public class PlayerRefreshLintener {
|
|||||||
}else {
|
}else {
|
||||||
//刷新MM怪物
|
//刷新MM怪物
|
||||||
try {
|
try {
|
||||||
entity = MythicMobs.inst().getAPIHelper().spawnMythicMob(entityCondition.getEntityName(), location);
|
entity = MythicMobs.inst().getAPIHelper().spawnMythicMob(entityCondition.getEntityName()+levelStr, location);
|
||||||
} catch (InvalidMobTypeException e) {
|
} catch (InvalidMobTypeException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
risk_1: 0|20
|
||||||
|
risk_2: 20|30
|
||||||
|
|
||||||
DESERT: #群系名称,下方标出该群系需要刷新的entity
|
DESERT: #群系名称,下方标出该群系需要刷新的entity
|
||||||
ENTITY_LEVEL_1: [ZOMBIE,PIG_ZOMBIE] #该群系刷新的entity,具体的怪物刷新配置需要去entityConfig.yml中配置,!!注意此处的实体配置一定要在实体配置文件中存在,否则会不会刷新!
|
ENTITY_LEVEL_1: [ZOMBIE,PIG_ZOMBIE] #该群系刷新的entity,具体的怪物刷新配置需要去entityConfig.yml中配置,!!注意此处的实体配置一定要在实体配置文件中存在,否则会不会刷新!
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#RISK_MAX: 10 #当最大危险度为多少时读取这个yml文件,10的时候会读取
|
|
||||||
#RISK_MIN: 0 #当最小危险度为多少时读取这个yml文件,0的时候不会读取
|
|
||||||
DESERT:
|
DESERT:
|
||||||
ZOMBIE: #指出entity在该群系的刷新条件
|
ZOMBIE: #指出entity在该群系的刷新条件
|
||||||
Matching_direction: ROOFED_FOREST_ZOMBIE #群系_怪物 会直接读取该实体的刷新配置
|
Matching_direction: ROOFED|ZOMBIE #群系_怪物 会直接读取该实体的刷新配置
|
||||||
ROOFED_FOREST:
|
ROOFED_FOREST:
|
||||||
ZOMBIE: #指出entity在该群系的刷新条件
|
ZOMBIE: #指出entity在该群系的刷新条件
|
||||||
type: 0 #0表示生成mc原生实体,1表示生成MM怪物,2表示生成萌芽怪物
|
type: 0 #0表示生成mc原生实体,1表示生成MM怪物,2表示生成萌芽怪物
|
13
src/main/resources/generalCondition.yml
Normal file
13
src/main/resources/generalCondition.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#通用
|
||||||
|
PIG_ZOMBIE:
|
||||||
|
weight: 0.6
|
||||||
|
type: 0 #0表示生成mc原生实体,1表示生成MM怪物,2表示生成萌芽怪物
|
||||||
|
site: 1 #刷新位置,数字代表不同的刷新位置
|
||||||
|
light: 15 #刷新亮度
|
||||||
|
startTiming: 0 #刷新怪物的时间,注意这里需要用mc中的时间格式来表示,而不是现实中的时间
|
||||||
|
endTiming: 24000 #结束刷新的时间,怪物会在这个区间内刷新
|
||||||
|
nums: 2 #entity的刷新数量,注意,这里的数量会和通群系中其他entity相关,总数不会超过config.yml中的定义
|
||||||
|
yMax: 150 #极限刷新高度
|
||||||
|
yMin: 60 #最小刷新高度
|
||||||
|
riskMax: 10 #刷新危险度的范围
|
||||||
|
riskMin: 0
|
Loading…
x
Reference in New Issue
Block a user