-
-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes include: * Per-world scoreboards have been removed * The 'server' scoreboard is now accessible through the API * Teams are now registered to only one scoreboard at a time
- Loading branch information
Showing
5 changed files
with
141 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,6 @@ public interface Scoreboard { | |
static Builder builder() { | ||
return Sponge.getRegistry().createBuilder(Builder.class); | ||
} | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
gabizou
Member
|
||
/** | ||
* Gets an {@link Objective} on this scoreboard by name, if it exists. | ||
* | ||
|
@@ -64,6 +63,16 @@ static Builder builder() { | |
*/ | ||
Optional<Objective> getObjective(String name); | ||
|
||
/** | ||
* Adds the specified {@link Objective} to this scoreboard. | ||
* | ||
* @param objective The {@link Objective} add | ||
* @throws IllegalArgumentException if an {@link Objective} with the same | ||
* {@link Objective#getName() name} already exists, or if the | ||
* specified {@link Objective} has already been added. | ||
*/ | ||
void addObjective(Objective objective) throws IllegalArgumentException; | ||
|
||
/** | ||
* Gets the {@link Objective} currently displayed in a {@link DisplaySlot} on this | ||
* scoreboard, if one is present. | ||
|
@@ -84,17 +93,16 @@ static Builder builder() { | |
* @throws IllegalStateException if the specified {@link Objective} does not exist | ||
* on this scoreboard | ||
*/ | ||
void addObjective(@Nullable Objective objective, DisplaySlot displaySlot) throws IllegalStateException; | ||
void updateDisplaySlot(@Nullable Objective objective, DisplaySlot displaySlot) throws IllegalStateException; | ||
|
||
/** | ||
* Adds the specified {@link Objective} to this scoreboard. | ||
* Clears any {@link Objective} in the specified slot. | ||
* | ||
* @param objective The {@link Objective} add | ||
* @throws IllegalArgumentException if an {@link Objective} with the same | ||
* {@link Objective#getName() name} already exists, or if the | ||
* specified {@link Objective} has already been added. | ||
* @param slot The {@link DisplaySlot} to remove any {@link Objective} for | ||
*/ | ||
void addObjective(Objective objective) throws IllegalArgumentException; | ||
default void clearSlot(DisplaySlot slot) { | ||
this.updateDisplaySlot(null, slot); | ||
} | ||
|
||
/** | ||
* Gets all {@link Objective}s of a Criteria on this scoreboard. | ||
|
@@ -118,10 +126,23 @@ static Builder builder() { | |
*/ | ||
void removeObjective(Objective objective); | ||
|
||
/** | ||
* Gets all the scores on this scoreboard, across all objectives. | ||
* | ||
* <p>If the same {@link Score} has been added to multiple objectives, | ||
* it will only appear once in the set.</p> | ||
* | ||
* @return A set of all scores | ||
*/ | ||
Set<Score> getScores(); | ||
|
||
/** | ||
* Gets all scores with the specified name on this scoreboard, | ||
* across all objectives. | ||
* | ||
* <p>If the same {@link Score} has been added to multiple objectives, | ||
* it will only appear once in the set.</p> | ||
* | ||
* @param name The name whose scores are being retrieved | ||
* @return A set of all scores for the name | ||
*/ | ||
|
@@ -135,15 +156,6 @@ static Builder builder() { | |
*/ | ||
void removeScores(Text name); | ||
|
||
/** | ||
* Gets a {@link Text} member's {@link Team} on this scoreboard. | ||
* | ||
* @param member The {@link Text} to search for | ||
* @return The {@link Text} member's {@link Team}, or Optional.empty() | ||
* if the member has no team | ||
*/ | ||
Optional<Team> getMemberTeam(Text member); | ||
|
||
/** | ||
* Gets a {@link Team} by name on this scoreboard. | ||
* | ||
|
@@ -153,21 +165,15 @@ static Builder builder() { | |
Optional<Team> getTeam(String teamName); | ||
|
||
/** | ||
* Removes the specified {@link Team} to this scoreboard. | ||
* Registers the specified {@link Team} to this scoreboard. | ||
* | ||
* @param team The {@link Team} to remove | ||
*/ | ||
void removeTeam(Team team); | ||
|
||
/** | ||
* Adds the specified {@link Team} to this scoreboard. | ||
* | ||
* @param team The {@link Team} to add | ||
* @param team The {@link Team} to register | ||
* @throws IllegalArgumentException if a team with the same | ||
* {@link Team#getName() name} already exists, or the specified | ||
* {@link Team} has been added | ||
* {@link Team#getName() name} already exists on this scoreboard, or if the specified | ||
* {@link Team} is already registered to a scoreboard (this scoreboard, | ||
* or another one). | ||
*/ | ||
void addTeam(Team team) throws IllegalArgumentException; | ||
void registerTeam(Team team) throws IllegalArgumentException; | ||
|
||
/** | ||
* Gets all the {@link Team}s on this scoreboard. | ||
|
@@ -177,11 +183,13 @@ static Builder builder() { | |
Set<Team> getTeams(); | ||
|
||
/** | ||
* Clears any {@link Objective} in the specified slot. | ||
* Gets a {@link Text} member's {@link Team} on this scoreboard. | ||
* | ||
* @param slot The {@link DisplaySlot} to remove any {@link Objective} for | ||
* @param member The {@link Text} to search for | ||
* @return The {@link Text} member's {@link Team}, or Optional.empty() | ||
* if the member has no team | ||
*/ | ||
void clearSlot(DisplaySlot slot); | ||
Optional<Team> getMemberTeam(Text member); | ||
|
||
/** | ||
* Represents a builder to create {@link Scoreboard} instances. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
import org.spongepowered.api.util.ResettableBuilder; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
/** | ||
|
@@ -71,7 +72,7 @@ static Builder builder() { | |
* | ||
* @param displayName Display name to set | ||
* @throws IllegalArgumentException if displayName is longer than 32 | ||
* characters | ||
* characters (in its legacy representation) | ||
*/ | ||
void setDisplayName(Text displayName) throws IllegalArgumentException; | ||
|
||
|
@@ -103,6 +104,14 @@ static Builder builder() { | |
*/ | ||
Map<Text, Score> getScores(); | ||
|
||
/** | ||
* Returns whether this objective has a {@link Score} with the given name. | ||
* | ||
* @param name The name of the {@link Score} to check for. | ||
* @return Whether this objective has a {@link Score} with the given name. | ||
*/ | ||
This comment has been minimized.
Sorry, something went wrong.
Zidane
Member
|
||
boolean hasScore(Text name); | ||
|
||
/** | ||
* Adds the specified {@link Score} to this objective. | ||
* | ||
|
@@ -112,21 +121,43 @@ static Builder builder() { | |
void addScore(Score score) throws IllegalArgumentException; | ||
|
||
/** | ||
* Gets an entry's {@link Score} for this Objective. | ||
* Gets an entry's {@link Score} for this objective, if it exists. | ||
* | ||
* @param name The name of the {@link Score} to get. | ||
* @return The {@link Score} for te specified {@link Text}, if it exists. | ||
*/ | ||
default Optional<Score> getScore(Text name) { | ||
if (!this.hasScore(name)) { | ||
return Optional.empty(); | ||
} | ||
return Optional.of(this.getOrCreateScore(name)); | ||
} | ||
|
||
/** | ||
* Gets an entry's {@link Score} for this objective. | ||
* | ||
* <p>If the {@link Score} does not exist, it will be created.</p> | ||
* | ||
* @param name The name of the {@link Score} to get | ||
* @return The {@link Score} for the specified {@link Text} | ||
*/ | ||
Score getScore(Text name); | ||
Score getOrCreateScore(Text name); | ||
|
||
/** | ||
* Removes the specified {@link Score} to this objective. | ||
* Removes the specified {@link Score} from this objective, if present. | ||
* | ||
* @param score The {@link Score} to remove | ||
* @return Whether the score existed on this objective | ||
*/ | ||
boolean removeScore(Score score); | ||
|
||
/** | ||
* Removes the {@link Score} with the specified name from this objectie, if present. | ||
* | ||
* @param name The name of the {@link Score} to remove. | ||
* @return Whether the score existed on this objective | ||
*/ | ||
void removeScore(Score score); | ||
boolean removeScore(Text name); | ||
|
||
/** | ||
* Returns a {@link Set} of parent {@link Scoreboard}s this | ||
|
Oops, something went wrong.
I think that blank line shouldn't be removed.