Commit d32f706c authored by KingRainbow44's avatar KingRainbow44
Browse files

Merge branch 'development' into api

# Conflicts:
#	src/main/java/emu/grasscutter/plugin/api/ServerHook.java
parents 47d8fd3c f0d728b4
...@@ -3,12 +3,13 @@ package emu.grasscutter.server.packet.send; ...@@ -3,12 +3,13 @@ package emu.grasscutter.server.packet.send;
import java.util.List; import java.util.List;
import emu.grasscutter.game.gacha.GachaBanner; import emu.grasscutter.game.gacha.GachaBanner;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.DoGachaRspOuterClass.DoGachaRsp; import emu.grasscutter.net.proto.DoGachaRspOuterClass.DoGachaRsp;
import emu.grasscutter.net.proto.GachaItemOuterClass.GachaItem; import emu.grasscutter.net.proto.GachaItemOuterClass.GachaItem;
import emu.grasscutter.net.proto.RetcodeOuterClass;
public class PacketDoGachaRsp extends GenshinPacket { public class PacketDoGachaRsp extends BasePacket {
public PacketDoGachaRsp(GachaBanner banner, List<GachaItem> list) { public PacketDoGachaRsp(GachaBanner banner, List<GachaItem> list) {
super(PacketOpcodes.DoGachaRsp); super(PacketOpcodes.DoGachaRsp);
...@@ -33,7 +34,7 @@ public class PacketDoGachaRsp extends GenshinPacket { ...@@ -33,7 +34,7 @@ public class PacketDoGachaRsp extends GenshinPacket {
super(PacketOpcodes.DoGachaRsp); super(PacketOpcodes.DoGachaRsp);
DoGachaRsp p = DoGachaRsp.newBuilder() DoGachaRsp p = DoGachaRsp.newBuilder()
.setRetcode(1) .setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE)
.build(); .build();
this.setData(p); this.setData(p);
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.EnterSceneDoneRspOuterClass.EnterSceneDoneRsp; import emu.grasscutter.net.proto.EnterSceneDoneRspOuterClass.EnterSceneDoneRsp;
public class PacketEnterSceneDoneRsp extends GenshinPacket { public class PacketEnterSceneDoneRsp extends BasePacket {
public PacketEnterSceneDoneRsp(GenshinPlayer player) { public PacketEnterSceneDoneRsp(Player player) {
super(PacketOpcodes.EnterSceneDoneRsp); super(PacketOpcodes.EnterSceneDoneRsp);
EnterSceneDoneRsp p = EnterSceneDoneRsp.newBuilder() EnterSceneDoneRsp p = EnterSceneDoneRsp.newBuilder()
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.EnterScenePeerNotifyOuterClass.EnterScenePeerNotify; import emu.grasscutter.net.proto.EnterScenePeerNotifyOuterClass.EnterScenePeerNotify;
public class PacketEnterScenePeerNotify extends GenshinPacket { public class PacketEnterScenePeerNotify extends BasePacket {
public PacketEnterScenePeerNotify(GenshinPlayer player) { public PacketEnterScenePeerNotify(Player player) {
super(PacketOpcodes.EnterScenePeerNotify); super(PacketOpcodes.EnterScenePeerNotify);
EnterScenePeerNotify proto = EnterScenePeerNotify.newBuilder() EnterScenePeerNotify proto = EnterScenePeerNotify.newBuilder()
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.EnterSceneReadyRspOuterClass.EnterSceneReadyRsp; import emu.grasscutter.net.proto.EnterSceneReadyRspOuterClass.EnterSceneReadyRsp;
public class PacketEnterSceneReadyRsp extends GenshinPacket { public class PacketEnterSceneReadyRsp extends BasePacket {
public PacketEnterSceneReadyRsp(GenshinPlayer player) { public PacketEnterSceneReadyRsp(Player player) {
super(PacketOpcodes.EnterSceneReadyRsp, 11); super(PacketOpcodes.EnterSceneReadyRsp, 11);
EnterSceneReadyRsp p = EnterSceneReadyRsp.newBuilder() EnterSceneReadyRsp p = EnterSceneReadyRsp.newBuilder()
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.EnterWorldAreaReqOuterClass.EnterWorldAreaReq; import emu.grasscutter.net.proto.EnterWorldAreaReqOuterClass.EnterWorldAreaReq;
import emu.grasscutter.net.proto.EnterWorldAreaRspOuterClass.EnterWorldAreaRsp; import emu.grasscutter.net.proto.EnterWorldAreaRspOuterClass.EnterWorldAreaRsp;
public class PacketEnterWorldAreaRsp extends GenshinPacket { public class PacketEnterWorldAreaRsp extends BasePacket {
public PacketEnterWorldAreaRsp(int clientSequence, EnterWorldAreaReq enterWorld) { public PacketEnterWorldAreaRsp(int clientSequence, EnterWorldAreaReq enterWorld) {
super(PacketOpcodes.EnterWorldAreaRsp, clientSequence); super(PacketOpcodes.EnterWorldAreaRsp, clientSequence);
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AiSyncInfoOuterClass.AiSyncInfo; import emu.grasscutter.net.proto.AiSyncInfoOuterClass.AiSyncInfo;
import emu.grasscutter.net.proto.EntityAiSyncNotifyOuterClass.EntityAiSyncNotify; import emu.grasscutter.net.proto.EntityAiSyncNotifyOuterClass.EntityAiSyncNotify;
public class PacketEntityAiSyncNotify extends GenshinPacket { public class PacketEntityAiSyncNotify extends BasePacket {
public PacketEntityAiSyncNotify(EntityAiSyncNotify notify) { public PacketEntityAiSyncNotify(EntityAiSyncNotify notify) {
super(PacketOpcodes.EntityAiSyncNotify, true); super(PacketOpcodes.EntityAiSyncNotify, true);
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.entity.GenshinEntity; import emu.grasscutter.game.entity.GameEntity;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.EntityFightPropUpdateNotifyOuterClass.EntityFightPropUpdateNotify; import emu.grasscutter.net.proto.EntityFightPropUpdateNotifyOuterClass.EntityFightPropUpdateNotify;
public class PacketEntityFightPropUpdateNotify extends GenshinPacket { public class PacketEntityFightPropUpdateNotify extends BasePacket {
public PacketEntityFightPropUpdateNotify(GenshinEntity entity, FightProperty prop) { public PacketEntityFightPropUpdateNotify(GameEntity entity, FightProperty prop) {
super(PacketOpcodes.EntityFightPropUpdateNotify); super(PacketOpcodes.EntityFightPropUpdateNotify);
EntityFightPropUpdateNotify proto = EntityFightPropUpdateNotify.newBuilder() EntityFightPropUpdateNotify proto = EntityFightPropUpdateNotify.newBuilder()
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify; import emu.grasscutter.net.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify;
public class PacketEvtAvatarSitDownNotify extends GenshinPacket { public class PacketEvtAvatarSitDownNotify extends BasePacket {
public PacketEvtAvatarSitDownNotify(EvtAvatarSitDownNotify notify) { public PacketEvtAvatarSitDownNotify(EvtAvatarSitDownNotify notify) {
super(PacketOpcodes.EvtAvatarSitDownNotify); super(PacketOpcodes.EvtAvatarSitDownNotify);
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.entity.EntityGadget; import emu.grasscutter.game.entity.EntityGadget;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GadgetInteractRspOuterClass.GadgetInteractRsp; import emu.grasscutter.net.proto.GadgetInteractRspOuterClass.GadgetInteractRsp;
import emu.grasscutter.net.proto.InteractTypeOuterClass.InteractType; import emu.grasscutter.net.proto.InteractTypeOuterClass.InteractType;
import emu.grasscutter.net.proto.RetcodeOuterClass;
public class PacketGadgetInteractRsp extends GenshinPacket { public class PacketGadgetInteractRsp extends BasePacket {
public PacketGadgetInteractRsp(EntityGadget gadget, InteractType interact) { public PacketGadgetInteractRsp(EntityGadget gadget, InteractType interact) {
super(PacketOpcodes.GadgetInteractRsp); super(PacketOpcodes.GadgetInteractRsp);
...@@ -23,7 +24,7 @@ public class PacketGadgetInteractRsp extends GenshinPacket { ...@@ -23,7 +24,7 @@ public class PacketGadgetInteractRsp extends GenshinPacket {
super(PacketOpcodes.GadgetInteractRsp); super(PacketOpcodes.GadgetInteractRsp);
GadgetInteractRsp proto = GadgetInteractRsp.newBuilder() GadgetInteractRsp proto = GadgetInteractRsp.newBuilder()
.setRetcode(1) .setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE)
.build(); .build();
this.setData(proto); this.setData(proto);
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GetActivityInfoRspOuterClass.GetActivityInfoRsp; import emu.grasscutter.net.proto.GetActivityInfoRspOuterClass.GetActivityInfoRsp;
public class PacketGetActivityInfoRsp extends GenshinPacket { public class PacketGetActivityInfoRsp extends BasePacket {
public PacketGetActivityInfoRsp() { public PacketGetActivityInfoRsp() {
super(PacketOpcodes.GetActivityInfoRsp); super(PacketOpcodes.GetActivityInfoRsp);
......
package emu.grasscutter.server.packet.send;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.mail.Mail;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GetAllMailRspOuterClass.GetAllMailRsp;
import emu.grasscutter.net.proto.ItemParamOuterClass;
import emu.grasscutter.net.proto.MailDataOuterClass;
import emu.grasscutter.net.proto.MailDataOuterClass.MailData;
import emu.grasscutter.net.proto.MailItemOuterClass;
import emu.grasscutter.net.proto.MailTextContentOuterClass.MailTextContent;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
public class PacketGetAllMailRsp extends BasePacket {
public PacketGetAllMailRsp(Player player, boolean isGiftMail) {
super(PacketOpcodes.GetAllMailRsp);
GetAllMailRsp.Builder proto = GetAllMailRsp.newBuilder();
if (isGiftMail) {
proto.setIsGiftMail(true);
} else {
proto.setIsGiftMail(false);
if (player.getAllMail().size() != 0) { // Make sure the player has mail
List<MailData> mailDataList = new ArrayList<MailData>();
for (Mail message : player.getAllMail()) {
if(message.stateValue == 1) { // Make sure it isn't a gift
if (message.expireTime > (int) Instant.now().getEpochSecond()) { // Make sure the message isn't expired (The game won't show expired mail, but I don't want to send unnecessary information).
if(mailDataList.size() <= 1000) { // Make sure that there isn't over 1000 messages in the mailbox. (idk what will happen if there is but the game probably won't like it.)
MailTextContent.Builder mailTextContent = MailTextContent.newBuilder();
mailTextContent.setTitle(message.mailContent.title);
mailTextContent.setContent(message.mailContent.content);
mailTextContent.setSender(message.mailContent.sender);
List<MailItemOuterClass.MailItem> mailItems = new ArrayList<>();
for (Mail.MailItem item : message.itemList) {
MailItemOuterClass.MailItem.Builder mailItem = MailItemOuterClass.MailItem.newBuilder();
ItemParamOuterClass.ItemParam.Builder itemParam = ItemParamOuterClass.ItemParam.newBuilder();
itemParam.setItemId(item.itemId);
itemParam.setCount(item.itemCount);
mailItem.setItemParam(itemParam.build());
mailItems.add(mailItem.build());
}
MailDataOuterClass.MailData.Builder mailData = MailDataOuterClass.MailData.newBuilder();
mailData.setMailId(player.getMailId(message));
mailData.setMailTextContent(mailTextContent.build());
mailData.addAllItemList(mailItems);
mailData.setSendTime((int) message.sendTime);
mailData.setExpireTime((int) message.expireTime);
mailData.setImportance(message.importance);
mailData.setIsRead(message.isRead);
mailData.setIsAttachmentGot(message.isAttachmentGot);
mailData.setStateValue(1);
mailDataList.add(mailData.build());
}
}
}
}
proto.addAllMailList(mailDataList);
proto.setIsTruncated(mailDataList.size() <= 1000 ? false : true); // When enabled this will send a notification to the user telling them their inbox is full and they should delete old messages when opening the mailbox.
}
}
this.setData(proto.build());
}
}
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GetAllUnlockNameCardRspOuterClass.GetAllUnlockNameCardRsp; import emu.grasscutter.net.proto.GetAllUnlockNameCardRspOuterClass.GetAllUnlockNameCardRsp;
public class PacketGetAllUnlockNameCardRsp extends GenshinPacket { public class PacketGetAllUnlockNameCardRsp extends BasePacket {
public PacketGetAllUnlockNameCardRsp(GenshinPlayer player) { public PacketGetAllUnlockNameCardRsp(Player player) {
super(PacketOpcodes.GetAllUnlockNameCardRsp); super(PacketOpcodes.GetAllUnlockNameCardRsp);
GetAllUnlockNameCardRsp proto = GetAllUnlockNameCardRsp.newBuilder() GetAllUnlockNameCardRsp proto = GetAllUnlockNameCardRsp.newBuilder()
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GetAuthkeyRspOuterClass.GetAuthkeyRsp; import emu.grasscutter.net.proto.GetAuthkeyRspOuterClass.GetAuthkeyRsp;
import emu.grasscutter.net.proto.RetcodeOuterClass;
public class PacketGetAuthkeyRsp extends GenshinPacket { public class PacketGetAuthkeyRsp extends BasePacket {
public PacketGetAuthkeyRsp() { public PacketGetAuthkeyRsp() {
super(PacketOpcodes.GetAuthkeyRsp); super(PacketOpcodes.GetAuthkeyRsp);
GetAuthkeyRsp proto = GetAuthkeyRsp.newBuilder().setRetcode(1).build(); GetAuthkeyRsp proto = GetAuthkeyRsp.newBuilder().setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE).build();
this.setData(proto); this.setData(proto);
} }
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.gacha.GachaManager; import emu.grasscutter.game.gacha.GachaManager;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
public class PacketGetGachaInfoRsp extends GenshinPacket { public class PacketGetGachaInfoRsp extends BasePacket {
public PacketGetGachaInfoRsp(GachaManager manager) { public PacketGetGachaInfoRsp(GachaManager manager) {
super(PacketOpcodes.GetGachaInfoRsp); super(PacketOpcodes.GetGachaInfoRsp);
......
package emu.grasscutter.server.packet.send;
import emu.grasscutter.data.GameData;
import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.mail.Mail;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.props.ActionReason;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.EquipParamOuterClass;
import emu.grasscutter.net.proto.GetMailItemRspOuterClass.GetMailItemRsp;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public class PacketGetMailItemRsp extends BasePacket {
public PacketGetMailItemRsp(Player player, List<Integer> mailList) {
super(PacketOpcodes.GetMailItemRsp);
List<Mail> claimedMessages = new ArrayList<>();
List<EquipParamOuterClass.EquipParam> claimedItems = new ArrayList<>();
GetMailItemRsp.Builder proto = GetMailItemRsp.newBuilder();
for (int mailId : mailList) {
Mail message = player.getMail(mailId);
for(Mail.MailItem mailItem : message.itemList) {
EquipParamOuterClass.EquipParam.Builder item = EquipParamOuterClass.EquipParam.newBuilder();
int promoteLevel = 0;
if (mailItem.itemLevel > 20) { // 20/40
promoteLevel = 1;
} else if (mailItem.itemLevel > 40) { // 40/50
promoteLevel = 2;
} else if (mailItem.itemLevel > 50) { // 50/60
promoteLevel = 3;
} else if (mailItem.itemLevel > 60) { // 60/70
promoteLevel = 4;
} else if (mailItem.itemLevel > 70) { // 70/80
promoteLevel = 5;
} else if (mailItem.itemLevel > 80) { // 80/90
promoteLevel = 6;
}
item.setItemId(mailItem.itemId);
item.setItemNum(mailItem.itemCount);
item.setItemLevel(mailItem.itemLevel);
item.setPromoteLevel(promoteLevel);
claimedItems.add(item.build());
GameItem gameItem = new GameItem(GameData.getItemDataMap().get(mailItem.itemId));
gameItem.setCount(mailItem.itemCount);
gameItem.setLevel(mailItem.itemLevel);
gameItem.setPromoteLevel(promoteLevel);
player.getInventory().addItem(gameItem, ActionReason.MailAttachment);
}
message.isAttachmentGot = true;
claimedMessages.add(message);
player.replaceMailByIndex(mailId, message);
}
proto.addAllMailIdList(claimedMessages.stream().map(message -> player.getMailId(message)).collect(Collectors.toList()));
proto.addAllItemList(claimedItems);
this.setData(proto.build());
player.getSession().send(new PacketMailChangeNotify(player, claimedMessages)); // For some reason you have to also send the MailChangeNotify packet
}
}
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.friends.Friendship; import emu.grasscutter.game.friends.Friendship;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GetPlayerAskFriendListRspOuterClass.GetPlayerAskFriendListRsp; import emu.grasscutter.net.proto.GetPlayerAskFriendListRspOuterClass.GetPlayerAskFriendListRsp;
public class PacketGetPlayerAskFriendListRsp extends GenshinPacket { public class PacketGetPlayerAskFriendListRsp extends BasePacket {
public PacketGetPlayerAskFriendListRsp(GenshinPlayer player) { public PacketGetPlayerAskFriendListRsp(Player player) {
super(PacketOpcodes.GetPlayerAskFriendListRsp); super(PacketOpcodes.GetPlayerAskFriendListRsp);
GetPlayerAskFriendListRsp.Builder proto = GetPlayerAskFriendListRsp.newBuilder(); GetPlayerAskFriendListRsp.Builder proto = GetPlayerAskFriendListRsp.newBuilder();
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.GenshinConstants; import emu.grasscutter.GameConstants;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.friends.Friendship; import emu.grasscutter.game.friends.Friendship;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.FriendBriefOuterClass.FriendBrief; import emu.grasscutter.net.proto.FriendBriefOuterClass.FriendBrief;
import emu.grasscutter.net.proto.FriendOnlineStateOuterClass.FriendOnlineState; import emu.grasscutter.net.proto.FriendOnlineStateOuterClass.FriendOnlineState;
import emu.grasscutter.net.proto.GetPlayerFriendListRspOuterClass.GetPlayerFriendListRsp; import emu.grasscutter.net.proto.GetPlayerFriendListRspOuterClass.GetPlayerFriendListRsp;
import emu.grasscutter.net.proto.HeadImageOuterClass.HeadImage; import emu.grasscutter.net.proto.HeadImageOuterClass.HeadImage;
import emu.grasscutter.net.proto.PlatformTypeOuterClass;
public class PacketGetPlayerFriendListRsp extends GenshinPacket { public class PacketGetPlayerFriendListRsp extends BasePacket {
public PacketGetPlayerFriendListRsp(GenshinPlayer player) { public PacketGetPlayerFriendListRsp(Player player) {
super(PacketOpcodes.GetPlayerFriendListRsp); super(PacketOpcodes.GetPlayerFriendListRsp);
FriendBrief serverFriend = FriendBrief.newBuilder() FriendBrief serverFriend = FriendBrief.newBuilder()
.setUid(GenshinConstants.SERVER_CONSOLE_UID) .setUid(GameConstants.SERVER_CONSOLE_UID)
.setNickname("Server") .setNickname("Server")
.setLevel(1) .setLevel(1)
.setAvatar(HeadImage.newBuilder().setAvatarId(GenshinConstants.MAIN_CHARACTER_FEMALE)) .setAvatarId(HeadImage.newBuilder().setAvatarId(GameConstants.MAIN_CHARACTER_FEMALE).getAvatarId())
.setWorldLevel(0) .setWorldLevel(0)
.setSignature("") .setSignature("")
.setLastActiveTime((int) (System.currentTimeMillis() / 1000f)) .setLastActiveTime((int) (System.currentTimeMillis() / 1000f))
.setNameCardId(210001) .setNameCardId(210001)
.setOnlineState(FriendOnlineState.FRIEND_ONLINE) .setOnlineState(FriendOnlineState.FRIEND_ONLINE)
.setParam(1) .setParam(1)
.setUnk1(1) .setIsGameSource(true)
.setUnk2(3) .setPlatformType(PlatformTypeOuterClass.PlatformType.PC)
.build(); .build();
GetPlayerFriendListRsp.Builder proto = GetPlayerFriendListRsp.newBuilder().addFriendList(serverFriend); GetPlayerFriendListRsp.Builder proto = GetPlayerFriendListRsp.newBuilder().addFriendList(serverFriend);
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GetPlayerSocialDetailRspOuterClass.GetPlayerSocialDetailRsp; import emu.grasscutter.net.proto.GetPlayerSocialDetailRspOuterClass.GetPlayerSocialDetailRsp;
import emu.grasscutter.net.proto.RetcodeOuterClass;
import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail; import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail;
public class PacketGetPlayerSocialDetailRsp extends GenshinPacket { public class PacketGetPlayerSocialDetailRsp extends BasePacket {
public PacketGetPlayerSocialDetailRsp(SocialDetail.Builder detail) { public PacketGetPlayerSocialDetailRsp(SocialDetail.Builder detail) {
super(PacketOpcodes.GetPlayerSocialDetailRsp); super(PacketOpcodes.GetPlayerSocialDetailRsp);
...@@ -15,7 +16,7 @@ public class PacketGetPlayerSocialDetailRsp extends GenshinPacket { ...@@ -15,7 +16,7 @@ public class PacketGetPlayerSocialDetailRsp extends GenshinPacket {
if (detail != null) { if (detail != null) {
proto.setDetailData(detail); proto.setDetailData(detail);
} else { } else {
proto.setRetcode(1); proto.setRetcode(RetcodeOuterClass.Retcode.RET_SVR_ERROR_VALUE);
} }
this.setData(proto); this.setData(proto);
......
...@@ -2,13 +2,13 @@ package emu.grasscutter.server.packet.send; ...@@ -2,13 +2,13 @@ package emu.grasscutter.server.packet.send;
import com.google.protobuf.ByteString; import com.google.protobuf.ByteString;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GetPlayerTokenRspOuterClass.GetPlayerTokenRsp; import emu.grasscutter.net.proto.GetPlayerTokenRspOuterClass.GetPlayerTokenRsp;
import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.utils.Crypto; import emu.grasscutter.utils.Crypto;
public class PacketGetPlayerTokenRsp extends GenshinPacket { public class PacketGetPlayerTokenRsp extends BasePacket {
public PacketGetPlayerTokenRsp(GameSession session, boolean doesPlayerExist) { public PacketGetPlayerTokenRsp(GameSession session, boolean doesPlayerExist) {
super(PacketOpcodes.GetPlayerTokenRsp, true); super(PacketOpcodes.GetPlayerTokenRsp, true);
...@@ -16,18 +16,18 @@ public class PacketGetPlayerTokenRsp extends GenshinPacket { ...@@ -16,18 +16,18 @@ public class PacketGetPlayerTokenRsp extends GenshinPacket {
this.setUseDispatchKey(true); this.setUseDispatchKey(true);
GetPlayerTokenRsp p = GetPlayerTokenRsp.newBuilder() GetPlayerTokenRsp p = GetPlayerTokenRsp.newBuilder()
.setPlayerUid(session.getAccount().getPlayerUid()) .setUid(session.getAccount().getPlayerUid())
.setAccountToken(session.getAccount().getToken()) .setToken(session.getAccount().getToken())
.setAccountType(1) .setAccountType(1)
.setIsProficientPlayer(doesPlayerExist) // Not sure where this goes .setIsProficientPlayer(doesPlayerExist) // Not sure where this goes
.setSecretKey(Crypto.ENCRYPT_SEED) .setSecretKeySeed(Crypto.ENCRYPT_SEED)
.setSecretKeyBuffer(ByteString.copyFrom(Crypto.ENCRYPT_SEED_BUFFER)) .setSecurityCmdBuffer(ByteString.copyFrom(Crypto.ENCRYPT_SEED_BUFFER))
.setPlatformType(3) .setPlatformType(3)
.setChannelId(1) .setChannelId(1)
.setCountryCode("US") .setCountryCode("US")
.setUnk1("c25-314dd05b0b5f") .setClientVersionRandomKey("c25-314dd05b0b5f")
.setUnk3(3) .setRegPlatform(3)
.setClientIp(session.getAddress().getAddress().getHostAddress()) .setClientIpStr(session.getAddress().getAddress().getHostAddress())
.build(); .build();
this.setData(p.toByteArray()); this.setData(p.toByteArray());
......
...@@ -3,12 +3,12 @@ package emu.grasscutter.server.packet.send; ...@@ -3,12 +3,12 @@ package emu.grasscutter.server.packet.send;
import java.util.Arrays; import java.util.Arrays;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import emu.grasscutter.net.packet.GenshinPacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.CityInfoOuterClass.CityInfo; import emu.grasscutter.net.proto.CityInfoOuterClass.CityInfo;
import emu.grasscutter.net.proto.GetSceneAreaRspOuterClass.GetSceneAreaRsp; import emu.grasscutter.net.proto.GetSceneAreaRspOuterClass.GetSceneAreaRsp;
public class PacketGetSceneAreaRsp extends GenshinPacket { public class PacketGetSceneAreaRsp extends BasePacket {
public PacketGetSceneAreaRsp(int sceneId) { public PacketGetSceneAreaRsp(int sceneId) {
super(PacketOpcodes.GetSceneAreaRsp); super(PacketOpcodes.GetSceneAreaRsp);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment