mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-13 05:44:36 +01:00
Send welcome mail on player creation
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package emu.lunarcore;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import emu.lunarcore.data.common.ItemParam;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@@ -91,6 +93,7 @@ public class Config {
|
||||
public int staminaReserveRecoveryRate = 18 * 60;
|
||||
public String language = "EN";
|
||||
public Set<String> defaultPermissions = Set.of("*");
|
||||
public WelcomeMail welcomeMail = new WelcomeMail();
|
||||
|
||||
public int getStaminaRecoveryRate() {
|
||||
return staminaRecoveryRate > 0 ? staminaRecoveryRate : 1;
|
||||
@@ -101,6 +104,27 @@ public class Config {
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class WelcomeMail {
|
||||
public String title;
|
||||
public String sender;
|
||||
public String content;
|
||||
public List<ItemParam> attachments;
|
||||
|
||||
public WelcomeMail() {
|
||||
this.title = "Welcome to a LunarCore server";
|
||||
this.sender = "Server";
|
||||
this.content = "Welcome to Lunar Core! Please take these items as a starter gift. For a list of commands, type /help in the server chat window. <a type=OpenURL1 href=https://discord.gg/cfPKJ6N5hw>Check out our Discord for more information about the server.</a>";
|
||||
this.attachments = List.of(
|
||||
new ItemParam(2, 1000000),
|
||||
new ItemParam(101, 100),
|
||||
new ItemParam(102, 100),
|
||||
new ItemParam(1001, 1),
|
||||
new ItemParam(1002, 1)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class LogOptions {
|
||||
public boolean commands = true;
|
||||
|
||||
@@ -13,7 +13,7 @@ public class ItemParam {
|
||||
@SerializedName(value = "count", alternate = {"ItemCount", "ItemNum"})
|
||||
private int count;
|
||||
|
||||
private ItemParamType type = ItemParamType.PILE;
|
||||
private transient ItemParamType type = ItemParamType.PILE;
|
||||
|
||||
public ItemParam() {
|
||||
// Gson
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import emu.lunarcore.LunarCore;
|
||||
import emu.lunarcore.data.common.ItemParam;
|
||||
import emu.lunarcore.game.inventory.GameItem;
|
||||
import emu.lunarcore.game.player.BasePlayerManager;
|
||||
import emu.lunarcore.game.player.Player;
|
||||
@@ -116,6 +117,19 @@ public class Mailbox extends BasePlayerManager implements Iterable<Mail> {
|
||||
return deleteList;
|
||||
}
|
||||
|
||||
public void sendWelcomeMail() {
|
||||
var welcomeMail = LunarCore.getConfig().getServerOptions().welcomeMail;
|
||||
if (welcomeMail == null) return;
|
||||
|
||||
Mail mail = new Mail(welcomeMail.getTitle(), welcomeMail.getSender(), welcomeMail.getContent());
|
||||
|
||||
for (ItemParam param : welcomeMail.getAttachments()) {
|
||||
mail.addAttachment(new GameItem(param.getId(), param.getCount()));
|
||||
}
|
||||
|
||||
this.sendMail(mail);
|
||||
}
|
||||
|
||||
// Internal method to put mail into the hash map
|
||||
private void putMail(Mail mail) {
|
||||
mail.setUniqueId(this.getNextMailId());
|
||||
|
||||
@@ -169,6 +169,9 @@ public class Player {
|
||||
this.addAvatar(avatar);
|
||||
this.getCurrentLineup().getAvatars().add(avatar.getAvatarId());
|
||||
this.getCurrentLineup().save();
|
||||
|
||||
// Welcome mail
|
||||
this.getMailbox().sendWelcomeMail();
|
||||
}
|
||||
|
||||
public GameServer getServer() {
|
||||
|
||||
Reference in New Issue
Block a user