Implement mail attachments

This commit is contained in:
Melledy
2023-10-17 22:56:36 -07:00
parent 0bbd30eb17
commit f0c10071d9
7 changed files with 1418 additions and 2 deletions

View File

@@ -0,0 +1,339 @@
// 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 ClientMailAttachmentItemOuterClass {
/**
* Protobuf type {@code ClientMailAttachmentItem}
*/
public static final class ClientMailAttachmentItem extends ProtoMessage<ClientMailAttachmentItem> implements Cloneable {
private static final long serialVersionUID = 0L;
/**
* <code>optional uint32 FKIPJPLMBFI = 2;</code>
*/
private int fKIPJPLMBFI;
/**
* <code>optional uint32 ANAFKBMJOBJ = 12;</code>
*/
private int aNAFKBMJOBJ;
private ClientMailAttachmentItem() {
}
/**
* @return a new empty instance of {@code ClientMailAttachmentItem}
*/
public static ClientMailAttachmentItem newInstance() {
return new ClientMailAttachmentItem();
}
/**
* <code>optional uint32 FKIPJPLMBFI = 2;</code>
* @return whether the fKIPJPLMBFI field is set
*/
public boolean hasFKIPJPLMBFI() {
return (bitField0_ & 0x00000001) != 0;
}
/**
* <code>optional uint32 FKIPJPLMBFI = 2;</code>
* @return this
*/
public ClientMailAttachmentItem clearFKIPJPLMBFI() {
bitField0_ &= ~0x00000001;
fKIPJPLMBFI = 0;
return this;
}
/**
* <code>optional uint32 FKIPJPLMBFI = 2;</code>
* @return the fKIPJPLMBFI
*/
public int getFKIPJPLMBFI() {
return fKIPJPLMBFI;
}
/**
* <code>optional uint32 FKIPJPLMBFI = 2;</code>
* @param value the fKIPJPLMBFI to set
* @return this
*/
public ClientMailAttachmentItem setFKIPJPLMBFI(final int value) {
bitField0_ |= 0x00000001;
fKIPJPLMBFI = value;
return this;
}
/**
* <code>optional uint32 ANAFKBMJOBJ = 12;</code>
* @return whether the aNAFKBMJOBJ field is set
*/
public boolean hasANAFKBMJOBJ() {
return (bitField0_ & 0x00000002) != 0;
}
/**
* <code>optional uint32 ANAFKBMJOBJ = 12;</code>
* @return this
*/
public ClientMailAttachmentItem clearANAFKBMJOBJ() {
bitField0_ &= ~0x00000002;
aNAFKBMJOBJ = 0;
return this;
}
/**
* <code>optional uint32 ANAFKBMJOBJ = 12;</code>
* @return the aNAFKBMJOBJ
*/
public int getANAFKBMJOBJ() {
return aNAFKBMJOBJ;
}
/**
* <code>optional uint32 ANAFKBMJOBJ = 12;</code>
* @param value the aNAFKBMJOBJ to set
* @return this
*/
public ClientMailAttachmentItem setANAFKBMJOBJ(final int value) {
bitField0_ |= 0x00000002;
aNAFKBMJOBJ = value;
return this;
}
@Override
public ClientMailAttachmentItem copyFrom(final ClientMailAttachmentItem other) {
cachedSize = other.cachedSize;
if ((bitField0_ | other.bitField0_) != 0) {
bitField0_ = other.bitField0_;
fKIPJPLMBFI = other.fKIPJPLMBFI;
aNAFKBMJOBJ = other.aNAFKBMJOBJ;
}
return this;
}
@Override
public ClientMailAttachmentItem mergeFrom(final ClientMailAttachmentItem other) {
if (other.isEmpty()) {
return this;
}
cachedSize = -1;
if (other.hasFKIPJPLMBFI()) {
setFKIPJPLMBFI(other.fKIPJPLMBFI);
}
if (other.hasANAFKBMJOBJ()) {
setANAFKBMJOBJ(other.aNAFKBMJOBJ);
}
return this;
}
@Override
public ClientMailAttachmentItem clear() {
if (isEmpty()) {
return this;
}
cachedSize = -1;
bitField0_ = 0;
fKIPJPLMBFI = 0;
aNAFKBMJOBJ = 0;
return this;
}
@Override
public ClientMailAttachmentItem 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 ClientMailAttachmentItem)) {
return false;
}
ClientMailAttachmentItem other = (ClientMailAttachmentItem) o;
return bitField0_ == other.bitField0_
&& (!hasFKIPJPLMBFI() || fKIPJPLMBFI == other.fKIPJPLMBFI)
&& (!hasANAFKBMJOBJ() || aNAFKBMJOBJ == other.aNAFKBMJOBJ);
}
@Override
public void writeTo(final ProtoSink output) throws IOException {
if ((bitField0_ & 0x00000001) != 0) {
output.writeRawByte((byte) 16);
output.writeUInt32NoTag(fKIPJPLMBFI);
}
if ((bitField0_ & 0x00000002) != 0) {
output.writeRawByte((byte) 96);
output.writeUInt32NoTag(aNAFKBMJOBJ);
}
}
@Override
protected int computeSerializedSize() {
int size = 0;
if ((bitField0_ & 0x00000001) != 0) {
size += 1 + ProtoSink.computeUInt32SizeNoTag(fKIPJPLMBFI);
}
if ((bitField0_ & 0x00000002) != 0) {
size += 1 + ProtoSink.computeUInt32SizeNoTag(aNAFKBMJOBJ);
}
return size;
}
@Override
@SuppressWarnings("fallthrough")
public ClientMailAttachmentItem mergeFrom(final ProtoSource input) throws IOException {
// Enabled Fall-Through Optimization (QuickBuffers)
int tag = input.readTag();
while (true) {
switch (tag) {
case 16: {
// fKIPJPLMBFI
fKIPJPLMBFI = input.readUInt32();
bitField0_ |= 0x00000001;
tag = input.readTag();
if (tag != 96) {
break;
}
}
case 96: {
// aNAFKBMJOBJ
aNAFKBMJOBJ = input.readUInt32();
bitField0_ |= 0x00000002;
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.fKIPJPLMBFI, fKIPJPLMBFI);
}
if ((bitField0_ & 0x00000002) != 0) {
output.writeUInt32(FieldNames.aNAFKBMJOBJ, aNAFKBMJOBJ);
}
output.endObject();
}
@Override
public ClientMailAttachmentItem mergeFrom(final JsonSource input) throws IOException {
if (!input.beginObject()) {
return this;
}
while (!input.isAtEnd()) {
switch (input.readFieldHash()) {
case -581795918: {
if (input.isAtField(FieldNames.fKIPJPLMBFI)) {
if (!input.trySkipNullValue()) {
fKIPJPLMBFI = input.readUInt32();
bitField0_ |= 0x00000001;
}
} else {
input.skipUnknownField();
}
break;
}
case 1037527505: {
if (input.isAtField(FieldNames.aNAFKBMJOBJ)) {
if (!input.trySkipNullValue()) {
aNAFKBMJOBJ = input.readUInt32();
bitField0_ |= 0x00000002;
}
} else {
input.skipUnknownField();
}
break;
}
default: {
input.skipUnknownField();
break;
}
}
}
input.endObject();
return this;
}
@Override
public ClientMailAttachmentItem clone() {
return new ClientMailAttachmentItem().copyFrom(this);
}
@Override
public boolean isEmpty() {
return ((bitField0_) == 0);
}
public static ClientMailAttachmentItem parseFrom(final byte[] data) throws
InvalidProtocolBufferException {
return ProtoMessage.mergeFrom(new ClientMailAttachmentItem(), data).checkInitialized();
}
public static ClientMailAttachmentItem parseFrom(final ProtoSource input) throws IOException {
return ProtoMessage.mergeFrom(new ClientMailAttachmentItem(), input).checkInitialized();
}
public static ClientMailAttachmentItem parseFrom(final JsonSource input) throws IOException {
return ProtoMessage.mergeFrom(new ClientMailAttachmentItem(), input).checkInitialized();
}
/**
* @return factory for creating ClientMailAttachmentItem messages
*/
public static MessageFactory<ClientMailAttachmentItem> getFactory() {
return ClientMailAttachmentItemFactory.INSTANCE;
}
private enum ClientMailAttachmentItemFactory implements MessageFactory<ClientMailAttachmentItem> {
INSTANCE;
@Override
public ClientMailAttachmentItem create() {
return ClientMailAttachmentItem.newInstance();
}
}
/**
* Contains name constants used for serializing JSON
*/
static class FieldNames {
static final FieldName fKIPJPLMBFI = FieldName.forField("FKIPJPLMBFI");
static final FieldName aNAFKBMJOBJ = FieldName.forField("ANAFKBMJOBJ");
}
}
}

