From 7c5eaf30f15dece0eeb33c73899d952364425dab Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 17 Apr 2014 19:36:09 +1000 Subject: [PATCH] Add Score.isScoreSet()Z API. Also fix generics on CraftScore.getScore()I. --- .../0027-Add-Score.isScoreSet-Z-API.patch | 31 +++++++++++++++ .../0144-Add-Score.isScoreSet-Z-API.patch | 39 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 Bukkit-Patches/0027-Add-Score.isScoreSet-Z-API.patch create mode 100644 CraftBukkit-Patches/0144-Add-Score.isScoreSet-Z-API.patch diff --git a/Bukkit-Patches/0027-Add-Score.isScoreSet-Z-API.patch b/Bukkit-Patches/0027-Add-Score.isScoreSet-Z-API.patch new file mode 100644 index 0000000..2972bb5 --- /dev/null +++ b/Bukkit-Patches/0027-Add-Score.isScoreSet-Z-API.patch @@ -0,0 +1,31 @@ +From 42fb4c3837a133f6bbfd221dbe690c5a59e3c561 Mon Sep 17 00:00:00 2001 +From: md_5 +Date: Thu, 17 Apr 2014 19:35:13 +1000 +Subject: [PATCH] Add Score.isScoreSet()Z API. + + +diff --git a/src/main/java/org/bukkit/scoreboard/Score.java b/src/main/java/org/bukkit/scoreboard/Score.java +index 4c10346..2410cbd 100644 +--- a/src/main/java/org/bukkit/scoreboard/Score.java ++++ b/src/main/java/org/bukkit/scoreboard/Score.java +@@ -51,6 +51,17 @@ public interface Score { + */ + void setScore(int score) throws IllegalStateException; + ++ // Spigot start ++ /** ++ * Shows if this score has been set at any point in time. ++ * ++ * @return if this score has been set before ++ * @throws IllegalStateException if the associated objective has been ++ * unregistered ++ */ ++ boolean isScoreSet() throws IllegalStateException; ++ // Spigot end ++ + /** + * Gets the scoreboard for the associated objective. + * +-- +1.8.3.2 + diff --git a/CraftBukkit-Patches/0144-Add-Score.isScoreSet-Z-API.patch b/CraftBukkit-Patches/0144-Add-Score.isScoreSet-Z-API.patch new file mode 100644 index 0000000..2733f7a --- /dev/null +++ b/CraftBukkit-Patches/0144-Add-Score.isScoreSet-Z-API.patch @@ -0,0 +1,39 @@ +From ff88954cd61861bd5bf8a26feeca291491e90fa0 Mon Sep 17 00:00:00 2001 +From: md_5 +Date: Thu, 17 Apr 2014 19:35:53 +1000 +Subject: [PATCH] Add Score.isScoreSet()Z API. + +Also fix generics on CraftScore.getScore()I. + +diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java +index 7095f6d..b265616 100644 +--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java ++++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScore.java +@@ -41,7 +41,7 @@ final class CraftScore implements Score { + Scoreboard board = objective.checkState().board; + + if (board.getPlayers().contains(entry)) { // Lazy +- Map scores = board.getPlayerObjectives(entry); ++ Map scores = board.getPlayerObjectives(entry); // Spigot + ScoreboardScore score = scores.get(objective.getHandle()); + if (score != null) { // Lazy + return score.getScore(); +@@ -55,6 +55,15 @@ final class CraftScore implements Score { + objective.checkState().board.getPlayerScoreForObjective(entry, objective.getHandle()).setScore(score); + } + ++ // Spigot start ++ @Override ++ public boolean isScoreSet() throws IllegalStateException { ++ Scoreboard board = objective.checkState().board; ++ ++ return board.getPlayers().contains(entry) && board.getPlayerObjectives(entry).containsKey(objective.getHandle()); ++ } ++ // Spigot end ++ + public CraftScoreboard getScoreboard() { + return objective.getScoreboard(); + } +-- +1.8.3.2 +