Commit 9fc8cc1c authored by Kengxxiao's avatar Kengxxiao Committed by GitHub
Browse files

Merge pull request #1 from Grasscutters/development

merge
parents 627a2f1e d1fc8c1f
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; 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);
......
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.GetScenePointRspOuterClass.GetScenePointRsp; import emu.grasscutter.net.proto.GetScenePointRspOuterClass.GetScenePointRsp;
public class PacketGetScenePointRsp extends GenshinPacket { public class PacketGetScenePointRsp extends BasePacket {
public PacketGetScenePointRsp(int sceneId) { public PacketGetScenePointRsp(int sceneId) {
super(PacketOpcodes.GetScenePointRsp); super(PacketOpcodes.GetScenePointRsp);
......
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.GetShopRspOuterClass.GetShopRsp; import emu.grasscutter.net.proto.GetShopRspOuterClass.GetShopRsp;
import emu.grasscutter.net.proto.ShopOuterClass.Shop; import emu.grasscutter.net.proto.ShopOuterClass.Shop;
public class PacketGetShopRsp extends GenshinPacket { public class PacketGetShopRsp extends BasePacket {
public PacketGetShopRsp(int shopType) { public PacketGetShopRsp(int shopType) {
super(PacketOpcodes.GetShopRsp); super(PacketOpcodes.GetShopRsp);
......
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.GetShopmallDataRspOuterClass.GetShopmallDataRsp; import emu.grasscutter.net.proto.GetShopmallDataRspOuterClass.GetShopmallDataRsp;
public class PacketGetShopmallDataRsp extends GenshinPacket { public class PacketGetShopmallDataRsp extends BasePacket {
public PacketGetShopmallDataRsp() { public PacketGetShopmallDataRsp() {
super(PacketOpcodes.GetShopmallDataRsp); super(PacketOpcodes.GetShopmallDataRsp);
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.World; import emu.grasscutter.game.world.World;
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.GetWorldMpInfoRspOuterClass.GetWorldMpInfoRsp; import emu.grasscutter.net.proto.GetWorldMpInfoRspOuterClass.GetWorldMpInfoRsp;
public class PacketGetWorldMpInfoRsp extends GenshinPacket { public class PacketGetWorldMpInfoRsp extends BasePacket {
public PacketGetWorldMpInfoRsp(World world) { public PacketGetWorldMpInfoRsp(World world) {
super(PacketOpcodes.GetWorldMpInfoRsp); super(PacketOpcodes.GetWorldMpInfoRsp);
......
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.H5ActivityIdsNotifyOuterClass.H5ActivityIdsNotify; import emu.grasscutter.net.proto.H5ActivityIdsNotifyOuterClass.H5ActivityIdsNotify;
public class PacketH5ActivityIdsNotify extends GenshinPacket { public class PacketH5ActivityIdsNotify extends BasePacket {
public PacketH5ActivityIdsNotify() { public PacketH5ActivityIdsNotify() {
super(PacketOpcodes.H5ActivityIdsNotify); super(PacketOpcodes.H5ActivityIdsNotify);
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.World; import emu.grasscutter.game.world.World;
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.HostPlayerNotifyOuterClass.HostPlayerNotify; import emu.grasscutter.net.proto.HostPlayerNotifyOuterClass.HostPlayerNotify;
public class PacketHostPlayerNotify extends GenshinPacket { public class PacketHostPlayerNotify extends BasePacket {
public PacketHostPlayerNotify(World world) { public PacketHostPlayerNotify(World world) {
super(PacketOpcodes.HostPlayerNotify); super(PacketOpcodes.HostPlayerNotify);
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import java.util.Collection;
import java.util.List; import java.util.List;
import emu.grasscutter.game.inventory.GenshinItem; import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.props.ActionReason; import emu.grasscutter.game.props.ActionReason;
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.ItemAddHintNotifyOuterClass.ItemAddHintNotify; import emu.grasscutter.net.proto.ItemAddHintNotifyOuterClass.ItemAddHintNotify;
public class PacketItemAddHintNotify extends GenshinPacket { public class PacketItemAddHintNotify extends BasePacket {
public PacketItemAddHintNotify(GenshinItem item, ActionReason reason) { public PacketItemAddHintNotify(GameItem item, ActionReason reason) {
super(PacketOpcodes.ItemAddHintNotify); super(PacketOpcodes.ItemAddHintNotify);
ItemAddHintNotify proto = ItemAddHintNotify.newBuilder() ItemAddHintNotify proto = ItemAddHintNotify.newBuilder()
...@@ -21,13 +22,13 @@ public class PacketItemAddHintNotify extends GenshinPacket { ...@@ -21,13 +22,13 @@ public class PacketItemAddHintNotify extends GenshinPacket {
this.setData(proto); this.setData(proto);
} }
public PacketItemAddHintNotify(List<GenshinItem> items, ActionReason reason) { public PacketItemAddHintNotify(Collection<GameItem> items, ActionReason reason) {
super(PacketOpcodes.ItemAddHintNotify); super(PacketOpcodes.ItemAddHintNotify);
ItemAddHintNotify.Builder proto = ItemAddHintNotify.newBuilder() ItemAddHintNotify.Builder proto = ItemAddHintNotify.newBuilder()
.setReason(reason.getValue()); .setReason(reason.getValue());
for (GenshinItem item : items) { for (GameItem item : items) {
proto.addItemList(item.toItemHintProto()); proto.addItemList(item.toItemHintProto());
} }
......
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.LifeState; import emu.grasscutter.game.props.LifeState;
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.LifeStateChangeNotifyOuterClass.LifeStateChangeNotify; import emu.grasscutter.net.proto.LifeStateChangeNotifyOuterClass.LifeStateChangeNotify;
public class PacketLifeStateChangeNotify extends GenshinPacket { public class PacketLifeStateChangeNotify extends BasePacket {
public PacketLifeStateChangeNotify(GenshinEntity attacker, GenshinEntity target, LifeState lifeState) { public PacketLifeStateChangeNotify(GameEntity attacker, GameEntity target, LifeState lifeState) {
super(PacketOpcodes.LifeStateChangeNotify); super(PacketOpcodes.LifeStateChangeNotify);
LifeStateChangeNotify proto = LifeStateChangeNotify.newBuilder() LifeStateChangeNotify proto = LifeStateChangeNotify.newBuilder()
...@@ -18,7 +18,7 @@ public class PacketLifeStateChangeNotify extends GenshinPacket { ...@@ -18,7 +18,7 @@ public class PacketLifeStateChangeNotify extends GenshinPacket {
this.setData(proto); this.setData(proto);
} }
public PacketLifeStateChangeNotify(int attackerId, GenshinEntity target, LifeState lifeState) { public PacketLifeStateChangeNotify(int attackerId, GameEntity target, LifeState lifeState) {
super(PacketOpcodes.LifeStateChangeNotify); super(PacketOpcodes.LifeStateChangeNotify);
LifeStateChangeNotify proto = LifeStateChangeNotify.newBuilder() LifeStateChangeNotify proto = LifeStateChangeNotify.newBuilder()
......
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.*;
import java.util.ArrayList;
import java.util.List;
public class PacketMailChangeNotify extends BasePacket {
public PacketMailChangeNotify(Player player, Mail message) {
this (player, new ArrayList<Mail>(){{add(message);}});
}
public PacketMailChangeNotify(Player player, List<Mail> mailList) {
this(player, mailList, null);
}
public PacketMailChangeNotify(Player player, List<Mail> mailList, List<Integer> delMailIdList) {
super(PacketOpcodes.MailChangeNotify);
MailChangeNotifyOuterClass.MailChangeNotify.Builder proto = MailChangeNotifyOuterClass.MailChangeNotify.newBuilder();
if (mailList != null) {
for (Mail message : mailList) {
MailTextContentOuterClass.MailTextContent.Builder mailTextContent = MailTextContentOuterClass.MailTextContent.newBuilder();
mailTextContent.setTitle(message.mailContent.title);
mailTextContent.setContent(message.mailContent.content);
mailTextContent.setSender(message.mailContent.sender);
List<MailItemOuterClass.MailItem> mailItems = new ArrayList<MailItemOuterClass.MailItem>();
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(message.stateValue);
proto.addMailList(mailData.build());
}
}
if(delMailIdList != null) {
proto.addAllDelMailIdList(delMailIdList);
}
this.setData(proto.build());
}
}
\ No newline at end of file
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.NpcTalkRspOuterClass.NpcTalkRsp; import emu.grasscutter.net.proto.NpcTalkRspOuterClass.NpcTalkRsp;
public class PacketNpcTalkRsp extends GenshinPacket { public class PacketNpcTalkRsp extends BasePacket {
public PacketNpcTalkRsp(int npcEntityId, int curTalkId, int entityId) { public PacketNpcTalkRsp(int npcEntityId, int curTalkId, int entityId) {
super(PacketOpcodes.NpcTalkRsp); super(PacketOpcodes.NpcTalkRsp);
......
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