Skip to content

Commit

Permalink
修复了修改发光、飞行权限时无法立即生效只有重新进出领地才会生效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ColdeZhang committed Jun 12, 2024
1 parent dc50603 commit d492663
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>cn.lunadeer</groupId>
<artifactId>Dominion</artifactId>
<version>1.31.3-beta</version>
<version>1.31.4-beta</version>
<packaging>jar</packaging>

<name>Dominion</name>
Expand Down Expand Up @@ -82,7 +82,7 @@
<dependency>
<groupId>cn.lunadeer</groupId>
<artifactId>MinecraftPluginUtils</artifactId>
<version>1.3.1-SNAPSHOT</version>
<version>1.3.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.github.BlueMap-Minecraft</groupId>
Expand Down
19 changes: 9 additions & 10 deletions src/main/java/cn/lunadeer/dominion/Cache.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ private void loadDominionsExecution() {
world_dominion_tree.put(entry.getKey(), DominionNode.BuildNodeTree(-1, entry.getValue()));
}
BlueMapConnect.render();
recheckPlayerState = true;
_last_update_dominion.set(System.currentTimeMillis());
}

Expand Down Expand Up @@ -106,6 +107,7 @@ private void loadPlayerPrivilegesExecution() {
}
player_uuid_to_privilege.get(player_uuid).put(privilege.getDomID(), privilege);
}
recheckPlayerState = true;
_last_update_privilege.set(System.currentTimeMillis());
}

Expand All @@ -127,6 +129,11 @@ public DominionDTO getPlayerCurrentDominion(Player player) {
if (isInDominion(last_dominion, player)) {
if (dominion_children.get(last_in_dom_id) == null || dominion_children.get(last_in_dom_id).size() == 0) {
// 如果玩家仍在领地内,且领地没有子领地,则直接返回
if (recheckPlayerState) {
lightOrNot(player, last_dominion);
flyOrNot(player, last_dominion);
recheckPlayerState = false;
}
return last_dominion;
}
}
Expand All @@ -137,19 +144,11 @@ public DominionDTO getPlayerCurrentDominion(Player player) {
return last_dominion;
}
if (last_dom_id != -1) {
// if (last_dominion.getParentDomId() == -1)
// Notification.info(player, "您已离开领地:%s", last_dominion.getName());
// else
// Notification.info(player, "您已离开子领地:%s", last_dominion.getName());
String msg = last_dominion.getLeaveMessage();
msg = msg.replace("${DOM_NAME}", last_dominion.getName());
Notification.actionBar(player, msg);
}
if (current_dom_id != -1) {
// if (current_dominion.getParentDomId() == -1)
// Notification.info(player, "您正在进入领地:%s", current_dominion.getName());
// else
// Notification.info(player, "您正在进入子领地:%s", current_dominion.getName());
String msg = current_dominion.getJoinMessage();
msg = msg.replace("${DOM_NAME}", current_dominion.getName());
Notification.actionBar(player, msg);
Expand Down Expand Up @@ -315,7 +314,7 @@ public List<DominionDTO> getDominions() {
private final AtomicBoolean _update_dominion_is_scheduled = new AtomicBoolean(false);
private final AtomicLong _last_update_privilege = new AtomicLong(0);
private final AtomicBoolean _update_privilege_is_scheduled = new AtomicBoolean(false);
private static final long UPDATE_INTERVAL = 1000 * 4;

private static final long UPDATE_INTERVAL = 1000 * 5;
private boolean recheckPlayerState = false; // 是否需要重新检查玩家状态(发光、飞行)
public final Map<UUID, LocalDateTime> NextTimeAllowTeleport = new java.util.HashMap<>();
}
4 changes: 3 additions & 1 deletion src/main/java/cn/lunadeer/dominion/Dominion.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ public void onEnable() {
new Scheduler(this);
AutoClean.run();
Cache.instance = new Cache();
new VaultConnect(this);
if (config.getEconomyEnable()) {
new VaultConnect(this);
}

Bukkit.getPluginManager().registerEvents(new PlayerEvents(), this);
Bukkit.getPluginManager().registerEvents(new EnvironmentEvents(), this);
Expand Down

0 comments on commit d492663

Please sign in to comment.