From e6647b04f82aa76ab6853706ec8cfac6f4a9b615 Mon Sep 17 00:00:00 2001 From: Hiro Date: Thu, 30 Nov 2023 09:23:54 +0200 Subject: [PATCH] basic GetQuestData --- .../proto/GetQuestDataCsReqOuterClass.java | 174 ++++ .../proto/GetQuestDataScRspOuterClass.java | 455 ++++++++++ .../emu/lunarcore/proto/QuestOuterClass.java | 809 ++++++++++++++++++ .../java/emu/lunarcore/data/GameData.java | 12 + .../emu/lunarcore/data/excel/QuestExcel.java | 17 + .../lunarcore/server/packet/CmdIdUtils.java | 3 +- .../packet/recv/HandlerGetQuestDataCsReq.java | 16 + .../packet/send/PacketGetQuestDataScRsp.java | 32 + 8 files changed, 1517 insertions(+), 1 deletion(-) create mode 100644 src/generated/main/emu/lunarcore/proto/GetQuestDataCsReqOuterClass.java create mode 100644 src/generated/main/emu/lunarcore/proto/GetQuestDataScRspOuterClass.java create mode 100644 src/generated/main/emu/lunarcore/proto/QuestOuterClass.java create mode 100644 src/main/java/emu/lunarcore/data/excel/QuestExcel.java create mode 100644 src/main/java/emu/lunarcore/server/packet/recv/HandlerGetQuestDataCsReq.java create mode 100644 src/main/java/emu/lunarcore/server/packet/send/PacketGetQuestDataScRsp.java diff --git a/src/generated/main/emu/lunarcore/proto/GetQuestDataCsReqOuterClass.java b/src/generated/main/emu/lunarcore/proto/GetQuestDataCsReqOuterClass.java new file mode 100644 index 0000000..de1eec4 --- /dev/null +++ b/src/generated/main/emu/lunarcore/proto/GetQuestDataCsReqOuterClass.java @@ -0,0 +1,174 @@ +// Code generated by protocol buffer compiler. Do not edit! +package emu.lunarcore.proto; + +import java.io.IOException; +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 GetQuestDataCsReqOuterClass { + /** + * Protobuf type {@code GetQuestDataCsReq} + */ + public static final class GetQuestDataCsReq extends ProtoMessage implements Cloneable { + private static final long serialVersionUID = 0L; + + private GetQuestDataCsReq() { + } + + /** + * @return a new empty instance of {@code GetQuestDataCsReq} + */ + public static GetQuestDataCsReq newInstance() { + return new GetQuestDataCsReq(); + } + + @Override + public GetQuestDataCsReq copyFrom(final GetQuestDataCsReq other) { + cachedSize = other.cachedSize; + return this; + } + + @Override + public GetQuestDataCsReq mergeFrom(final GetQuestDataCsReq other) { + if (other.isEmpty()) { + return this; + } + cachedSize = -1; + return this; + } + + @Override + public GetQuestDataCsReq clear() { + if (isEmpty()) { + return this; + } + cachedSize = -1; + return this; + } + + @Override + public GetQuestDataCsReq clearQuick() { + if (isEmpty()) { + return this; + } + cachedSize = -1; + return this; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (!(o instanceof GetQuestDataCsReq)) { + return false; + } + GetQuestDataCsReq other = (GetQuestDataCsReq) o; + return true; + } + + @Override + public void writeTo(final ProtoSink output) throws IOException { + } + + @Override + protected int computeSerializedSize() { + int size = 0; + return size; + } + + @Override + @SuppressWarnings("fallthrough") + public GetQuestDataCsReq mergeFrom(final ProtoSource input) throws IOException { + // Enabled Fall-Through Optimization (QuickBuffers) + int tag = input.readTag(); + while (true) { + switch (tag) { + 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(); + output.endObject(); + } + + @Override + public GetQuestDataCsReq mergeFrom(final JsonSource input) throws IOException { + if (!input.beginObject()) { + return this; + } + while (!input.isAtEnd()) { + switch (input.readFieldHash()) { + default: { + input.skipUnknownField(); + break; + } + } + } + input.endObject(); + return this; + } + + @Override + public GetQuestDataCsReq clone() { + return new GetQuestDataCsReq().copyFrom(this); + } + + @Override + public boolean isEmpty() { + return ((bitField0_) == 0); + } + + public static GetQuestDataCsReq parseFrom(final byte[] data) throws + InvalidProtocolBufferException { + return ProtoMessage.mergeFrom(new GetQuestDataCsReq(), data).checkInitialized(); + } + + public static GetQuestDataCsReq parseFrom(final ProtoSource input) throws IOException { + return ProtoMessage.mergeFrom(new GetQuestDataCsReq(), input).checkInitialized(); + } + + public static GetQuestDataCsReq parseFrom(final JsonSource input) throws IOException { + return ProtoMessage.mergeFrom(new GetQuestDataCsReq(), input).checkInitialized(); + } + + /** + * @return factory for creating GetQuestDataCsReq messages + */ + public static MessageFactory getFactory() { + return GetQuestDataCsReqFactory.INSTANCE; + } + + private enum GetQuestDataCsReqFactory implements MessageFactory { + INSTANCE; + + @Override + public GetQuestDataCsReq create() { + return GetQuestDataCsReq.newInstance(); + } + } + + /** + * Contains name constants used for serializing JSON + */ + static class FieldNames { + } + } +} diff --git a/src/generated/main/emu/lunarcore/proto/GetQuestDataScRspOuterClass.java b/src/generated/main/emu/lunarcore/proto/GetQuestDataScRspOuterClass.java new file mode 100644 index 0000000..45e4b68 --- /dev/null +++ b/src/generated/main/emu/lunarcore/proto/GetQuestDataScRspOuterClass.java @@ -0,0 +1,455 @@ +// 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.RepeatedMessage; + +public final class GetQuestDataScRspOuterClass { + /** + * Protobuf type {@code GetQuestDataScRsp} + */ + public static final class GetQuestDataScRsp extends ProtoMessage implements Cloneable { + private static final long serialVersionUID = 0L; + + /** + * optional uint32 total_achievement_exp = 1; + */ + private int totalAchievementExp; + + /** + * optional uint32 retcode = 8; + */ + private int retcode; + + /** + * repeated .Quest quest_list = 10; + */ + private final RepeatedMessage questList = RepeatedMessage.newEmptyInstance(QuestOuterClass.Quest.getFactory()); + + private GetQuestDataScRsp() { + } + + /** + * @return a new empty instance of {@code GetQuestDataScRsp} + */ + public static GetQuestDataScRsp newInstance() { + return new GetQuestDataScRsp(); + } + + /** + * optional uint32 total_achievement_exp = 1; + * @return whether the totalAchievementExp field is set + */ + public boolean hasTotalAchievementExp() { + return (bitField0_ & 0x00000001) != 0; + } + + /** + * optional uint32 total_achievement_exp = 1; + * @return this + */ + public GetQuestDataScRsp clearTotalAchievementExp() { + bitField0_ &= ~0x00000001; + totalAchievementExp = 0; + return this; + } + + /** + * optional uint32 total_achievement_exp = 1; + * @return the totalAchievementExp + */ + public int getTotalAchievementExp() { + return totalAchievementExp; + } + + /** + * optional uint32 total_achievement_exp = 1; + * @param value the totalAchievementExp to set + * @return this + */ + public GetQuestDataScRsp setTotalAchievementExp(final int value) { + bitField0_ |= 0x00000001; + totalAchievementExp = value; + return this; + } + + /** + * optional uint32 retcode = 8; + * @return whether the retcode field is set + */ + public boolean hasRetcode() { + return (bitField0_ & 0x00000002) != 0; + } + + /** + * optional uint32 retcode = 8; + * @return this + */ + public GetQuestDataScRsp clearRetcode() { + bitField0_ &= ~0x00000002; + retcode = 0; + return this; + } + + /** + * optional uint32 retcode = 8; + * @return the retcode + */ + public int getRetcode() { + return retcode; + } + + /** + * optional uint32 retcode = 8; + * @param value the retcode to set + * @return this + */ + public GetQuestDataScRsp setRetcode(final int value) { + bitField0_ |= 0x00000002; + retcode = value; + return this; + } + + /** + * repeated .Quest quest_list = 10; + * @return whether the questList field is set + */ + public boolean hasQuestList() { + return (bitField0_ & 0x00000004) != 0; + } + + /** + * repeated .Quest quest_list = 10; + * @return this + */ + public GetQuestDataScRsp clearQuestList() { + bitField0_ &= ~0x00000004; + questList.clear(); + return this; + } + + /** + * repeated .Quest quest_list = 10; + * + * 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 #getMutableQuestList()} if you want to modify it. + * + * @return internal storage object for reading + */ + public RepeatedMessage getQuestList() { + return questList; + } + + /** + * repeated .Quest quest_list = 10; + * + * 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 RepeatedMessage getMutableQuestList() { + bitField0_ |= 0x00000004; + return questList; + } + + /** + * repeated .Quest quest_list = 10; + * @param value the questList to add + * @return this + */ + public GetQuestDataScRsp addQuestList(final QuestOuterClass.Quest value) { + bitField0_ |= 0x00000004; + questList.add(value); + return this; + } + + /** + * repeated .Quest quest_list = 10; + * @param values the questList to add + * @return this + */ + public GetQuestDataScRsp addAllQuestList(final QuestOuterClass.Quest... values) { + bitField0_ |= 0x00000004; + questList.addAll(values); + return this; + } + + @Override + public GetQuestDataScRsp copyFrom(final GetQuestDataScRsp other) { + cachedSize = other.cachedSize; + if ((bitField0_ | other.bitField0_) != 0) { + bitField0_ = other.bitField0_; + totalAchievementExp = other.totalAchievementExp; + retcode = other.retcode; + questList.copyFrom(other.questList); + } + return this; + } + + @Override + public GetQuestDataScRsp mergeFrom(final GetQuestDataScRsp other) { + if (other.isEmpty()) { + return this; + } + cachedSize = -1; + if (other.hasTotalAchievementExp()) { + setTotalAchievementExp(other.totalAchievementExp); + } + if (other.hasRetcode()) { + setRetcode(other.retcode); + } + if (other.hasQuestList()) { + getMutableQuestList().addAll(other.questList); + } + return this; + } + + @Override + public GetQuestDataScRsp clear() { + if (isEmpty()) { + return this; + } + cachedSize = -1; + bitField0_ = 0; + totalAchievementExp = 0; + retcode = 0; + questList.clear(); + return this; + } + + @Override + public GetQuestDataScRsp clearQuick() { + if (isEmpty()) { + return this; + } + cachedSize = -1; + bitField0_ = 0; + questList.clearQuick(); + return this; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (!(o instanceof GetQuestDataScRsp)) { + return false; + } + GetQuestDataScRsp other = (GetQuestDataScRsp) o; + return bitField0_ == other.bitField0_ + && (!hasTotalAchievementExp() || totalAchievementExp == other.totalAchievementExp) + && (!hasRetcode() || retcode == other.retcode) + && (!hasQuestList() || questList.equals(other.questList)); + } + + @Override + public void writeTo(final ProtoSink output) throws IOException { + if ((bitField0_ & 0x00000001) != 0) { + output.writeRawByte((byte) 8); + output.writeUInt32NoTag(totalAchievementExp); + } + if ((bitField0_ & 0x00000002) != 0) { + output.writeRawByte((byte) 64); + output.writeUInt32NoTag(retcode); + } + if ((bitField0_ & 0x00000004) != 0) { + for (int i = 0; i < questList.length(); i++) { + output.writeRawByte((byte) 82); + output.writeMessageNoTag(questList.get(i)); + } + } + } + + @Override + protected int computeSerializedSize() { + int size = 0; + if ((bitField0_ & 0x00000001) != 0) { + size += 1 + ProtoSink.computeUInt32SizeNoTag(totalAchievementExp); + } + if ((bitField0_ & 0x00000002) != 0) { + size += 1 + ProtoSink.computeUInt32SizeNoTag(retcode); + } + if ((bitField0_ & 0x00000004) != 0) { + size += (1 * questList.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(questList); + } + return size; + } + + @Override + @SuppressWarnings("fallthrough") + public GetQuestDataScRsp mergeFrom(final ProtoSource input) throws IOException { + // Enabled Fall-Through Optimization (QuickBuffers) + int tag = input.readTag(); + while (true) { + switch (tag) { + case 8: { + // totalAchievementExp + totalAchievementExp = input.readUInt32(); + bitField0_ |= 0x00000001; + tag = input.readTag(); + if (tag != 64) { + break; + } + } + case 64: { + // retcode + retcode = input.readUInt32(); + bitField0_ |= 0x00000002; + tag = input.readTag(); + if (tag != 82) { + break; + } + } + case 82: { + // questList + tag = input.readRepeatedMessage(questList, tag); + bitField0_ |= 0x00000004; + 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.totalAchievementExp, totalAchievementExp); + } + if ((bitField0_ & 0x00000002) != 0) { + output.writeUInt32(FieldNames.retcode, retcode); + } + if ((bitField0_ & 0x00000004) != 0) { + output.writeRepeatedMessage(FieldNames.questList, questList); + } + output.endObject(); + } + + @Override + public GetQuestDataScRsp mergeFrom(final JsonSource input) throws IOException { + if (!input.beginObject()) { + return this; + } + while (!input.isAtEnd()) { + switch (input.readFieldHash()) { + case 255336658: + case -1295039982: { + if (input.isAtField(FieldNames.totalAchievementExp)) { + if (!input.trySkipNullValue()) { + totalAchievementExp = input.readUInt32(); + bitField0_ |= 0x00000001; + } + } else { + input.skipUnknownField(); + } + break; + } + case 1097936398: { + if (input.isAtField(FieldNames.retcode)) { + if (!input.trySkipNullValue()) { + retcode = input.readUInt32(); + bitField0_ |= 0x00000002; + } + } else { + input.skipUnknownField(); + } + break; + } + case -1783104352: + case 575966683: { + if (input.isAtField(FieldNames.questList)) { + if (!input.trySkipNullValue()) { + input.readRepeatedMessage(questList); + bitField0_ |= 0x00000004; + } + } else { + input.skipUnknownField(); + } + break; + } + default: { + input.skipUnknownField(); + break; + } + } + } + input.endObject(); + return this; + } + + @Override + public GetQuestDataScRsp clone() { + return new GetQuestDataScRsp().copyFrom(this); + } + + @Override + public boolean isEmpty() { + return ((bitField0_) == 0); + } + + public static GetQuestDataScRsp parseFrom(final byte[] data) throws + InvalidProtocolBufferException { + return ProtoMessage.mergeFrom(new GetQuestDataScRsp(), data).checkInitialized(); + } + + public static GetQuestDataScRsp parseFrom(final ProtoSource input) throws IOException { + return ProtoMessage.mergeFrom(new GetQuestDataScRsp(), input).checkInitialized(); + } + + public static GetQuestDataScRsp parseFrom(final JsonSource input) throws IOException { + return ProtoMessage.mergeFrom(new GetQuestDataScRsp(), input).checkInitialized(); + } + + /** + * @return factory for creating GetQuestDataScRsp messages + */ + public static MessageFactory getFactory() { + return GetQuestDataScRspFactory.INSTANCE; + } + + private enum GetQuestDataScRspFactory implements MessageFactory { + INSTANCE; + + @Override + public GetQuestDataScRsp create() { + return GetQuestDataScRsp.newInstance(); + } + } + + /** + * Contains name constants used for serializing JSON + */ + static class FieldNames { + static final FieldName totalAchievementExp = FieldName.forField("totalAchievementExp", "total_achievement_exp"); + + static final FieldName retcode = FieldName.forField("retcode"); + + static final FieldName questList = FieldName.forField("questList", "quest_list"); + } + } +} diff --git a/src/generated/main/emu/lunarcore/proto/QuestOuterClass.java b/src/generated/main/emu/lunarcore/proto/QuestOuterClass.java new file mode 100644 index 0000000..e0de460 --- /dev/null +++ b/src/generated/main/emu/lunarcore/proto/QuestOuterClass.java @@ -0,0 +1,809 @@ +// 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.ProtoEnum; +import us.hebi.quickbuf.ProtoMessage; +import us.hebi.quickbuf.ProtoSink; +import us.hebi.quickbuf.ProtoSource; +import us.hebi.quickbuf.ProtoUtil; +import us.hebi.quickbuf.RepeatedInt; + +public final class QuestOuterClass { + /** + * Protobuf type {@code Quest} + */ + public static final class Quest extends ProtoMessage implements Cloneable { + private static final long serialVersionUID = 0L; + + /** + * optional int64 finish_time = 12; + */ + private long finishTime; + + /** + * optional uint32 progress = 8; + */ + private int progress; + + /** + * optional uint32 id = 11; + */ + private int id; + + /** + * optional .Quest.QuestStatus status = 13; + */ + private int status; + + /** + * repeated uint32 taken_achievement_level_list = 3; + */ + private final RepeatedInt takenAchievementLevelList = RepeatedInt.newEmptyInstance(); + + private Quest() { + } + + /** + * @return a new empty instance of {@code Quest} + */ + public static Quest newInstance() { + return new Quest(); + } + + /** + * optional int64 finish_time = 12; + * @return whether the finishTime field is set + */ + public boolean hasFinishTime() { + return (bitField0_ & 0x00000001) != 0; + } + + /** + * optional int64 finish_time = 12; + * @return this + */ + public Quest clearFinishTime() { + bitField0_ &= ~0x00000001; + finishTime = 0L; + return this; + } + + /** + * optional int64 finish_time = 12; + * @return the finishTime + */ + public long getFinishTime() { + return finishTime; + } + + /** + * optional int64 finish_time = 12; + * @param value the finishTime to set + * @return this + */ + public Quest setFinishTime(final long value) { + bitField0_ |= 0x00000001; + finishTime = value; + return this; + } + + /** + * optional uint32 progress = 8; + * @return whether the progress field is set + */ + public boolean hasProgress() { + return (bitField0_ & 0x00000002) != 0; + } + + /** + * optional uint32 progress = 8; + * @return this + */ + public Quest clearProgress() { + bitField0_ &= ~0x00000002; + progress = 0; + return this; + } + + /** + * optional uint32 progress = 8; + * @return the progress + */ + public int getProgress() { + return progress; + } + + /** + * optional uint32 progress = 8; + * @param value the progress to set + * @return this + */ + public Quest setProgress(final int value) { + bitField0_ |= 0x00000002; + progress = value; + return this; + } + + /** + * optional uint32 id = 11; + * @return whether the id field is set + */ + public boolean hasId() { + return (bitField0_ & 0x00000004) != 0; + } + + /** + * optional uint32 id = 11; + * @return this + */ + public Quest clearId() { + bitField0_ &= ~0x00000004; + id = 0; + return this; + } + + /** + * optional uint32 id = 11; + * @return the id + */ + public int getId() { + return id; + } + + /** + * optional uint32 id = 11; + * @param value the id to set + * @return this + */ + public Quest setId(final int value) { + bitField0_ |= 0x00000004; + id = value; + return this; + } + + /** + * optional .Quest.QuestStatus status = 13; + * @return whether the status field is set + */ + public boolean hasStatus() { + return (bitField0_ & 0x00000008) != 0; + } + + /** + * optional .Quest.QuestStatus status = 13; + * @return this + */ + public Quest clearStatus() { + bitField0_ &= ~0x00000008; + status = 0; + return this; + } + + /** + * optional .Quest.QuestStatus status = 13; + * @return the status + */ + public QuestStatus getStatus() { + return QuestStatus.forNumber(status); + } + + /** + * Gets the value of the internal enum store. The result is + * equivalent to {@link Quest#getStatus()}.getNumber(). + * + * @return numeric wire representation + */ + public int getStatusValue() { + return status; + } + + /** + * 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 QuestStatus}. Setting an invalid value + * can cause {@link Quest#getStatus()} to return null + * + * @param value the numeric wire value to set + * @return this + */ + public Quest setStatusValue(final int value) { + bitField0_ |= 0x00000008; + status = value; + return this; + } + + /** + * optional .Quest.QuestStatus status = 13; + * @param value the status to set + * @return this + */ + public Quest setStatus(final QuestStatus value) { + bitField0_ |= 0x00000008; + status = value.getNumber(); + return this; + } + + /** + * repeated uint32 taken_achievement_level_list = 3; + * @return whether the takenAchievementLevelList field is set + */ + public boolean hasTakenAchievementLevelList() { + return (bitField0_ & 0x00000010) != 0; + } + + /** + * repeated uint32 taken_achievement_level_list = 3; + * @return this + */ + public Quest clearTakenAchievementLevelList() { + bitField0_ &= ~0x00000010; + takenAchievementLevelList.clear(); + return this; + } + + /** + * repeated uint32 taken_achievement_level_list = 3; + * + * 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 #getMutableTakenAchievementLevelList()} if you want to modify it. + * + * @return internal storage object for reading + */ + public RepeatedInt getTakenAchievementLevelList() { + return takenAchievementLevelList; + } + + /** + * repeated uint32 taken_achievement_level_list = 3; + * + * 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 RepeatedInt getMutableTakenAchievementLevelList() { + bitField0_ |= 0x00000010; + return takenAchievementLevelList; + } + + /** + * repeated uint32 taken_achievement_level_list = 3; + * @param value the takenAchievementLevelList to add + * @return this + */ + public Quest addTakenAchievementLevelList(final int value) { + bitField0_ |= 0x00000010; + takenAchievementLevelList.add(value); + return this; + } + + /** + * repeated uint32 taken_achievement_level_list = 3; + * @param values the takenAchievementLevelList to add + * @return this + */ + public Quest addAllTakenAchievementLevelList(final int... values) { + bitField0_ |= 0x00000010; + takenAchievementLevelList.addAll(values); + return this; + } + + @Override + public Quest copyFrom(final Quest other) { + cachedSize = other.cachedSize; + if ((bitField0_ | other.bitField0_) != 0) { + bitField0_ = other.bitField0_; + finishTime = other.finishTime; + progress = other.progress; + id = other.id; + status = other.status; + takenAchievementLevelList.copyFrom(other.takenAchievementLevelList); + } + return this; + } + + @Override + public Quest mergeFrom(final Quest other) { + if (other.isEmpty()) { + return this; + } + cachedSize = -1; + if (other.hasFinishTime()) { + setFinishTime(other.finishTime); + } + if (other.hasProgress()) { + setProgress(other.progress); + } + if (other.hasId()) { + setId(other.id); + } + if (other.hasStatus()) { + setStatusValue(other.status); + } + if (other.hasTakenAchievementLevelList()) { + getMutableTakenAchievementLevelList().addAll(other.takenAchievementLevelList); + } + return this; + } + + @Override + public Quest clear() { + if (isEmpty()) { + return this; + } + cachedSize = -1; + bitField0_ = 0; + finishTime = 0L; + progress = 0; + id = 0; + status = 0; + takenAchievementLevelList.clear(); + return this; + } + + @Override + public Quest clearQuick() { + if (isEmpty()) { + return this; + } + cachedSize = -1; + bitField0_ = 0; + takenAchievementLevelList.clear(); + return this; + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (!(o instanceof Quest)) { + return false; + } + Quest other = (Quest) o; + return bitField0_ == other.bitField0_ + && (!hasFinishTime() || finishTime == other.finishTime) + && (!hasProgress() || progress == other.progress) + && (!hasId() || id == other.id) + && (!hasStatus() || status == other.status) + && (!hasTakenAchievementLevelList() || takenAchievementLevelList.equals(other.takenAchievementLevelList)); + } + + @Override + public void writeTo(final ProtoSink output) throws IOException { + if ((bitField0_ & 0x00000001) != 0) { + output.writeRawByte((byte) 96); + output.writeInt64NoTag(finishTime); + } + if ((bitField0_ & 0x00000002) != 0) { + output.writeRawByte((byte) 64); + output.writeUInt32NoTag(progress); + } + if ((bitField0_ & 0x00000004) != 0) { + output.writeRawByte((byte) 88); + output.writeUInt32NoTag(id); + } + if ((bitField0_ & 0x00000008) != 0) { + output.writeRawByte((byte) 104); + output.writeEnumNoTag(status); + } + if ((bitField0_ & 0x00000010) != 0) { + for (int i = 0; i < takenAchievementLevelList.length(); i++) { + output.writeRawByte((byte) 24); + output.writeUInt32NoTag(takenAchievementLevelList.array()[i]); + } + } + } + + @Override + protected int computeSerializedSize() { + int size = 0; + if ((bitField0_ & 0x00000001) != 0) { + size += 1 + ProtoSink.computeInt64SizeNoTag(finishTime); + } + if ((bitField0_ & 0x00000002) != 0) { + size += 1 + ProtoSink.computeUInt32SizeNoTag(progress); + } + if ((bitField0_ & 0x00000004) != 0) { + size += 1 + ProtoSink.computeUInt32SizeNoTag(id); + } + if ((bitField0_ & 0x00000008) != 0) { + size += 1 + ProtoSink.computeEnumSizeNoTag(status); + } + if ((bitField0_ & 0x00000010) != 0) { + size += (1 * takenAchievementLevelList.length()) + ProtoSink.computeRepeatedUInt32SizeNoTag(takenAchievementLevelList); + } + return size; + } + + @Override + @SuppressWarnings("fallthrough") + public Quest mergeFrom(final ProtoSource input) throws IOException { + // Enabled Fall-Through Optimization (QuickBuffers) + int tag = input.readTag(); + while (true) { + switch (tag) { + case 96: { + // finishTime + finishTime = input.readInt64(); + bitField0_ |= 0x00000001; + tag = input.readTag(); + if (tag != 64) { + break; + } + } + case 64: { + // progress + progress = input.readUInt32(); + bitField0_ |= 0x00000002; + tag = input.readTag(); + if (tag != 88) { + break; + } + } + case 88: { + // id + id = input.readUInt32(); + bitField0_ |= 0x00000004; + tag = input.readTag(); + if (tag != 104) { + break; + } + } + case 104: { + // status + final int value = input.readInt32(); + if (QuestStatus.forNumber(value) != null) { + status = value; + bitField0_ |= 0x00000008; + } + tag = input.readTag(); + if (tag != 26) { + break; + } + } + case 26: { + // takenAchievementLevelList [packed=true] + input.readPackedUInt32(takenAchievementLevelList, tag); + bitField0_ |= 0x00000010; + tag = input.readTag(); + if (tag != 0) { + break; + } + } + case 0: { + return this; + } + default: { + if (!input.skipField(tag)) { + return this; + } + tag = input.readTag(); + break; + } + case 24: { + // takenAchievementLevelList [packed=false] + tag = input.readRepeatedUInt32(takenAchievementLevelList, tag); + bitField0_ |= 0x00000010; + break; + } + } + } + } + + @Override + public void writeTo(final JsonSink output) throws IOException { + output.beginObject(); + if ((bitField0_ & 0x00000001) != 0) { + output.writeInt64(FieldNames.finishTime, finishTime); + } + if ((bitField0_ & 0x00000002) != 0) { + output.writeUInt32(FieldNames.progress, progress); + } + if ((bitField0_ & 0x00000004) != 0) { + output.writeUInt32(FieldNames.id, id); + } + if ((bitField0_ & 0x00000008) != 0) { + output.writeEnum(FieldNames.status, status, QuestStatus.converter()); + } + if ((bitField0_ & 0x00000010) != 0) { + output.writeRepeatedUInt32(FieldNames.takenAchievementLevelList, takenAchievementLevelList); + } + output.endObject(); + } + + @Override + public Quest mergeFrom(final JsonSource input) throws IOException { + if (!input.beginObject()) { + return this; + } + while (!input.isAtEnd()) { + switch (input.readFieldHash()) { + case 1151521280: + case 1347904249: { + if (input.isAtField(FieldNames.finishTime)) { + if (!input.trySkipNullValue()) { + finishTime = input.readInt64(); + bitField0_ |= 0x00000001; + } + } else { + input.skipUnknownField(); + } + break; + } + case -1001078227: { + if (input.isAtField(FieldNames.progress)) { + if (!input.trySkipNullValue()) { + progress = input.readUInt32(); + bitField0_ |= 0x00000002; + } + } else { + input.skipUnknownField(); + } + break; + } + case 3355: { + if (input.isAtField(FieldNames.id)) { + if (!input.trySkipNullValue()) { + id = input.readUInt32(); + bitField0_ |= 0x00000004; + } + } else { + input.skipUnknownField(); + } + break; + } + case -892481550: { + if (input.isAtField(FieldNames.status)) { + if (!input.trySkipNullValue()) { + final QuestStatus value = input.readEnum(QuestStatus.converter()); + if (value != null) { + status = value.getNumber(); + bitField0_ |= 0x00000008; + } else { + input.skipUnknownEnumValue(); + } + } + } else { + input.skipUnknownField(); + } + break; + } + case 149879610: + case 1076639233: { + if (input.isAtField(FieldNames.takenAchievementLevelList)) { + if (!input.trySkipNullValue()) { + input.readRepeatedUInt32(takenAchievementLevelList); + bitField0_ |= 0x00000010; + } + } else { + input.skipUnknownField(); + } + break; + } + default: { + input.skipUnknownField(); + break; + } + } + } + input.endObject(); + return this; + } + + @Override + public Quest clone() { + return new Quest().copyFrom(this); + } + + @Override + public boolean isEmpty() { + return ((bitField0_) == 0); + } + + public static Quest parseFrom(final byte[] data) throws InvalidProtocolBufferException { + return ProtoMessage.mergeFrom(new Quest(), data).checkInitialized(); + } + + public static Quest parseFrom(final ProtoSource input) throws IOException { + return ProtoMessage.mergeFrom(new Quest(), input).checkInitialized(); + } + + public static Quest parseFrom(final JsonSource input) throws IOException { + return ProtoMessage.mergeFrom(new Quest(), input).checkInitialized(); + } + + /** + * @return factory for creating Quest messages + */ + public static MessageFactory getFactory() { + return QuestFactory.INSTANCE; + } + + /** + * Protobuf enum {@code QuestStatus} + */ + public enum QuestStatus implements ProtoEnum { + /** + * QUEST_NONE = 0; + */ + QUEST_NONE("QUEST_NONE", 0), + + /** + * QUEST_DOING = 1; + */ + QUEST_DOING("QUEST_DOING", 1), + + /** + * QUEST_FINISH = 2; + */ + QUEST_FINISH("QUEST_FINISH", 2), + + /** + * QUEST_CLOSE = 3; + */ + QUEST_CLOSE("QUEST_CLOSE", 3), + + /** + * QUEST_DELETE = 4; + */ + QUEST_DELETE("QUEST_DELETE", 4); + + /** + * QUEST_NONE = 0; + */ + public static final int QUEST_NONE_VALUE = 0; + + /** + * QUEST_DOING = 1; + */ + public static final int QUEST_DOING_VALUE = 1; + + /** + * QUEST_FINISH = 2; + */ + public static final int QUEST_FINISH_VALUE = 2; + + /** + * QUEST_CLOSE = 3; + */ + public static final int QUEST_CLOSE_VALUE = 3; + + /** + * QUEST_DELETE = 4; + */ + public static final int QUEST_DELETE_VALUE = 4; + + private final String name; + + private final int number; + + private QuestStatus(String name, int number) { + this.name = name; + this.number = number; + } + + /** + * @return the string representation of enum entry + */ + @Override + public String getName() { + return name; + } + + /** + * @return the numeric wire value of this enum entry + */ + @Override + public int getNumber() { + return number; + } + + /** + * @return a converter that maps between this enum's numeric and text representations + */ + public static ProtoEnum.EnumConverter converter() { + return QuestStatusConverter.INSTANCE; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value, or null if unknown. + */ + public static QuestStatus forNumber(int value) { + return QuestStatusConverter.INSTANCE.forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @param other Fallback value in case the value is not known. + * @return The enum associated with the given numeric wire value, or the fallback value if unknown. + */ + public static QuestStatus forNumberOr(int number, QuestStatus other) { + QuestStatus value = forNumber(number); + return value == null ? other : value; + } + + enum QuestStatusConverter implements ProtoEnum.EnumConverter { + INSTANCE; + + private static final QuestStatus[] lookup = new QuestStatus[5]; + + static { + lookup[0] = QUEST_NONE; + lookup[1] = QUEST_DOING; + lookup[2] = QUEST_FINISH; + lookup[3] = QUEST_CLOSE; + lookup[4] = QUEST_DELETE; + } + + @Override + public final QuestStatus forNumber(final int value) { + if (value >= 0 && value < lookup.length) { + return lookup[value]; + } + return null; + } + + @Override + public final QuestStatus forName(final CharSequence value) { + if (value.length() == 10) { + if (ProtoUtil.isEqual("QUEST_NONE", value)) { + return QUEST_NONE; + } + } + if (value.length() == 11) { + if (ProtoUtil.isEqual("QUEST_DOING", value)) { + return QUEST_DOING; + } + if (ProtoUtil.isEqual("QUEST_CLOSE", value)) { + return QUEST_CLOSE; + } + } + if (value.length() == 12) { + if (ProtoUtil.isEqual("QUEST_FINISH", value)) { + return QUEST_FINISH; + } + if (ProtoUtil.isEqual("QUEST_DELETE", value)) { + return QUEST_DELETE; + } + } + return null; + } + } + } + + private enum QuestFactory implements MessageFactory { + INSTANCE; + + @Override + public Quest create() { + return Quest.newInstance(); + } + } + + /** + * Contains name constants used for serializing JSON + */ + static class FieldNames { + static final FieldName finishTime = FieldName.forField("finishTime", "finish_time"); + + static final FieldName progress = FieldName.forField("progress"); + + static final FieldName id = FieldName.forField("id"); + + static final FieldName status = FieldName.forField("status"); + + static final FieldName takenAchievementLevelList = FieldName.forField("takenAchievementLevelList", "taken_achievement_level_list"); + } + } +} diff --git a/src/main/java/emu/lunarcore/data/GameData.java b/src/main/java/emu/lunarcore/data/GameData.java index f7fa101..7cef824 100644 --- a/src/main/java/emu/lunarcore/data/GameData.java +++ b/src/main/java/emu/lunarcore/data/GameData.java @@ -60,6 +60,7 @@ public class GameData { private static Int2ObjectMap phoneThemeExcelMap = new Int2ObjectOpenHashMap<>(); private static Int2ObjectMap monsterDropExcelMap = new Int2ObjectOpenHashMap<>(); private static Int2ObjectMap monsterExcelMap = new Int2ObjectOpenHashMap<>(); + private static Int2ObjectMap questExcelMap = new Int2ObjectLinkedOpenHashMap<>(); private static Int2ObjectMap playerLevelExcelMap = new Int2ObjectOpenHashMap<>(); private static Int2ObjectMap expTypeExcelMap = new Int2ObjectOpenHashMap<>(); @@ -141,6 +142,17 @@ public class GameData { return allIds; } + public static List getAllQuestIds() { + List allIds = new ArrayList<>(); + + for (Int2ObjectMap.Entry entry : questExcelMap.int2ObjectEntrySet()) { + QuestExcel questExcel = entry.getValue(); + allIds.add(questExcel.getId()); + } + + return allIds; + } + public static List getAllMonsterIds() { List allIds = new ArrayList<>(); diff --git a/src/main/java/emu/lunarcore/data/excel/QuestExcel.java b/src/main/java/emu/lunarcore/data/excel/QuestExcel.java new file mode 100644 index 0000000..0c2f50f --- /dev/null +++ b/src/main/java/emu/lunarcore/data/excel/QuestExcel.java @@ -0,0 +1,17 @@ +package emu.lunarcore.data.excel; + +import emu.lunarcore.data.GameResource; +import emu.lunarcore.data.ResourceType; +import emu.lunarcore.data.ResourceType.LoadPriority; +import lombok.Getter; + +@Getter +@ResourceType(name = {"QuestData.json"}, loadPriority = LoadPriority.NORMAL) +public class QuestExcel extends GameResource { + private int QuestID; + + @Override + public int getId() { + return QuestID; + } +} diff --git a/src/main/java/emu/lunarcore/server/packet/CmdIdUtils.java b/src/main/java/emu/lunarcore/server/packet/CmdIdUtils.java index f993745..d7c08a3 100644 --- a/src/main/java/emu/lunarcore/server/packet/CmdIdUtils.java +++ b/src/main/java/emu/lunarcore/server/packet/CmdIdUtils.java @@ -19,7 +19,8 @@ public class CmdIdUtils { CmdId.PlayerHeartBeatCsReq, CmdId.PlayerHeartBeatScRsp, CmdId.SceneEntityMoveCsReq, - CmdId.SceneEntityMoveScRsp + CmdId.SceneEntityMoveScRsp, + CmdId.GetQuestDataScRsp ); private static Int2ObjectMap opcodeMap; diff --git a/src/main/java/emu/lunarcore/server/packet/recv/HandlerGetQuestDataCsReq.java b/src/main/java/emu/lunarcore/server/packet/recv/HandlerGetQuestDataCsReq.java new file mode 100644 index 0000000..0de5187 --- /dev/null +++ b/src/main/java/emu/lunarcore/server/packet/recv/HandlerGetQuestDataCsReq.java @@ -0,0 +1,16 @@ +package emu.lunarcore.server.packet.recv; + +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.PacketGetQuestDataScRsp; + +@Opcodes(CmdId.GetQuestDataCsReq) +public class HandlerGetQuestDataCsReq extends PacketHandler { + + @Override + public void handle(GameSession session, byte[] data) throws Exception { + session.send(new PacketGetQuestDataScRsp()); + } +} \ No newline at end of file diff --git a/src/main/java/emu/lunarcore/server/packet/send/PacketGetQuestDataScRsp.java b/src/main/java/emu/lunarcore/server/packet/send/PacketGetQuestDataScRsp.java new file mode 100644 index 0000000..a22db8e --- /dev/null +++ b/src/main/java/emu/lunarcore/server/packet/send/PacketGetQuestDataScRsp.java @@ -0,0 +1,32 @@ +package emu.lunarcore.server.packet.send; + +import emu.lunarcore.proto.GetQuestDataScRspOuterClass.GetQuestDataScRsp; +import emu.lunarcore.proto.QuestOuterClass.Quest; +import emu.lunarcore.proto.QuestOuterClass.Quest.QuestStatus; +import emu.lunarcore.server.game.GameSession; +import emu.lunarcore.server.packet.BasePacket; +import emu.lunarcore.server.packet.CmdId; +import emu.lunarcore.data.GameData; + +public class PacketGetQuestDataScRsp extends BasePacket { + + public PacketGetQuestDataScRsp() { + super(CmdId.GetQuestDataScRsp); + + var allIds = GameData.getAllQuestIds(); + + var data = GetQuestDataScRsp.newInstance() + .setTotalAchievementExp(69); + + for (int questId : allIds) { + var questItem = Quest.newInstance() + .setId(questId) + .setStatus(QuestStatus.QUEST_FINISH) + .setFinishTime(10000L) + .setProgress(1); + data.addQuestList(questItem); + } + + this.setData(data); + } +}