diff --git a/api/src/main/java/net/md_5/bungee/api/scoreboard/Scoreboard.java b/api/src/main/java/net/md_5/bungee/api/scoreboard/Scoreboard.java new file mode 100644 index 00000000..c0d81cb0 --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/scoreboard/Scoreboard.java @@ -0,0 +1,17 @@ +package net.md_5.bungee.api.scoreboard; + +import lombok.Data; + +@Data +public class Scoreboard +{ + + /** + * Unique name for this scoreboard. + */ + private final String name; + /** + * Text to be displayed with this scoreboard. + */ + private final String text; +} diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java index 74132296..7d03b019 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -13,9 +13,9 @@ import net.md_5.bungee.connection.DownstreamBridge; import net.md_5.bungee.netty.HandlerBoss; import net.md_5.bungee.packet.DefinedPacket; import net.md_5.bungee.packet.Packet1Login; -import net.md_5.bungee.packet.Packet2Handshake; import net.md_5.bungee.packet.Packet9Respawn; import net.md_5.bungee.packet.PacketCDClientStatus; +import net.md_5.bungee.packet.PacketCESetScoreboard; import net.md_5.bungee.packet.PacketFDEncryptionRequest; import net.md_5.bungee.packet.PacketFFKick; import net.md_5.bungee.packet.PacketHandler; @@ -90,6 +90,11 @@ public class ServerConnector extends PacketHandler } else { bungee.getTabListHandler().onServerChange( user ); + + if ( user.serverSentScoreboard != null ) + { + user.sendPacket( new PacketCESetScoreboard( user.serverSentScoreboard.getName(), user.serverSentScoreboard.getText(), (byte) 1 ) ); + } user.sendPacket( Packet9Respawn.DIM1_SWITCH ); user.sendPacket( Packet9Respawn.DIM2_SWITCH ); diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java index a6dd36ed..a055999d 100644 --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java @@ -24,6 +24,7 @@ import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.connection.PendingConnection; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.ServerConnectEvent; +import net.md_5.bungee.api.scoreboard.Scoreboard; import net.md_5.bungee.netty.HandlerBoss; import net.md_5.bungee.netty.PipelineUtils; import net.md_5.bungee.packet.*; @@ -61,6 +62,7 @@ public final class UserConnection implements ProxiedPlayer @Getter private final Object switchMutex = new Object(); public PacketCCSettings settings; + public Scoreboard serverSentScoreboard; public UserConnection(BungeeCord bungee, Channel channel, PendingConnection pendingConnection, Packet2Handshake handshake, Packet1Login forgeLogin, List loginMessages) { diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java index 2acac2a4..c36e4ddd 100644 --- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java @@ -14,9 +14,11 @@ import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.event.ChatEvent; import net.md_5.bungee.api.event.PluginMessageEvent; +import net.md_5.bungee.api.scoreboard.Scoreboard; import net.md_5.bungee.packet.Packet0KeepAlive; import net.md_5.bungee.packet.Packet3Chat; import net.md_5.bungee.packet.PacketC9PlayerListItem; +import net.md_5.bungee.packet.PacketCESetScoreboard; import net.md_5.bungee.packet.PacketFAPluginMessage; import net.md_5.bungee.packet.PacketFFKick; import net.md_5.bungee.packet.PacketHandler; @@ -73,6 +75,12 @@ public class DownstreamBridge extends PacketHandler } } + @Override + public void handle(PacketCESetScoreboard scoreboard) throws Exception + { + con.serverSentScoreboard = new Scoreboard( scoreboard.name, scoreboard.text ); + } + @Override public void handle(PacketC9PlayerListItem playerList) throws Exception { diff --git a/proxy/src/main/java/net/md_5/bungee/packet/DefinedPacket.java b/proxy/src/main/java/net/md_5/bungee/packet/DefinedPacket.java index 3cabcbad..3737ab83 100644 --- a/proxy/src/main/java/net/md_5/bungee/packet/DefinedPacket.java +++ b/proxy/src/main/java/net/md_5/bungee/packet/DefinedPacket.java @@ -226,6 +226,7 @@ public abstract class DefinedPacket implements DataOutput classes[0x09] = Packet9Respawn.class; classes[0xC9] = PacketC9PlayerListItem.class; classes[0xCD] = PacketCDClientStatus.class; + classes[0xCE] = PacketCESetScoreboard.class; classes[0xFA] = PacketFAPluginMessage.class; classes[0xFC] = PacketFCEncryptionResponse.class; classes[0xFD] = PacketFDEncryptionRequest.class; diff --git a/proxy/src/main/java/net/md_5/bungee/packet/Packet9Respawn.java b/proxy/src/main/java/net/md_5/bungee/packet/Packet9Respawn.java index 1ef47734..11986184 100644 --- a/proxy/src/main/java/net/md_5/bungee/packet/Packet9Respawn.java +++ b/proxy/src/main/java/net/md_5/bungee/packet/Packet9Respawn.java @@ -1,6 +1,5 @@ package net.md_5.bungee.packet; -import io.netty.buffer.ByteBuf; import lombok.EqualsAndHashCode; import lombok.ToString; diff --git a/proxy/src/main/java/net/md_5/bungee/packet/PacketCDClientStatus.java b/proxy/src/main/java/net/md_5/bungee/packet/PacketCDClientStatus.java index 12499025..c82a7f41 100644 --- a/proxy/src/main/java/net/md_5/bungee/packet/PacketCDClientStatus.java +++ b/proxy/src/main/java/net/md_5/bungee/packet/PacketCDClientStatus.java @@ -1,6 +1,5 @@ package net.md_5.bungee.packet; -import io.netty.buffer.ByteBuf; import lombok.EqualsAndHashCode; import lombok.ToString; diff --git a/proxy/src/main/java/net/md_5/bungee/packet/PacketCESetScoreboard.java b/proxy/src/main/java/net/md_5/bungee/packet/PacketCESetScoreboard.java new file mode 100644 index 00000000..a73b6b2e --- /dev/null +++ b/proxy/src/main/java/net/md_5/bungee/packet/PacketCESetScoreboard.java @@ -0,0 +1,42 @@ +package net.md_5.bungee.packet; + +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@ToString +@EqualsAndHashCode(callSuper = false) +public class PacketCESetScoreboard extends DefinedPacket +{ + + public String name; + public String text; + /** + * 0 to create, 1 to remove. + */ + public byte status; + + public PacketCESetScoreboard(String name, String text, byte status) + { + super( 0xCE ); + writeUTF( name ); + writeUTF( text ); + writeByte( status ); + this.name = name; + this.text = text; + this.status = status; + } + + PacketCESetScoreboard(byte[] buf) + { + super( 0xCE, buf ); + this.name = readUTF(); + this.text = readUTF(); + this.status = readByte(); + } + + @Override + public void handle(PacketHandler handler) throws Exception + { + handler.handle( this ); + } +} diff --git a/proxy/src/main/java/net/md_5/bungee/packet/PacketHandler.java b/proxy/src/main/java/net/md_5/bungee/packet/PacketHandler.java index 429955fb..c4f12ad1 100644 --- a/proxy/src/main/java/net/md_5/bungee/packet/PacketHandler.java +++ b/proxy/src/main/java/net/md_5/bungee/packet/PacketHandler.java @@ -56,6 +56,10 @@ public abstract class PacketHandler { } + public void handle(PacketCESetScoreboard scoreboard) throws Exception + { + } + public void handle(PacketFAPluginMessage pluginMessage) throws Exception { }