PaperMC/patches/api/0332-Improve-scoreboard-entries.patch
Nassim Jahnke efd47e3a68
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#9188)
* Updated Upstream (Bukkit/CraftBukkit/Spigot)

Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
2fcba9b2 SPIGOT-7347: Add missing documentation and details to ShapedRecipe
c278419d PR-854: Move getHighestBlockYAt methods from World to RegionAccessor
201399fb PR-853: Add API for directly setting Display transformation matrices
ecfa559a PR-849: Add InventoryView#setTitle
653d7edb SPIGOT-519: Add TNTPrimeEvent
22fccc09 PR-846: Add method to get chunk load level
a070a52c PR-844: Add methods to convert Vector to and from JOML vectors
cc7111fe PR-276: Add accessors to Wither's invulnerability ticks
777d24e9 SPIGOT-7209: Accessors and events for player's exp cooldown
ccb2d01b SPIGOT-6308: Deprecate the location name property of map items
cd04a31b PR-780: Add PlayerSpawnChangeEvent
7d1f5b64 SPIGOT-6780: Improve documentation for World#spawnFallingBlock
5696668a SPIGOT-6885: Add test and easier to debug code for reference in yaml configuration comments
2e13cff7 PR-589: Expand the FishHook API
2c7d3da5 PR-279: Minor edits to various Javadocs

CraftBukkit Changes:
01b2e1af4 SPIGOT-7346: Disallow players from executing commands after disconnecting
7fe5ee022 PR-1186: Move getHighestBlockYAt methods from World to RegionAccessor
bcc85ef67 PR-1185: Add API for directly setting Display transformation matrices
a7cfc778f PR-1176: Add InventoryView#setTitle
563d42226 SPIGOT-519: Add TNTPrimeEvent
ccbc6abca Add test for Chunk.LoadLevel mirroring
2926e0513 PR-1171: Add method to get chunk load level
63cad7f84 PR-375: Add accessors to Wither's invulnerability ticks
bfd8b1ac8 SPIGOT-7209: Accessors and events for player's exp cooldown
f92a41c39 PR-1181: Consolidate Location conversion code
10f866759 SPIGOT-6308: Deprecate the location name property of map items
82f7b658a PR-1095: Add PlayerSpawnChangeEvent
b421af7e4 PR-808: Expand the FishHook API
598ad7b3f Increase outdated build delay

Spigot Changes:
d1bd3bd2 Rebuild patches
e4265cc8 SPIGOT-7297: Entity Tracking Range option for Display entities

* Work around javac bug

* Call PlayerSpawnChangeEvent

* Updated Upstream (Bukkit/CraftBukkit/Spigot)

Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
2fcba9b2 SPIGOT-7347: Add missing documentation and details to ShapedRecipe
c278419d PR-854: Move getHighestBlockYAt methods from World to RegionAccessor
201399fb PR-853: Add API for directly setting Display transformation matrices

CraftBukkit Changes:
01b2e1af4 SPIGOT-7346: Disallow players from executing commands after disconnecting
7fe5ee022 PR-1186: Move getHighestBlockYAt methods from World to RegionAccessor
bcc85ef67 PR-1185: Add API for directly setting Display transformation matrices

Spigot Changes:
7da74dae Rebuild patches
2023-05-12 13:10:08 +02:00

