轻弹记分牌(龙头)

Flicking Scoreboard (Spigot)

首先我的记分板插件有一些问题,例如: 如果我加入 LocalHost Server(IP): 插件真的很好用(没有闪光发生)但是,否则,如果我加入连接的域(IP)..然后我在世界各地移动时每次都会得到一些闪光[X Y Z]

我想我应该更改“PlayerMoveEvent”的代码,我知道 ping 差异会导致闪烁。 在我看来,MOVEMENT 部分似乎出现了闪光灯

同样,每次更改玩家位置..然后每秒闪烁一次

我真的很想得到反馈!

如果您需要更多详细信息(视频):https://youtu.be/rKO36Lw73rc

...

public class ScoreSidebar implements Listener {

    public static void main(String[] args) {
    }


    @EventHandler
    public void onPlayerJoinBoard(@NotNull PlayerJoinEvent event) {
        createBoard(event.getPlayer());

    }
    @EventHandler
    public void PlayerMoveEvent(@NotNull PlayerMoveEvent event) {
        createBoard(event.getPlayer());

    }

    public void createBoard(@NotNull Player player) {
        ScoreboardManager manager = Bukkit.getScoreboardManager();
        assert manager != null;
        Scoreboard board = manager.getNewScoreboard();

        Objective o = board.registerNewObjective("Scores", "dummy", ChatColor.AQUA + "§lSTATUS");
        o.setDisplaySlot(DisplaySlot.SIDEBAR);

        Score score5 = o.getScore(" ");
        score5.setScore(6);

        Score score4 = o.getScore(ChatColor.YELLOW + "PLAYER: " +
                ChatColor.BOLD + Bukkit.getOnlinePlayers().size() + ChatColor.WHITE + "/명");
        score4.setScore(5);

        Score score3 = o.getScore(ChatColor.GOLD + "MOVEMENT: " +
                ChatColor.WHITE + player.getLocation().getBlockX() + " " + player.getLocation().getBlockY()
                + " " + player.getLocation().getBlockZ() + "");
        score3.setScore(4);
        // Stream Location

        Score score2 = o.getScore(ChatColor.GRAY + "            " + " X | Y | Z ");
        score2.setScore(3);

        Score score1 = o.getScore("");
        score1.setScore(2);

        Score score = o.getScore(ChatColor.GRAY + "uhm... ");
        score.setScore(1);

        player.setScoreboard(board);

    }
}

无需创建新记分板并替换 objective 和所有分数,您必须保留创建的记分板并更新一些分数。

怎么做?

首先,创建玩家加入时的计分板,保留这部分:

    @EventHandler
    public void onPlayerJoinBoard(@NotNull PlayerJoinEvent event) {
        createBoard(event.getPlayer());
    }

    public void createBoard(@NotNull Player player) {
        ScoreboardManager manager = Bukkit.getScoreboardManager();
        assert manager != null;
        Scoreboard board = manager.getNewScoreboard();

        Objective o = board.registerNewObjective("Scores", "dummy", ChatColor.AQUA + "§lSTATUS");
        o.setDisplaySlot(DisplaySlot.SIDEBAR);
        // here create default lines
        
        player.setScoreboard(board);

    }

然后,我们将添加将更改的行:

public void addLineToSb(Player p) {
   Scoreboard board = p.getScoreboard();
   Team myData = board.registerNewTeam("myData");
   myData.addEntry(ChatColor.BLACK + "");
   myData.setPrefix(ChatColor.RED + "My amazing data");
   obj.getScore(ChatColor.BLACK + "").setScore(14);
}

现在,我们要更新这一行,所以我们将使用这样的东西:

public void update(Player p) {
   Scoreboard board = p.getScoreboard();
   board.getTeam("myData").setPrefix(ChatColor.RED + "My amazing data (2)");
}

终于好了!

更多信息:official wiki