Class Scoreboard

java.lang.Object
cn.nukkit.scoreboard.scoreboard.Scoreboard
All Implemented Interfaces:
IScoreboard

@PowerNukkitXOnly @Since("1.19.30-r1") public class Scoreboard extends Object implements IScoreboard
  • Field Details

  • Constructor Details

    • Scoreboard

      public Scoreboard(String objectiveName, String displayName)
    • Scoreboard

      public Scoreboard(String objectiveName, String displayName, String criteriaName)
    • Scoreboard

      public Scoreboard(String objectiveName, String displayName, String criteriaName, SortOrder sortOrder)
  • Method Details

    • getAllViewers

      public Set<IScoreboardViewer> getAllViewers()
      Specified by:
      getAllViewers in interface IScoreboard
      Returns:
      此计分板的所有观察者
    • getViewers

      public Set<IScoreboardViewer> getViewers(DisplaySlot slot)
      Specified by:
      getViewers in interface IScoreboard
      Parameters:
      slot - 目标槽位
      Returns:
      此计分板目标槽位的观察者
    • removeViewer

      public boolean removeViewer(IScoreboardViewer viewer, DisplaySlot slot)
      Description copied from interface: IScoreboard
      删除此计分板目标槽位中的某个观察者
      Specified by:
      removeViewer in interface IScoreboard
      Parameters:
      viewer - 目标观察者
      slot - 目标槽位
      Returns:
      是否删除成功
    • addViewer

      public boolean addViewer(IScoreboardViewer viewer, DisplaySlot slot)
      Description copied from interface: IScoreboard
      向此计分板目标槽位中添加一个观察者
      Specified by:
      addViewer in interface IScoreboard
      Parameters:
      viewer - 目标观察者
      slot - 目标槽位
      Returns:
      是否添加成功
    • containViewer

      public boolean containViewer(IScoreboardViewer viewer, DisplaySlot slot)
      Description copied from interface: IScoreboard
      检查此计分板目标槽位中是否有特定观察者
      Specified by:
      containViewer in interface IScoreboard
      Parameters:
      viewer - 目标观察者
      slot - 目标槽位
      Returns:
      是否存在
    • getLine

      @Nullable public IScoreboardLine getLine(IScorer scorer)
      Description copied from interface: IScoreboard
      获取追踪对象在此计分板上对应的行(如果存在)
      Specified by:
      getLine in interface IScoreboard
      Parameters:
      scorer - 追踪对象
      Returns:
      对应行
    • addLine

      public boolean addLine(IScoreboardLine line)
      Description copied from interface: IScoreboard
      为此计分板添加一个行
      Specified by:
      addLine in interface IScoreboard
      Parameters:
      line - 目标行
      Returns:
      是否添加成功
    • addLine

      public boolean addLine(IScorer scorer, int score)
      Description copied from interface: IScoreboard
      为此计分板添加一个行
      Specified by:
      addLine in interface IScoreboard
      Parameters:
      scorer - 追踪对象
      score - 分数
      Returns:
      是否添加成功
    • addLine

      public boolean addLine(String text, int score)
      Description copied from interface: IScoreboard
      为插件提供的便捷的计分板显示接口
      Specified by:
      addLine in interface IScoreboard
      Parameters:
      text - FakeScorer的名称
      score - 分数
      Returns:
      是否添加成功
    • removeLine

      public boolean removeLine(IScorer scorer)
      Description copied from interface: IScoreboard
      删除追踪对象在此计分板上对应的行(如果存在)
      Specified by:
      removeLine in interface IScoreboard
      Parameters:
      scorer - 目标追踪对象
      Returns:
      是否删除成功
    • removeAllLine

      public boolean removeAllLine(boolean send)
      Description copied from interface: IScoreboard
      删除计分板所有行
      Specified by:
      removeAllLine in interface IScoreboard
      Parameters:
      send - 是否发送到观察者
      Returns:
      是否删除成功
    • containLine

      public boolean containLine(IScorer scorer)
      Description copied from interface: IScoreboard
      检查追踪对象在此计分板上是否有记录
      Specified by:
      containLine in interface IScoreboard
      Parameters:
      scorer - 目标追踪对象
      Returns:
      是否存在
    • updateScore

      public void updateScore(IScoreboardLine update)
      Description copied from interface: IScoreboard
      向所有观察者发送新的分数
      Specified by:
      updateScore in interface IScoreboard
      Parameters:
      update - 需要更新的行
    • resend

      public void resend()
      Description copied from interface: IScoreboard
      向所有观察者重新发送此计分板以及行信息
      例如当对计分板进行了大量的更改后,调用此方法
      可节省大量带宽
      Specified by:
      resend in interface IScoreboard
    • setLines

      public void setLines(List<String> lines)
      Description copied from interface: IScoreboard
      为插件提供的快捷接口
      按照List顺序设置计分板的内容 (使用FakeScorer作为追踪对象)
      会覆盖之前的所有行
      Specified by:
      setLines in interface IScoreboard
      Parameters:
      lines - 需要设置的字符串内容
    • setLines

      public void setLines(Collection<IScoreboardLine> lines)
      Description copied from interface: IScoreboard
      按照List顺序设置计分板的内容
      会覆盖之前的所有行
      Specified by:
      setLines in interface IScoreboard
      Parameters:
      lines - 需要设置的行内容
    • shouldCallEvent

      public boolean shouldCallEvent()
      Specified by:
      shouldCallEvent in interface IScoreboard
      Returns:
      对此计分板的更改是否会产生事件
    • getObjectiveName

      public String getObjectiveName()
      Specified by:
      getObjectiveName in interface IScoreboard
      Returns:
      此计分板的标识名称
    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in interface IScoreboard
      Returns:
      此计分板的显示名称
    • getCriteriaName

      public String getCriteriaName()
      Specified by:
      getCriteriaName in interface IScoreboard
      Returns:
      此计分板的 “准则” (eg: dummy)
    • getSortOrder

      public SortOrder getSortOrder()
      Specified by:
      getSortOrder in interface IScoreboard
      Returns:
      此计分板的排序规则
    • getViewers

      public Map<DisplaySlot,Set<IScoreboardViewer>> getViewers()
    • getLines

      public Map<IScorer,IScoreboardLine> getLines()
      Specified by:
      getLines in interface IScoreboard
      Returns:
      此计分板的所有行
    • setSortOrder

      public void setSortOrder(SortOrder sortOrder)
      Description copied from interface: IScoreboard
      设置计分板的排序规则
      Specified by:
      setSortOrder in interface IScoreboard
      Parameters:
      sortOrder - 排序规则