Skip to content

Commit

Permalink
starting scoreboard fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
Faithcaio committed Nov 25, 2023
1 parent 881dfd2 commit b51e2a0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/main/java/org/spongepowered/api/scoreboard/Score.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
package org.spongepowered.api.scoreboard;

import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.api.scoreboard.objective.Objective;

import java.util.Optional;
import java.util.Set;

/**
Expand All @@ -39,7 +41,7 @@ public interface Score {
*
* @return The name of this score
*/
Component name();
String name();

/**
* Gets the current score value.
Expand Down Expand Up @@ -69,6 +71,12 @@ public interface Score {
*/
void setLocked(boolean locked);

// TODO javadocs
void setDisplay(@Nullable Component display);
Optional<Component> display();

// TODO numberformat

/**
* Returns a {@link Set} of parent {@link Objective}s this {@link Score} is
* registered to.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ static Builder builder() {
*
* @return The set of {@link Score}s for this objective
*/
Map<Component, Score> scores();
Map<String, Score> scores();

/**
* 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.
*/
boolean hasScore(Component name);
boolean hasScore(String name);

/**
* Adds the specified {@link Score} to this objective.
Expand All @@ -121,13 +121,15 @@ static Builder builder() {
*/
void addScore(Score score) throws IllegalArgumentException;

// TODO findScore for player/entity?

/**
* 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 Component}, if it exists.
*/
default Optional<Score> findScore(final Component name) {
default Optional<Score> findScore(final String name) {
if (!this.hasScore(name)) {
return Optional.empty();
}
Expand All @@ -142,7 +144,7 @@ default Optional<Score> findScore(final Component name) {
* @param name The name of the {@link Score} to get
* @return The {@link Score} for the specified {@link Component}
*/
Score findOrCreateScore(Component name);
Score findOrCreateScore(String name);

/**
* Removes the specified {@link Score} from this objective, if present.
Expand All @@ -158,7 +160,7 @@ default Optional<Score> findScore(final Component name) {
* @param name The name of the {@link Score} to remove.
* @return Whether the score existed on this objective
*/
boolean removeScore(Component name);
boolean removeScore(String name);

/**
* Returns a {@link Set} of parent {@link Scoreboard}s this
Expand Down

0 comments on commit b51e2a0

Please sign in to comment.