diff --git a/api/src/main/java/net/md_5/bungee/api/scoreboard/Objective.java b/api/src/main/java/net/md_5/bungee/api/scoreboard/Objective.java new file mode 100644 index 00000000..a884d02b --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/scoreboard/Objective.java @@ -0,0 +1,20 @@ +package net.md_5.bungee.api.scoreboard; + +import lombok.Data; + +/** + * Represents an objective entry. + */ +@Data +public class Objective +{ + + /** + * Name of the objective. + */ + private final String name; + /** + * Value of the objective. + */ + private final String value; +} diff --git a/api/src/main/java/net/md_5/bungee/api/scoreboard/Position.java b/api/src/main/java/net/md_5/bungee/api/scoreboard/Position.java new file mode 100644 index 00000000..ad3cde81 --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/scoreboard/Position.java @@ -0,0 +1,10 @@ +package net.md_5.bungee.api.scoreboard; + +/** + * Represents locations for a scoreboard to be displayed. + */ +public enum Position +{ + + LIST, SIDEBAR, BELOW; +} diff --git a/api/src/main/java/net/md_5/bungee/api/scoreboard/Score.java b/api/src/main/java/net/md_5/bungee/api/scoreboard/Score.java new file mode 100644 index 00000000..685fbbd3 --- /dev/null +++ b/api/src/main/java/net/md_5/bungee/api/scoreboard/Score.java @@ -0,0 +1,24 @@ +package net.md_5.bungee.api.scoreboard; + +import lombok.Data; + +/** + * Represents a scoreboard score entry. + */ +@Data +public class Score +{ + + /** + * Name to be displayed in the list. + */ + private final String itemName; + /** + * Unique name of the score. + */ + private final String scoreName; + /** + * Value of the score. + */ + private final int value; +} 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 index c0d81cb0..67917748 100644 --- 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 @@ -1,5 +1,6 @@ package net.md_5.bungee.api.scoreboard; +import java.util.Collection; import lombok.Data; @Data @@ -11,7 +12,15 @@ public class Scoreboard */ private final String name; /** - * Text to be displayed with this scoreboard. + * Position of this scoreboard. */ - private final String text; + private final Position position; + /** + * Objectives for this scoreboard. + */ + private final Collection objectives; + /** + * Scores for this scoreboard. + */ + private final Collection scores; } diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/PacketDefinitions.java b/protocol/src/main/java/net/md_5/bungee/protocol/PacketDefinitions.java index 48f01260..e14e5054 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/PacketDefinitions.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/PacketDefinitions.java @@ -12,7 +12,7 @@ public class PacketDefinitions public enum OpCode { - BOOLEAN, BULK_CHUNK, BYTE, BYTE_INT, DOUBLE, FLOAT, INT, INT_3, INT_BYTE, ITEM, LONG, METADATA, OPTIONAL_MOTION, SHORT, SHORT_BYTE, SHORT_ITEM, STRING, TEAM, USHORT_BYTE + BOOLEAN, BULK_CHUNK, BYTE, BYTE_INT, DOUBLE, FLOAT, INT, INT_3, INT_BYTE, ITEM, LONG, METADATA, OPTIONAL_MOTION, SCORE, SHORT, SHORT_BYTE, SHORT_ITEM, STRING, TEAM, USHORT_BYTE } static @@ -307,7 +307,7 @@ public class PacketDefinitions }; opCodes[0xCF] = new OpCode[] { - STRING, BYTE, STRING, INT + SCORE }; opCodes[0xD0] = new OpCode[] { 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 7d03b019..5baa32bb 100644 --- a/proxy/src/main/java/net/md_5/bungee/ServerConnector.java +++ b/proxy/src/main/java/net/md_5/bungee/ServerConnector.java @@ -15,7 +15,7 @@ import net.md_5.bungee.packet.DefinedPacket; import net.md_5.bungee.packet.Packet1Login; 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.PacketCEScoreboardObjective; import net.md_5.bungee.packet.PacketFDEncryptionRequest; import net.md_5.bungee.packet.PacketFFKick; import net.md_5.bungee.packet.PacketHandler; @@ -91,10 +91,6 @@ public class ServerConnector extends PacketHandler { 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/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java index c36e4ddd..deb2e6ae 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 @@ -18,7 +18,7 @@ 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.PacketCEScoreboardObjective; import net.md_5.bungee.packet.PacketFAPluginMessage; import net.md_5.bungee.packet.PacketFFKick; import net.md_5.bungee.packet.PacketHandler; @@ -75,12 +75,6 @@ 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 3737ab83..6f032360 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,7 +226,9 @@ public abstract class DefinedPacket implements DataOutput classes[0x09] = Packet9Respawn.class; classes[0xC9] = PacketC9PlayerListItem.class; classes[0xCD] = PacketCDClientStatus.class; - classes[0xCE] = PacketCESetScoreboard.class; + classes[0xCE] = PacketCEScoreboardObjective.class; + classes[0xCF] = PacketCFScoreboardScore.class; + classes[0xD0] = PacketD0DisplayScoreboard.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/PacketCESetScoreboard.java b/proxy/src/main/java/net/md_5/bungee/packet/PacketCEScoreboardObjective.java similarity index 79% rename from proxy/src/main/java/net/md_5/bungee/packet/PacketCESetScoreboard.java rename to proxy/src/main/java/net/md_5/bungee/packet/PacketCEScoreboardObjective.java index a73b6b2e..ffae1042 100644 --- a/proxy/src/main/java/net/md_5/bungee/packet/PacketCESetScoreboard.java +++ b/proxy/src/main/java/net/md_5/bungee/packet/PacketCEScoreboardObjective.java @@ -5,7 +5,7 @@ import lombok.ToString; @ToString @EqualsAndHashCode(callSuper = false) -public class PacketCESetScoreboard extends DefinedPacket +public class PacketCEScoreboardObjective extends DefinedPacket { public String name; @@ -15,7 +15,7 @@ public class PacketCESetScoreboard extends DefinedPacket */ public byte status; - public PacketCESetScoreboard(String name, String text, byte status) + public PacketCEScoreboardObjective(String name, String text, byte status) { super( 0xCE ); writeUTF( name ); @@ -26,7 +26,7 @@ public class PacketCESetScoreboard extends DefinedPacket this.status = status; } - PacketCESetScoreboard(byte[] buf) + PacketCEScoreboardObjective(byte[] buf) { super( 0xCE, buf ); this.name = readUTF(); diff --git a/proxy/src/main/java/net/md_5/bungee/packet/PacketCFScoreboardScore.java b/proxy/src/main/java/net/md_5/bungee/packet/PacketCFScoreboardScore.java new file mode 100644 index 00000000..25294a32 --- /dev/null +++ b/proxy/src/main/java/net/md_5/bungee/packet/PacketCFScoreboardScore.java @@ -0,0 +1,36 @@ +package net.md_5.bungee.packet; + +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@ToString +@EqualsAndHashCode(callSuper = false) +public class PacketCFScoreboardScore extends DefinedPacket +{ + + public String itemName; + /** + * 0 = create / update, 1 = remove. + */ + public byte action; + public String scoreName; + public int value; + + public PacketCFScoreboardScore(byte[] buf) + { + super( 0xCF, buf ); + itemName = readUTF(); + action = readByte(); + if ( action == 0 ) + { + scoreName = readUTF(); + value = readInt(); + } + } + + @Override + public void handle(PacketHandler handler) throws Exception + { + handler.handle( this ); + } +} diff --git a/proxy/src/main/java/net/md_5/bungee/packet/PacketD0DisplayScoreboard.java b/proxy/src/main/java/net/md_5/bungee/packet/PacketD0DisplayScoreboard.java new file mode 100644 index 00000000..4eaeeb0c --- /dev/null +++ b/proxy/src/main/java/net/md_5/bungee/packet/PacketD0DisplayScoreboard.java @@ -0,0 +1,29 @@ +package net.md_5.bungee.packet; + +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@ToString +@EqualsAndHashCode(callSuper = false) +public class PacketD0DisplayScoreboard extends DefinedPacket +{ + + /** + * 0 = list, 1 = side, 2 = below. + */ + public byte position; + public String name; + + public PacketD0DisplayScoreboard(byte[] buf) + { + super( 0xCF, buf ); + position = readByte(); + name = readUTF(); + } + + @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 c4f12ad1..81f965a7 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,7 +56,15 @@ public abstract class PacketHandler { } - public void handle(PacketCESetScoreboard scoreboard) throws Exception + public void handle(PacketCEScoreboardObjective objective) throws Exception + { + } + + public void handle(PacketCFScoreboardScore score) throws Exception + { + } + + public void handle(PacketD0DisplayScoreboard displayScoreboard) throws Exception { }