diff options
author | md_5 <git@md-5.net> | 2018-07-29 21:30:31 +1000 |
---|---|---|
committer | md_5 <git@md-5.net> | 2018-07-29 21:30:31 +1000 |
commit | 3b8f5be77be456fa291a8089ba10ddbad1cb82b6 (patch) | |
tree | 8cae6b6c347b4dc6047ac2a255274ef882456c7f /src/main | |
parent | 2ba567f29b5b4acf0f4c710171bb530888124172 (diff) | |
download | craftbukkit-3b8f5be77be456fa291a8089ba10ddbad1cb82b6.tar craftbukkit-3b8f5be77be456fa291a8089ba10ddbad1cb82b6.tar.gz craftbukkit-3b8f5be77be456fa291a8089ba10ddbad1cb82b6.tar.lz craftbukkit-3b8f5be77be456fa291a8089ba10ddbad1cb82b6.tar.xz craftbukkit-3b8f5be77be456fa291a8089ba10ddbad1cb82b6.zip |
SPIGOT-1714: Draft API for player list header / footer
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index c41294ff..c10816cf 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -31,6 +31,7 @@ import net.minecraft.server.AttributeMapServer; import net.minecraft.server.AttributeModifiable; import net.minecraft.server.AttributeRanged; import net.minecraft.server.BlockPosition; +import net.minecraft.server.ChatComponentText; import net.minecraft.server.Container; import net.minecraft.server.Entity; import net.minecraft.server.EntityHuman; @@ -52,6 +53,7 @@ import net.minecraft.server.PacketPlayOutCustomSoundEffect; import net.minecraft.server.PacketPlayOutMap; import net.minecraft.server.PacketPlayOutNamedSoundEffect; import net.minecraft.server.PacketPlayOutPlayerInfo; +import net.minecraft.server.PacketPlayOutPlayerListHeaderFooter; import net.minecraft.server.PacketPlayOutSpawnPosition; import net.minecraft.server.PacketPlayOutStopSound; import net.minecraft.server.PacketPlayOutTitle; @@ -228,6 +230,47 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } } + private IChatBaseComponent playerListHeader; + private IChatBaseComponent playerListFooter; + + @Override + public String getPlayerListHeader() { + return (playerListHeader == null) ? null : CraftChatMessage.fromComponent(playerListHeader); + } + + @Override + public String getPlayerListFooter() { + return (playerListFooter == null) ? null : CraftChatMessage.fromComponent(playerListFooter); + } + + @Override + public void setPlayerListHeader(String header) { + this.playerListHeader = CraftChatMessage.fromStringOrNull(header); + updatePlayerListHeaderFooter(); + } + + @Override + public void setPlayerListFooter(String footer) { + this.playerListFooter = CraftChatMessage.fromStringOrNull(footer); + updatePlayerListHeaderFooter(); + } + + @Override + public void setPlayerListHeaderFooter(String header, String footer) { + this.playerListHeader = CraftChatMessage.fromStringOrNull(header); + this.playerListFooter = CraftChatMessage.fromStringOrNull(footer); + updatePlayerListHeaderFooter(); + } + + private void updatePlayerListHeaderFooter() { + if (getHandle().playerConnection == null) return; + + PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter(); + packet.a = (this.playerListHeader == null) ? new ChatComponentText("") : this.playerListHeader; + packet.b = (this.playerListFooter == null) ? new ChatComponentText("") : this.playerListFooter; + getHandle().playerConnection.sendPacket(packet); + } + @Override public boolean equals(Object obj) { if (!(obj instanceof OfflinePlayer)) { |