View File

@@ -0,0 +1,381 @@
// 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.RepeatedInt;
public final class TakeMailAttachmentCsReqOuterClass {
/**
* Protobuf type {@code TakeMailAttachmentCsReq}
*/
public static final class TakeMailAttachmentCsReq extends ProtoMessage<TakeMailAttachmentCsReq> implements Cloneable {
private static final long serialVersionUID = 0L;
/**
* <code>optional uint32 BBFNEALMHJB = 7;</code>
*/
private int bBFNEALMHJB;
/**
* <code>repeated uint32 mail_id_list = 12;</code>
*/
private final RepeatedInt mailIdList = RepeatedInt.newEmptyInstance();
private TakeMailAttachmentCsReq() {
}
/**
* @return a new empty instance of {@code TakeMailAttachmentCsReq}
*/
public static TakeMailAttachmentCsReq newInstance() {
return new TakeMailAttachmentCsReq();
}
/**
* <code>optional uint32 BBFNEALMHJB = 7;</code>
* @return whether the bBFNEALMHJB field is set
*/
public boolean hasBBFNEALMHJB() {
return (bitField0_ & 0x00000001) != 0;
}
/**
* <code>optional uint32 BBFNEALMHJB = 7;</code>
* @return this
*/
public TakeMailAttachmentCsReq clearBBFNEALMHJB() {
bitField0_ &= ~0x00000001;
bBFNEALMHJB = 0;
return this;
}
/**
* <code>optional uint32 BBFNEALMHJB = 7;</code>
* @return the bBFNEALMHJB
*/
public int getBBFNEALMHJB() {
return bBFNEALMHJB;
}
/**
* <code>optional uint32 BBFNEALMHJB = 7;</code>
* @param value the bBFNEALMHJB to set
* @return this
*/
public TakeMailAttachmentCsReq setBBFNEALMHJB(final int value) {
bitField0_ |= 0x00000001;
bBFNEALMHJB = value;
return this;
}
/**
* <code>repeated uint32 mail_id_list = 12;</code>
* @return whether the mailIdList field is set
*/
public boolean hasMailIdList() {
return (bitField0_ & 0x00000002) != 0;
}
/**
* <code>repeated uint32 mail_id_list = 12;</code>
* @return this
*/
public TakeMailAttachmentCsReq clearMailIdList() {
bitField0_ &= ~0x00000002;
mailIdList.clear();
return this;
}
/**
* <code>repeated uint32 mail_id_list = 12;</code>
*
* 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 #getMutableMailIdList()} if you want to modify it.
*
* @return internal storage object for reading
*/
public RepeatedInt getMailIdList() {
return mailIdList;
}
/**
* <code>repeated uint32 mail_id_list = 12;</code>
*
* 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 getMutableMailIdList() {
bitField0_ |= 0x00000002;
return mailIdList;
}
/**
* <code>repeated uint32 mail_id_list = 12;</code>
* @param value the mailIdList to add
* @return this
*/
public TakeMailAttachmentCsReq addMailIdList(final int value) {
bitField0_ |= 0x00000002;
mailIdList.add(value);
return this;
}
/**
* <code>repeated uint32 mail_id_list = 12;</code>
* @param values the mailIdList to add
* @return this
*/
public TakeMailAttachmentCsReq addAllMailIdList(final int... values) {
bitField0_ |= 0x00000002;
mailIdList.addAll(values);
return this;
}
@Override
public TakeMailAttachmentCsReq copyFrom(final TakeMailAttachmentCsReq other) {
cachedSize = other.cachedSize;
if ((bitField0_ | other.bitField0_) != 0) {
bitField0_ = other.bitField0_;
bBFNEALMHJB = other.bBFNEALMHJB;
mailIdList.copyFrom(other.mailIdList);
}
return this;
}
@Override
public TakeMailAttachmentCsReq mergeFrom(final TakeMailAttachmentCsReq other) {
if (other.isEmpty()) {
return this;
}
cachedSize = -1;
if (other.hasBBFNEALMHJB()) {
setBBFNEALMHJB(other.bBFNEALMHJB);
}
if (other.hasMailIdList()) {
getMutableMailIdList().addAll(other.mailIdList);
}
return this;
}
@Override
public TakeMailAttachmentCsReq clear() {
if (isEmpty()) {
return this;
}
cachedSize = -1;
bitField0_ = 0;
bBFNEALMHJB = 0;
mailIdList.clear();
return this;
}
@Override
public TakeMailAttachmentCsReq clearQuick() {
if (isEmpty()) {
return this;
}
cachedSize = -1;
bitField0_ = 0;
mailIdList.clear();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof TakeMailAttachmentCsReq)) {
return false;
}
TakeMailAttachmentCsReq other = (TakeMailAttachmentCsReq) o;
return bitField0_ == other.bitField0_
&& (!hasBBFNEALMHJB() || bBFNEALMHJB == other.bBFNEALMHJB)
&& (!hasMailIdList() || mailIdList.equals(other.mailIdList));
}
@Override
public void writeTo(final ProtoSink output) throws IOException {
if ((bitField0_ & 0x00000001) != 0) {
output.writeRawByte((byte) 56);
output.writeUInt32NoTag(bBFNEALMHJB);
}
if ((bitField0_ & 0x00000002) != 0) {
for (int i = 0; i < mailIdList.length(); i++) {
output.writeRawByte((byte) 96);
output.writeUInt32NoTag(mailIdList.array()[i]);
}
}
}
@Override
protected int computeSerializedSize() {
int size = 0;
if ((bitField0_ & 0x00000001) != 0) {
size += 1 + ProtoSink.computeUInt32SizeNoTag(bBFNEALMHJB);
}
if ((bitField0_ & 0x00000002) != 0) {
size += (1 * mailIdList.length()) + ProtoSink.computeRepeatedUInt32SizeNoTag(mailIdList);
}
return size;
}
@Override
@SuppressWarnings("fallthrough")
public TakeMailAttachmentCsReq mergeFrom(final ProtoSource input) throws IOException {
// Enabled Fall-Through Optimization (QuickBuffers)
int tag = input.readTag();
while (true) {
switch (tag) {
case 56: {
// bBFNEALMHJB
bBFNEALMHJB = input.readUInt32();
bitField0_ |= 0x00000001;
tag = input.readTag();
if (tag != 98) {
break;
}
}
case 98: {
// mailIdList [packed=true]
input.readPackedUInt32(mailIdList, tag);
bitField0_ |= 0x00000002;
tag = input.readTag();
if (tag != 0) {
break;
}
}
case 0: {
return this;
}
default: {
if (!input.skipField(tag)) {
return this;
}
tag = input.readTag();
break;
}
case 96: {
// mailIdList [packed=false]
tag = input.readRepeatedUInt32(mailIdList, tag);
bitField0_ |= 0x00000002;
break;
}
}
}
}
@Override
public void writeTo(final JsonSink output) throws IOException {
output.beginObject();
if ((bitField0_ & 0x00000001) != 0) {
output.writeUInt32(FieldNames.bBFNEALMHJB, bBFNEALMHJB);
}
if ((bitField0_ & 0x00000002) != 0) {
output.writeRepeatedUInt32(FieldNames.mailIdList, mailIdList);
}
output.endObject();
}
@Override
public TakeMailAttachmentCsReq mergeFrom(final JsonSource input) throws IOException {
if (!input.beginObject()) {
return this;
}
while (!input.isAtEnd()) {
switch (input.readFieldHash()) {
case 1149456699: {
if (input.isAtField(FieldNames.bBFNEALMHJB)) {
if (!input.trySkipNullValue()) {
bBFNEALMHJB = input.readUInt32();
bitField0_ |= 0x00000001;
}
} else {
input.skipUnknownField();
}
break;
}
case -1612269328:
case 1599691450: {
if (input.isAtField(FieldNames.mailIdList)) {
if (!input.trySkipNullValue()) {
input.readRepeatedUInt32(mailIdList);
bitField0_ |= 0x00000002;
}
} else {
input.skipUnknownField();
}
break;
}
default: {
input.skipUnknownField();
break;
}
}
}
input.endObject();
return this;
}
@Override
public TakeMailAttachmentCsReq clone() {
return new TakeMailAttachmentCsReq().copyFrom(this);
}
@Override
public boolean isEmpty() {
return ((bitField0_) == 0);
}
public static TakeMailAttachmentCsReq parseFrom(final byte[] data) throws
InvalidProtocolBufferException {
return ProtoMessage.mergeFrom(new TakeMailAttachmentCsReq(), data).checkInitialized();
}
public static TakeMailAttachmentCsReq parseFrom(final ProtoSource input) throws IOException {
return ProtoMessage.mergeFrom(new TakeMailAttachmentCsReq(), input).checkInitialized();
}
public static TakeMailAttachmentCsReq parseFrom(final JsonSource input) throws IOException {
return ProtoMessage.mergeFrom(new TakeMailAttachmentCsReq(), input).checkInitialized();
}
/**
* @return factory for creating TakeMailAttachmentCsReq messages
*/
public static MessageFactory<TakeMailAttachmentCsReq> getFactory() {
return TakeMailAttachmentCsReqFactory.INSTANCE;
}
private enum TakeMailAttachmentCsReqFactory implements MessageFactory<TakeMailAttachmentCsReq> {
INSTANCE;
@Override
public TakeMailAttachmentCsReq create() {
return TakeMailAttachmentCsReq.newInstance();
}
}
/**
* Contains name constants used for serializing JSON
*/
static class FieldNames {
static final FieldName bBFNEALMHJB = FieldName.forField("BBFNEALMHJB");
static final FieldName mailIdList = FieldName.forField("mailIdList", "mail_id_list");
}
}
}

