Skip to content

Commit

Permalink
Remove scoreboard name length limitations
Browse files Browse the repository at this point in the history
These were lifted in 1.18
  • Loading branch information
aromaa committed Nov 25, 2023
1 parent 17b64ac commit 6c88bf5
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,20 +252,14 @@ public Collection<net.minecraft.world.scores.Objective> getObjectives() {

public static final class Builder implements Objective.Builder {

private static final int MAX_NAME_LENGTH = 16;
private @Nullable String name;
private @Nullable Component displayName;
private @Nullable Criterion criterion;
private @Nullable ObjectiveDisplayMode objectiveDisplayMode;

@Override
public Objective.Builder name(final String name) {
Objects.requireNonNull(name);
if (org.spongepowered.common.scoreboard.SpongeObjective.Builder.MAX_NAME_LENGTH < name.length()) {
throw new IllegalStateException(String.format("name '%s' is too long: %s characters over limit of %s",
name, org.spongepowered.common.scoreboard.SpongeObjective.Builder.MAX_NAME_LENGTH - name.length(), org.spongepowered.common.scoreboard.SpongeObjective.Builder.MAX_NAME_LENGTH));
}
this.name = name;
this.name = Objects.requireNonNull(name);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.spongepowered.common.accessor.world.scores.ScoreAccessor;
import org.spongepowered.common.bridge.world.scores.ObjectiveBridge;
import org.spongepowered.common.bridge.world.scores.ScoreBridge;
import org.spongepowered.common.util.Constants;

import java.util.HashMap;
import java.util.HashSet;
Expand All @@ -51,9 +50,6 @@ public final class SpongeScore implements Score {
public SpongeScore(final Component name) {
this.name = name;
this.legacyName = LegacyComponentSerializer.legacySection().serialize(name);
if (this.legacyName.length() > Constants.Scoreboards.SCORE_NAME_LENGTH) {
throw new IllegalArgumentException(String.format("The score name %s is too long! It must be at most %s characters.", this.legacyName, Constants.Scoreboards.SCORE_NAME_LENGTH));
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public SpongeTeamBuilder() {
@Override
public Team.Builder name(final String name) {
this.name = checkNotNull(name, "Name cannot be null!");
checkState(name.length() < 17, "Name is " + name.length() + " characters long! It must be at most 16.");
if (this.displayName == null) {
this.displayName = Component.text(this.name);
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/spongepowered/common/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,6 @@ public static final class Scoreboards {

public static final int OBJECTIVE_PACKET_ADD = 0;
public static final int OBJECTIVE_PACKET_REMOVE = 1;
public static final int SCORE_NAME_LENGTH = 40;
}

public static final class Functional {
Expand Down

0 comments on commit 6c88bf5

Please sign in to comment.