Receiving items in mail

This commit is contained in:
Benjamin Elsdon
2022-04-25 13:51:19 +08:00
parent a548fe6c52
commit 9bf94f9539
9 changed files with 7662 additions and 45 deletions

View File

@@ -573,15 +573,45 @@ public class GenshinPlayer {
this.sendPacket(new PacketPrivateChatNotify(sender.getUid(), this.getUid(), message.toString()));
}
public List<Mail> getMail() { return mail; }
// ---------------------MAIL------------------------
public List<Mail> getAllMail() { return this.mail; }
public void sendMail(Mail message) {
this.mail.add(message);
message._id = this.mail.size() + 1;
this.save();
this.sendPacket(new PacketMailChangeNotify(this, message));
}
public boolean deleteMail(int mailId) {
Mail message = getMailById(mailId);
if(message != null) {
this.mail.remove(message);
this.save();
return true;
}
return false;
}
public Mail getMailById(int mailId) {
return this.mail.stream().filter(message -> message._id == mailId).findFirst().orElse(null);
}
public int getMailIndex(Mail message) {
return this.mail.indexOf(message);
}
public boolean replaceMailByIndex(int mailId, Mail message) {
if(getMailById(mailId) != null) {
this.mail.set(mailId, message);
return true;
} else {
return false;
}
}
public void interactWith(int gadgetEntityId) {
GenshinEntity entity = getScene().getEntityById(gadgetEntityId);

View File

@@ -55,6 +55,10 @@ public class Mail {
this.stateValue = state;
}
public int getId() {
return this._id;
}
@Entity
public static class MailContent {
public String title;