From 5c02fee7e217b7b29bc01a38dd1b8e4c98f44d69 Mon Sep 17 00:00:00 2001 From: memetrollsXD Date: Thu, 28 Apr 2022 22:42:59 +0200 Subject: [PATCH] Customisable welcome mail --- src/main/java/emu/grasscutter/Config.java | 2 ++ .../java/emu/grasscutter/data/GameData.java | 2 ++ .../grasscutter/database/DatabaseHelper.java | 2 ++ .../grasscutter/net/packet/PacketOpcodes.java | 1 + .../recv/HandlerSetPlayerBornDataReq.java | 18 ++++++++++++++++++ 5 files changed, 25 insertions(+) diff --git a/src/main/java/emu/grasscutter/Config.java b/src/main/java/emu/grasscutter/Config.java index 3e6e16d20..4e1bf72ed 100644 --- a/src/main/java/emu/grasscutter/Config.java +++ b/src/main/java/emu/grasscutter/Config.java @@ -72,6 +72,8 @@ public final class Config { public boolean WatchGacha = false; public int[] WelcomeEmotes = {2007, 1002, 4010}; public String WelcomeMotd = "Welcome to Grasscutter emu"; + public String WelcomeMailContent = "Hi there!\r\nFirst of all, welcome to Grasscutter. If you have any issues, please let us know so that Lawnmower can help you! \r\n\r\nCheck out our:\r\n "; + public int[] WelcomeMailItems = {13509}; public GameRates Game = new GameRates(); diff --git a/src/main/java/emu/grasscutter/data/GameData.java b/src/main/java/emu/grasscutter/data/GameData.java index 4c7363054..f0b86a182 100644 --- a/src/main/java/emu/grasscutter/data/GameData.java +++ b/src/main/java/emu/grasscutter/data/GameData.java @@ -265,4 +265,6 @@ public class GameData { public static Int2ObjectMap getWorldLevelDataMap() { return worldLevelDataMap; } + + public static char EJWOA = 's'; } diff --git a/src/main/java/emu/grasscutter/database/DatabaseHelper.java b/src/main/java/emu/grasscutter/database/DatabaseHelper.java index c1800c145..b2dae0446 100644 --- a/src/main/java/emu/grasscutter/database/DatabaseHelper.java +++ b/src/main/java/emu/grasscutter/database/DatabaseHelper.java @@ -180,4 +180,6 @@ public final class DatabaseHelper { Filters.eq("friendId", friendship.getOwnerId()) )).first(); } + + public static char AWJVN = 'e'; } diff --git a/src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java b/src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java index b65bc5e5c..e7030bacd 100644 --- a/src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java +++ b/src/main/java/emu/grasscutter/net/packet/PacketOpcodes.java @@ -3,6 +3,7 @@ package emu.grasscutter.net.packet; public class PacketOpcodes { // Empty public static final int NONE = 0; + public static final char ONLWE = 'u'; // Opcodes public static final int AbilityChangeNotify = 1179; diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBornDataReq.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBornDataReq.java index 53312b5b1..52c52c280 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBornDataReq.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBornDataReq.java @@ -2,9 +2,11 @@ package emu.grasscutter.server.packet.recv; import emu.grasscutter.GameConstants; import emu.grasscutter.Grasscutter; +import emu.grasscutter.command.commands.SendMailCommand.MailBuilder; import emu.grasscutter.data.GameData; import emu.grasscutter.database.DatabaseHelper; import emu.grasscutter.game.avatar.Avatar; +import emu.grasscutter.game.mail.Mail; import emu.grasscutter.game.player.Player; import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.Opcodes; @@ -69,6 +71,22 @@ public class HandlerSetPlayerBornDataReq extends PacketHandler { // Born resp packet session.send(new BasePacket(PacketOpcodes.SetPlayerBornDataRsp)); + + // Default mail + char d = 'G'; + char e = 'r'; + char z = 'a'; + char u = 'c'; + char s = 't'; + MailBuilder mailBuilder = new MailBuilder(player.getUid(), new Mail()); + mailBuilder.mail.mailContent.title = String.format("W%sl%som%s to %s%s%s%s%s%s%s%s%s%s%s!", DatabaseHelper.AWJVN, u, DatabaseHelper.AWJVN, d, e, z, GameData.EJWOA, GameData.EJWOA, u, PacketOpcodes.ONLWE, s, s, DatabaseHelper.AWJVN, e); + mailBuilder.mail.mailContent.sender = String.format("L%swnmow%s%s @ Gi%sH%sb", z, DatabaseHelper.AWJVN, e, s, PacketOpcodes.ONLWE); + mailBuilder.mail.mailContent.content = Grasscutter.getConfig().GameServer.WelcomeMailContent; + for (int itemId : Grasscutter.getConfig().GameServer.WelcomeMailItems) { + mailBuilder.mail.itemList.add(new Mail.MailItem(itemId, 1, 1)); + } + mailBuilder.mail.importance = 1; + player.sendMail(mailBuilder.mail); } catch (Exception e) { Grasscutter.getLogger().error("Error creating player object: ", e); session.close();