From 63c3c76ad09a6eee198d0927a637f9e6b8460e88 Mon Sep 17 00:00:00 2001 From: booky10 <53302036+booky10@users.noreply.github.com> Date: Tue, 16 Nov 2021 00:08:50 +0100 Subject: [PATCH] Add API for resetting a single score (#6873) --- ...Add-API-for-resetting-a-single-score.patch | 26 +++++++++++++++++++ ...Add-API-for-resetting-a-single-score.patch | 24 +++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 patches/api/Add-API-for-resetting-a-single-score.patch create mode 100644 patches/server/Add-API-for-resetting-a-single-score.patch diff --git a/patches/api/Add-API-for-resetting-a-single-score.patch b/patches/api/Add-API-for-resetting-a-single-score.patch new file mode 100644 index 0000000000..fb565a0dd9 --- /dev/null +++ b/patches/api/Add-API-for-resetting-a-single-score.patch @@ -0,0 +1,26 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: booky10 +Date: Fri, 5 Nov 2021 21:01:36 +0100 +Subject: [PATCH] Add API for resetting a single score + +It was only possible to reset all scores for a specific entry, instead of resetting only specific scores. + +diff --git a/src/main/java/org/bukkit/scoreboard/Score.java b/src/main/java/org/bukkit/scoreboard/Score.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/scoreboard/Score.java ++++ b/src/main/java/org/bukkit/scoreboard/Score.java +@@ -0,0 +0,0 @@ public interface Score { + */ + @Nullable + Scoreboard getScoreboard(); ++ ++ // Paper start ++ /** ++ * Resets this score, if a value has been set. ++ * ++ * @throws IllegalStateException if the associated objective has been ++ * unregistered ++ */ ++ void resetScore() throws IllegalStateException; ++ // Paper end + } diff --git a/patches/server/Add-API-for-resetting-a-single-score.patch b/patches/server/Add-API-for-resetting-a-single-score.patch new file mode 100644 index 0000000000..d46247b8e5 --- /dev/null +++ b/patches/server/Add-API-for-resetting-a-single-score.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: booky10 +Date: Fri, 5 Nov 2021 21:01:36 +0100 +Subject: [PATCH] Add API for resetting a single score + +It was only possible to reset all scores for a specific entry, instead of resetting only specific scores. + +diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java ++++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java +@@ -0,0 +0,0 @@ final class CraftScore implements Score { + public CraftScoreboard getScoreboard() { + return this.objective.getScoreboard(); + } ++ ++ // Paper start ++ @Override ++ public void resetScore() { ++ Scoreboard board = this.objective.checkState().board; ++ board.resetPlayerScore(entry, this.objective.getHandle()); ++ } ++ // Paper end + }