玩家当前坐标实时刷新

This commit is contained in:
2024-12-20 03:14:57 +08:00
parent d51403b58e
commit a281e2924b
2 changed files with 20 additions and 1 deletions

View File

@@ -109,6 +109,6 @@ public class PlayerData {
/// 玩家位置信息发生改变
public void updateLocal() {
ui.playerMove();
}
}

View File

@@ -52,6 +52,25 @@ public class ScoreboardUI {
flashLocations();
}
protected boolean isLocal(Location l1, Location l2) {
if ((long) l1.getX() != (long) l2.getX())
return true;
if ((long) l1.getY() != (long) l2.getY())
return true;
return (long) l1.getZ() != (long) l2.getZ();
}
protected void playerMove() {
Location local = player.getLocation();
if (!isLocal(this.location, local)) {
return;
}
this.scoreboard.resetScores(this.meLocation.getEntry());
this.location = local;
meLocation = this.objective.getScore(getLocationString());
meLocation.setScore(999);
}
protected void closeUI() {
var manager = Bukkit.getScoreboardManager();
assert manager != null;