Commit fa9d703d authored by BaiSugar's avatar BaiSugar Committed by GitHub
Browse files

Merge branch 'Grasscutters:development' into development

parents 6a5d97a3 d1fc8c1f
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.GenshinPlayer;
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.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);
EnterSceneReadyRsp p = EnterSceneReadyRsp.newBuilder()
......
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.proto.EnterWorldAreaReqOuterClass.EnterWorldAreaReq;
import emu.grasscutter.net.proto.EnterWorldAreaRspOuterClass.EnterWorldAreaRsp;
public class PacketEnterWorldAreaRsp extends GenshinPacket {
public class PacketEnterWorldAreaRsp extends BasePacket {
public PacketEnterWorldAreaRsp(int clientSequence, EnterWorldAreaReq enterWorld) {
super(PacketOpcodes.EnterWorldAreaRsp, clientSequence);
......
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.proto.AiSyncInfoOuterClass.AiSyncInfo;
import emu.grasscutter.net.proto.EntityAiSyncNotifyOuterClass.EntityAiSyncNotify;
public class PacketEntityAiSyncNotify extends GenshinPacket {
public class PacketEntityAiSyncNotify extends BasePacket {
public PacketEntityAiSyncNotify(EntityAiSyncNotify notify) {
super(PacketOpcodes.EntityAiSyncNotify, true);
......
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.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
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);
EntityFightPropUpdateNotify proto = EntityFightPropUpdateNotify.newBuilder()
......
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.proto.EvtAvatarSitDownNotifyOuterClass.EvtAvatarSitDownNotify;
public class PacketEvtAvatarSitDownNotify extends GenshinPacket {
public class PacketEvtAvatarSitDownNotify extends BasePacket {
public PacketEvtAvatarSitDownNotify(EvtAvatarSitDownNotify notify) {
super(PacketOpcodes.EvtAvatarSitDownNotify);
......
package emu.grasscutter.server.packet.send;
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.proto.GadgetInteractRspOuterClass.GadgetInteractRsp;
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) {
super(PacketOpcodes.GadgetInteractRsp);
......
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.proto.GetActivityInfoRspOuterClass.GetActivityInfoRsp;
public class PacketGetActivityInfoRsp extends GenshinPacket {
public class PacketGetActivityInfoRsp extends BasePacket {
public PacketGetActivityInfoRsp() {
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.Base64;
import java.util.List;
public class PacketGetAllMailRsp extends BasePacket {
public PacketGetAllMailRsp(Player player, boolean isGiftMail) {
super(PacketOpcodes.GetAllMailRsp);
if (isGiftMail) {
// TODO: Gift Mail
// Make sure to send the stupid empty packet
Base64.Decoder decoder = Base64.getDecoder();
byte[] rsp = decoder.decode("IAE=");
try {
GetAllMailRsp var = GetAllMailRsp.parseFrom(rsp);
this.setData(var.toBuilder().build());
} catch (Exception e) {
}
} else {
if (player.getAllMail().size() != 0) { // Make sure the player has mail
GetAllMailRsp.Builder proto = GetAllMailRsp.newBuilder();
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());
} else {
// Make sure to send the stupid empty packet
Base64.Decoder decoder = Base64.getDecoder();
byte[] rsp = decoder.decode("IAE=");
try {
GetAllMailRsp var = GetAllMailRsp.parseFrom(rsp);
this.setData(var.toBuilder().build());
} catch (Exception e) {}
}
}
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.GenshinPlayer;
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.proto.GetAllUnlockNameCardRspOuterClass.GetAllUnlockNameCardRsp;
public class PacketGetAllUnlockNameCardRsp extends GenshinPacket {
public class PacketGetAllUnlockNameCardRsp extends BasePacket {
public PacketGetAllUnlockNameCardRsp(GenshinPlayer player) {
public PacketGetAllUnlockNameCardRsp(Player player) {
super(PacketOpcodes.GetAllUnlockNameCardRsp);
GetAllUnlockNameCardRsp proto = GetAllUnlockNameCardRsp.newBuilder()
......
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.proto.GetAuthkeyRspOuterClass.GetAuthkeyRsp;
import emu.grasscutter.net.proto.RetcodeOuterClass;
public class PacketGetAuthkeyRsp extends GenshinPacket {
public class PacketGetAuthkeyRsp extends BasePacket {
public PacketGetAuthkeyRsp() {
super(PacketOpcodes.GetAuthkeyRsp);
......
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.gacha.GachaManager;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
public class PacketGetGachaInfoRsp extends GenshinPacket {
public class PacketGetGachaInfoRsp extends BasePacket {
public PacketGetGachaInfoRsp(GachaManager manager) {
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;
import emu.grasscutter.game.GenshinPlayer;
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.proto.GetPlayerAskFriendListRspOuterClass.GetPlayerAskFriendListRsp;
public class PacketGetPlayerAskFriendListRsp extends GenshinPacket {
public class PacketGetPlayerAskFriendListRsp extends BasePacket {
public PacketGetPlayerAskFriendListRsp(GenshinPlayer player) {
public PacketGetPlayerAskFriendListRsp(Player player) {
super(PacketOpcodes.GetPlayerAskFriendListRsp);
GetPlayerAskFriendListRsp.Builder proto = GetPlayerAskFriendListRsp.newBuilder();
......
package emu.grasscutter.server.packet.send;
import emu.grasscutter.GenshinConstants;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.GameConstants;
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.proto.FriendBriefOuterClass.FriendBrief;
import emu.grasscutter.net.proto.FriendOnlineStateOuterClass.FriendOnlineState;
......@@ -11,16 +11,16 @@ import emu.grasscutter.net.proto.GetPlayerFriendListRspOuterClass.GetPlayerFrien
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);
FriendBrief serverFriend = FriendBrief.newBuilder()
.setUid(GenshinConstants.SERVER_CONSOLE_UID)
.setUid(GameConstants.SERVER_CONSOLE_UID)
.setNickname("Server")
.setLevel(1)
.setAvatarId(HeadImage.newBuilder().setAvatarId(GenshinConstants.MAIN_CHARACTER_FEMALE).getAvatarId())
.setAvatarId(HeadImage.newBuilder().setAvatarId(GameConstants.MAIN_CHARACTER_FEMALE).getAvatarId())
.setWorldLevel(0)
.setSignature("")
.setLastActiveTime((int) (System.currentTimeMillis() / 1000f))
......
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.proto.GetPlayerSocialDetailRspOuterClass.GetPlayerSocialDetailRsp;
import emu.grasscutter.net.proto.RetcodeOuterClass;
import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail;
public class PacketGetPlayerSocialDetailRsp extends GenshinPacket {
public class PacketGetPlayerSocialDetailRsp extends BasePacket {
public PacketGetPlayerSocialDetailRsp(SocialDetail.Builder detail) {
super(PacketOpcodes.GetPlayerSocialDetailRsp);
......
......@@ -2,13 +2,13 @@ package emu.grasscutter.server.packet.send;
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.proto.GetPlayerTokenRspOuterClass.GetPlayerTokenRsp;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.utils.Crypto;
public class PacketGetPlayerTokenRsp extends GenshinPacket {
public class PacketGetPlayerTokenRsp extends BasePacket {
public PacketGetPlayerTokenRsp(GameSession session, boolean doesPlayerExist) {
super(PacketOpcodes.GetPlayerTokenRsp, true);
......
......@@ -3,12 +3,12 @@ package emu.grasscutter.server.packet.send;
import java.util.Arrays;
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.proto.CityInfoOuterClass.CityInfo;
import emu.grasscutter.net.proto.GetSceneAreaRspOuterClass.GetSceneAreaRsp;
public class PacketGetSceneAreaRsp extends GenshinPacket {
public class PacketGetSceneAreaRsp extends BasePacket {
public PacketGetSceneAreaRsp(int sceneId) {
super(PacketOpcodes.GetSceneAreaRsp);
......
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.proto.GetScenePointRspOuterClass.GetScenePointRsp;
public class PacketGetScenePointRsp extends GenshinPacket {
public class PacketGetScenePointRsp extends BasePacket {
public PacketGetScenePointRsp(int sceneId) {
super(PacketOpcodes.GetScenePointRsp);
......
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.proto.GetShopRspOuterClass.GetShopRsp;
import emu.grasscutter.net.proto.ShopOuterClass.Shop;
public class PacketGetShopRsp extends GenshinPacket {
public class PacketGetShopRsp extends BasePacket {
public PacketGetShopRsp(int shopType) {
super(PacketOpcodes.GetShopRsp);
......
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.proto.GetShopmallDataRspOuterClass.GetShopmallDataRsp;
public class PacketGetShopmallDataRsp extends GenshinPacket {
public class PacketGetShopmallDataRsp extends BasePacket {
public PacketGetShopmallDataRsp() {
super(PacketOpcodes.GetShopmallDataRsp);
......
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