diff --git a/src/generated/main/emu/lunarcore/proto/UseItemCsReqOuterClass.java b/src/generated/main/emu/lunarcore/proto/UseItemCsReqOuterClass.java new file mode 100644 index 0000000..d003502 --- /dev/null +++ b/src/generated/main/emu/lunarcore/proto/UseItemCsReqOuterClass.java @@ -0,0 +1,616 @@ +// 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; + +public final class UseItemCsReqOuterClass { + /** + * Protobuf type {@code UseItemCsReq} + */ + public static final class UseItemCsReq extends ProtoMessage implements Cloneable { + private static final long serialVersionUID = 0L; + + /** + * optional uint32 base_avatar_id = 1; + */ + private int baseAvatarId; + + /** + * optional uint32 use_item_count = 4; + */ + private int useItemCount; + + /** + * optional uint32 optional_reward_id = 6; + */ + private int optionalRewardId; + + /** + * optional uint32 use_item_id = 14; + */ + private int useItemId; + + /** + * optional .AvatarType use_avatar_type = 9; + */ + private int useAvatarType; + + private UseItemCsReq() { + } + + /** + * @return a new empty instance of {@code UseItemCsReq} + */ + public static UseItemCsReq newInstance() { + return new UseItemCsReq(); + } + + /** + * optional uint32 base_avatar_id = 1; + * @return whether the baseAvatarId field is set + */ + public boolean hasBaseAvatarId() { + return (bitField0_ & 0x00000001) != 0; + } + + /** + * optional uint32 base_avatar_id = 1; + * @return this + */ + public UseItemCsReq clearBaseAvatarId() { + bitField0_ &= ~0x00000001; + baseAvatarId = 0; + return this; + } + + /** + * optional uint32 base_avatar_id = 1; + * @return the baseAvatarId + */ + public int getBaseAvatarId() { + return baseAvatarId; + } + + /** + * optional uint32 base_avatar_id = 1; + * @param value the baseAvatarId to set + * @return this + */ + public UseItemCsReq setBaseAvatarId(final int value) { + bitField0_ |= 0x00000001; + baseAvatarId = value; + return this; + } + + /** + * optional uint32 use_item_count = 4; + * @return whether the useItemCount field is set + */ + public boolean hasUseItemCount() { + return (bitField0_ & 0x00000002) != 0; + } + + /** + * optional uint32 use_item_count = 4; + * @return this + */ + public UseItemCsReq clearUseItemCount() { + bitField0_ &= ~0x00000002; + useItemCount = 0; + return this; + } + + /** + * optional uint32 use_item_count = 4; + * @return the useItemCount + */ + public int getUseItemCount() { + return useItemCount; + } + + /** + * optional uint32 use_item_count = 4; + * @param value the useItemCount to set + * @return this + */ + public UseItemCsReq setUseItemCount(final int value) { + bitField0_ |= 0x00000002; + useItemCount = value; + return this; + } + + /** + * optional uint32 optional_reward_id = 6; + * @return whether the optionalRewardId field is set + */ + public boolean hasOptionalRewardId() { + return (bitField0_ & 0x00000004) != 0; + } + + /** + * optional uint32 optional_reward_id = 6; + * @return this + */ + public UseItemCsReq clearOptionalRewardId() { + bitField0_ &= ~0x00000004; + optionalRewardId = 0; + return this; + } + + /** + * optional uint32 optional_reward_id = 6; + * @return the optionalRewardId + */ + public int getOptionalRewardId() { + return optionalRewardId; + } + + /** + * optional uint32 optional_reward_id = 6; + * @param value the optionalRewardId to set + * @return this + */ + public UseItemCsReq setOptionalRewardId(final int value) { + bitField0_ |= 0x00000004; + optionalRewardId = value; + return this; + } + + /** + * optional uint32 use_item_id = 14; + * @return whether the useItemId field is set + */ + public boolean hasUseItemId() { + return (bitField0_ & 0x00000008) != 0; + } + + /** + * optional uint32 use_item_id = 14; + * @return this + */ + public UseItemCsReq clearUseItemId() { + bitField0_ &= ~0x00000008; + useItemId = 0; + return this; + } + + /** + * optional uint32 use_item_id = 14; + * @return the useItemId + */ + public int getUseItemId() { + return useItemId; + } + + /** + * optional uint32 use_item_id = 14; + * @param value the useItemId to set + * @return this + */ + public UseItemCsReq setUseItemId(final int value) { + bitField0_ |= 0x00000008; + useItemId = value; + return this; + } + + /** + * optional .AvatarType use_avatar_type = 9; + * @return whether the useAvatarType field is set + */ + public boolean hasUseAvatarType() { + return (bitField0_ & 0x00000010) != 0; + } + + /** + * optional .AvatarType use_avatar_type = 9; + * @return this + */ + public UseItemCsReq clearUseAvatarType() { + bitField0_ &= ~0x00000010; + useAvatarType = 0; + return this; + } + + /** + * optional .AvatarType use_avatar_type = 9; + * @return the useAvatarType + */ + public AvatarTypeOuterClass.AvatarType getUseAvatarType() { + return AvatarTypeOuterClass.AvatarType.forNumber(useAvatarType); + } + + /** + * Gets the value of the internal enum store. The result is + * equivalent to {@link UseItemCsReq#getUseAvatarType()}.getNumber(). + * + * @return numeric wire representation + */ + public int getUseAvatarTypeValue() { + return useAvatarType; + } + + /** + * Sets the value of the internal enum store. This does not + * do any validity checks, so be sure to use appropriate value + * constants from {@link AvatarTypeOuterClass.AvatarType}. Setting an invalid value + * can cause {@link UseItemCsReq#getUseAvatarType()} to return null + * + * @param value the numeric wire value to set + * @return this + */ + public UseItemCsReq setUseAvatarTypeValue(final int value) { + bitField0_ |= 0x00000010; + useAvatarType = value; + return this; + } + + /** + * optional .AvatarType use_avatar_type = 9; + * @param value the useAvatarType to set + * @return this + */ + public UseItemCsReq setUseAvatarType(final AvatarTypeOuterClass.AvatarType value) { + bitField0_ |= 0x00000010; + useAvatarType = value.getNumber(); + return this; + } + + @Override + public UseItemCsReq copyFrom(final UseItemCsReq other) { + cachedSize = other.cachedSize; + if ((bitField0_ | other.bitField0_) != 0) { + bitField0_ = other.bitField0_; + baseAvatarId = other.baseAvatarId; + useItemCount = other.useItemCount; + optionalRewardId = other.optionalRewardId; + useItemId = other.useItemId; + useAvatarType = other.useAvatarType; + } + return this; + } + + @Override + public UseItemCsReq mergeFrom(final UseItemCsReq other) { + if (other.isEmpty()) { + return this; + } + cachedSize = -1; + if (other.hasBaseAvatarId()) { + setBaseAvatarId(other.baseAvatarId); + } + if (other.hasUseItemCount()) { + setUseItemCount(other.useItemCount); + } + if (other.hasOptionalRewardId()) { + setOptionalRewardId(other.optionalRewardId); + } + if (other.hasUseItemId()) { + setUseItemId(other.useItemId); + } + if (other.hasUseAvatarType()) { + setUseAvatarTypeValue(other.useAvatarType); + } + return this; + } + + @Override + public UseItemCsReq clear() { + if (isEmpty()) { + return this; + } + cachedSize = -1; + bitField0_ = 0; + baseAvatarId = 0; + useItemCount = 0; + optionalRewardId = 0; + useItemId = 0; + useAvatarType = 0; + return this; + } + + @Override + public UseItemCsReq clearQuick() { + if (isEmpty()) { + return this; + } + cachedSize = -1; + bitField0_ = 0; + return this; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (!(o instanceof UseItemCsReq)) { + return false; + } + UseItemCsReq other = (UseItemCsReq) o; + return bitField0_ == other.bitField0_ + && (!hasBaseAvatarId() || baseAvatarId == other.baseAvatarId) + && (!hasUseItemCount() || useItemCount == other.useItemCount) + && (!hasOptionalRewardId() || optionalRewardId == other.optionalRewardId) + && (!hasUseItemId() || useItemId == other.useItemId) + && (!hasUseAvatarType() || useAvatarType == other.useAvatarType); + } + + @Override + public void writeTo(final ProtoSink output) throws IOException { + if ((bitField0_ & 0x00000001) != 0) { + output.writeRawByte((byte) 8); + output.writeUInt32NoTag(baseAvatarId); + } + if ((bitField0_ & 0x00000002) != 0) { + output.writeRawByte((byte) 32); + output.writeUInt32NoTag(useItemCount); + } + if ((bitField0_ & 0x00000004) != 0) { + output.writeRawByte((byte) 48); + output.writeUInt32NoTag(optionalRewardId); + } + if ((bitField0_ & 0x00000008) != 0) { + output.writeRawByte((byte) 112); + output.writeUInt32NoTag(useItemId); + } + if ((bitField0_ & 0x00000010) != 0) { + output.writeRawByte((byte) 72); + output.writeEnumNoTag(useAvatarType); + } + } + + @Override + protected int computeSerializedSize() { + int size = 0; + if ((bitField0_ & 0x00000001) != 0) { + size += 1 + ProtoSink.computeUInt32SizeNoTag(baseAvatarId); + } + if ((bitField0_ & 0x00000002) != 0) { + size += 1 + ProtoSink.computeUInt32SizeNoTag(useItemCount); + } + if ((bitField0_ & 0x00000004) != 0) { + size += 1 + ProtoSink.computeUInt32SizeNoTag(optionalRewardId); + } + if ((bitField0_ & 0x00000008) != 0) { + size += 1 + ProtoSink.computeUInt32SizeNoTag(useItemId); + } + if ((bitField0_ & 0x00000010) != 0) { + size += 1 + ProtoSink.computeEnumSizeNoTag(useAvatarType); + } + return size; + } + + @Override + @SuppressWarnings("fallthrough") + public UseItemCsReq mergeFrom(final ProtoSource input) throws IOException { + // Enabled Fall-Through Optimization (QuickBuffers) + int tag = input.readTag(); + while (true) { + switch (tag) { + case 8: { + // baseAvatarId + baseAvatarId = input.readUInt32(); + bitField0_ |= 0x00000001; + tag = input.readTag(); + if (tag != 32) { + break; + } + } + case 32: { + // useItemCount + useItemCount = input.readUInt32(); + bitField0_ |= 0x00000002; + tag = input.readTag(); + if (tag != 48) { + break; + } + } + case 48: { + // optionalRewardId + optionalRewardId = input.readUInt32(); + bitField0_ |= 0x00000004; + tag = input.readTag(); + if (tag != 112) { + break; + } + } + case 112: { + // useItemId + useItemId = input.readUInt32(); + bitField0_ |= 0x00000008; + tag = input.readTag(); + if (tag != 72) { + break; + } + } + case 72: { + // useAvatarType + final int value = input.readInt32(); + if (AvatarTypeOuterClass.AvatarType.forNumber(value) != null) { + useAvatarType = value; + bitField0_ |= 0x00000010; + } + 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.baseAvatarId, baseAvatarId); + } + if ((bitField0_ & 0x00000002) != 0) { + output.writeUInt32(FieldNames.useItemCount, useItemCount); + } + if ((bitField0_ & 0x00000004) != 0) { + output.writeUInt32(FieldNames.optionalRewardId, optionalRewardId); + } + if ((bitField0_ & 0x00000008) != 0) { + output.writeUInt32(FieldNames.useItemId, useItemId); + } + if ((bitField0_ & 0x00000010) != 0) { + output.writeEnum(FieldNames.useAvatarType, useAvatarType, AvatarTypeOuterClass.AvatarType.converter()); + } + output.endObject(); + } + + @Override + public UseItemCsReq mergeFrom(final JsonSource input) throws IOException { + if (!input.beginObject()) { + return this; + } + while (!input.isAtEnd()) { + switch (input.readFieldHash()) { + case 118022725: + case -1756826157: { + if (input.isAtField(FieldNames.baseAvatarId)) { + if (!input.trySkipNullValue()) { + baseAvatarId = input.readUInt32(); + bitField0_ |= 0x00000001; + } + } else { + input.skipUnknownField(); + } + break; + } + case -1104380939: + case 871430811: { + if (input.isAtField(FieldNames.useItemCount)) { + if (!input.trySkipNullValue()) { + useItemCount = input.readUInt32(); + bitField0_ |= 0x00000002; + } + } else { + input.skipUnknownField(); + } + break; + } + case -1391749078: + case -1451381236: { + if (input.isAtField(FieldNames.optionalRewardId)) { + if (!input.trySkipNullValue()) { + optionalRewardId = input.readUInt32(); + bitField0_ |= 0x00000004; + } + } else { + input.skipUnknownField(); + } + break; + } + case -815318027: + case 1396027151: { + if (input.isAtField(FieldNames.useItemId)) { + if (!input.trySkipNullValue()) { + useItemId = input.readUInt32(); + bitField0_ |= 0x00000008; + } + } else { + input.skipUnknownField(); + } + break; + } + case -1816914662: + case -1808431192: { + if (input.isAtField(FieldNames.useAvatarType)) { + if (!input.trySkipNullValue()) { + final AvatarTypeOuterClass.AvatarType value = input.readEnum(AvatarTypeOuterClass.AvatarType.converter()); + if (value != null) { + useAvatarType = value.getNumber(); + bitField0_ |= 0x00000010; + } else { + input.skipUnknownEnumValue(); + } + } + } else { + input.skipUnknownField(); + } + break; + } + default: { + input.skipUnknownField(); + break; + } + } + } + input.endObject(); + return this; + } + + @Override + public UseItemCsReq clone() { + return new UseItemCsReq().copyFrom(this); + } + + @Override + public boolean isEmpty() { + return ((bitField0_) == 0); + } + + public static UseItemCsReq parseFrom(final byte[] data) throws InvalidProtocolBufferException { + return ProtoMessage.mergeFrom(new UseItemCsReq(), data).checkInitialized(); + } + + public static UseItemCsReq parseFrom(final ProtoSource input) throws IOException { + return ProtoMessage.mergeFrom(new UseItemCsReq(), input).checkInitialized(); + } + + public static UseItemCsReq parseFrom(final JsonSource input) throws IOException { + return ProtoMessage.mergeFrom(new UseItemCsReq(), input).checkInitialized(); + } + + /** + * @return factory for creating UseItemCsReq messages + */ + public static MessageFactory getFactory() { + return UseItemCsReqFactory.INSTANCE; + } + + private enum UseItemCsReqFactory implements MessageFactory { + INSTANCE; + + @Override + public UseItemCsReq create() { + return UseItemCsReq.newInstance(); + } + } + + /** + * Contains name constants used for serializing JSON + */ + static class FieldNames { + static final FieldName baseAvatarId = FieldName.forField("baseAvatarId", "base_avatar_id"); + + static final FieldName useItemCount = FieldName.forField("useItemCount", "use_item_count"); + + static final FieldName optionalRewardId = FieldName.forField("optionalRewardId", "optional_reward_id"); + + static final FieldName useItemId = FieldName.forField("useItemId", "use_item_id"); + + static final FieldName useAvatarType = FieldName.forField("useAvatarType", "use_avatar_type"); + } + } +} diff --git a/src/generated/main/emu/lunarcore/proto/UseItemScRspOuterClass.java b/src/generated/main/emu/lunarcore/proto/UseItemScRspOuterClass.java new file mode 100644 index 0000000..97c8ab3 --- /dev/null +++ b/src/generated/main/emu/lunarcore/proto/UseItemScRspOuterClass.java @@ -0,0 +1,522 @@ +// 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; + +public final class UseItemScRspOuterClass { + /** + * Protobuf type {@code UseItemScRsp} + */ + public static final class UseItemScRsp extends ProtoMessage implements Cloneable { + private static final long serialVersionUID = 0L; + + /** + * optional uint32 use_item_id = 6; + */ + private int useItemId; + + /** + * optional uint32 use_item_count = 10; + */ + private int useItemCount; + + /** + * optional uint32 retcode = 13; + */ + private int retcode; + + /** + * optional .ItemList return_data = 9; + */ + private final ItemListOuterClass.ItemList returnData = ItemListOuterClass.ItemList.newInstance(); + + private UseItemScRsp() { + } + + /** + * @return a new empty instance of {@code UseItemScRsp} + */ + public static UseItemScRsp newInstance() { + return new UseItemScRsp(); + } + + /** + * optional uint32 use_item_id = 6; + * @return whether the useItemId field is set + */ + public boolean hasUseItemId() { + return (bitField0_ & 0x00000001) != 0; + } + + /** + * optional uint32 use_item_id = 6; + * @return this + */ + public UseItemScRsp clearUseItemId() { + bitField0_ &= ~0x00000001; + useItemId = 0; + return this; + } + + /** + * optional uint32 use_item_id = 6; + * @return the useItemId + */ + public int getUseItemId() { + return useItemId; + } + + /** + * optional uint32 use_item_id = 6; + * @param value the useItemId to set + * @return this + */ + public UseItemScRsp setUseItemId(final int value) { + bitField0_ |= 0x00000001; + useItemId = value; + return this; + } + + /** + * optional uint32 use_item_count = 10; + * @return whether the useItemCount field is set + */ + public boolean hasUseItemCount() { + return (bitField0_ & 0x00000002) != 0; + } + + /** + * optional uint32 use_item_count = 10; + * @return this + */ + public UseItemScRsp clearUseItemCount() { + bitField0_ &= ~0x00000002; + useItemCount = 0; + return this; + } + + /** + * optional uint32 use_item_count = 10; + * @return the useItemCount + */ + public int getUseItemCount() { + return useItemCount; + } + + /** + * optional uint32 use_item_count = 10; + * @param value the useItemCount to set + * @return this + */ + public UseItemScRsp setUseItemCount(final int value) { + bitField0_ |= 0x00000002; + useItemCount = value; + return this; + } + + /** + * optional uint32 retcode = 13; + * @return whether the retcode field is set + */ + public boolean hasRetcode() { + return (bitField0_ & 0x00000004) != 0; + } + + /** + * optional uint32 retcode = 13; + * @return this + */ + public UseItemScRsp clearRetcode() { + bitField0_ &= ~0x00000004; + retcode = 0; + return this; + } + + /** + * optional uint32 retcode = 13; + * @return the retcode + */ + public int getRetcode() { + return retcode; + } + + /** + * optional uint32 retcode = 13; + * @param value the retcode to set + * @return this + */ + public UseItemScRsp setRetcode(final int value) { + bitField0_ |= 0x00000004; + retcode = value; + return this; + } + + /** + * optional .ItemList return_data = 9; + * @return whether the returnData field is set + */ + public boolean hasReturnData() { + return (bitField0_ & 0x00000008) != 0; + } + + /** + * optional .ItemList return_data = 9; + * @return this + */ + public UseItemScRsp clearReturnData() { + bitField0_ &= ~0x00000008; + returnData.clear(); + return this; + } + + /** + * optional .ItemList return_data = 9; + * + * This method returns the internal storage object without modifying any has state. + * The returned object should not be modified and be treated as read-only. + * + * Use {@link #getMutableReturnData()} if you want to modify it. + * + * @return internal storage object for reading + */ + public ItemListOuterClass.ItemList getReturnData() { + return returnData; + } + + /** + * optional .ItemList return_data = 9; + * + * This method returns the internal storage object and sets the corresponding + * has state. The returned object will become part of this message and its + * contents may be modified as long as the has state is not cleared. + * + * @return internal storage object for modifications + */ + public ItemListOuterClass.ItemList getMutableReturnData() { + bitField0_ |= 0x00000008; + return returnData; + } + + /** + * optional .ItemList return_data = 9; + * @param value the returnData to set + * @return this + */ + public UseItemScRsp setReturnData(final ItemListOuterClass.ItemList value) { + bitField0_ |= 0x00000008; + returnData.copyFrom(value); + return this; + } + + @Override + public UseItemScRsp copyFrom(final UseItemScRsp other) { + cachedSize = other.cachedSize; + if ((bitField0_ | other.bitField0_) != 0) { + bitField0_ = other.bitField0_; + useItemId = other.useItemId; + useItemCount = other.useItemCount; + retcode = other.retcode; + returnData.copyFrom(other.returnData); + } + return this; + } + + @Override + public UseItemScRsp mergeFrom(final UseItemScRsp other) { + if (other.isEmpty()) { + return this; + } + cachedSize = -1; + if (other.hasUseItemId()) { + setUseItemId(other.useItemId); + } + if (other.hasUseItemCount()) { + setUseItemCount(other.useItemCount); + } + if (other.hasRetcode()) { + setRetcode(other.retcode); + } + if (other.hasReturnData()) { + getMutableReturnData().mergeFrom(other.returnData); + } + return this; + } + + @Override + public UseItemScRsp clear() { + if (isEmpty()) { + return this; + } + cachedSize = -1; + bitField0_ = 0; + useItemId = 0; + useItemCount = 0; + retcode = 0; + returnData.clear(); + return this; + } + + @Override + public UseItemScRsp clearQuick() { + if (isEmpty()) { + return this; + } + cachedSize = -1; + bitField0_ = 0; + returnData.clearQuick(); + return this; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (!(o instanceof UseItemScRsp)) { + return false; + } + UseItemScRsp other = (UseItemScRsp) o; + return bitField0_ == other.bitField0_ + && (!hasUseItemId() || useItemId == other.useItemId) + && (!hasUseItemCount() || useItemCount == other.useItemCount) + && (!hasRetcode() || retcode == other.retcode) + && (!hasReturnData() || returnData.equals(other.returnData)); + } + + @Override + public void writeTo(final ProtoSink output) throws IOException { + if ((bitField0_ & 0x00000001) != 0) { + output.writeRawByte((byte) 48); + output.writeUInt32NoTag(useItemId); + } + if ((bitField0_ & 0x00000002) != 0) { + output.writeRawByte((byte) 80); + output.writeUInt32NoTag(useItemCount); + } + if ((bitField0_ & 0x00000004) != 0) { + output.writeRawByte((byte) 104); + output.writeUInt32NoTag(retcode); + } + if ((bitField0_ & 0x00000008) != 0) { + output.writeRawByte((byte) 74); + output.writeMessageNoTag(returnData); + } + } + + @Override + protected int computeSerializedSize() { + int size = 0; + if ((bitField0_ & 0x00000001) != 0) { + size += 1 + ProtoSink.computeUInt32SizeNoTag(useItemId); + } + if ((bitField0_ & 0x00000002) != 0) { + size += 1 + ProtoSink.computeUInt32SizeNoTag(useItemCount); + } + if ((bitField0_ & 0x00000004) != 0) { + size += 1 + ProtoSink.computeUInt32SizeNoTag(retcode); + } + if ((bitField0_ & 0x00000008) != 0) { + size += 1 + ProtoSink.computeMessageSizeNoTag(returnData); + } + return size; + } + + @Override + @SuppressWarnings("fallthrough") + public UseItemScRsp mergeFrom(final ProtoSource input) throws IOException { + // Enabled Fall-Through Optimization (QuickBuffers) + int tag = input.readTag(); + while (true) { + switch (tag) { + case 48: { + // useItemId + useItemId = input.readUInt32(); + bitField0_ |= 0x00000001; + tag = input.readTag(); + if (tag != 80) { + break; + } + } + case 80: { + // useItemCount + useItemCount = input.readUInt32(); + bitField0_ |= 0x00000002; + tag = input.readTag(); + if (tag != 104) { + break; + } + } + case 104: { + // retcode + retcode = input.readUInt32(); + bitField0_ |= 0x00000004; + tag = input.readTag(); + if (tag != 74) { + break; + } + } + case 74: { + // returnData + input.readMessage(returnData); + bitField0_ |= 0x00000008; + 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.useItemId, useItemId); + } + if ((bitField0_ & 0x00000002) != 0) { + output.writeUInt32(FieldNames.useItemCount, useItemCount); + } + if ((bitField0_ & 0x00000004) != 0) { + output.writeUInt32(FieldNames.retcode, retcode); + } + if ((bitField0_ & 0x00000008) != 0) { + output.writeMessage(FieldNames.returnData, returnData); + } + output.endObject(); + } + + @Override + public UseItemScRsp mergeFrom(final JsonSource input) throws IOException { + if (!input.beginObject()) { + return this; + } + while (!input.isAtEnd()) { + switch (input.readFieldHash()) { + case -815318027: + case 1396027151: { + if (input.isAtField(FieldNames.useItemId)) { + if (!input.trySkipNullValue()) { + useItemId = input.readUInt32(); + bitField0_ |= 0x00000001; + } + } else { + input.skipUnknownField(); + } + break; + } + case -1104380939: + case 871430811: { + if (input.isAtField(FieldNames.useItemCount)) { + if (!input.trySkipNullValue()) { + useItemCount = input.readUInt32(); + bitField0_ |= 0x00000002; + } + } else { + input.skipUnknownField(); + } + break; + } + case 1097936398: { + if (input.isAtField(FieldNames.retcode)) { + if (!input.trySkipNullValue()) { + retcode = input.readUInt32(); + bitField0_ |= 0x00000004; + } + } else { + input.skipUnknownField(); + } + break; + } + case 1336707322: + case -1486739111: { + if (input.isAtField(FieldNames.returnData)) { + if (!input.trySkipNullValue()) { + input.readMessage(returnData); + bitField0_ |= 0x00000008; + } + } else { + input.skipUnknownField(); + } + break; + } + default: { + input.skipUnknownField(); + break; + } + } + } + input.endObject(); + return this; + } + + @Override + public UseItemScRsp clone() { + return new UseItemScRsp().copyFrom(this); + } + + @Override + public boolean isEmpty() { + return ((bitField0_) == 0); + } + + public static UseItemScRsp parseFrom(final byte[] data) throws InvalidProtocolBufferException { + return ProtoMessage.mergeFrom(new UseItemScRsp(), data).checkInitialized(); + } + + public static UseItemScRsp parseFrom(final ProtoSource input) throws IOException { + return ProtoMessage.mergeFrom(new UseItemScRsp(), input).checkInitialized(); + } + + public static UseItemScRsp parseFrom(final JsonSource input) throws IOException { + return ProtoMessage.mergeFrom(new UseItemScRsp(), input).checkInitialized(); + } + + /** + * @return factory for creating UseItemScRsp messages + */ + public static MessageFactory getFactory() { + return UseItemScRspFactory.INSTANCE; + } + + private enum UseItemScRspFactory implements MessageFactory { + INSTANCE; + + @Override + public UseItemScRsp create() { + return UseItemScRsp.newInstance(); + } + } + + /** + * Contains name constants used for serializing JSON + */ + static class FieldNames { + static final FieldName useItemId = FieldName.forField("useItemId", "use_item_id"); + + static final FieldName useItemCount = FieldName.forField("useItemCount", "use_item_count"); + + static final FieldName retcode = FieldName.forField("retcode"); + + static final FieldName returnData = FieldName.forField("returnData", "return_data"); + } + } +} diff --git a/src/main/java/emu/lunarcore/game/inventory/Inventory.java b/src/main/java/emu/lunarcore/game/inventory/Inventory.java index f793cff..c6a7f31 100644 --- a/src/main/java/emu/lunarcore/game/inventory/Inventory.java +++ b/src/main/java/emu/lunarcore/game/inventory/Inventory.java @@ -425,6 +425,27 @@ public class Inventory extends BasePlayerManager { public boolean verifyHcoin(int cost) { return this.getPlayer().getHcoin() >= cost; } + + // Use item + + public List useItem(int itemId, int count, int baseAvatarId) { + // Verify that the player actually has the item + GameItem useItem = this.getMaterialByItemId(itemId); + if (useItem == null || useItem.getCount() < count) { + return null; + } + + // Remove item from inventory + this.removeItem(useItem, count); + + // Use the item now + // TODO write better handler for this later + if (itemId == 201) { + this.getPlayer().addStamina(60 * count); + } + + return null; + } // Equips diff --git a/src/main/java/emu/lunarcore/game/player/Player.java b/src/main/java/emu/lunarcore/game/player/Player.java index f60d5c3..68b4a7c 100644 --- a/src/main/java/emu/lunarcore/game/player/Player.java +++ b/src/main/java/emu/lunarcore/game/player/Player.java @@ -360,7 +360,7 @@ public class Player { } public void addStamina(int amount) { - this.stamina = Math.min(this.stamina + amount, GameConstants.MAX_STAMINA); + this.stamina += amount; this.sendPacket(new PacketStaminaInfoScNotify(this)); } diff --git a/src/main/java/emu/lunarcore/server/packet/recv/HandlerUseItemCsReq.java b/src/main/java/emu/lunarcore/server/packet/recv/HandlerUseItemCsReq.java new file mode 100644 index 0000000..25fd27b --- /dev/null +++ b/src/main/java/emu/lunarcore/server/packet/recv/HandlerUseItemCsReq.java @@ -0,0 +1,24 @@ +package emu.lunarcore.server.packet.recv; + +import java.util.List; + +import emu.lunarcore.game.inventory.GameItem; +import emu.lunarcore.proto.UseItemCsReqOuterClass.UseItemCsReq; +import emu.lunarcore.server.game.GameSession; +import emu.lunarcore.server.packet.CmdId; +import emu.lunarcore.server.packet.Opcodes; +import emu.lunarcore.server.packet.PacketHandler; +import emu.lunarcore.server.packet.send.PacketUseItemScRsp; + +@Opcodes(CmdId.UseItemCsReq) +public class HandlerUseItemCsReq extends PacketHandler { + + @Override + public void handle(GameSession session, byte[] header, byte[] data) throws Exception { + var req = UseItemCsReq.parseFrom(data); + + List returnItems = session.getPlayer().getInventory().useItem(req.getUseItemId(), req.getUseItemCount(), req.getBaseAvatarId()); + session.send(new PacketUseItemScRsp(req.getUseItemId(), req.getUseItemCount(), returnItems)); + } + +} diff --git a/src/main/java/emu/lunarcore/server/packet/send/PacketUseItemScRsp.java b/src/main/java/emu/lunarcore/server/packet/send/PacketUseItemScRsp.java new file mode 100644 index 0000000..ccf6708 --- /dev/null +++ b/src/main/java/emu/lunarcore/server/packet/send/PacketUseItemScRsp.java @@ -0,0 +1,31 @@ +package emu.lunarcore.server.packet.send; + +import java.util.List; + +import emu.lunarcore.game.inventory.GameItem; +import emu.lunarcore.proto.ItemListOuterClass.ItemList; +import emu.lunarcore.proto.UseItemScRspOuterClass.UseItemScRsp; +import emu.lunarcore.server.packet.BasePacket; +import emu.lunarcore.server.packet.CmdId; + +public class PacketUseItemScRsp extends BasePacket { + + public PacketUseItemScRsp(int itemId, int itemCount, List returnItems) { + super(CmdId.UseItemScRsp); + + var itemList = ItemList.newInstance(); + + if (returnItems != null && returnItems.size() > 0) { + for (var item : returnItems) { + itemList.addItemList(item.toProto()); + } + } + + var data = UseItemScRsp.newInstance() + .setUseItemId(itemId) + .setUseItemCount(itemCount) + .setReturnData(itemList); + + this.setData(data); + } +}