From e6583aca258eee05ee4dda7641ea1d2fb0707294 Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 26 Oct 2018 19:38:20 +1100 Subject: SPIGOT-4443: Scoreboard RenderType API --- src/main/java/org/bukkit/scoreboard/Objective.java | 16 ++++++++++++++++ src/main/java/org/bukkit/scoreboard/RenderType.java | 19 +++++++++++++++++++ src/main/java/org/bukkit/scoreboard/Scoreboard.java | 21 +++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 src/main/java/org/bukkit/scoreboard/RenderType.java diff --git a/src/main/java/org/bukkit/scoreboard/Objective.java b/src/main/java/org/bukkit/scoreboard/Objective.java index 1802d1db..cc3a3e04 100644 --- a/src/main/java/org/bukkit/scoreboard/Objective.java +++ b/src/main/java/org/bukkit/scoreboard/Objective.java @@ -85,6 +85,22 @@ public interface Objective { */ DisplaySlot getDisplaySlot() throws IllegalStateException; + /** + * Sets manner in which this objective will be rendered. + * + * @param renderType new render type + * @throws IllegalStateException if this objective has been unregistered + */ + void setRenderType(RenderType renderType) throws IllegalStateException; + + /** + * Sets manner in which this objective will be rendered. + * + * @return the render type + * @throws IllegalStateException if this objective has been unregistered + */ + RenderType getRenderType() throws IllegalStateException; + /** * Gets a player's Score for an Objective on this Scoreboard * diff --git a/src/main/java/org/bukkit/scoreboard/RenderType.java b/src/main/java/org/bukkit/scoreboard/RenderType.java new file mode 100644 index 00000000..df267cce --- /dev/null +++ b/src/main/java/org/bukkit/scoreboard/RenderType.java @@ -0,0 +1,19 @@ +package org.bukkit.scoreboard; + +/** + * Controls the way in which an {@link Objective} is rendered client side. + * + * @deprecated draft API + */ +@Deprecated +public enum RenderType { + + /** + * Display integer value. + */ + INTEGER, + /** + * Display number of hearts corresponding to value. + */ + HEARTS; +} diff --git a/src/main/java/org/bukkit/scoreboard/Scoreboard.java b/src/main/java/org/bukkit/scoreboard/Scoreboard.java index 40f36b47..85471b3f 100644 --- a/src/main/java/org/bukkit/scoreboard/Scoreboard.java +++ b/src/main/java/org/bukkit/scoreboard/Scoreboard.java @@ -45,6 +45,27 @@ public interface Scoreboard { */ Objective registerNewObjective(String name, String criteria, String displayName) throws IllegalArgumentException; + /** + * Registers an Objective on this Scoreboard + * + * @param name Name of the Objective + * @param criteria Criteria for the Objective + * @param displayName Name displayed to players for the Objective. + * @param renderType Manner of rendering the Objective + * @return The registered Objective + * @throws IllegalArgumentException if name is null + * @throws IllegalArgumentException if name is longer than 16 + * characters. + * @throws IllegalArgumentException if criteria is null + * @throws IllegalArgumentException if displayName is null + * @throws IllegalArgumentException if displayName is longer than 128 + * characters. + * @throws IllegalArgumentException if renderType is null + * @throws IllegalArgumentException if an objective by that name already + * exists + */ + Objective registerNewObjective(String name, String criteria, String displayName, RenderType renderType) throws IllegalArgumentException; + /** * Gets an Objective on this Scoreboard by name * -- cgit v1.2.3