mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-23 17:37:45 +01:00
SPIGOT-1714: Draft API for player list header / footer
This commit is contained in:
parent
2ba567f29b
commit
3b8f5be77b
13
nms-patches/PacketPlayOutPlayerListHeaderFooter.patch
Normal file
13
nms-patches/PacketPlayOutPlayerListHeaderFooter.patch
Normal file
@ -0,0 +1,13 @@
|
||||
--- a/net/minecraft/server/PacketPlayOutPlayerListHeaderFooter.java
|
||||
+++ b/net/minecraft/server/PacketPlayOutPlayerListHeaderFooter.java
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
public class PacketPlayOutPlayerListHeaderFooter implements Packet<PacketListenerPlayOut> {
|
||||
|
||||
- private IChatBaseComponent a;
|
||||
- private IChatBaseComponent b;
|
||||
+ public IChatBaseComponent a; // PAIL
|
||||
+ public IChatBaseComponent b; // PAIL
|
||||
|
||||
public PacketPlayOutPlayerListHeaderFooter() {}
|
||||
|
@ -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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user