无法重置分数

时间:2014-04-12 04:33:34

标签: java bukkit

所以在这里使用我的两种方法

 public static void run(final Plugin plugin, String oldText, final Scroller scroller, final      Scoreboard board, final Objective obj){
    final String text = scroller.next();

    board.resetScores(Bukkit.getOfflinePlayer(oldText));

    Bukkit.getScheduler().runTaskTimer(plugin, new Runnable(){
        public void run(){
            Score score = obj.getScore(Bukkit.getOfflinePlayer(text));
            score.setScore(4);
            resetScores(scroller.next(), board, plugin, scroller);
        }
    }, 20L, 20L);
}

public static void resetScores(final String args, final Scoreboard board, Plugin plugin, Scroller scroller){
    Bukkit.getScheduler().runTaskLater(plugin, new Runnable(){
        @Override
        public void run() {
            board.resetScores(Bukkit.getOfflinePlayer(args));
        }
    }, 20L);

    scroller.next();
}

我无法重置播放器的分数。我想要它所以它在我的记分牌上创建滚动时尚。我这样称呼它(在另一个班级)

scoreboardScroller.run(plugin, "One Moment...", rankScroller, scoreboard, objective);

1 个答案:

答案 0 :(得分:0)

如果你想在同一行设置值,你可以循环记分牌的离线玩家,如果操作得分==你的行重置它。

public void update(String line, int row) {
   if (!this.scoreboard.getPlayers().contains(Bukkit.getOfflinePlayer(name))) {
    for (OfflinePlayer op : this.scoreboard.getPlayers()) {
     if (this.objective.getScore(op).getScore() == row) {
      remove(op.getName());
       break;
     }
    }
    add(line, row);
  }
}

Full code