Improve scoreboard entries

This commit is contained in:
Jake Potrebic 2021-11-04 12:31:24 -07:00
parent d237e02832
commit 6ad7b27bb3
3 changed files with 49 additions and 0 deletions

View File

@ -144,6 +144,15 @@ final class CraftObjective extends CraftScoreboardComponent implements Objective
return new CraftScore(this, CraftScoreboard.getScoreHolder(entry));
}
// Paper start
@Override
public Score getScoreFor(org.bukkit.entity.Entity entity) throws IllegalArgumentException, IllegalStateException {
Preconditions.checkArgument(entity != null, "Entity cannot be null");
this.checkState();
return new CraftScore(this, ((org.bukkit.craftbukkit.entity.CraftEntity) entity).getHandle());
}
// Paper end
@Override
public void unregister() {
CraftScoreboard scoreboard = this.checkState();

View File

@ -235,6 +235,26 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
this.board.setDisplayObjective(CraftScoreboardTranslations.fromBukkitSlot(slot), null);
}
// Paper start
@Override
public ImmutableSet<Score> getScoresFor(org.bukkit.entity.Entity entity) throws IllegalArgumentException {
Preconditions.checkArgument(entity != null, "Entity cannot be null");
return this.getScores(((org.bukkit.craftbukkit.entity.CraftEntity) entity).getHandle());
}
@Override
public void resetScoresFor(org.bukkit.entity.Entity entity) throws IllegalArgumentException {
Preconditions.checkArgument(entity != null, "Entity cannot be null");
this.resetScores(((org.bukkit.craftbukkit.entity.CraftEntity) entity).getHandle());
}
@Override
public Team getEntityTeam(org.bukkit.entity.Entity entity) throws IllegalArgumentException {
Preconditions.checkArgument(entity != null, "Entity cannot be null");
return this.getEntryTeam(((org.bukkit.craftbukkit.entity.CraftEntity) entity).getHandle().getScoreboardName());
}
// Paper end
// CraftBukkit method
public Scoreboard getHandle() {
return this.board;

View File

@ -304,6 +304,26 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
}
}
// Paper start
@Override
public void addEntity(org.bukkit.entity.Entity entity) throws IllegalStateException, IllegalArgumentException {
Preconditions.checkArgument(entity != null, "Entity cannot be null");
this.addEntry(((org.bukkit.craftbukkit.entity.CraftEntity) entity).getHandle().getScoreboardName());
}
@Override
public boolean removeEntity(org.bukkit.entity.Entity entity) throws IllegalStateException, IllegalArgumentException {
Preconditions.checkArgument(entity != null, "Entity cannot be null");
return this.removeEntry(((org.bukkit.craftbukkit.entity.CraftEntity) entity).getHandle().getScoreboardName());
}
@Override
public boolean hasEntity(org.bukkit.entity.Entity entity) throws IllegalStateException, IllegalArgumentException {
Preconditions.checkArgument(entity != null, "Entity cannot be null");
return this.hasEntry(((org.bukkit.craftbukkit.entity.CraftEntity) entity).getHandle().getScoreboardName());
}
// Paper end
public static Visibility bukkitToNotch(NameTagVisibility visibility) {
switch (visibility) {
case ALWAYS: