From a2fb9be33fd066ead498d6716c3198ce3ea60e1c Mon Sep 17 00:00:00 2001 From: "Alex \"mcmonkey\" Goodwin" Date: Thu, 28 Jul 2022 07:07:11 -0700 Subject: [PATCH] server.scoreboard.objective.score --- .../denizen/tags/core/ServerTagBase.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/plugin/src/main/java/com/denizenscript/denizen/tags/core/ServerTagBase.java b/plugin/src/main/java/com/denizenscript/denizen/tags/core/ServerTagBase.java index 341e5c1f8e..c476e3a80a 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/tags/core/ServerTagBase.java +++ b/plugin/src/main/java/com/denizenscript/denizen/tags/core/ServerTagBase.java @@ -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; @@ -420,6 +421,29 @@ else if (recipe instanceof CookingRecipe) { } event.setReplacedObject(new ElementTag(objective.getDisplaySlot().name()).getObjectAttribute(attribute.fulfill(1))); } + + // <--[tag] + // @attribute )].objective[].score[]> + // @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]