Skip to content

Commit

Permalink
1.19.3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
NEZNAMY committed Dec 12, 2022
1 parent 64ae986 commit 01b3a12
Show file tree
Hide file tree
Showing 30 changed files with 613 additions and 255 deletions.
1 change: 1 addition & 0 deletions api/src/main/java/me/neznamy/tab/api/ProtocolVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public enum ProtocolVersion {
UNKNOWN_SERVER_VERSION ("Unknown"),
UNKNOWN_CLIENT_VERSION ("Unknown"),
PROXY ("Proxy"),
V1_19_3 (761),
V1_19_2 (760),
V1_19_1 (760),
V1_19 (759),
Expand Down
6 changes: 6 additions & 0 deletions api/src/main/java/me/neznamy/tab/api/TabPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,10 @@ public interface TabPlayer {
* @return Player's direct chat message signing key
*/
Object getProfilePublicKey();

/**
* Return player's chat session ID
* @return player's chat session ID
*/
UUID getChatSessionId();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.neznamy.tab.api.protocol;

import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import java.util.UUID;

Expand All @@ -12,8 +13,8 @@
*/
public class PacketPlayOutPlayerInfo implements TabPacket {

/** Packet action */
private final EnumPlayerInfoAction action;
/** Packet actions */
private final EnumSet<EnumPlayerInfoAction> actions;

/** List of affected entries */
private final List<PlayerInfoData> entries;
Expand All @@ -27,10 +28,7 @@ public class PacketPlayOutPlayerInfo implements TabPacket {
* Affected entries
*/
public PacketPlayOutPlayerInfo(EnumPlayerInfoAction action, PlayerInfoData... entries) {
Preconditions.checkNotNull(action, "action");
Preconditions.checkNotNull(entries, "entries");
this.action = action;
this.entries = Arrays.asList(entries);
this(action, Arrays.asList(entries));
}

/**
Expand All @@ -44,22 +42,61 @@ public PacketPlayOutPlayerInfo(EnumPlayerInfoAction action, PlayerInfoData... en
public PacketPlayOutPlayerInfo(EnumPlayerInfoAction action, List<PlayerInfoData> entries) {
Preconditions.checkNotNull(action, "action");
Preconditions.checkNotNull(entries, "entries");
this.action = action;
if (action == EnumPlayerInfoAction.ADD_PLAYER) {
actions = EnumSet.of(EnumPlayerInfoAction.ADD_PLAYER,
EnumPlayerInfoAction.INITIALIZE_CHAT,
EnumPlayerInfoAction.UPDATE_GAME_MODE,
EnumPlayerInfoAction.UPDATE_LISTED,
EnumPlayerInfoAction.UPDATE_LATENCY,
EnumPlayerInfoAction.UPDATE_DISPLAY_NAME);
} else {
this.actions = EnumSet.of(action);
}
this.entries = entries;
}

/**
* Constructs new instance with given parameters.
*
* @param actions
* Packet actions
* @param entries
* Affected entries
*/
public PacketPlayOutPlayerInfo(EnumSet<EnumPlayerInfoAction> actions, PlayerInfoData... entries) {
Preconditions.checkNotNull(actions, "action");
Preconditions.checkNotNull(entries, "entries");
this.actions = actions;
this.entries = Arrays.asList(entries);
}

/**
* Constructs new instance with given parameters.
*
* @param actions
* Packet actions
* @param entries
* Affected entries
*/
public PacketPlayOutPlayerInfo(EnumSet<EnumPlayerInfoAction> actions, List<PlayerInfoData> entries) {
Preconditions.checkNotNull(actions, "action");
Preconditions.checkNotNull(entries, "entries");
this.actions = actions;
this.entries = entries;
}

@Override
public String toString() {
return String.format("PacketPlayOutPlayerInfo{action=%s,entries=%s}", action, entries);
return String.format("PacketPlayOutPlayerInfo{actions=%s,entries=%s}", actions, entries);
}

/**
* Returns {@link #action}
* Returns {@link #actions}
*
* @return packet action
*/
public EnumPlayerInfoAction getAction() {
return action;
public EnumSet<EnumPlayerInfoAction> getActions() {
return actions;
}

/**
Expand All @@ -79,6 +116,9 @@ public static class PlayerInfoData {
/** Latency */
private int latency;

/** I have no idea what this is */
private boolean listed;

/** GameMode */
private EnumGamemode gameMode = EnumGamemode.SURVIVAL; //ProtocolLib causes NPE even when action does not use GameMode

Expand All @@ -97,12 +137,15 @@ public static class PlayerInfoData {
/** Player's skin, null for empty skin */
private Skin skin;

/** Chat session ID */
private UUID chatSessionId;

/** Player's chat signing key */
private Object profilePublicKey;

/**
* Constructs new instance with given parameters. Suitable for
* {@link EnumPlayerInfoAction}.ADD_PLAYER action
* {@link EnumPlayerInfoAction#ADD_PLAYER} action
*
* @param name
* Player's name
Expand All @@ -119,20 +162,22 @@ public static class PlayerInfoData {
* @param profilePublicKey
* Player's chat signing key
*/
public PlayerInfoData(String name, UUID uniqueId, Skin skin, int latency, EnumGamemode gameMode, IChatBaseComponent displayName, Object profilePublicKey) {
public PlayerInfoData(String name, UUID uniqueId, Skin skin, boolean listed, int latency, EnumGamemode gameMode, IChatBaseComponent displayName, UUID chatSessionId, Object profilePublicKey) {
Preconditions.checkNotNull(uniqueId, "uuid");
this.name = name;
this.uniqueId = uniqueId;
this.skin = skin;
this.listed = listed;
this.latency = latency;
this.gameMode = gameMode;
this.displayName = displayName;
this.chatSessionId = chatSessionId;
this.profilePublicKey = profilePublicKey;
}

/**
* Constructs new instance with given parameters. Suitable for
* {@link EnumPlayerInfoAction}.UPDATE_GAME_MODE action
* {@link EnumPlayerInfoAction#UPDATE_GAME_MODE} action
*
* @param uniqueId
* Player's uuid
Expand All @@ -147,7 +192,7 @@ public PlayerInfoData(UUID uniqueId, EnumGamemode gameMode) {

/**
* Constructs new instance with given parameters. Suitable for
* {@link EnumPlayerInfoAction}.UPDATE_LATENCY action
* {@link EnumPlayerInfoAction#UPDATE_LATENCY} action
*
* @param uniqueId
* Player's uuid
Expand All @@ -162,7 +207,7 @@ public PlayerInfoData(UUID uniqueId, int latency) {

/**
* Constructs new instance with given parameters. Suitable for
* {@link EnumPlayerInfoAction}.UPDATE_DISPLAY_NAME action
* {@link EnumPlayerInfoAction#UPDATE_DISPLAY_NAME} action
*
* @param uniqueId
* Player's uuid
Expand All @@ -177,7 +222,7 @@ public PlayerInfoData(UUID uniqueId, IChatBaseComponent displayName) {

/**
* Constructs new instance with given parameter. Suitable for
* {@link EnumPlayerInfoAction}.REMOVE_PLAYER action
* {@link EnumPlayerInfoAction#REMOVE_PLAYER} action
*
* @param uniqueId
* Player's uuid
Expand Down Expand Up @@ -211,6 +256,25 @@ public void setLatency(int latency) {
this.latency = latency;
}

/**
* Returns {@link #listed}
*
* @return listed
*/
public boolean isListed() {
return listed;
}

/**
* Sets {@link #listed} to specified value
*
* @param listed
* Listed flag
*/
public void setListed(boolean listed) {
this.listed = listed;
}

/**
* Returns {@link #displayName}
*
Expand Down Expand Up @@ -306,6 +370,25 @@ public void setSkin(Skin skin) {
this.skin = skin;
}

/**
* Returns {@link #chatSessionId}
*
* @return chatSessionId
*/
public UUID getChatSessionId() {
return chatSessionId;
}

/**
* Sets {@link #chatSessionId} to specified value
*
* @param chatSessionId
* chatSessionId to use
*/
public void setChatSessionId(UUID chatSessionId) {
this.chatSessionId = chatSessionId;
}

/**
* Returns {@link #profilePublicKey}
*
Expand All @@ -328,12 +411,13 @@ public void setProfilePublicKey(Object profilePublicKey) {

/**
* En enum representing packet action
* Calling ordinal() will return action's network ID.
*/
public enum EnumPlayerInfoAction {

ADD_PLAYER,
INITIALIZE_CHAT,
UPDATE_GAME_MODE,
UPDATE_LISTED,
UPDATE_LATENCY,
UPDATE_DISPLAY_NAME,
REMOVE_PLAYER
Expand Down
Loading

0 comments on commit 01b3a12

Please sign in to comment.