191 lines
8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Thu, 4 Nov 2021 12:31:45 -0700
Subject: [PATCH] Improve scoreboard entries
diff --git a/src/main/java/org/bukkit/scoreboard/Objective.java b/src/main/java/org/bukkit/scoreboard/Objective.java
index 571b43c2809d2b248feebc7decba6017a67c8aee..4830db50f408bd9b7e79c30a6d90af567a45af0c 100644
--- a/src/main/java/org/bukkit/scoreboard/Objective.java
+++ b/src/main/java/org/bukkit/scoreboard/Objective.java
@@ -151,9 +151,8 @@ public interface Objective {
* @throws IllegalArgumentException if player is null
* @throws IllegalStateException if this objective has been unregistered
* @see #getScore(String)
- * @deprecated Scoreboards can contain entries that aren't players
*/
- @Deprecated
+ // @Deprecated // Paper
@NotNull
Score getScore(@NotNull OfflinePlayer player) throws IllegalArgumentException, IllegalStateException;
@@ -168,4 +167,16 @@ public interface Objective {
*/
@NotNull
Score getScore(@NotNull String entry) throws IllegalArgumentException, IllegalStateException;
+
+ // Paper start
+ /**
+ * Gets an entity's Score for an Objective on this Scoreboard.
+ *
+ * @param entity Entity for the Score
+ * @return Score tracking the Objective and entity specified
+ * @throws IllegalArgumentException if entity is null
+ * @throws IllegalStateException if this objective has been unregistered
+ */
+ @NotNull Score getScoreFor(@NotNull org.bukkit.entity.Entity entity) throws IllegalArgumentException, IllegalStateException;
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/scoreboard/Scoreboard.java b/src/main/java/org/bukkit/scoreboard/Scoreboard.java
index ebb72912c1f8431606162b0643f6289203331253..5547f82d3d739035da3acc4bdbda72930c863138 100644
--- a/src/main/java/org/bukkit/scoreboard/Scoreboard.java
+++ b/src/main/java/org/bukkit/scoreboard/Scoreboard.java
@@ -265,9 +265,8 @@ public interface Scoreboard {
* @return immutable set of all scores tracked for the player
* @throws IllegalArgumentException if player is null
* @see #getScores(String)
- * @deprecated Scoreboards can contain entries that aren't players
*/
- @Deprecated
+ // @Deprecated // Paper
@NotNull
Set<Score> getScores(@NotNull OfflinePlayer player) throws IllegalArgumentException;
@@ -287,9 +286,8 @@ public interface Scoreboard {
* @param player the player to drop all current scores for
* @throws IllegalArgumentException if player is null
* @see #resetScores(String)
- * @deprecated Scoreboards can contain entries that aren't players
*/
- @Deprecated
+ // @Deprecated // Paper
void resetScores(@NotNull OfflinePlayer player) throws IllegalArgumentException;
/**
@@ -307,9 +305,8 @@ public interface Scoreboard {
* @return the player's Team or null if the player is not on a team
* @throws IllegalArgumentException if player is null
* @see #getEntryTeam(String)
- * @deprecated Scoreboards can contain entries that aren't players
*/
- @Deprecated
+ // @Deprecated // Paper
@Nullable
Team getPlayerTeam(@NotNull OfflinePlayer player) throws IllegalArgumentException;
@@ -378,4 +375,35 @@ public interface Scoreboard {
* @throws IllegalArgumentException if slot is null
*/
void clearSlot(@NotNull DisplaySlot slot) throws IllegalArgumentException;
+
+ // Paper start
+ /**
+ * Gets all scores for an entity on this Scoreboard
+ *
+ * @param entity the entity whose scores are being retrieved
+ * @return immutable set of all scores tracked for the entity
+ * @throws IllegalArgumentException if entity is null
+ * @see #getScores(String)
+ */
+ @NotNull Set<Score> getScoresFor(@NotNull org.bukkit.entity.Entity entity) throws IllegalArgumentException;
+
+ /**
+ * Removes all scores for an entity on this Scoreboard
+ *
+ * @param entity the entity to drop all current scores for
+ * @throws IllegalArgumentException if entity is null
+ * @see #resetScores(String)
+ */
+ void resetScoresFor(@NotNull org.bukkit.entity.Entity entity) throws IllegalArgumentException;
+
+ /**
+ * Gets an entity's Team on this Scoreboard
+ *
+ * @param entity the entity to search for
+ * @return the entity's Team or null if the entity is not on a team
+ * @throws IllegalArgumentException if entity is null
+ * @see #getEntryTeam(String)
+ */
+ @Nullable Team getEntityTeam(@NotNull org.bukkit.entity.Entity entity) throws IllegalArgumentException;
+ // Paper end
}
diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/bukkit/scoreboard/Team.java
index 937a28638c251509ebeb254178a4583fe03c52d0..b7f0686d22cef8d9bd23105ab60051ccb10fa1e6 100644
--- a/src/main/java/org/bukkit/scoreboard/Team.java
+++ b/src/main/java/org/bukkit/scoreboard/Team.java
@@ -308,9 +308,8 @@ public interface Team {
* @throws IllegalArgumentException if player is null
* @throws IllegalStateException if this team has been unregistered
* @see #addEntry(String)
- * @deprecated Teams can contain entries that aren't players
*/
- @Deprecated
+ // @Deprecated // Paper
void addPlayer(@NotNull OfflinePlayer player) throws IllegalStateException, IllegalArgumentException;
/**
@@ -332,9 +331,8 @@ public interface Team {
* @throws IllegalArgumentException if player is null
* @throws IllegalStateException if this team has been unregistered
* @see #removeEntry(String)
- * @deprecated Teams can contain entries that aren't players
*/
- @Deprecated
+ // @Deprecated // Paper
boolean removePlayer(@NotNull OfflinePlayer player) throws IllegalStateException, IllegalArgumentException;
/**
@@ -362,9 +360,8 @@ public interface Team {
* @throws IllegalArgumentException if player is null
* @throws IllegalStateException if this team has been unregistered
* @see #hasEntry(String)
- * @deprecated Teams can contain entries that aren't players
*/
- @Deprecated
+ // @Deprecated // Paper
boolean hasPlayer(@NotNull OfflinePlayer player) throws IllegalArgumentException, IllegalStateException;
/**
* Checks to see if the specified entry is a member of this team.
@@ -395,6 +392,42 @@ public interface Team {
*/
void setOption(@NotNull Option option, @NotNull OptionStatus status) throws IllegalStateException;
+ // Paper start
+ /**
+ * This puts the specified entity onto this team for the scoreboard.
+ * <p>
+ * This will remove the entity from any other team on the scoreboard.
+ *
+ * @param entity the entity to add
+ * @throws IllegalArgumentException if entity is null
+ * @throws IllegalStateException if this team has been unregistered
+ * @see #addEntry(String)
+ */
+ void addEntity(@NotNull org.bukkit.entity.Entity entity) throws IllegalStateException, IllegalArgumentException;
+
+ /**
+ * Removes the entity from this team.
+ *
+ * @param entity the entity to remove
+ * @return if the entity was on this team
+ * @throws IllegalArgumentException if entity is null
+ * @throws IllegalStateException if this team has been unregistered
+ * @see #removeEntry(String)
+ */
+ boolean removeEntity(@NotNull org.bukkit.entity.Entity entity) throws IllegalStateException, IllegalArgumentException;
+
+ /**
+ * Checks to see if the specified entity is a member of this team.
+ *
+ * @param entity the entity to search for
+ * @return true if the entity is a member of this team
+ * @throws IllegalArgumentException if entity is null
+ * @throws IllegalStateException if this team has been unregistered
+ * @see #hasEntry(String)
+ */
+ boolean hasEntity(@NotNull org.bukkit.entity.Entity entity) throws IllegalStateException, IllegalArgumentException;
+ // Paper end
+
/**
* Represents an option which may be applied to this team.
*/