修复了缓存中的一个潜在空值

This commit is contained in:
zhangyuheng 2024-05-29 10:47:42 +08:00
parent da10ce05e2
commit fe623f41a2
2 changed files with 6 additions and 4 deletions

View File

@ -6,7 +6,7 @@
<groupId>cn.lunadeer</groupId>
<artifactId>Dominion</artifactId>
<version>1.29.0-beta</version>
<version>1.29.1-beta</version>
<packaging>jar</packaging>
<name>Dominion</name>

View File

@ -124,9 +124,11 @@ public class Cache {
if (last_in_dom_id != null) {
last_dominion = id_dominions.get(last_in_dom_id);
}
if (last_in_dom_id != null && dominion_children.get(last_in_dom_id).isEmpty() && isInDominion(last_dominion, player)) {
// 如果玩家仍在领地内且领地没有子领地则直接返回
return last_dominion;
if (isInDominion(last_dominion, player)) {
if (dominion_children.get(last_in_dom_id) == null) {
// 如果玩家仍在领地内且领地没有子领地则直接返回
return last_dominion;
}
}
DominionDTO current_dominion = getLocInDominionDTO(world_dominion_tree.get(player.getWorld().getName()), player.getLocation());
int last_dom_id = last_dominion == null ? -1 : last_dominion.getId();