// Code generated by protocol buffer compiler. Do not edit!
package emu.lunarcore.proto;

import java.io.IOException;
import us.hebi.quickbuf.FieldName;
import us.hebi.quickbuf.InvalidProtocolBufferException;
import us.hebi.quickbuf.JsonSink;
import us.hebi.quickbuf.JsonSource;
import us.hebi.quickbuf.MessageFactory;
import us.hebi.quickbuf.ProtoMessage;
import us.hebi.quickbuf.ProtoSink;
import us.hebi.quickbuf.ProtoSource;
import us.hebi.quickbuf.Utf8String;

public final class PlayerBasicInfoOuterClass {
  /**
   * Protobuf type {@code PlayerBasicInfo}
   */
  public static final class PlayerBasicInfo extends ProtoMessage<PlayerBasicInfo> implements Cloneable {
    private static final long serialVersionUID = 0L;

    /**
     * <code>optional uint32 level = 2;</code>
     */
    private int level;

    /**
     * <code>optional uint32 exp = 3;</code>
     */
    private int exp;

    /**
     * <code>optional uint32 stamina = 4;</code>
     */
    private int stamina;

    /**
     * <code>optional uint32 mcoin = 5;</code>
     */
    private int mcoin;

    /**
     * <code>optional uint32 hcoin = 6;</code>
     */
    private int hcoin;

    /**
     * <code>optional uint32 scoin = 7;</code>
     */
    private int scoin;

    /**
     * <code>optional uint32 world_level = 8;</code>
     */
    private int worldLevel;

    /**
     * <code>optional string nickname = 1;</code>
     */
    private final Utf8String nickname = Utf8String.newEmptyInstance();

    private PlayerBasicInfo() {
    }

    /**
     * @return a new empty instance of {@code PlayerBasicInfo}
     */
    public static PlayerBasicInfo newInstance() {
      return new PlayerBasicInfo();
    }

    /**
     * <code>optional uint32 level = 2;</code>
     * @return whether the level field is set
     */
    public boolean hasLevel() {
      return (bitField0_ & 0x00000001) != 0;
    }

    /**
     * <code>optional uint32 level = 2;</code>
     * @return this
     */
    public PlayerBasicInfo clearLevel() {
      bitField0_ &= ~0x00000001;
      level = 0;
      return this;
    }

    /**
     * <code>optional uint32 level = 2;</code>
     * @return the level
     */
    public int getLevel() {
      return level;
    }

    /**
     * <code>optional uint32 level = 2;</code>
     * @param value the level to set
     * @return this
     */
    public PlayerBasicInfo setLevel(final int value) {
      bitField0_ |= 0x00000001;
      level = value;
      return this;
    }

    /**
     * <code>optional uint32 exp = 3;</code>
     * @return whether the exp field is set
     */
    public boolean hasExp() {
      return (bitField0_ & 0x00000002) != 0;
    }

    /**
     * <code>optional uint32 exp = 3;</code>
     * @return this
     */
    public PlayerBasicInfo clearExp() {
      bitField0_ &= ~0x00000002;
      exp = 0;
      return this;
    }

    /**
     * <code>optional uint32 exp = 3;</code>
     * @return the exp
     */
    public int getExp() {
      return exp;
    }

    /**
     * <code>optional uint32 exp = 3;</code>
     * @param value the exp to set
     * @return this
     */
    public PlayerBasicInfo setExp(final int value) {
      bitField0_ |= 0x00000002;
      exp = value;
      return this;
    }

    /**
     * <code>optional uint32 stamina = 4;</code>
     * @return whether the stamina field is set
     */
    public boolean hasStamina() {
      return (bitField0_ & 0x00000004) != 0;
    }

    /**
     * <code>optional uint32 stamina = 4;</code>
     * @return this
     */
    public PlayerBasicInfo clearStamina() {
      bitField0_ &= ~0x00000004;
      stamina = 0;
      return this;
    }

    /**
     * <code>optional uint32 stamina = 4;</code>
     * @return the stamina
     */
    public int getStamina() {
      return stamina;
    }

