diff options
author | Adam Thomas <aet2505@gmail.com> | 2014-11-29 02:54:00 +0000 |
---|---|---|
committer | md_5 <git@md-5.net> | 2014-12-18 21:27:46 +1100 |
commit | 606cf0eea44b88d5630623ff8a5d63571fa42793 (patch) | |
tree | b2111a5e8fa59d2bd36e06aaf601c2eff0a5db55 /src/main/java | |
parent | dadb43af9262c69809ee05c5dae2642b3eaf8a43 (diff) | |
download | craftbukkit-606cf0eea44b88d5630623ff8a5d63571fa42793.tar craftbukkit-606cf0eea44b88d5630623ff8a5d63571fa42793.tar.gz craftbukkit-606cf0eea44b88d5630623ff8a5d63571fa42793.tar.lz craftbukkit-606cf0eea44b88d5630623ff8a5d63571fa42793.tar.xz craftbukkit-606cf0eea44b88d5630623ff8a5d63571fa42793.zip |
Implement NameTag visibility API for Teams.
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java index 8a640d36..e8d1c081 100644 --- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java +++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java @@ -2,9 +2,11 @@ package org.bukkit.craftbukkit.scoreboard; import java.util.Set; +import net.minecraft.server.EnumNameTagVisibility; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; +import org.bukkit.scoreboard.NameTagVisibility; import org.bukkit.scoreboard.Team; import com.google.common.collect.ImmutableSet; @@ -92,6 +94,20 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { team.setCanSeeFriendlyInvisibles(enabled); } + public NameTagVisibility getNameTagVisibility() throws IllegalArgumentException { + CraftScoreboard scoreboard = checkState(); + + // PAIL: Rename + return notchToBukkit(team.i()); // i is sent in PacketPlayOutScoreboardTeam, cannot see a use of j + } + + public void setNameTagVisibility(NameTagVisibility visibility) throws IllegalArgumentException { + CraftScoreboard scoreboard = checkState(); + + // PAIL: Rename + team.a(bukkitToNotch(visibility)); // i is sent in PacketPlayOutScoreboardTeam, cannot see a use of j + } + public Set<OfflinePlayer> getPlayers() throws IllegalStateException { CraftScoreboard scoreboard = checkState(); @@ -142,4 +158,34 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { scoreboard.teams.remove(team.getName()); setUnregistered(); } + + public static EnumNameTagVisibility bukkitToNotch(NameTagVisibility visibility) { + switch (visibility) { + case ALWAYS: + return EnumNameTagVisibility.ALWAYS; + case NEVER: + return EnumNameTagVisibility.NEVER; + case HIDE_FOR_OTHER_TEAMS: + return EnumNameTagVisibility.HIDE_FOR_OTHER_TEAMS; + case HIDE_FOR_OWN_TEAM: + return EnumNameTagVisibility.HIDE_FOR_OWN_TEAM; + default: + throw new IllegalArgumentException("Unknown visibility level " + visibility); + } + } + + public static NameTagVisibility notchToBukkit(EnumNameTagVisibility visibility) { + switch (visibility) { + case ALWAYS: + return NameTagVisibility.ALWAYS; + case NEVER: + return NameTagVisibility.NEVER; + case HIDE_FOR_OTHER_TEAMS: + return NameTagVisibility.HIDE_FOR_OTHER_TEAMS; + case HIDE_FOR_OWN_TEAM: + return NameTagVisibility.HIDE_FOR_OWN_TEAM; + default: + throw new IllegalArgumentException("Unknown visibility level " + visibility); + } + } } |