From 6742811d6973512302f4ff77e9e004d7478c566c Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 3 Mar 2016 19:12:48 +1100 Subject: [PATCH] SPIGOT-1666: Expand Team option API --- .../craftbukkit/scoreboard/CraftTeam.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java index f5ff0f712e..160d34a0ef 100644 --- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java +++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java @@ -12,6 +12,7 @@ import org.bukkit.scoreboard.Team; import com.google.common.collect.ImmutableSet; import net.minecraft.server.ScoreboardTeam; +import net.minecraft.server.ScoreboardTeamBase; final class CraftTeam extends CraftScoreboardComponent implements Team { private final ScoreboardTeam team; @@ -181,6 +182,41 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { scoreboard.board.removeTeam(team); } + @Override + public OptionStatus getOption(Option option) throws IllegalStateException { + checkState(); + + switch (option) { + case NAME_TAG_VISIBILITY: + return OptionStatus.values()[team.getNameTagVisibility().ordinal()]; + case DEATH_MESSAGE_VISIBILITY: + return OptionStatus.values()[team.j().ordinal()]; // PAIL: rename + case COLLISION_RULE: + return OptionStatus.values()[team.k().ordinal()]; // PAIL: rename + default: + throw new IllegalArgumentException("Unrecognised option " + option); + } + } + + @Override + public void setOption(Option option, OptionStatus status) throws IllegalStateException { + checkState(); + + switch (option) { + case NAME_TAG_VISIBILITY: + team.setNameTagVisibility(EnumNameTagVisibility.values()[status.ordinal()]); + break; + case DEATH_MESSAGE_VISIBILITY: + team.b(EnumNameTagVisibility.values()[status.ordinal()]); // PAIL: rename + break; + case COLLISION_RULE: + team.a(ScoreboardTeamBase.EnumTeamPush.values()[status.ordinal()]); // PAIL: rename + break; + default: + throw new IllegalArgumentException("Unrecognised option " + option); + } + } + public static EnumNameTagVisibility bukkitToNotch(NameTagVisibility visibility) { switch (visibility) { case ALWAYS: