ScoreboardDisplayPacket
This commit is contained in:
@@ -56,6 +56,7 @@ public enum State {
|
||||
Map.of(
|
||||
PingPacket.class, 0x1F,
|
||||
JoinGamePacket.class, 0x23,
|
||||
ScoreboardDisplayPacket.class, 0x3B,
|
||||
SpawnPositionPacket.class, 0x46,
|
||||
ChunkDataPacket.class, 0x20,
|
||||
PlayerAbilitiesPacket.class,0x2C,
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package mc.protocol.packets.server;
|
||||
|
||||
import lombok.Data;
|
||||
import mc.protocol.io.NetByteBuf;
|
||||
import mc.protocol.packets.ServerSidePacket;
|
||||
|
||||
/**
|
||||
* Отображение Scoreboard.
|
||||
*
|
||||
* <p>Структура пакета</p>
|
||||
* <pre>
|
||||
* | FIELD | TYPE | NOTES |
|
||||
* |------------|-------------|--------------------------------|
|
||||
* | Position | Byte | Положение: |
|
||||
* | | | 0 - list |
|
||||
* | | | 1 - sidebar |
|
||||
* | | | 2 - below name |
|
||||
* | | | 3-18 - team specific sidebar |
|
||||
* | Score Name | String (16) | Уникальное название Scoreboard |
|
||||
* </pre>
|
||||
*
|
||||
* @see <a href="https://wiki.vg/index.php?title=Protocol&oldid=14204#Display_Scoreboard" target="_top">Display Scoreboard</a>
|
||||
*/
|
||||
@Data
|
||||
public class ScoreboardDisplayPacket implements ServerSidePacket {
|
||||
|
||||
private int position;
|
||||
private String name;
|
||||
|
||||
public void setPosition(int position) {
|
||||
this.position = (position < 0) ? 0 : (Math.min(position, 18));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSelf(NetByteBuf netByteBuf) {
|
||||
netByteBuf.writeByte(position);
|
||||
netByteBuf.writeString(name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package mc.protocol.utils;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
@UtilityClass
|
||||
public class ScoreboardPosition {
|
||||
public final int LIST = 0;
|
||||
public final int SIDEBAR = 1;
|
||||
public final int BELOW_NAME = 2;
|
||||
}
|
||||
Reference in New Issue
Block a user