mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-24 05:49:12 +00:00
GenshinPlayer fix (for two issues) and updated sendmail with Magix's suggestions
This commit is contained in:
parent
63d0db376a
commit
e4899034b2
@ -37,16 +37,15 @@ public class SendMailCommand implements CommandHandler {
|
|||||||
|
|
||||||
if (!mailBeingConstructed.containsKey(senderId)) {
|
if (!mailBeingConstructed.containsKey(senderId)) {
|
||||||
switch (args.size()) {
|
switch (args.size()) {
|
||||||
case 1:
|
case 1 -> {
|
||||||
MailBuilder mailBuilder;
|
MailBuilder mailBuilder;
|
||||||
switch (args.get(0).toLowerCase()) {
|
switch (args.get(0).toLowerCase()) {
|
||||||
case "help":
|
case "help" -> {
|
||||||
CommandHandler.sendMessage(sender, this.getClass().getAnnotation(Command.class).description() + "\nUsage: " + this.getClass().getAnnotation(Command.class).usage());
|
CommandHandler.sendMessage(sender, this.getClass().getAnnotation(Command.class).description() + "\nUsage: " + this.getClass().getAnnotation(Command.class).usage());
|
||||||
return;
|
return;
|
||||||
case "all":
|
}
|
||||||
mailBuilder = new MailBuilder(true, new Mail());
|
case "all" -> mailBuilder = new MailBuilder(true, new Mail());
|
||||||
break;
|
default -> {
|
||||||
default:
|
|
||||||
if (DatabaseHelper.getPlayerById(Integer.parseInt(args.get(0))) != null) {
|
if (DatabaseHelper.getPlayerById(Integer.parseInt(args.get(0))) != null) {
|
||||||
mailBuilder = new MailBuilder(Integer.parseInt(args.get(0)), new Mail());
|
mailBuilder = new MailBuilder(Integer.parseInt(args.get(0)), new Mail());
|
||||||
break;
|
break;
|
||||||
@ -55,26 +54,24 @@ public class SendMailCommand implements CommandHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
mailBeingConstructed.put(senderId, mailBuilder);
|
mailBeingConstructed.put(senderId, mailBuilder);
|
||||||
CommandHandler.sendMessage(sender, "Starting composition of message.\nPlease use `/sendmail <title>` to continue.\nYou can use `/sendmail stop` at any time");
|
CommandHandler.sendMessage(sender, "Starting composition of message.\nPlease use `/sendmail <title>` to continue.\nYou can use `/sendmail stop` at any time");
|
||||||
break;
|
}
|
||||||
case 2:
|
case 2 -> CommandHandler.sendMessage(sender, "Mail templates coming soon implemented...");
|
||||||
CommandHandler.sendMessage(sender, "Mail templates coming soon implemented...");
|
default -> CommandHandler.sendMessage(sender, "Invalid arguments.\nUsage `/sendmail <userId|all|help> [templateId]`");
|
||||||
return;
|
|
||||||
default:
|
|
||||||
CommandHandler.sendMessage(sender, "Invalid arguments.\nUsage `/sendmail <userId|all|help> [templateId]`");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MailBuilder mailBuilder = mailBeingConstructed.get(senderId);
|
MailBuilder mailBuilder = mailBeingConstructed.get(senderId);
|
||||||
|
|
||||||
if (args.size() >= 1) {
|
if (args.size() >= 1) {
|
||||||
switch (args.get(0).toLowerCase()) {
|
switch (args.get(0).toLowerCase()) {
|
||||||
case "stop":
|
case "stop" -> {
|
||||||
mailBeingConstructed.remove(senderId);
|
mailBeingConstructed.remove(senderId);
|
||||||
CommandHandler.sendMessage(sender, "Message sending cancelled");
|
CommandHandler.sendMessage(sender, "Message sending cancelled");
|
||||||
return;
|
return;
|
||||||
case "finish":
|
}
|
||||||
|
case "finish" -> {
|
||||||
if (mailBuilder.constructionStage == 3) {
|
if (mailBuilder.constructionStage == 3) {
|
||||||
if (mailBuilder.sendToAll == false) {
|
if (mailBuilder.sendToAll == false) {
|
||||||
Grasscutter.getGameServer().getPlayerByUid(mailBuilder.recipient, true).sendMail(mailBuilder.mail);
|
Grasscutter.getGameServer().getPlayerByUid(mailBuilder.recipient, true).sendMail(mailBuilder.mail);
|
||||||
@ -90,37 +87,40 @@ public class SendMailCommand implements CommandHandler {
|
|||||||
CommandHandler.sendMessage(sender, "Message composition not at final stage.\nPlease use `/sendmail " + getConstructionArgs(mailBuilder.constructionStage) + "` or `/sendmail stop` to cancel");
|
CommandHandler.sendMessage(sender, "Message composition not at final stage.\nPlease use `/sendmail " + getConstructionArgs(mailBuilder.constructionStage) + "` or `/sendmail stop` to cancel");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case "help":
|
}
|
||||||
|
case "help" -> {
|
||||||
CommandHandler.sendMessage(sender, "Please use `/sendmail " + getConstructionArgs(mailBuilder.constructionStage) + "`");
|
CommandHandler.sendMessage(sender, "Please use `/sendmail " + getConstructionArgs(mailBuilder.constructionStage) + "`");
|
||||||
return;
|
return;
|
||||||
default:
|
}
|
||||||
|
default -> {
|
||||||
switch (mailBuilder.constructionStage) {
|
switch (mailBuilder.constructionStage) {
|
||||||
case 0:
|
case 0 -> {
|
||||||
String title = String.join(" ", args.subList(0, args.size()));
|
String title = String.join(" ", args.subList(0, args.size()));
|
||||||
mailBuilder.mail.mailContent.title = title;
|
mailBuilder.mail.mailContent.title = title;
|
||||||
CommandHandler.sendMessage(sender, "Message title set as '" + title + "'.\nUse '/sendmail <content>' to continue.");
|
CommandHandler.sendMessage(sender, "Message title set as '" + title + "'.\nUse '/sendmail <content>' to continue.");
|
||||||
mailBuilder.constructionStage++;
|
mailBuilder.constructionStage++;
|
||||||
break;
|
}
|
||||||
case 1:
|
case 1 -> {
|
||||||
String contents = String.join(" ", args.subList(0, args.size()));
|
String contents = String.join(" ", args.subList(0, args.size()));
|
||||||
mailBuilder.mail.mailContent.content = contents;
|
mailBuilder.mail.mailContent.content = contents;
|
||||||
CommandHandler.sendMessage(sender, "Message contents set as '" + contents + "'.\nUse '/sendmail <sender>' to continue.");
|
CommandHandler.sendMessage(sender, "Message contents set as '" + contents + "'.\nUse '/sendmail <sender>' to continue.");
|
||||||
mailBuilder.constructionStage++;
|
mailBuilder.constructionStage++;
|
||||||
break;
|
}
|
||||||
case 2:
|
case 2 -> {
|
||||||
String msgSender = String.join(" ", args.subList(0, args.size()));
|
String msgSender = String.join(" ", args.subList(0, args.size()));
|
||||||
mailBuilder.mail.mailContent.sender = msgSender;
|
mailBuilder.mail.mailContent.sender = msgSender;
|
||||||
CommandHandler.sendMessage(sender, "Message sender set as '" + msgSender + "'.\nUse '/sendmail <itemId|itemName|finish> [amount] [level]' to continue.");
|
CommandHandler.sendMessage(sender, "Message sender set as '" + msgSender + "'.\nUse '/sendmail <itemId|itemName|finish> [amount] [level]' to continue.");
|
||||||
mailBuilder.constructionStage++;
|
mailBuilder.constructionStage++;
|
||||||
break;
|
}
|
||||||
case 3:
|
case 3 -> {
|
||||||
// Literally just copy-pasted from the give command lol.
|
// Literally just copy-pasted from the give command lol.
|
||||||
int item, lvl, amount = 1;
|
int item, lvl, amount = 1;
|
||||||
switch (args.size()) {
|
switch (args.size()) {
|
||||||
default: // *No args*
|
default -> { // *No args*
|
||||||
CommandHandler.sendMessage(sender, "Usage: give [player] <itemId|itemName> [amount]");
|
CommandHandler.sendMessage(sender, "Usage: give [player] <itemId|itemName> [amount]");
|
||||||
return;
|
return;
|
||||||
case 1: // <itemId|itemName>
|
}
|
||||||
|
case 1 -> { // <itemId|itemName>
|
||||||
try {
|
try {
|
||||||
item = Integer.parseInt(args.get(0));
|
item = Integer.parseInt(args.get(0));
|
||||||
lvl = 1;
|
lvl = 1;
|
||||||
@ -129,13 +129,13 @@ public class SendMailCommand implements CommandHandler {
|
|||||||
CommandHandler.sendMessage(sender, "Invalid item id.");
|
CommandHandler.sendMessage(sender, "Invalid item id.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case 2: // <itemId|itemName> [amount]
|
case 2 -> { // <itemId|itemName> [amount]
|
||||||
lvl = 1;
|
lvl = 1;
|
||||||
item = Integer.parseInt(args.get(0));
|
item = Integer.parseInt(args.get(0));
|
||||||
amount = Integer.parseInt(args.get(1));
|
amount = Integer.parseInt(args.get(1));
|
||||||
break;
|
}
|
||||||
case 3: // <itemId|itemName> [amount] [level]
|
case 3 -> { // <itemId|itemName> [amount] [level]
|
||||||
try {
|
try {
|
||||||
item = Integer.parseInt(args.get(0));
|
item = Integer.parseInt(args.get(0));
|
||||||
amount = Integer.parseInt(args.get(1));
|
amount = Integer.parseInt(args.get(1));
|
||||||
@ -146,12 +146,13 @@ public class SendMailCommand implements CommandHandler {
|
|||||||
CommandHandler.sendMessage(sender, "Invalid item or player ID.");
|
CommandHandler.sendMessage(sender, "Invalid item or player ID.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
mailBuilder.mail.itemList.add(new Mail.MailItem(item, amount, lvl));
|
mailBuilder.mail.itemList.add(new Mail.MailItem(item, amount, lvl));
|
||||||
CommandHandler.sendMessage(sender, String.format("Attached %s of %s (level %s) to the message.\nContinue adding more items or use `/sendmail finish` to send the message.", amount, item, lvl));
|
CommandHandler.sendMessage(sender, String.format("Attached %s of %s (level %s) to the message.\nContinue adding more items or use `/sendmail finish` to send the message.", amount, item, lvl));
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CommandHandler.sendMessage(sender, "Invalid arguments \n Please use `/sendmail " + getConstructionArgs(mailBuilder.constructionStage));
|
CommandHandler.sendMessage(sender, "Invalid arguments \n Please use `/sendmail " + getConstructionArgs(mailBuilder.constructionStage));
|
||||||
@ -159,21 +160,27 @@ public class SendMailCommand implements CommandHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getConstructionArgs(int stage) {
|
private String getConstructionArgs(int stage) {
|
||||||
switch (stage) {
|
switch (stage) {
|
||||||
case 0:
|
case 0 -> {
|
||||||
return "<title>";
|
return "<title>";
|
||||||
case 1:
|
}
|
||||||
|
case 1 -> {
|
||||||
return "<message>";
|
return "<message>";
|
||||||
case 2:
|
}
|
||||||
|
case 2 -> {
|
||||||
return "<sender>";
|
return "<sender>";
|
||||||
case 3:
|
|
||||||
|
}
|
||||||
|
case 3 -> {
|
||||||
return "<itemId|itemName|finish> [amount] [level]";
|
return "<itemId|itemName|finish> [amount] [level]";
|
||||||
default:
|
}
|
||||||
|
default -> {
|
||||||
Thread.dumpStack();
|
Thread.dumpStack();
|
||||||
return "ERROR: invalid construction stage " + stage + ". Check console for stacktrace.";
|
return "ERROR: invalid construction stage " + stage + ". Check console for stacktrace.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class MailBuilder {
|
public static class MailBuilder {
|
||||||
public int recipient;
|
public int recipient;
|
||||||
|
@ -37,30 +37,7 @@ import emu.grasscutter.net.proto.PlayerWorldLocationInfoOuterClass;
|
|||||||
import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail;
|
import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail;
|
||||||
import emu.grasscutter.server.game.GameServer;
|
import emu.grasscutter.server.game.GameServer;
|
||||||
import emu.grasscutter.server.game.GameSession;
|
import emu.grasscutter.server.game.GameSession;
|
||||||
import emu.grasscutter.server.packet.send.PacketAbilityInvocationsNotify;
|
import emu.grasscutter.server.packet.send.*;
|
||||||
import emu.grasscutter.server.packet.send.PacketAvatarAddNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketAvatarDataNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketAvatarGainCostumeNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketAvatarGainFlycloakNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketClientAbilityInitFinishNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketCombatInvocationsNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketGadgetInteractRsp;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketItemAddHintNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketOpenStateUpdateNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketPlayerApplyEnterMpResultNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketPlayerDataNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketPlayerEnterSceneNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketPlayerPropNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketPlayerStoreNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketPrivateChatNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketScenePlayerLocationNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketPlayerLevelRewardUpdateNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketSetNameCardRsp;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketStoreWeightLimitNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketUnlockNameCardNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketWorldPlayerLocationNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketWorldPlayerRTTNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketMailChangeNotify;
|
|
||||||
import emu.grasscutter.utils.Position;
|
import emu.grasscutter.utils.Position;
|
||||||
import emu.grasscutter.utils.DateHelper;
|
import emu.grasscutter.utils.DateHelper;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
|
@ -4,11 +4,12 @@ import emu.grasscutter.game.GenshinPlayer;
|
|||||||
import emu.grasscutter.net.packet.GenshinPacket;
|
import emu.grasscutter.net.packet.GenshinPacket;
|
||||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
import emu.grasscutter.net.proto.PlayerApplyEnterMpReasonOuterClass.PlayerApplyEnterMpReason;
|
import emu.grasscutter.net.proto.PlayerApplyEnterMpReasonOuterClass.PlayerApplyEnterMpReason;
|
||||||
|
import emu.grasscutter.net.proto.PlayerApplyEnterMpResultNotifyOuterClass;
|
||||||
import emu.grasscutter.net.proto.PlayerApplyEnterMpResultNotifyOuterClass.PlayerApplyEnterMpResultNotify;
|
import emu.grasscutter.net.proto.PlayerApplyEnterMpResultNotifyOuterClass.PlayerApplyEnterMpResultNotify;
|
||||||
|
|
||||||
public class PacketPlayerApplyEnterMpResultNotify extends GenshinPacket {
|
public class PacketPlayerApplyEnterMpResultNotify extends GenshinPacket {
|
||||||
|
|
||||||
public PacketPlayerApplyEnterMpResultNotify(GenshinPlayer target, boolean isAgreed, PlayerApplyEnterMpResultNotify.Reason reason) {
|
public PacketPlayerApplyEnterMpResultNotify(GenshinPlayer target, boolean isAgreed, PlayerApplyEnterMpResultNotifyOuterClass.PlayerApplyEnterMpResultNotify.Reason reason) {
|
||||||
super(PacketOpcodes.PlayerApplyEnterMpResultNotify);
|
super(PacketOpcodes.PlayerApplyEnterMpResultNotify);
|
||||||
|
|
||||||
PlayerApplyEnterMpResultNotify proto = PlayerApplyEnterMpResultNotify.newBuilder()
|
PlayerApplyEnterMpResultNotify proto = PlayerApplyEnterMpResultNotify.newBuilder()
|
||||||
|
Loading…
Reference in New Issue
Block a user