View File

@@ -0,0 +1,601 @@
// 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.RepeatedInt;
import us.hebi.quickbuf.RepeatedMessage;
public final class TakeMailAttachmentScRspOuterClass {
/**
* Protobuf type {@code TakeMailAttachmentScRsp}
*/
public static final class TakeMailAttachmentScRsp extends ProtoMessage<TakeMailAttachmentScRsp> implements Cloneable {
private static final long serialVersionUID = 0L;
/**
* <code>optional uint32 retcode = 11;</code>
*/
private int retcode;
/**
* <code>optional .ItemList attachment = 10;</code>
*/
private final ItemListOuterClass.ItemList attachment = ItemListOuterClass.ItemList.newInstance();
/**
* <code>repeated uint32 succ_mail_id_list = 6;</code>
*/
private final RepeatedInt succMailIdList = RepeatedInt.newEmptyInstance();
/**
* <code>repeated .ClientMailAttachmentItem fail_mail_list = 13;</code>
*/
private final RepeatedMessage<ClientMailAttachmentItemOuterClass.ClientMailAttachmentItem> failMailList = RepeatedMessage.newEmptyInstance(ClientMailAttachmentItemOuterClass.ClientMailAttachmentItem.getFactory());
private TakeMailAttachmentScRsp() {
}
/**
* @return a new empty instance of {@code TakeMailAttachmentScRsp}
*/
public static TakeMailAttachmentScRsp newInstance() {
return new TakeMailAttachmentScRsp();
}
/**
* <code>optional uint32 retcode = 11;</code>
* @return whether the retcode field is set
*/
public boolean hasRetcode() {
return (bitField0_ & 0x00000001) != 0;
}
/**
* <code>optional uint32 retcode = 11;</code>
* @return this
*/
public TakeMailAttachmentScRsp clearRetcode() {
bitField0_ &= ~0x00000001;
retcode = 0;
return this;
}
/**
* <code>optional uint32 retcode = 11;</code>
* @return the retcode
*/
public int getRetcode() {
return retcode;
}
/**
* <code>optional uint32 retcode = 11;</code>
* @param value the retcode to set
* @return this
*/
public TakeMailAttachmentScRsp setRetcode(final int value) {
bitField0_ |= 0x00000001;
retcode = value;
return this;
}
/**
* <code>optional .ItemList attachment = 10;</code>
* @return whether the attachment field is set
*/
public boolean hasAttachment() {
return (bitField0_ & 0x00000002) != 0;
}
/**
* <code>optional .ItemList attachment = 10;</code>
* @return this
*/
public TakeMailAttachmentScRsp clearAttachment() {
bitField0_ &= ~0x00000002;
attachment.clear();
return this;
}
/**
* <code>optional .ItemList attachment = 10;</code>
*
* 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 #getMutableAttachment()} if you want to modify it.
*
* @return internal storage object for reading
*/
public ItemListOuterClass.ItemList getAttachment() {
return attachment;
}
/**
* <code>optional .ItemList attachment = 10;</code>
*
* 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 getMutableAttachment() {
bitField0_ |= 0x00000002;
return attachment;
}
/**
* <code>optional .ItemList attachment = 10;</code>
* @param value the attachment to set
* @return this
*/
public TakeMailAttachmentScRsp setAttachment(final ItemListOuterClass.ItemList value) {
bitField0_ |= 0x00000002;
attachment.copyFrom(value);
return this;
}
/**
* <code>repeated uint32 succ_mail_id_list = 6;</code>
* @return whether the succMailIdList field is set
*/
public boolean hasSuccMailIdList() {
return (bitField0_ & 0x00000004) != 0;
}
/**
* <code>repeated uint32 succ_mail_id_list = 6;</code>
* @return this
*/
public TakeMailAttachmentScRsp clearSuccMailIdList() {
bitField0_ &= ~0x00000004;
succMailIdList.clear();
return this;
}
/**
* <code>repeated uint32 succ_mail_id_list = 6;</code>
*
* 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 #getMutableSuccMailIdList()} if you want to modify it.
*
* @return internal storage object for reading
*/
public RepeatedInt getSuccMailIdList() {
return succMailIdList;
}
/**
* <code>repeated uint32 succ_mail_id_list = 6;</code>
*
* 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 getMutableSuccMailIdList() {
bitField0_ |= 0x00000004;
return succMailIdList;
}
/**
* <code>repeated uint32 succ_mail_id_list = 6;</code>
* @param value the succMailIdList to add
* @return this
*/
public TakeMailAttachmentScRsp addSuccMailIdList(final int value) {
bitField0_ |= 0x00000004;
succMailIdList.add(value);
return this;
}
/**
* <code>repeated uint32 succ_mail_id_list = 6;</code>
* @param values the succMailIdList to add
* @return this
*/
public TakeMailAttachmentScRsp addAllSuccMailIdList(final int... values) {
bitField0_ |= 0x00000004;
succMailIdList.addAll(values);
return this;
}
/**
* <code>repeated .ClientMailAttachmentItem fail_mail_list = 13;</code>
* @return whether the failMailList field is set
*/
public boolean hasFailMailList() {
return (bitField0_ & 0x00000008) != 0;
}
/**
* <code>repeated .ClientMailAttachmentItem fail_mail_list = 13;</code>
* @return this
*/
public TakeMailAttachmentScRsp clearFailMailList() {
bitField0_ &= ~0x00000008;
failMailList.clear();
return this;
}
/**
* <code>repeated .ClientMailAttachmentItem fail_mail_list = 13;</code>
*
* 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 #getMutableFailMailList()} if you want to modify it.
*
* @return internal storage object for reading
*/
public RepeatedMessage<ClientMailAttachmentItemOuterClass.ClientMailAttachmentItem> getFailMailList(
) {
return failMailList;
}
/**
* <code>repeated .ClientMailAttachmentItem fail_mail_list = 13;</code>
*
* 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<ClientMailAttachmentItemOuterClass.ClientMailAttachmentItem> getMutableFailMailList(
) {
bitField0_ |= 0x00000008;
return failMailList;
}
/**
* <code>repeated .ClientMailAttachmentItem fail_mail_list = 13;</code>
* @param value the failMailList to add
* @return this
*/
public TakeMailAttachmentScRsp addFailMailList(
final ClientMailAttachmentItemOuterClass.ClientMailAttachmentItem value) {
bitField0_ |= 0x00000008;
failMailList.add(value);
return this;
}
/**
* <code>repeated .ClientMailAttachmentItem fail_mail_list = 13;</code>
* @param values the failMailList to add
* @return this
*/
public TakeMailAttachmentScRsp addAllFailMailList(
final ClientMailAttachmentItemOuterClass.ClientMailAttachmentItem... values) {
bitField0_ |= 0x00000008;
failMailList.addAll(values);
return this;
}
@Override
public TakeMailAttachmentScRsp copyFrom(final TakeMailAttachmentScRsp other) {
cachedSize = other.cachedSize;
if ((bitField0_ | other.bitField0_) != 0) {
bitField0_ = other.bitField0_;
retcode = other.retcode;
attachment.copyFrom(other.attachment);
succMailIdList.copyFrom(other.succMailIdList);
failMailList.copyFrom(other.failMailList);
}
return this;
}
@Override
public TakeMailAttachmentScRsp mergeFrom(final TakeMailAttachmentScRsp other) {
if (other.isEmpty()) {
return this;
}
cachedSize = -1;
if (other.hasRetcode()) {
setRetcode(other.retcode);
}
if (other.hasAttachment()) {
getMutableAttachment().mergeFrom(other.attachment);
}
if (other.hasSuccMailIdList()) {
getMutableSuccMailIdList().addAll(other.succMailIdList);
}
if (other.hasFailMailList()) {
getMutableFailMailList().addAll(other.failMailList);
}
return this;
}
@Override
public TakeMailAttachmentScRsp clear() {
if (isEmpty()) {
return this;
}
cachedSize = -1;
bitField0_ = 0;
retcode = 0;
attachment.clear();
succMailIdList.clear();
failMailList.clear();
return this;
}
@Override
public TakeMailAttachmentScRsp clearQuick() {
if (isEmpty()) {
return this;
}
cachedSize = -1;
bitField0_ = 0;
attachment.clearQuick();
succMailIdList.clear();
failMailList.clearQuick();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof TakeMailAttachmentScRsp)) {
return false;
}
TakeMailAttachmentScRsp other = (TakeMailAttachmentScRsp) o;
return bitField0_ == other.bitField0_
&& (!hasRetcode() || retcode == other.retcode)
&& (!hasAttachment() || attachment.equals(other.attachment))
&& (!hasSuccMailIdList() || succMailIdList.equals(other.succMailIdList))
&& (!hasFailMailList() || failMailList.equals(other.failMailList));
}
@Override
public void writeTo(final ProtoSink output) throws IOException {
if ((bitField0_ & 0x00000001) != 0) {
output.writeRawByte((byte) 88);
output.writeUInt32NoTag(retcode);
}
if ((bitField0_ & 0x00000002) != 0) {
output.writeRawByte((byte) 82);
output.writeMessageNoTag(attachment);
}
if ((bitField0_ & 0x00000004) != 0) {
for (int i = 0; i < succMailIdList.length(); i++) {
output.writeRawByte((byte) 48);
output.writeUInt32NoTag(succMailIdList.array()[i]);
}
}
if ((bitField0_ & 0x00000008) != 0) {
for (int i = 0; i < failMailList.length(); i++) {
output.writeRawByte((byte) 106);
output.writeMessageNoTag(failMailList.get(i));
}
}
}
@Override
protected int computeSerializedSize() {
int size = 0;
if ((bitField0_ & 0x00000001) != 0) {
size += 1 + ProtoSink.computeUInt32SizeNoTag(retcode);
}
if ((bitField0_ & 0x00000002) != 0) {
size += 1 + ProtoSink.computeMessageSizeNoTag(attachment);
}
if ((bitField0_ & 0x00000004) != 0) {
size += (1 * succMailIdList.length()) + ProtoSink.computeRepeatedUInt32SizeNoTag(succMailIdList);
}
if ((bitField0_ & 0x00000008) != 0) {
size += (1 * failMailList.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(failMailList);
}
return size;
}
@Override
@SuppressWarnings("fallthrough")
public TakeMailAttachmentScRsp mergeFrom(final ProtoSource input) throws IOException {
// Enabled Fall-Through Optimization (QuickBuffers)
int tag = input.readTag();
while (true) {
switch (tag) {
case 88: {
// retcode
retcode = input.readUInt32();
bitField0_ |= 0x00000001;
tag = input.readTag();
if (tag != 82) {
break;
}
}
case 82: {
// attachment
input.readMessage(attachment);
bitField0_ |= 0x00000002;
tag = input.readTag();
if (tag != 50) {
break;
}
}
case 50: {
// succMailIdList [packed=true]
input.readPackedUInt32(succMailIdList, tag);
bitField0_ |= 0x00000004;
tag = input.readTag();
if (tag != 106) {
break;
}
}
case 106: {
// failMailList
tag = input.readRepeatedMessage(failMailList, tag);
bitField0_ |= 0x00000008;
if (tag != 0) {
break;
}
}
case 0: {
return this;
}
default: {
if (!input.skipField(tag)) {
return this;
}
tag = input.readTag();
break;
}
case 48: {
// succMailIdList [packed=false]
tag = input.readRepeatedUInt32(succMailIdList, tag);
bitField0_ |= 0x00000004;
break;
}
}
}
}
@Override
public void writeTo(final JsonSink output) throws IOException {
output.beginObject();
if ((bitField0_ & 0x00000001) != 0) {
output.writeUInt32(FieldNames.retcode, retcode);
}
if ((bitField0_ & 0x00000002) != 0) {
output.writeMessage(FieldNames.attachment, attachment);
}
if ((bitField0_ & 0x00000004) != 0) {
output.writeRepeatedUInt32(FieldNames.succMailIdList, succMailIdList);
}
if ((bitField0_ & 0x00000008) != 0) {
output.writeRepeatedMessage(FieldNames.failMailList, failMailList);
}
output.endObject();
}
@Override
public TakeMailAttachmentScRsp mergeFrom(final JsonSource input) throws IOException {
if (!input.beginObject()) {
return this;
}
while (!input.isAtEnd()) {
switch (input.readFieldHash()) {
case 1097936398: {
if (input.isAtField(FieldNames.retcode)) {
if (!input.trySkipNullValue()) {
retcode = input.readUInt32();
bitField0_ |= 0x00000001;
}
} else {
input.skipUnknownField();
}
break;
}
case -1963501277: {
if (input.isAtField(FieldNames.attachment)) {
if (!input.trySkipNullValue()) {
input.readMessage(attachment);
bitField0_ |= 0x00000002;
}
} else {
input.skipUnknownField();
}
break;
}
case 492844242:
case 1318122903: {
if (input.isAtField(FieldNames.succMailIdList)) {
if (!input.trySkipNullValue()) {
input.readRepeatedUInt32(succMailIdList);
bitField0_ |= 0x00000004;
}
} else {
input.skipUnknownField();
}
break;
}
case 1034400819:
case -348560827: {
if (input.isAtField(FieldNames.failMailList)) {
if (!input.trySkipNullValue()) {
input.readRepeatedMessage(failMailList);
bitField0_ |= 0x00000008;
}
} else {
input.skipUnknownField();
}
break;
}
default: {
input.skipUnknownField();
break;
}
}
}
input.endObject();
return this;
}
@Override
public TakeMailAttachmentScRsp clone() {
return new TakeMailAttachmentScRsp().copyFrom(this);
}
@Override
public boolean isEmpty() {
return ((bitField0_) == 0);
}
public static TakeMailAttachmentScRsp parseFrom(final byte[] data) throws
InvalidProtocolBufferException {
return ProtoMessage.mergeFrom(new TakeMailAttachmentScRsp(), data).checkInitialized();
}
public static TakeMailAttachmentScRsp parseFrom(final ProtoSource input) throws IOException {
return ProtoMessage.mergeFrom(new TakeMailAttachmentScRsp(), input).checkInitialized();
}
public static TakeMailAttachmentScRsp parseFrom(final JsonSource input) throws IOException {
return ProtoMessage.mergeFrom(new TakeMailAttachmentScRsp(), input).checkInitialized();
}
/**
* @return factory for creating TakeMailAttachmentScRsp messages
*/
public static MessageFactory<TakeMailAttachmentScRsp> getFactory() {
return TakeMailAttachmentScRspFactory.INSTANCE;
}
private enum TakeMailAttachmentScRspFactory implements MessageFactory<TakeMailAttachmentScRsp> {
INSTANCE;
@Override
public TakeMailAttachmentScRsp create() {
return TakeMailAttachmentScRsp.newInstance();
}
}
/**
* Contains name constants used for serializing JSON
*/
static class FieldNames {
static final FieldName retcode = FieldName.forField("retcode");
static final FieldName attachment = FieldName.forField("attachment");
static final FieldName succMailIdList = FieldName.forField("succMailIdList", "succ_mail_id_list");
static final FieldName failMailList = FieldName.forField("failMailList", "fail_mail_list");
}
}
}

