测试版

This commit is contained in:
tianyu 2024-08-23 01:54:29 +08:00
parent e0ccdfc871
commit 916d4fd0c6
2 changed files with 18 additions and 17 deletions

View File

@ -14,13 +14,13 @@ public class BossManage {
private boolean bossSurvive; private boolean bossSurvive;
private final List<String> bossKeyList = new ArrayList<>(); // 获取boss名列表 private final List<String> bossKeyList = new ArrayList<>(); // 获取boss名列表
private final List<String> customNameList = new ArrayList<>(); // 获取boss名列表 private final List<String> customNameList = new ArrayList<>(); // 获取boss名列表
private final HashMap<String,BossData> bossDataMap = new HashMap<>(); private final HashMap<String, BossData> bossDataMap = new HashMap<>();
public BossManage(FileConfiguration yml) { public BossManage(FileConfiguration yml) {
this.bossSurvive = false; this.bossSurvive = false;
for (String bossKey : yml.getConfigurationSection("BossData").getKeys(false)){ for (String bossKey : yml.getConfigurationSection("BossData").getKeys(false)) {
bossDataMap.put(bossKey,new BossData(bossKey,yml)); bossDataMap.put(bossKey, new BossData(bossKey, yml));
String customName = yml.getString("BossData."+bossKey+".name"); String customName = yml.getString("BossData." + bossKey + ".name");
customNameList.add(customName); customNameList.add(customName);
bossKeyList.add(bossKey); bossKeyList.add(bossKey);
} }
@ -28,17 +28,17 @@ public class BossManage {
} }
public BossData getBossData(String bossKey) { public BossData getBossData(String bossKey) {
if(bossDataMap.get(bossKey) == null){ if (bossDataMap.get(bossKey) == null) {
return null; return null;
} }
return bossDataMap.get(bossKey); return bossDataMap.get(bossKey);
} }
public BossData getNameToData(String customName) { public BossData getNameToData(String customName) {
for (String bossKey : bossDataMap.keySet()){ for (String bossKey : bossDataMap.keySet()) {
BossData data = bossDataMap.get(bossKey); BossData data = bossDataMap.get(bossKey);
String bossName = data.getBossName(); String bossName = data.getBossName();
if(customName.contains(bossName)){ if (customName.contains(bossName)) {
return data; return data;
} }
} }
@ -48,7 +48,8 @@ public class BossManage {
public boolean isBossSurvive() { public boolean isBossSurvive() {
return bossSurvive; return bossSurvive;
} }
public void setBossSurvive(boolean butt){
public void setBossSurvive(boolean butt) {
bossSurvive = butt; bossSurvive = butt;
} }
@ -56,14 +57,18 @@ public class BossManage {
return bossKeyList; return bossKeyList;
} }
public boolean isCustomNameContains(String customName){ public boolean isCustomNameContains(String customName) {
for (String name : this.customNameList){ // 检查 customName 是否为 null
if(customName.contains(name)){ if (customName == null) {
return false;
}
// 遍历 customNameList 检查是否有任何名称包含 customName
for (String name : this.customNameList) {
// 检查 name 是否为 null
if (name != null && customName.contains(name)) {
return true; return true;
} }
} }
return false; return false;
} }
} }

View File

@ -1,14 +1,10 @@
package com.io.yaohun.worldbosshurt.mangage; package com.io.yaohun.worldbosshurt.mangage;
import com.io.yaohun.worldbosshurt.data.BossData;
import com.io.yaohun.worldbosshurt.data.RewardData; import com.io.yaohun.worldbosshurt.data.RewardData;
import com.sun.xml.internal.txw2.output.StreamSerializer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
public class RewardManage { public class RewardManage {