Skip to content

Commit

Permalink
server.scoreboard.objective.score
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jul 28, 2022
1 parent a6e06d7 commit a2fb9be
Showing 1 changed file with 24 additions and 0 deletions.
Expand Up @@ -61,6 +61,7 @@
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Score;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
import org.bukkit.util.permissions.DefaultPermissions;
Expand Down Expand Up @@ -420,6 +421,29 @@ else if (recipe instanceof CookingRecipe<?>) {
}
event.setReplacedObject(new ElementTag(objective.getDisplaySlot().name()).getObjectAttribute(attribute.fulfill(1)));
}

// <--[tag]
// @attribute <server.scoreboard[(<board>)].objective[<name>].score[<input>]>
// @returns ElementTag(Number)
// @description
// Returns the current score in the objective for the given input.
// Input can be a PlayerTag (translates to name internally), EntityTag (translates to UUID internally) or any plaintext score holder label.
// Optionally, specify which scoreboard to use.
// -->
if (attribute.startsWith("score")) {
String value = attribute.getParam();
if (value.startsWith("p@")) {
value = PlayerTag.valueOf(value, attribute.context).getName();
}
else if (value.startsWith("e@")) {
value = EntityTag.valueOf(value, attribute.context).getUUID().toString();
}
Score score = objective.getScore(value);
if (!score.isScoreSet()) {
return;
}
event.setReplacedObject(new ElementTag(score.getScore()).getObjectAttribute(attribute.fulfill(1)));
}
}

// <--[tag]
Expand Down

0 comments on commit a2fb9be

Please sign in to comment.