View File

@@ -1,5 +1,6 @@
package emu.lunarcore.game.mail;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -55,6 +56,13 @@ public class Mail {
}
}
public void addAttachment(GameItem item) {
if (this.attachments == null) {
this.attachments = new ArrayList<>();
}
this.attachments.add(item);
}
// Database
public void save() {
@@ -75,8 +83,16 @@ public class Mail {
.setSender(this.getSender())
.setTime(this.getTime())
.setExpireTime(this.getExpiry())
.setIsRead(this.isRead())
.setAttachment(ItemList.newInstance());
.setIsRead(this.isRead());
// Add attachments
ItemList list = ItemList.newInstance();
if (this.attachments != null) {
this.attachments.stream().map(GameItem::toProto).forEach(list::addItemList);
}
proto.setAttachment(list);
return proto;
}

View File

@@ -1,9 +1,12 @@
package emu.lunarcore.game.mail;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Stream;
import emu.lunarcore.LunarRail;
import emu.lunarcore.game.inventory.GameItem;
import emu.lunarcore.game.player.BasePlayerManager;
import emu.lunarcore.game.player.Player;
import emu.lunarcore.server.packet.send.PacketNewMailScNotify;
@@ -56,6 +59,28 @@ public class Mailbox extends BasePlayerManager implements Iterable<Mail> {
// Send packet
this.getPlayer().sendPacket(new PacketNewMailScNotify(mail));
}
public synchronized List<GameItem> takeMailAttachments(RepeatedInt idList) {
List<GameItem> attachments = new ArrayList<>();
for (int id : idList) {
Mail mail = getMap().get(id);
if (mail == null || mail.isRead() || mail.getAttachments() == null) {
continue;
}
// Add attachments to inventory
for (GameItem item : mail.getAttachments()) {
getPlayer().getInventory().addItem(item);
attachments.add(item);
}
// Set read
mail.setRead();
}
return attachments;
}
public synchronized IntList deleteMail(RepeatedInt idList) {
IntList deleteList = new IntArrayList();
@@ -91,4 +116,5 @@ public class Mailbox extends BasePlayerManager implements Iterable<Mail> {
stream.forEach(this::putMail);
}
}

View File

@@ -0,0 +1,25 @@
package emu.lunarcore.server.packet.recv;
import java.util.List;
import emu.lunarcore.game.inventory.GameItem;
import emu.lunarcore.proto.TakeMailAttachmentCsReqOuterClass.TakeMailAttachmentCsReq;
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.PacketTakeMailAttachmentScRsp;
@Opcodes(CmdId.TakeMailAttachmentCsReq)
public class HandlerTakeMailAttachmentCsReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] data) throws Exception {
var req = TakeMailAttachmentCsReq.parseFrom(data);
List<GameItem> attachments = session.getPlayer().getMailbox().takeMailAttachments(req.getMailIdList());
session.send(new PacketTakeMailAttachmentScRsp(req.getMailIdList(), attachments));
}
}

View File

@@ -0,0 +1,28 @@
package emu.lunarcore.server.packet.send;
import java.util.Collection;
import emu.lunarcore.game.inventory.GameItem;
import emu.lunarcore.proto.TakeMailAttachmentScRspOuterClass.TakeMailAttachmentScRsp;
import emu.lunarcore.server.packet.BasePacket;
import emu.lunarcore.server.packet.CmdId;
import us.hebi.quickbuf.RepeatedInt;
public class PacketTakeMailAttachmentScRsp extends BasePacket {
public PacketTakeMailAttachmentScRsp(RepeatedInt idList, Collection<GameItem> items) {
super(CmdId.TakeMailAttachmentScRsp);
var data = TakeMailAttachmentScRsp.newInstance();
for (int id : idList) {
data.addSuccMailIdList(id);
}
for (GameItem item : items) {
data.getMutableAttachment().addItemList(item.toProto());
}
this.setData(data);
}
}