13
0
geforkt von Mirrors/Paper

#1223: Remove non-existent scoreboard display name/prefix/suffix limits

By: Parker Hawke <hawkeboyz2@hotmail.com>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2023-07-16 15:21:56 +10:00
Ursprung c00ddac0c8
Commit c0e2080221
6 geänderte Dateien mit 62 neuen und 69 gelöschten Zeilen

Datei anzeigen

@ -26,51 +26,50 @@ final class CraftObjective extends CraftScoreboardComponent implements Objective
} }
@Override @Override
public String getName() throws IllegalStateException { public String getName() {
checkState(); checkState();
return objective.getName(); return objective.getName();
} }
@Override @Override
public String getDisplayName() throws IllegalStateException { public String getDisplayName() {
checkState(); checkState();
return CraftChatMessage.fromComponent(objective.getDisplayName()); return CraftChatMessage.fromComponent(objective.getDisplayName());
} }
@Override @Override
public void setDisplayName(String displayName) throws IllegalStateException, IllegalArgumentException { public void setDisplayName(String displayName) {
Preconditions.checkArgument(displayName != null, "Display name cannot be null"); Preconditions.checkArgument(displayName != null, "Display name cannot be null");
Preconditions.checkArgument(displayName.length() <= 128, "Display name '" + displayName + "' is longer than the limit of 128 characters");
checkState(); checkState();
objective.setDisplayName(CraftChatMessage.fromString(displayName)[0]); // SPIGOT-4112: not nullable objective.setDisplayName(CraftChatMessage.fromString(displayName)[0]); // SPIGOT-4112: not nullable
} }
@Override @Override
public String getCriteria() throws IllegalStateException { public String getCriteria() {
checkState(); checkState();
return criteria.bukkitName; return criteria.bukkitName;
} }
@Override @Override
public Criteria getTrackedCriteria() throws IllegalStateException { public Criteria getTrackedCriteria() {
checkState(); checkState();
return criteria; return criteria;
} }
@Override @Override
public boolean isModifiable() throws IllegalStateException { public boolean isModifiable() {
checkState(); checkState();
return !criteria.criteria.isReadOnly(); return !criteria.criteria.isReadOnly();
} }
@Override @Override
public void setDisplaySlot(DisplaySlot slot) throws IllegalStateException { public void setDisplaySlot(DisplaySlot slot) {
CraftScoreboard scoreboard = checkState(); CraftScoreboard scoreboard = checkState();
Scoreboard board = scoreboard.board; Scoreboard board = scoreboard.board;
ScoreboardObjective objective = this.objective; ScoreboardObjective objective = this.objective;
@ -87,7 +86,7 @@ final class CraftObjective extends CraftScoreboardComponent implements Objective
} }
@Override @Override
public DisplaySlot getDisplaySlot() throws IllegalStateException { public DisplaySlot getDisplaySlot() {
CraftScoreboard scoreboard = checkState(); CraftScoreboard scoreboard = checkState();
Scoreboard board = scoreboard.board; Scoreboard board = scoreboard.board;
ScoreboardObjective objective = this.objective; ScoreboardObjective objective = this.objective;
@ -101,7 +100,7 @@ final class CraftObjective extends CraftScoreboardComponent implements Objective
} }
@Override @Override
public void setRenderType(RenderType renderType) throws IllegalStateException { public void setRenderType(RenderType renderType) {
Preconditions.checkArgument(renderType != null, "RenderType cannot be null"); Preconditions.checkArgument(renderType != null, "RenderType cannot be null");
checkState(); checkState();
@ -109,14 +108,14 @@ final class CraftObjective extends CraftScoreboardComponent implements Objective
} }
@Override @Override
public RenderType getRenderType() throws IllegalStateException { public RenderType getRenderType() {
checkState(); checkState();
return CraftScoreboardTranslations.toBukkitRender(this.objective.getRenderType()); return CraftScoreboardTranslations.toBukkitRender(this.objective.getRenderType());
} }
@Override @Override
public Score getScore(OfflinePlayer player) throws IllegalArgumentException, IllegalStateException { public Score getScore(OfflinePlayer player) {
Preconditions.checkArgument(player != null, "Player cannot be null"); Preconditions.checkArgument(player != null, "Player cannot be null");
checkState(); checkState();
@ -124,7 +123,7 @@ final class CraftObjective extends CraftScoreboardComponent implements Objective
} }
@Override @Override
public Score getScore(String entry) throws IllegalArgumentException, IllegalStateException { public Score getScore(String entry) {
Preconditions.checkArgument(entry != null, "Entry cannot be null"); Preconditions.checkArgument(entry != null, "Entry cannot be null");
Preconditions.checkArgument(entry.length() <= Short.MAX_VALUE, "Score '" + entry + "' is longer than the limit of 32767 characters"); Preconditions.checkArgument(entry.length() <= Short.MAX_VALUE, "Score '" + entry + "' is longer than the limit of 32767 characters");
checkState(); checkState();
@ -133,14 +132,14 @@ final class CraftObjective extends CraftScoreboardComponent implements Objective
} }
@Override @Override
public void unregister() throws IllegalStateException { public void unregister() {
CraftScoreboard scoreboard = checkState(); CraftScoreboard scoreboard = checkState();
scoreboard.board.removeObjective(objective); scoreboard.board.removeObjective(objective);
} }
@Override @Override
CraftScoreboard checkState() throws IllegalStateException { CraftScoreboard checkState() {
Preconditions.checkState(getScoreboard().board.getObjective(objective.getName()) != null, "Unregistered scoreboard component"); Preconditions.checkState(getScoreboard().board.getObjective(objective.getName()) != null, "Unregistered scoreboard component");
return getScoreboard(); return getScoreboard();

Datei anzeigen

@ -40,7 +40,7 @@ final class CraftScore implements Score {
} }
@Override @Override
public int getScore() throws IllegalStateException { public int getScore() {
Scoreboard board = objective.checkState().board; Scoreboard board = objective.checkState().board;
if (board.getTrackedPlayers().contains(entry)) { // Lazy if (board.getTrackedPlayers().contains(entry)) { // Lazy
@ -55,12 +55,12 @@ final class CraftScore implements Score {
} }
@Override @Override
public void setScore(int score) throws IllegalStateException { public void setScore(int score) {
objective.checkState().board.getOrCreatePlayerScore(entry, objective.getHandle()).setScore(score); objective.checkState().board.getOrCreatePlayerScore(entry, objective.getHandle()).setScore(score);
} }
@Override @Override
public boolean isScoreSet() throws IllegalStateException { public boolean isScoreSet() {
Scoreboard board = objective.checkState().board; Scoreboard board = objective.checkState().board;
return board.getTrackedPlayers().contains(entry) && board.getPlayerScores(entry).containsKey(objective.getHandle()); return board.getTrackedPlayers().contains(entry) && board.getPlayerScores(entry).containsKey(objective.getHandle());

Datei anzeigen

@ -25,33 +25,32 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
} }
@Override @Override
public CraftObjective registerNewObjective(String name, String criteria) throws IllegalArgumentException { public CraftObjective registerNewObjective(String name, String criteria) {
return registerNewObjective(name, criteria, name); return registerNewObjective(name, criteria, name);
} }
@Override @Override
public CraftObjective registerNewObjective(String name, String criteria, String displayName) throws IllegalArgumentException { public CraftObjective registerNewObjective(String name, String criteria, String displayName) {
return registerNewObjective(name, CraftCriteria.getFromBukkit(criteria), displayName, RenderType.INTEGER); return registerNewObjective(name, CraftCriteria.getFromBukkit(criteria), displayName, RenderType.INTEGER);
} }
@Override @Override
public CraftObjective registerNewObjective(String name, String criteria, String displayName, RenderType renderType) throws IllegalArgumentException { public CraftObjective registerNewObjective(String name, String criteria, String displayName, RenderType renderType) {
return registerNewObjective(name, CraftCriteria.getFromBukkit(criteria), displayName, renderType); return registerNewObjective(name, CraftCriteria.getFromBukkit(criteria), displayName, renderType);
} }
@Override @Override
public CraftObjective registerNewObjective(String name, Criteria criteria, String displayName) throws IllegalArgumentException { public CraftObjective registerNewObjective(String name, Criteria criteria, String displayName) {
return registerNewObjective(name, criteria, displayName, RenderType.INTEGER); return registerNewObjective(name, criteria, displayName, RenderType.INTEGER);
} }
@Override @Override
public CraftObjective registerNewObjective(String name, Criteria criteria, String displayName, RenderType renderType) throws IllegalArgumentException { public CraftObjective registerNewObjective(String name, Criteria criteria, String displayName, RenderType renderType) {
Preconditions.checkArgument(name != null, "Objective name cannot be null"); Preconditions.checkArgument(name != null, "Objective name cannot be null");
Preconditions.checkArgument(criteria != null, "Criteria cannot be null"); Preconditions.checkArgument(criteria != null, "Criteria cannot be null");
Preconditions.checkArgument(displayName != null, "Display name cannot be null"); Preconditions.checkArgument(displayName != null, "Display name cannot be null");
Preconditions.checkArgument(renderType != null, "RenderType cannot be null"); Preconditions.checkArgument(renderType != null, "RenderType cannot be null");
Preconditions.checkArgument(name.length() <= Short.MAX_VALUE, "The name '%s' is longer than the limit of 32767 characters (%s)", name, name.length()); Preconditions.checkArgument(name.length() <= Short.MAX_VALUE, "The name '%s' is longer than the limit of 32767 characters (%s)", name, name.length());
Preconditions.checkArgument(displayName.length() <= 128, "The display name '%s' is longer than the limit of 128 characters (%s)", displayName, displayName.length());
Preconditions.checkArgument(board.getObjective(name) == null, "An objective of name '%s' already exists", name); Preconditions.checkArgument(board.getObjective(name) == null, "An objective of name '%s' already exists", name);
ScoreboardObjective objective = board.addObjective(name, ((CraftCriteria) criteria).criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType)); ScoreboardObjective objective = board.addObjective(name, ((CraftCriteria) criteria).criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType));
@ -59,14 +58,14 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
} }
@Override @Override
public Objective getObjective(String name) throws IllegalArgumentException { public Objective getObjective(String name) {
Preconditions.checkArgument(name != null, "Objective name cannot be null"); Preconditions.checkArgument(name != null, "Objective name cannot be null");
ScoreboardObjective nms = board.getObjective(name); ScoreboardObjective nms = board.getObjective(name);
return nms == null ? null : new CraftObjective(this, nms); return nms == null ? null : new CraftObjective(this, nms);
} }
@Override @Override
public ImmutableSet<Objective> getObjectivesByCriteria(String criteria) throws IllegalArgumentException { public ImmutableSet<Objective> getObjectivesByCriteria(String criteria) {
Preconditions.checkArgument(criteria != null, "Criteria name cannot be null"); Preconditions.checkArgument(criteria != null, "Criteria name cannot be null");
ImmutableSet.Builder<Objective> objectives = ImmutableSet.builder(); ImmutableSet.Builder<Objective> objectives = ImmutableSet.builder();
@ -80,7 +79,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
} }
@Override @Override
public ImmutableSet<Objective> getObjectivesByCriteria(Criteria criteria) throws IllegalArgumentException { public ImmutableSet<Objective> getObjectivesByCriteria(Criteria criteria) {
Preconditions.checkArgument(criteria != null, "Criteria cannot be null"); Preconditions.checkArgument(criteria != null, "Criteria cannot be null");
ImmutableSet.Builder<Objective> objectives = ImmutableSet.builder(); ImmutableSet.Builder<Objective> objectives = ImmutableSet.builder();
@ -100,7 +99,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
} }
@Override @Override
public Objective getObjective(DisplaySlot slot) throws IllegalArgumentException { public Objective getObjective(DisplaySlot slot) {
Preconditions.checkArgument(slot != null, "Display slot cannot be null"); Preconditions.checkArgument(slot != null, "Display slot cannot be null");
ScoreboardObjective objective = board.getDisplayObjective(CraftScoreboardTranslations.fromBukkitSlot(slot)); ScoreboardObjective objective = board.getDisplayObjective(CraftScoreboardTranslations.fromBukkitSlot(slot));
if (objective == null) { if (objective == null) {
@ -110,14 +109,14 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
} }
@Override @Override
public ImmutableSet<Score> getScores(OfflinePlayer player) throws IllegalArgumentException { public ImmutableSet<Score> getScores(OfflinePlayer player) {
Preconditions.checkArgument(player != null, "OfflinePlayer cannot be null"); Preconditions.checkArgument(player != null, "OfflinePlayer cannot be null");
return getScores(player.getName()); return getScores(player.getName());
} }
@Override @Override
public ImmutableSet<Score> getScores(String entry) throws IllegalArgumentException { public ImmutableSet<Score> getScores(String entry) {
Preconditions.checkArgument(entry != null, "Entry cannot be null"); Preconditions.checkArgument(entry != null, "Entry cannot be null");
ImmutableSet.Builder<Score> scores = ImmutableSet.builder(); ImmutableSet.Builder<Score> scores = ImmutableSet.builder();
@ -128,14 +127,14 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
} }
@Override @Override
public void resetScores(OfflinePlayer player) throws IllegalArgumentException { public void resetScores(OfflinePlayer player) {
Preconditions.checkArgument(player != null, "OfflinePlayer cannot be null"); Preconditions.checkArgument(player != null, "OfflinePlayer cannot be null");
resetScores(player.getName()); resetScores(player.getName());
} }
@Override @Override
public void resetScores(String entry) throws IllegalArgumentException { public void resetScores(String entry) {
Preconditions.checkArgument(entry != null, "Entry cannot be null"); Preconditions.checkArgument(entry != null, "Entry cannot be null");
for (ScoreboardObjective objective : this.board.getObjectives()) { for (ScoreboardObjective objective : this.board.getObjectives()) {
@ -144,7 +143,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
} }
@Override @Override
public Team getPlayerTeam(OfflinePlayer player) throws IllegalArgumentException { public Team getPlayerTeam(OfflinePlayer player) {
Preconditions.checkArgument(player != null, "OfflinePlayer cannot be null"); Preconditions.checkArgument(player != null, "OfflinePlayer cannot be null");
ScoreboardTeam team = board.getPlayersTeam(player.getName()); ScoreboardTeam team = board.getPlayersTeam(player.getName());
@ -152,7 +151,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
} }
@Override @Override
public Team getEntryTeam(String entry) throws IllegalArgumentException { public Team getEntryTeam(String entry) {
Preconditions.checkArgument(entry != null, "Entry cannot be null"); Preconditions.checkArgument(entry != null, "Entry cannot be null");
ScoreboardTeam team = board.getPlayersTeam(entry); ScoreboardTeam team = board.getPlayersTeam(entry);
@ -160,7 +159,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
} }
@Override @Override
public Team getTeam(String teamName) throws IllegalArgumentException { public Team getTeam(String teamName) {
Preconditions.checkArgument(teamName != null, "Team name cannot be null"); Preconditions.checkArgument(teamName != null, "Team name cannot be null");
ScoreboardTeam team = board.getPlayerTeam(teamName); ScoreboardTeam team = board.getPlayerTeam(teamName);
@ -173,7 +172,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
} }
@Override @Override
public Team registerNewTeam(String name) throws IllegalArgumentException { public Team registerNewTeam(String name) {
Preconditions.checkArgument(name != null, "Team name cannot be null"); Preconditions.checkArgument(name != null, "Team name cannot be null");
Preconditions.checkArgument(name.length() <= Short.MAX_VALUE, "Team name '%s' is longer than the limit of 32767 characters (%s)", name, name.length()); Preconditions.checkArgument(name.length() <= Short.MAX_VALUE, "Team name '%s' is longer than the limit of 32767 characters (%s)", name, name.length());
Preconditions.checkArgument(board.getPlayerTeam(name) == null, "Team name '%s' is already in use", name); Preconditions.checkArgument(board.getPlayerTeam(name) == null, "Team name '%s' is already in use", name);
@ -200,7 +199,7 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
} }
@Override @Override
public void clearSlot(DisplaySlot slot) throws IllegalArgumentException { public void clearSlot(DisplaySlot slot) {
Preconditions.checkArgument(slot != null, "Slot cannot be null"); Preconditions.checkArgument(slot != null, "Slot cannot be null");
board.setDisplayObjective(CraftScoreboardTranslations.fromBukkitSlot(slot), null); board.setDisplayObjective(CraftScoreboardTranslations.fromBukkitSlot(slot), null);
} }

Datei anzeigen

@ -7,11 +7,11 @@ abstract class CraftScoreboardComponent {
this.scoreboard = scoreboard; this.scoreboard = scoreboard;
} }
abstract CraftScoreboard checkState() throws IllegalStateException; abstract CraftScoreboard checkState();
public CraftScoreboard getScoreboard() { public CraftScoreboard getScoreboard() {
return scoreboard; return scoreboard;
} }
abstract void unregister() throws IllegalStateException; abstract void unregister();
} }

Datei anzeigen

@ -53,7 +53,7 @@ public final class CraftScoreboardManager implements ScoreboardManager {
} }
// CraftBukkit method // CraftBukkit method
public void setPlayerBoard(CraftPlayer player, org.bukkit.scoreboard.Scoreboard bukkitScoreboard) throws IllegalArgumentException { public void setPlayerBoard(CraftPlayer player, org.bukkit.scoreboard.Scoreboard bukkitScoreboard) {
Preconditions.checkArgument(bukkitScoreboard instanceof CraftScoreboard, "Cannot set player scoreboard to an unregistered Scoreboard"); Preconditions.checkArgument(bukkitScoreboard instanceof CraftScoreboard, "Cannot set player scoreboard to an unregistered Scoreboard");
CraftScoreboard scoreboard = (CraftScoreboard) bukkitScoreboard; CraftScoreboard scoreboard = (CraftScoreboard) bukkitScoreboard;

Datei anzeigen

@ -22,64 +22,59 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
} }
@Override @Override
public String getName() throws IllegalStateException { public String getName() {
checkState(); checkState();
return team.getName(); return team.getName();
} }
@Override @Override
public String getDisplayName() throws IllegalStateException { public String getDisplayName() {
checkState(); checkState();
return CraftChatMessage.fromComponent(team.getDisplayName()); return CraftChatMessage.fromComponent(team.getDisplayName());
} }
@Override @Override
public void setDisplayName(String displayName) throws IllegalStateException { public void setDisplayName(String displayName) {
Preconditions.checkArgument(displayName != null, "Display name cannot be null"); Preconditions.checkArgument(displayName != null, "Display name cannot be null");
int lengthStripedDisplayName = ChatColor.stripColor(displayName).length();
Preconditions.checkArgument(lengthStripedDisplayName <= 128, "Display name '%s' is longer than the limit of 128 characters (%s)", displayName, lengthStripedDisplayName);
checkState(); checkState();
team.setDisplayName(CraftChatMessage.fromString(displayName)[0]); // SPIGOT-4112: not nullable team.setDisplayName(CraftChatMessage.fromString(displayName)[0]); // SPIGOT-4112: not nullable
} }
@Override @Override
public String getPrefix() throws IllegalStateException { public String getPrefix() {
checkState(); checkState();
return CraftChatMessage.fromComponent(team.getPlayerPrefix()); return CraftChatMessage.fromComponent(team.getPlayerPrefix());
} }
@Override @Override
public void setPrefix(String prefix) throws IllegalStateException, IllegalArgumentException { public void setPrefix(String prefix) {
Preconditions.checkArgument(prefix != null, "Prefix cannot be null"); Preconditions.checkArgument(prefix != null, "Prefix cannot be null");
int lengthStripedPrefix = ChatColor.stripColor(prefix).length();
Preconditions.checkArgument(lengthStripedPrefix <= 64, "Prefix '%s' is longer than the limit of 64 characters (%s)", prefix, lengthStripedPrefix);
checkState(); checkState();
team.setPlayerPrefix(CraftChatMessage.fromStringOrNull(prefix)); team.setPlayerPrefix(CraftChatMessage.fromStringOrNull(prefix));
} }
@Override @Override
public String getSuffix() throws IllegalStateException { public String getSuffix() {
checkState(); checkState();
return CraftChatMessage.fromComponent(team.getPlayerSuffix()); return CraftChatMessage.fromComponent(team.getPlayerSuffix());
} }
@Override @Override
public void setSuffix(String suffix) throws IllegalStateException, IllegalArgumentException { public void setSuffix(String suffix) {
Preconditions.checkArgument(suffix != null, "Suffix cannot be null"); Preconditions.checkArgument(suffix != null, "Suffix cannot be null");
int lengthStripedSuffix = ChatColor.stripColor(suffix).length(); checkState();
Preconditions.checkArgument(lengthStripedSuffix <= 64, "Suffix '%s' is longer than the limit of 64 characters (%s)", suffix, lengthStripedSuffix);
team.setPlayerSuffix(CraftChatMessage.fromStringOrNull(suffix)); team.setPlayerSuffix(CraftChatMessage.fromStringOrNull(suffix));
} }
@Override @Override
public ChatColor getColor() throws IllegalStateException { public ChatColor getColor() {
checkState(); checkState();
return CraftChatMessage.getColor(team.getColor()); return CraftChatMessage.getColor(team.getColor());
@ -94,28 +89,28 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
} }
@Override @Override
public boolean allowFriendlyFire() throws IllegalStateException { public boolean allowFriendlyFire() {
checkState(); checkState();
return team.isAllowFriendlyFire(); return team.isAllowFriendlyFire();
} }
@Override @Override
public void setAllowFriendlyFire(boolean enabled) throws IllegalStateException { public void setAllowFriendlyFire(boolean enabled) {
checkState(); checkState();
team.setAllowFriendlyFire(enabled); team.setAllowFriendlyFire(enabled);
} }
@Override @Override
public boolean canSeeFriendlyInvisibles() throws IllegalStateException { public boolean canSeeFriendlyInvisibles() {
checkState(); checkState();
return team.canSeeFriendlyInvisibles(); return team.canSeeFriendlyInvisibles();
} }
@Override @Override
public void setCanSeeFriendlyInvisibles(boolean enabled) throws IllegalStateException { public void setCanSeeFriendlyInvisibles(boolean enabled) {
checkState(); checkState();
team.setSeeFriendlyInvisibles(enabled); team.setSeeFriendlyInvisibles(enabled);
@ -136,7 +131,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
} }
@Override @Override
public Set<OfflinePlayer> getPlayers() throws IllegalStateException { public Set<OfflinePlayer> getPlayers() {
checkState(); checkState();
ImmutableSet.Builder<OfflinePlayer> players = ImmutableSet.builder(); ImmutableSet.Builder<OfflinePlayer> players = ImmutableSet.builder();
@ -147,7 +142,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
} }
@Override @Override
public Set<String> getEntries() throws IllegalStateException { public Set<String> getEntries() {
checkState(); checkState();
ImmutableSet.Builder<String> entries = ImmutableSet.builder(); ImmutableSet.Builder<String> entries = ImmutableSet.builder();
@ -158,20 +153,20 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
} }
@Override @Override
public int getSize() throws IllegalStateException { public int getSize() {
checkState(); checkState();
return team.getPlayers().size(); return team.getPlayers().size();
} }
@Override @Override
public void addPlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException { public void addPlayer(OfflinePlayer player) {
Preconditions.checkArgument(player != null, "OfflinePlayer cannot be null"); Preconditions.checkArgument(player != null, "OfflinePlayer cannot be null");
addEntry(player.getName()); addEntry(player.getName());
} }
@Override @Override
public void addEntry(String entry) throws IllegalStateException, IllegalArgumentException { public void addEntry(String entry) {
Preconditions.checkArgument(entry != null, "Entry cannot be null"); Preconditions.checkArgument(entry != null, "Entry cannot be null");
CraftScoreboard scoreboard = checkState(); CraftScoreboard scoreboard = checkState();
@ -179,13 +174,13 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
} }
@Override @Override
public boolean removePlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException { public boolean removePlayer(OfflinePlayer player) {
Preconditions.checkArgument(player != null, "OfflinePlayer cannot be null"); Preconditions.checkArgument(player != null, "OfflinePlayer cannot be null");
return removeEntry(player.getName()); return removeEntry(player.getName());
} }
@Override @Override
public boolean removeEntry(String entry) throws IllegalStateException, IllegalArgumentException { public boolean removeEntry(String entry) {
Preconditions.checkArgument(entry != null, "Entry cannot be null"); Preconditions.checkArgument(entry != null, "Entry cannot be null");
CraftScoreboard scoreboard = checkState(); CraftScoreboard scoreboard = checkState();
@ -212,14 +207,14 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
} }
@Override @Override
public void unregister() throws IllegalStateException { public void unregister() {
CraftScoreboard scoreboard = checkState(); CraftScoreboard scoreboard = checkState();
scoreboard.board.removePlayerTeam(team); scoreboard.board.removePlayerTeam(team);
} }
@Override @Override
public OptionStatus getOption(Option option) throws IllegalStateException { public OptionStatus getOption(Option option) {
checkState(); checkState();
switch (option) { switch (option) {
@ -235,7 +230,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
} }
@Override @Override
public void setOption(Option option, OptionStatus status) throws IllegalStateException { public void setOption(Option option, OptionStatus status) {
checkState(); checkState();
switch (option) { switch (option) {
@ -284,7 +279,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
} }
@Override @Override
CraftScoreboard checkState() throws IllegalStateException { CraftScoreboard checkState() {
Preconditions.checkState(getScoreboard().board.getPlayerTeam(team.getName()) != null, "Unregistered scoreboard component"); Preconditions.checkState(getScoreboard().board.getPlayerTeam(team.getName()) != null, "Unregistered scoreboard component");
return getScoreboard(); return getScoreboard();