    /**
     * <code>optional uint32 stamina = 4;</code>
     * @param value the stamina to set
     * @return this
     */
    public PlayerBasicInfo setStamina(final int value) {
      bitField0_ |= 0x00000004;
      stamina = value;
      return this;
    }

    /**
     * <code>optional uint32 mcoin = 5;</code>
     * @return whether the mcoin field is set
     */
    public boolean hasMcoin() {
      return (bitField0_ & 0x00000008) != 0;
    }

    /**
     * <code>optional uint32 mcoin = 5;</code>
     * @return this
     */
    public PlayerBasicInfo clearMcoin() {
      bitField0_ &= ~0x00000008;
      mcoin = 0;
      return this;
    }

    /**
     * <code>optional uint32 mcoin = 5;</code>
     * @return the mcoin
     */
    public int getMcoin() {
      return mcoin;
    }

    /**
     * <code>optional uint32 mcoin = 5;</code>
     * @param value the mcoin to set
     * @return this
     */
    public PlayerBasicInfo setMcoin(final int value) {
      bitField0_ |= 0x00000008;
      mcoin = value;
      return this;
    }

    /**
     * <code>optional uint32 hcoin = 6;</code>
     * @return whether the hcoin field is set
     */
    public boolean hasHcoin() {
      return (bitField0_ & 0x00000010) != 0;
    }

    /**
     * <code>optional uint32 hcoin = 6;</code>
     * @return this
     */
    public PlayerBasicInfo clearHcoin() {
      bitField0_ &= ~0x00000010;
      hcoin = 0;
      return this;
    }

    /**
     * <code>optional uint32 hcoin = 6;</code>
     * @return the hcoin
     */
    public int getHcoin() {
      return hcoin;
    }

    /**
     * <code>optional uint32 hcoin = 6;</code>
     * @param value the hcoin to set
     * @return this
     */
    public PlayerBasicInfo setHcoin(final int value) {
      bitField0_ |= 0x00000010;
      hcoin = value;
      return this;
    }

    /**
     * <code>optional uint32 scoin = 7;</code>
     * @return whether the scoin field is set
     */
    public boolean hasScoin() {
      return (bitField0_ & 0x00000020) != 0;
    }

    /**
     * <code>optional uint32 scoin = 7;</code>
     * @return this
     */
    public PlayerBasicInfo clearScoin() {
      bitField0_ &= ~0x00000020;
      scoin = 0;
      return this;
    }

    /**
     * <code>optional uint32 scoin = 7;</code>
     * @return the scoin
     */
    public int getScoin() {
      return scoin;
    }

    /**
     * <code>optional uint32 scoin = 7;</code>
     * @param value the scoin to set
     * @return this
     */
    public PlayerBasicInfo setScoin(final int value) {
      bitField0_ |= 0x00000020;
      scoin = value;
      return this;
    }

    /**
     * <code>optional uint32 world_level = 8;</code>
     * @return whether the worldLevel field is set
     */
    public boolean hasWorldLevel() {
      return (bitField0_ & 0x00000040) != 0;
    }

    /**
     * <code>optional uint32 world_level = 8;</code>
     * @return this
     */
    public PlayerBasicInfo clearWorldLevel() {
      bitField0_ &= ~0x00000040;
      worldLevel = 0;
      return this;
    }

    /**
     * <code>optional uint32 world_level = 8;</code>
     * @return the worldLevel
     */
    public int getWorldLevel() {
      return worldLevel;
    }

    /**
     * <code>optional uint32 world_level = 8;</code>
     * @param value the worldLevel to set
     * @return this
     */
    public PlayerBasicInfo setWorldLevel(final int value) {
      bitField0_ |= 0x00000040;
      worldLevel = value;
      return this;
    }

    /**
     * <code>optional string nickname = 1;</code>
     * @return whether the nickname field is set
     */
    public boolean hasNickname() {
      return (bitField0_ & 0x00000080) != 0;
    }

    /**
     * <code>optional string nickname = 1;</code>
     * @return this
     */
    public PlayerBasicInfo clearNickname() {
      bitField0_ &= ~0x00000080;
      nickname.clear();
      return this;
    }

