All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.nukkit.network.protocol.PositionTrackingDBClientRequestPacket Maven / Gradle / Ivy

There is a newer version: 1.20.40-r1
Show newest version
package cn.nukkit.network.protocol;

import cn.nukkit.api.PowerNukkitOnly;
import cn.nukkit.api.Since;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * @author joserobjr
 */
@PowerNukkitOnly
@Since("1.4.0.0-PN")
@ToString
@NoArgsConstructor(onConstructor = @__(@PowerNukkitOnly))
public class PositionTrackingDBClientRequestPacket extends DataPacket {
    @PowerNukkitOnly
    @Since("1.4.0.0-PN")
    public static final byte NETWORK_ID = ProtocolInfo.POS_TRACKING_CLIENT_REQUEST_PACKET;
    
    private static final Action[] ACTIONS = Action.values();
    
    private Action action;
    private int trackingId;

    @PowerNukkitOnly
    @Since("1.4.0.0-PN")
    public Action getAction() {
        return action;
    }

    @PowerNukkitOnly
    @Since("1.4.0.0-PN")
    public int getTrackingId() {
        return trackingId;
    }

    @Override
    public void encode() {
        reset();
        putByte((byte) action.ordinal());
        putVarInt(trackingId);
    }

    @Override
    public void decode() {
        int aByte = getByte();
        action = ACTIONS[aByte];
        trackingId = getVarInt();
    }

    @Override
    public byte pid() {
        return NETWORK_ID;
    }

    @Since("1.4.0.0-PN")
    @PowerNukkitOnly
    public enum Action {
        @PowerNukkitOnly
        @Since("1.4.0.0-PN")
        QUERY
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy