Score.fromSelected constructor

Score.fromSelected(
  1. String score, {
  2. bool addNew = true,
  3. String type = 'dummy',
})

same as Score() but with a predefined entity(Entity.Selected(),)

Score.fromSelected('objective').set(3)
⇒ scoreboard players set @s objective 3

Implementation

Score.fromSelected(
  this.score, {
  bool addNew = true,
  this.type = 'dummy',
}) : entity = Entity.Self() {
  if (addNew) {
    _commands.add(
      Scoreboard(score, type: type),
    );
  }
  if (Scoreboard.prefix != null && !score.contains(Scoreboard.prefix!)) {
    score = Scoreboard.prefix! + score;
  }
}