    /**
     * <code>optional string nickname = 1;</code>
     * @return the nickname
     */
    public String getNickname() {
      return nickname.getString();
    }

    /**
     * <code>optional string nickname = 1;</code>
     * @return internal {@code Utf8String} representation of nickname for reading
     */
    public Utf8String getNicknameBytes() {
      return this.nickname;
    }

    /**
     * <code>optional string nickname = 1;</code>
     * @return internal {@code Utf8String} representation of nickname for modifications
     */
    public Utf8String getMutableNicknameBytes() {
      bitField0_ |= 0x00000080;
      return this.nickname;
    }

    /**
     * <code>optional string nickname = 1;</code>
     * @param value the nickname to set
     * @return this
     */
    public PlayerBasicInfo setNickname(final CharSequence value) {
      bitField0_ |= 0x00000080;
      nickname.copyFrom(value);
      return this;
    }

    /**
     * <code>optional string nickname = 1;</code>
     * @param value the nickname to set
     * @return this
     */
    public PlayerBasicInfo setNickname(final Utf8String value) {
      bitField0_ |= 0x00000080;
      nickname.copyFrom(value);
      return this;
    }

    @Override
    public PlayerBasicInfo copyFrom(final PlayerBasicInfo other) {
      cachedSize = other.cachedSize;
      if ((bitField0_ | other.bitField0_) != 0) {
        bitField0_ = other.bitField0_;
        level = other.level;
        exp = other.exp;
        stamina = other.stamina;
        mcoin = other.mcoin;
        hcoin = other.hcoin;
        scoin = other.scoin;
        worldLevel = other.worldLevel;
        nickname.copyFrom(other.nickname);
      }
      return this;
    }

    @Override
    public PlayerBasicInfo mergeFrom(final PlayerBasicInfo other) {
      if (other.isEmpty()) {
        return this;
      }
      cachedSize = -1;
      if (other.hasLevel()) {
        setLevel(other.level);
      }
      if (other.hasExp()) {
        setExp(other.exp);
      }
      if (other.hasStamina()) {
        setStamina(other.stamina);
      }
      if (other.hasMcoin()) {
        setMcoin(other.mcoin);
      }
      if (other.hasHcoin()) {
        setHcoin(other.hcoin);
      }
      if (other.hasScoin()) {
        setScoin(other.scoin);
      }
      if (other.hasWorldLevel()) {
        setWorldLevel(other.worldLevel);
      }
      if (other.hasNickname()) {
        getMutableNicknameBytes().copyFrom(other.nickname);
      }
      return this;
    }

    @Override
    public PlayerBasicInfo clear() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      level = 0;
      exp = 0;
      stamina = 0;
      mcoin = 0;
      hcoin = 0;
      scoin = 0;
      worldLevel = 0;
      nickname.clear();
      return this;
    }

    @Override
    public PlayerBasicInfo clearQuick() {
      if (isEmpty()) {
        return this;
      }
      cachedSize = -1;
      bitField0_ = 0;
      nickname.clear();
      return this;
    }

    @Override
    public boolean equals(Object o) {
      if (o == this) {
        return true;
      }
      if (!(o instanceof PlayerBasicInfo)) {
        return false;
      }
      PlayerBasicInfo other = (PlayerBasicInfo) o;
      return bitField0_ == other.bitField0_
        && (!hasLevel() || level == other.level)
        && (!hasExp() || exp == other.exp)
        && (!hasStamina() || stamina == other.stamina)
        && (!hasMcoin() || mcoin == other.mcoin)
        && (!hasHcoin() || hcoin == other.hcoin)
        && (!hasScoin() || scoin == other.scoin)
        && (!hasWorldLevel() || worldLevel == other.worldLevel)
        && (!hasNickname() || nickname.equals(other.nickname));
    }

    @Override
    public void writeTo(final ProtoSink output) throws IOException {
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeRawByte((byte) 16);
        output.writeUInt32NoTag(level);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeRawByte((byte) 24);
        output.writeUInt32NoTag(exp);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeRawByte((byte) 32);
        output.writeUInt32NoTag(stamina);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeRawByte((byte) 40);
        output.writeUInt32NoTag(mcoin);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeRawByte((byte) 48);
        output.writeUInt32NoTag(hcoin);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        output.writeRawByte((byte) 56);
        output.writeUInt32NoTag(scoin);
      }
      if ((bitField0_ & 0x00000040) != 0) {
        output.writeRawByte((byte) 64);
        output.writeUInt32NoTag(worldLevel);
      }
      if ((bitField0_ & 0x00000080) != 0) {
        output.writeRawByte((byte) 10);
        output.writeStringNoTag(nickname);
      }
    }

    @Override
    protected int computeSerializedSize() {
      int size = 0;
      if ((bitField0_ & 0x00000001) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(level);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(exp);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(stamina);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(mcoin);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(hcoin);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(scoin);
      }
      if ((bitField0_ & 0x00000040) != 0) {
        size += 1 + ProtoSink.computeUInt32SizeNoTag(worldLevel);
      }
      if ((bitField0_ & 0x00000080) != 0) {
        size += 1 + ProtoSink.computeStringSizeNoTag(nickname);
      }
      return size;
    }

    @Override
    @SuppressWarnings("fallthrough")
    public PlayerBasicInfo mergeFrom(final ProtoSource input) throws IOException {
      // Enabled Fall-Through Optimization (QuickBuffers)
      int tag = input.readTag();
      while (true) {
        switch (tag) {
          case 16: {
            // level
            level = input.readUInt32();
            bitField0_ |= 0x00000001;
            tag = input.readTag();
            if (tag != 24) {
              break;
            }
          }
          case 24: {
            // exp
            exp = input.readUInt32();
            bitField0_ |= 0x00000002;
            tag = input.readTag();
            if (tag != 32) {
              break;
            }
          }
          case 32: {
            // stamina
            stamina = input.readUInt32();
            bitField0_ |= 0x00000004;
            tag = input.readTag();
            if (tag != 40) {
              break;
            }
          }
          case 40: {
            // mcoin
            mcoin = input.readUInt32();
            bitField0_ |= 0x00000008;
            tag = input.readTag();
            if (tag != 48) {
              break;
            }
          }
          case 48: {
            // hcoin
            hcoin = input.readUInt32();
            bitField0_ |= 0x00000010;
            tag = input.readTag();
            if (tag != 56) {
              break;
            }
          }
          case 56: {
            // scoin
            scoin = input.readUInt32();
            bitField0_ |= 0x00000020;
            tag = input.readTag();
            if (tag != 64) {
              break;
            }
          }
          case 64: {
            // worldLevel
            worldLevel = input.readUInt32();
            bitField0_ |= 0x00000040;
            tag = input.readTag();
            if (tag != 10) {
              break;
            }
          }
          case 10: {
            // nickname
            input.readString(nickname);
            bitField0_ |= 0x00000080;
            tag = input.readTag();
            if (tag != 0) {
              break;
            }
          }
          case 0: {
            return this;
          }
          default: {
            if (!input.skipField(tag)) {
              return this;
            }
            tag = input.readTag();
            break;
          }
        }
      }
    }

    @Override
    public void writeTo(final JsonSink output) throws IOException {
      output.beginObject();
      if ((bitField0_ & 0x00000001) != 0) {
        output.writeUInt32(FieldNames.level, level);
      }
      if ((bitField0_ & 0x00000002) != 0) {
        output.writeUInt32(FieldNames.exp, exp);
      }
      if ((bitField0_ & 0x00000004) != 0) {
        output.writeUInt32(FieldNames.stamina, stamina);
      }
      if ((bitField0_ & 0x00000008) != 0) {
        output.writeUInt32(FieldNames.mcoin, mcoin);
      }
      if ((bitField0_ & 0x00000010) != 0) {
        output.writeUInt32(FieldNames.hcoin, hcoin);
      }
      if ((bitField0_ & 0x00000020) != 0) {
        output.writeUInt32(FieldNames.scoin, scoin);
      }
      if ((bitField0_ & 0x00000040) != 0) {
        output.writeUInt32(FieldNames.worldLevel, worldLevel);
      }
      if ((bitField0_ & 0x00000080) != 0) {
        output.writeString(FieldNames.nickname, nickname);
      }
      output.endObject();
    }

    @Override
    public PlayerBasicInfo mergeFrom(final JsonSource input) throws IOException {
      if (!input.beginObject()) {
        return this;
      }
      while (!input.isAtEnd()) {
        switch (input.readFieldHash()) {
          case 102865796: {
            if (input.isAtField(FieldNames.level)) {
              if (!input.trySkipNullValue()) {
                level = input.readUInt32();
                bitField0_ |= 0x00000001;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 100893: {
            if (input.isAtField(FieldNames.exp)) {
              if (!input.trySkipNullValue()) {
                exp = input.readUInt32();
                bitField0_ |= 0x00000002;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case -1897344401: {
            if (input.isAtField(FieldNames.stamina)) {
              if (!input.trySkipNullValue()) {
                stamina = input.readUInt32();
                bitField0_ |= 0x00000004;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 103723134: {
            if (input.isAtField(FieldNames.mcoin)) {
              if (!input.trySkipNullValue()) {
                mcoin = input.readUInt32();
                bitField0_ |= 0x00000008;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 99105529: {
            if (input.isAtField(FieldNames.hcoin)) {
              if (!input.trySkipNullValue()) {
                hcoin = input.readUInt32();
                bitField0_ |= 0x00000010;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 109264260: {
            if (input.isAtField(FieldNames.scoin)) {
              if (!input.trySkipNullValue()) {
                scoin = input.readUInt32();
                bitField0_ |= 0x00000020;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 440007442:
          case 1305257111: {
            if (input.isAtField(FieldNames.worldLevel)) {
              if (!input.trySkipNullValue()) {
                worldLevel = input.readUInt32();
                bitField0_ |= 0x00000040;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          case 70690926: {
            if (input.isAtField(FieldNames.nickname)) {
              if (!input.trySkipNullValue()) {
                input.readString(nickname);
                bitField0_ |= 0x00000080;
              }
            } else {
              input.skipUnknownField();
            }
            break;
          }
          default: {
            input.skipUnknownField();
            break;
          }
        }
      }
      input.endObject();
      return this;
    }

    @Override
    public PlayerBasicInfo clone() {
      return new PlayerBasicInfo().copyFrom(this);
    }

    @Override
    public boolean isEmpty() {
      return ((bitField0_) == 0);
    }

    public static PlayerBasicInfo parseFrom(final byte[] data) throws
        InvalidProtocolBufferException {
      return ProtoMessage.mergeFrom(new PlayerBasicInfo(), data).checkInitialized();
    }

    public static PlayerBasicInfo parseFrom(final ProtoSource input) throws IOException {
      return ProtoMessage.mergeFrom(new PlayerBasicInfo(), input).checkInitialized();
    }

    public static PlayerBasicInfo parseFrom(final JsonSource input) throws IOException {
      return ProtoMessage.mergeFrom(new PlayerBasicInfo(), input).checkInitialized();
    }

    /**
     * @return factory for creating PlayerBasicInfo messages
     */
    public static MessageFactory<PlayerBasicInfo> getFactory() {
      return PlayerBasicInfoFactory.INSTANCE;
    }

    private enum PlayerBasicInfoFactory implements MessageFactory<PlayerBasicInfo> {
      INSTANCE;

      @Override
      public PlayerBasicInfo create() {
        return PlayerBasicInfo.newInstance();
      }
    }

    /**
     * Contains name constants used for serializing JSON
     */
    static class FieldNames {
      static final FieldName level = FieldName.forField("level");

      static final FieldName exp = FieldName.forField("exp");

      static final FieldName stamina = FieldName.forField("stamina");

      static final FieldName mcoin = FieldName.forField("mcoin");

      static final FieldName hcoin = FieldName.forField("hcoin");

      static final FieldName scoin = FieldName.forField("scoin");

      static final FieldName worldLevel = FieldName.forField("worldLevel", "world_level");

      static final FieldName nickname = FieldName.forField("nickname");
    }
  }
}
