Commit a8293102 authored by Melledy's avatar Melledy Committed by GitHub
Browse files

Merge branch 'development' into stable

parents 304b9cb8 ecf7a81a
...@@ -18,52 +18,60 @@ public class PacketGetMailItemRsp extends BasePacket { ...@@ -18,52 +18,60 @@ public class PacketGetMailItemRsp extends BasePacket {
public PacketGetMailItemRsp(Player player, List<Integer> mailList) { public PacketGetMailItemRsp(Player player, List<Integer> mailList) {
super(PacketOpcodes.GetMailItemRsp); super(PacketOpcodes.GetMailItemRsp);
List<Mail> claimedMessages = new ArrayList<>(); List<Mail> claimedMessages = new ArrayList<>();
List<EquipParamOuterClass.EquipParam> claimedItems = new ArrayList<>(); List<EquipParamOuterClass.EquipParam> claimedItems = new ArrayList<>();
GetMailItemRsp.Builder proto = GetMailItemRsp.newBuilder(); GetMailItemRsp.Builder proto = GetMailItemRsp.newBuilder();
for (int mailId : mailList) { synchronized (player) {
Mail message = player.getMail(mailId); boolean modified = false;
for (int mailId : mailList) {
Mail message = player.getMail(mailId);
if (!message.isAttachmentGot) {//No duplicated item
for (Mail.MailItem mailItem : message.itemList) {
EquipParamOuterClass.EquipParam.Builder item = EquipParamOuterClass.EquipParam.newBuilder();
int promoteLevel = 0;
for(Mail.MailItem mailItem : message.itemList) { if (mailItem.itemLevel > 80) { // 80/90
EquipParamOuterClass.EquipParam.Builder item = EquipParamOuterClass.EquipParam.newBuilder(); promoteLevel = 6;
int promoteLevel = 0; } else if (mailItem.itemLevel > 70) { // 70/80
if (mailItem.itemLevel > 20) { // 20/40 promoteLevel = 5;
promoteLevel = 1; } else if (mailItem.itemLevel > 60) { // 60/70
} else if (mailItem.itemLevel > 40) { // 40/50 promoteLevel = 4;
promoteLevel = 2; } else if (mailItem.itemLevel > 50) { // 50/60
} else if (mailItem.itemLevel > 50) { // 50/60 promoteLevel = 3;
promoteLevel = 3; } else if (mailItem.itemLevel > 40) { // 40/50
} else if (mailItem.itemLevel > 60) { // 60/70 promoteLevel = 2;
promoteLevel = 4; } else if (mailItem.itemLevel > 20) { // 20/40
} else if (mailItem.itemLevel > 70) { // 70/80 promoteLevel = 1;
promoteLevel = 5; }
} else if (mailItem.itemLevel > 80) { // 80/90
promoteLevel = 6;
}
item.setItemId(mailItem.itemId); item.setItemId(mailItem.itemId);
item.setItemNum(mailItem.itemCount); item.setItemNum(mailItem.itemCount);
item.setItemLevel(mailItem.itemLevel); item.setItemLevel(mailItem.itemLevel);
item.setPromoteLevel(promoteLevel); item.setPromoteLevel(promoteLevel);
claimedItems.add(item.build()); claimedItems.add(item.build());
GameItem gameItem = new GameItem(GameData.getItemDataMap().get(mailItem.itemId)); GameItem gameItem = new GameItem(GameData.getItemDataMap().get(mailItem.itemId));
gameItem.setCount(mailItem.itemCount); gameItem.setCount(mailItem.itemCount);
gameItem.setLevel(mailItem.itemLevel); gameItem.setLevel(mailItem.itemLevel);
gameItem.setPromoteLevel(promoteLevel); gameItem.setPromoteLevel(promoteLevel);
player.getInventory().addItem(gameItem, ActionReason.MailAttachment); player.getInventory().addItem(gameItem, ActionReason.MailAttachment);
} }
message.isAttachmentGot = true; message.isAttachmentGot = true;
claimedMessages.add(message); claimedMessages.add(message);
player.replaceMailByIndex(mailId, message); player.replaceMailByIndex(mailId, message);
modified = true;
}
}
if(modified) {
player.save();
}
} }
proto.addAllMailIdList(claimedMessages.stream().map(message -> player.getMailId(message)).collect(Collectors.toList())); proto.addAllMailIdList(claimedMessages.stream().map(player::getMailId).collect(Collectors.toList()));
proto.addAllItemList(claimedItems); proto.addAllItemList(claimedItems);
this.setData(proto.build()); this.setData(proto.build());
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.GameConstants; import emu.grasscutter.GameConstants;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.friends.Friendship; import emu.grasscutter.game.friends.Friendship;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
...@@ -12,24 +11,27 @@ import emu.grasscutter.net.proto.GetPlayerFriendListRspOuterClass.GetPlayerFrien ...@@ -12,24 +11,27 @@ import emu.grasscutter.net.proto.GetPlayerFriendListRspOuterClass.GetPlayerFrien
import emu.grasscutter.net.proto.ProfilePictureOuterClass.ProfilePicture; import emu.grasscutter.net.proto.ProfilePictureOuterClass.ProfilePicture;
import emu.grasscutter.net.proto.PlatformTypeOuterClass; import emu.grasscutter.net.proto.PlatformTypeOuterClass;
import static emu.grasscutter.Configuration.*;
public class PacketGetPlayerFriendListRsp extends BasePacket { public class PacketGetPlayerFriendListRsp extends BasePacket {
public PacketGetPlayerFriendListRsp(Player player) { public PacketGetPlayerFriendListRsp(Player player) {
super(PacketOpcodes.GetPlayerFriendListRsp); super(PacketOpcodes.GetPlayerFriendListRsp);
var serverAccount = GAME_INFO.serverAccount;
FriendBrief serverFriend = FriendBrief.newBuilder() FriendBrief serverFriend = FriendBrief.newBuilder()
.setUid(GameConstants.SERVER_CONSOLE_UID) .setUid(GameConstants.SERVER_CONSOLE_UID)
.setNickname(Grasscutter.getConfig().getGameServerOptions().ServerNickname) .setNickname(serverAccount.nickName)
.setLevel(Grasscutter.getConfig().getGameServerOptions().ServerLevel) .setLevel(serverAccount.adventureRank)
.setProfilePicture(ProfilePicture.newBuilder().setAvatarId(Grasscutter.getConfig().getGameServerOptions().ServerAvatarId)) .setProfilePicture(ProfilePicture.newBuilder().setAvatarId(serverAccount.avatarId))
.setWorldLevel(Grasscutter.getConfig().getGameServerOptions().ServerWorldLevel) .setWorldLevel(serverAccount.worldLevel)
.setSignature(Grasscutter.getConfig().getGameServerOptions().ServerSignature) .setSignature(serverAccount.signature)
.setLastActiveTime((int) (System.currentTimeMillis() / 1000f)) .setLastActiveTime((int) (System.currentTimeMillis() / 1000f))
.setNameCardId(Grasscutter.getConfig().getGameServerOptions().ServerNameCardId) .setNameCardId(serverAccount.nameCardId)
.setOnlineState(FriendOnlineState.FRIEND_ONLINE) .setOnlineState(FriendOnlineState.FRIEND_ONLINE_STATE_ONLINE)
.setParam(1) .setParam(1)
.setIsGameSource(true) .setIsGameSource(true)
.setPlatformType(PlatformTypeOuterClass.PlatformType.PC) .setPlatformType(PlatformTypeOuterClass.PlatformType.PLATFORM_TYPE_PC)
.build(); .build();
GetPlayerFriendListRsp.Builder proto = GetPlayerFriendListRsp.newBuilder().addFriendList(serverFriend); GetPlayerFriendListRsp.Builder proto = GetPlayerFriendListRsp.newBuilder().addFriendList(serverFriend);
...@@ -37,10 +39,12 @@ public class PacketGetPlayerFriendListRsp extends BasePacket { ...@@ -37,10 +39,12 @@ public class PacketGetPlayerFriendListRsp extends BasePacket {
for (Friendship friendship : player.getFriendsList().getFriends().values()) { for (Friendship friendship : player.getFriendsList().getFriends().values()) {
proto.addFriendList(friendship.toProto()); proto.addFriendList(friendship.toProto());
} }
for (Friendship friendship : player.getFriendsList().getPendingFriends().values()) { for (Friendship friendship : player.getFriendsList().getPendingFriends().values()) {
if (friendship.getAskerId() == player.getUid()) { if (friendship.getAskerId() == player.getUid()) {
continue; continue;
} }
proto.addAskFriendList(friendship.toProto()); proto.addAskFriendList(friendship.toProto());
} }
......
...@@ -10,16 +10,16 @@ import emu.grasscutter.utils.Crypto; ...@@ -10,16 +10,16 @@ import emu.grasscutter.utils.Crypto;
public class PacketGetPlayerTokenRsp extends BasePacket { public class PacketGetPlayerTokenRsp extends BasePacket {
public PacketGetPlayerTokenRsp(GameSession session, boolean doesPlayerExist) { public PacketGetPlayerTokenRsp(GameSession session) {
super(PacketOpcodes.GetPlayerTokenRsp, true); super(PacketOpcodes.GetPlayerTokenRsp, true);
this.setUseDispatchKey(true); this.setUseDispatchKey(true);
GetPlayerTokenRsp p = GetPlayerTokenRsp.newBuilder() GetPlayerTokenRsp p = GetPlayerTokenRsp.newBuilder()
.setUid(session.getAccount().getPlayerUid()) .setUid(session.getPlayer().getUid())
.setToken(session.getAccount().getToken()) .setToken(session.getAccount().getToken())
.setAccountType(1) .setAccountType(1)
.setIsProficientPlayer(doesPlayerExist) // Not sure where this goes .setIsProficientPlayer(session.getPlayer().getAvatars().getAvatarCount() > 0) // Not sure where this goes
.setSecretKeySeed(Crypto.ENCRYPT_SEED) .setSecretKeySeed(Crypto.ENCRYPT_SEED)
.setSecurityCmdBuffer(ByteString.copyFrom(Crypto.ENCRYPT_SEED_BUFFER)) .setSecurityCmdBuffer(ByteString.copyFrom(Crypto.ENCRYPT_SEED_BUFFER))
.setPlatformType(3) .setPlatformType(3)
......
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GetWidgetSlotRspOuterClass;
import emu.grasscutter.net.proto.WidgetSlotDataOuterClass;
import emu.grasscutter.net.proto.WidgetSlotTagOuterClass;
import java.util.List;
public class PacketGetWidgetSlotRsp extends BasePacket {
public PacketGetWidgetSlotRsp(Player player) {
super(PacketOpcodes.GetWidgetSlotRsp);
GetWidgetSlotRspOuterClass.GetWidgetSlotRsp.Builder proto =
GetWidgetSlotRspOuterClass.GetWidgetSlotRsp.newBuilder();
if (player.getWidgetId() == null) {
proto.addAllSlotList(List.of());
} else {
proto.addSlotList(
WidgetSlotDataOuterClass.WidgetSlotData.newBuilder()
.setIsActive(true)
.setMaterialId(player.getWidgetId())
.build()
);
proto.addSlotList(
WidgetSlotDataOuterClass.WidgetSlotData.newBuilder()
.setTag(WidgetSlotTagOuterClass.WidgetSlotTag.WIDGET_SLOT_TAG_ATTACH_AVATAR)
.build()
);
}
GetWidgetSlotRspOuterClass.GetWidgetSlotRsp protoData = proto.build();
this.setData(protoData);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.HomeChooseModuleRspOuterClass;
public class PacketHomeChooseModuleRsp extends BasePacket {
public PacketHomeChooseModuleRsp(int moduleId) {
super(PacketOpcodes.HomeChooseModuleRsp);
HomeChooseModuleRspOuterClass.HomeChooseModuleRsp proto = HomeChooseModuleRspOuterClass.HomeChooseModuleRsp.newBuilder()
.setRetcode(0)
.setModuleId(moduleId)
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.HomeComfortInfoNotifyOuterClass;
import emu.grasscutter.net.proto.HomeModuleComfortInfoOuterClass;
import java.util.ArrayList;
import java.util.List;
public class PacketHomeComfortInfoNotify extends BasePacket {
public PacketHomeComfortInfoNotify(Player player) {
super(PacketOpcodes.HomeComfortInfoNotify);
if (player.getRealmList() == null) {
// Do not send
return;
}
List<HomeModuleComfortInfoOuterClass.HomeModuleComfortInfo> comfortInfoList = new ArrayList<>();
for (int moduleId : player.getRealmList()) {
comfortInfoList.add(
HomeModuleComfortInfoOuterClass.HomeModuleComfortInfo.newBuilder()
.setModuleId(moduleId)
.build()
);
}
HomeComfortInfoNotifyOuterClass.HomeComfortInfoNotify proto = HomeComfortInfoNotifyOuterClass.HomeComfortInfoNotify
.newBuilder()
.addAllModuleInfoList(comfortInfoList)
.build();
this.setData(proto);
}
}
...@@ -37,10 +37,10 @@ public class PacketMailChangeNotify extends BasePacket { ...@@ -37,10 +37,10 @@ public class PacketMailChangeNotify extends BasePacket {
for (Mail.MailItem item : message.itemList) { for (Mail.MailItem item : message.itemList) {
MailItemOuterClass.MailItem.Builder mailItem = MailItemOuterClass.MailItem.newBuilder(); MailItemOuterClass.MailItem.Builder mailItem = MailItemOuterClass.MailItem.newBuilder();
ItemParamOuterClass.ItemParam.Builder itemParam = ItemParamOuterClass.ItemParam.newBuilder(); EquipParamOuterClass.EquipParam.Builder itemParam = EquipParamOuterClass.EquipParam.newBuilder();
itemParam.setItemId(item.itemId); itemParam.setItemId(item.itemId);
itemParam.setCount(item.itemCount); itemParam.setItemNum(item.itemCount);
mailItem.setItemParam(itemParam.build()); mailItem.setEquipParam(itemParam.build());
mailItems.add(mailItem.build()); mailItems.add(mailItem.build());
} }
...@@ -54,7 +54,7 @@ public class PacketMailChangeNotify extends BasePacket { ...@@ -54,7 +54,7 @@ public class PacketMailChangeNotify extends BasePacket {
mailData.setImportance(message.importance); mailData.setImportance(message.importance);
mailData.setIsRead(message.isRead); mailData.setIsRead(message.isRead);
mailData.setIsAttachmentGot(message.isAttachmentGot); mailData.setIsAttachmentGot(message.isAttachmentGot);
mailData.setStateValue(message.stateValue); mailData.setBHCAHLJIKFFValue(message.stateValue);
proto.addMailList(mailData.build()); proto.addMailList(mailData.build());
} }
......
...@@ -10,7 +10,7 @@ import java.util.*; ...@@ -10,7 +10,7 @@ import java.util.*;
public class PacketMarkMapRsp extends BasePacket { public class PacketMarkMapRsp extends BasePacket {
public PacketMarkMapRsp(Player player, HashMap<String, MapMark> mapMarks) { public PacketMarkMapRsp(HashMap<String, MapMark> mapMarks) {
super(PacketOpcodes.MarkMapRsp); super(PacketOpcodes.MarkMapRsp);
MarkMapRspOuterClass.MarkMapRsp.Builder proto = MarkMapRspOuterClass.MarkMapRsp.newBuilder(); MarkMapRspOuterClass.MarkMapRsp.Builder proto = MarkMapRspOuterClass.MarkMapRsp.newBuilder();
......
...@@ -23,7 +23,7 @@ public class PacketPlayerEnterSceneNotify extends BasePacket { ...@@ -23,7 +23,7 @@ public class PacketPlayerEnterSceneNotify extends BasePacket {
.setSceneId(player.getSceneId()) .setSceneId(player.getSceneId())
.setPos(player.getPos().toProto()) .setPos(player.getPos().toProto())
.setSceneBeginTime(System.currentTimeMillis()) .setSceneBeginTime(System.currentTimeMillis())
.setType(EnterType.ENTER_SELF) .setType(EnterType.ENTER_TYPE_SELF)
.setTargetUid(player.getUid()) .setTargetUid(player.getUid())
.setEnterSceneToken(player.getEnterSceneToken()) .setEnterSceneToken(player.getEnterSceneToken())
.setWorldLevel(player.getWorldLevel()) .setWorldLevel(player.getWorldLevel())
......
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PlayerHomeCompInfoNotifyOuterClass;
import emu.grasscutter.net.proto.PlayerHomeCompInfoOuterClass;
import java.util.List;
public class PacketPlayerHomeCompInfoNotify extends BasePacket {
public PacketPlayerHomeCompInfoNotify(Player player) {
super(PacketOpcodes.PlayerHomeCompInfoNotify);
if (player.getRealmList() == null) {
// Do not send
return;
}
PlayerHomeCompInfoNotifyOuterClass.PlayerHomeCompInfoNotify proto = PlayerHomeCompInfoNotifyOuterClass.PlayerHomeCompInfoNotify.newBuilder()
.setCompInfo(
PlayerHomeCompInfoOuterClass.PlayerHomeCompInfo.newBuilder()
.addAllUnlockedModuleIdList(player.getRealmList())
.addAllLevelupRewardGotLevelList(List.of(1)) // Hardcoded
.build()
)
.build();
this.setData(proto);
}
}
...@@ -2,7 +2,6 @@ package emu.grasscutter.server.packet.send; ...@@ -2,7 +2,6 @@ package emu.grasscutter.server.packet.send;
import com.google.protobuf.ByteString; import com.google.protobuf.ByteString;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.Grasscutter.ServerDebugMode;
import emu.grasscutter.Grasscutter.ServerRunMode; import emu.grasscutter.Grasscutter.ServerRunMode;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
...@@ -10,11 +9,15 @@ import emu.grasscutter.net.proto.PlayerLoginRspOuterClass.PlayerLoginRsp; ...@@ -10,11 +9,15 @@ import emu.grasscutter.net.proto.PlayerLoginRspOuterClass.PlayerLoginRsp;
import emu.grasscutter.net.proto.QueryCurrRegionHttpRspOuterClass; import emu.grasscutter.net.proto.QueryCurrRegionHttpRspOuterClass;
import emu.grasscutter.net.proto.RegionInfoOuterClass.RegionInfo; import emu.grasscutter.net.proto.RegionInfoOuterClass.RegionInfo;
import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.http.dispatch.RegionHandler;
import emu.grasscutter.utils.Crypto;
import emu.grasscutter.utils.FileUtils; import emu.grasscutter.utils.FileUtils;
import java.io.File; import java.io.File;
import java.net.URL;
import java.util.Base64; import java.util.Base64;
import java.util.Objects;
import static emu.grasscutter.Configuration.*;
public class PacketPlayerLoginRsp extends BasePacket { public class PacketPlayerLoginRsp extends BasePacket {
...@@ -27,27 +30,17 @@ public class PacketPlayerLoginRsp extends BasePacket { ...@@ -27,27 +30,17 @@ public class PacketPlayerLoginRsp extends BasePacket {
RegionInfo info; RegionInfo info;
if (Grasscutter.getConfig().RunMode == ServerRunMode.GAME_ONLY) { if (SERVER.runMode == ServerRunMode.GAME_ONLY) {
if (regionCache == null) { if (regionCache == null) {
try { try {
File file = new File(Grasscutter.getConfig().DATA_FOLDER + "query_cur_region.txt"); // todo: we might want to push custom config to client
String query_cur_region = ""; RegionInfo serverRegion = RegionInfo.newBuilder()
if (file.exists()) { .setGateserverIp(lr(GAME_INFO.accessAddress, GAME_INFO.bindAddress))
query_cur_region = new String(FileUtils.read(file)); .setGateserverPort(lr(GAME_INFO.accessPort, GAME_INFO.bindPort))
} else { .setSecretKey(ByteString.copyFrom(Crypto.DISPATCH_SEED))
Grasscutter.getLogger().warn("query_cur_region not found! Using default current region.");
}
byte[] decodedCurRegion = Base64.getDecoder().decode(query_cur_region);
QueryCurrRegionHttpRspOuterClass.QueryCurrRegionHttpRsp regionQuery = QueryCurrRegionHttpRspOuterClass.QueryCurrRegionHttpRsp.parseFrom(decodedCurRegion);
RegionInfo serverRegion = regionQuery.getRegionInfo().toBuilder()
.setGateserverIp((Grasscutter.getConfig().getGameServerOptions().PublicIp.isEmpty() ? Grasscutter.getConfig().getGameServerOptions().Ip : Grasscutter.getConfig().getGameServerOptions().PublicIp))
.setGateserverPort(Grasscutter.getConfig().getGameServerOptions().PublicPort != 0 ? Grasscutter.getConfig().getGameServerOptions().PublicPort : Grasscutter.getConfig().getGameServerOptions().Port)
.setSecretKey(ByteString.copyFrom(FileUtils.read(Grasscutter.getConfig().KEY_FOLDER + "dispatchSeed.bin")))
.build(); .build();
regionCache = regionQuery.toBuilder().setRegionInfo(serverRegion).build(); regionCache = QueryCurrRegionHttpRspOuterClass.QueryCurrRegionHttpRsp.newBuilder().setRegionInfo(serverRegion).build();
} catch (Exception e) { } catch (Exception e) {
Grasscutter.getLogger().error("Error while initializing region cache!", e); Grasscutter.getLogger().error("Error while initializing region cache!", e);
} }
...@@ -55,7 +48,7 @@ public class PacketPlayerLoginRsp extends BasePacket { ...@@ -55,7 +48,7 @@ public class PacketPlayerLoginRsp extends BasePacket {
info = regionCache.getRegionInfo(); info = regionCache.getRegionInfo();
} else { } else {
info = Grasscutter.getDispatchServer().getCurrRegion().getRegionInfo(); info = Objects.requireNonNull(RegionHandler.getCurrentRegion()).getRegionInfo();
} }
PlayerLoginRsp p = PlayerLoginRsp.newBuilder() PlayerLoginRsp p = PlayerLoginRsp.newBuilder()
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.GameConstants;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.inventory.GameItem; import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
...@@ -10,6 +8,8 @@ import emu.grasscutter.net.proto.ItemOuterClass.Item; ...@@ -10,6 +8,8 @@ import emu.grasscutter.net.proto.ItemOuterClass.Item;
import emu.grasscutter.net.proto.PlayerStoreNotifyOuterClass.PlayerStoreNotify; import emu.grasscutter.net.proto.PlayerStoreNotifyOuterClass.PlayerStoreNotify;
import emu.grasscutter.net.proto.StoreTypeOuterClass.StoreType; import emu.grasscutter.net.proto.StoreTypeOuterClass.StoreType;
import static emu.grasscutter.Configuration.*;
public class PacketPlayerStoreNotify extends BasePacket { public class PacketPlayerStoreNotify extends BasePacket {
public PacketPlayerStoreNotify(Player player) { public PacketPlayerStoreNotify(Player player) {
...@@ -18,8 +18,8 @@ public class PacketPlayerStoreNotify extends BasePacket { ...@@ -18,8 +18,8 @@ public class PacketPlayerStoreNotify extends BasePacket {
this.buildHeader(2); this.buildHeader(2);
PlayerStoreNotify.Builder p = PlayerStoreNotify.newBuilder() PlayerStoreNotify.Builder p = PlayerStoreNotify.newBuilder()
.setStoreType(StoreType.STORE_PACK) .setStoreType(StoreType.STORE_TYPE_PACK)
.setWeightLimit(Grasscutter.getConfig().getGameServerOptions().InventoryLimitAll); .setWeightLimit(GAME_OPTIONS.inventoryLimits.all);
for (GameItem item : player.getInventory()) { for (GameItem item : player.getInventory()) {
Item itemProto = item.toProto(); Item itemProto = item.toProto();
......
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PlayerWorldSceneInfoListNotifyOuterClass.PlayerWorldSceneInfoListNotify;
import emu.grasscutter.net.proto.PlayerWorldSceneInfoOuterClass;
import emu.grasscutter.net.proto.SceneUnlockInfoOuterClass.SceneUnlockInfo;
import static emu.grasscutter.net.proto.PlayerWorldSceneInfoOuterClass.*;
public class PacketPlayerWorldSceneInfoListNotify extends BasePacket {
public PacketPlayerWorldSceneInfoListNotify() {
super(PacketOpcodes.PlayerWorldSceneInfoListNotify); // Rename opcode later
PlayerWorldSceneInfoListNotify proto = PlayerWorldSceneInfoListNotify.newBuilder()
.addInfoList(
PlayerWorldSceneInfo.newBuilder()
.setSceneId(1)
.setIsLocked(false)
.build()
)
.addInfoList(
PlayerWorldSceneInfo.newBuilder()
.setSceneId(3)
.setIsLocked(false)
.addSceneTagIdList(102)
.addSceneTagIdList(113)
.addSceneTagIdList(117)
.build()
)
.addInfoList(
PlayerWorldSceneInfo.newBuilder()
.setSceneId(4)
.setIsLocked(false)
.addSceneTagIdList(106)
.addSceneTagIdList(109)
.addSceneTagIdList(117)
.build()
)
.addInfoList(
PlayerWorldSceneInfo.newBuilder()
.setSceneId(5)
.setIsLocked(false)
.build()
)
.addInfoList(
PlayerWorldSceneInfo.newBuilder()
.setSceneId(6)
.setIsLocked(false)
.build()
)
.addInfoList(
PlayerWorldSceneInfo.newBuilder()
.setSceneId(7)
.setIsLocked(false)
.build()
)
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.Config.GameServerOptions;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
import emu.grasscutter.GameConstants; import emu.grasscutter.GameConstants;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.ChatInfoOuterClass.ChatInfo; import emu.grasscutter.net.proto.ChatInfoOuterClass.ChatInfo;
import emu.grasscutter.net.proto.PullRecentChatRspOuterClass.PullRecentChatRsp; import emu.grasscutter.net.proto.PullRecentChatRspOuterClass.PullRecentChatRsp;
import emu.grasscutter.utils.Utils; import emu.grasscutter.utils.Utils;
import static emu.grasscutter.Configuration.*;
public class PacketPullRecentChatRsp extends BasePacket { public class PacketPullRecentChatRsp extends BasePacket {
public PacketPullRecentChatRsp(Player player) { public PacketPullRecentChatRsp(Player player) {
super(PacketOpcodes.PullRecentChatRsp); super(PacketOpcodes.PullRecentChatRsp);
GameServerOptions serverOptions = Grasscutter.getConfig().getGameServerOptions(); var joinOptions = GAME_INFO.joinOptions;
PullRecentChatRsp.Builder proto = PullRecentChatRsp.newBuilder(); PullRecentChatRsp.Builder proto = PullRecentChatRsp.newBuilder();
if (serverOptions.WelcomeEmotes != null && serverOptions.WelcomeEmotes.length > 0) { if (joinOptions.welcomeEmotes != null && joinOptions.welcomeEmotes.length > 0) {
ChatInfo welcomeEmote = ChatInfo.newBuilder() ChatInfo welcomeEmote = ChatInfo.newBuilder()
.setTime((int) (System.currentTimeMillis() / 1000)) .setTime((int) (System.currentTimeMillis() / 1000))
.setUid(GameConstants.SERVER_CONSOLE_UID) .setUid(GameConstants.SERVER_CONSOLE_UID)
.setToUid(player.getUid()) .setToUid(player.getUid())
.setIcon(serverOptions.WelcomeEmotes[Utils.randomRange(0, serverOptions.WelcomeEmotes.length - 1)]) .setIcon(joinOptions.welcomeEmotes[Utils.randomRange(0, joinOptions.welcomeEmotes.length - 1)])
.build(); .build();
proto.addChatInfo(welcomeEmote); proto.addChatInfo(welcomeEmote);
} }
if (serverOptions.WelcomeMotd != null && serverOptions.WelcomeMotd.length() > 0) { if (joinOptions.welcomeMessage != null && joinOptions.welcomeMessage.length() > 0) {
ChatInfo welcomeMotd = ChatInfo.newBuilder() ChatInfo welcomeMessage = ChatInfo.newBuilder()
.setTime((int) (System.currentTimeMillis() / 1000)) .setTime((int) (System.currentTimeMillis() / 1000))
.setUid(GameConstants.SERVER_CONSOLE_UID) .setUid(GameConstants.SERVER_CONSOLE_UID)
.setToUid(player.getUid()) .setToUid(player.getUid())
.setText(Grasscutter.getConfig().getGameServerOptions().WelcomeMotd) .setText(joinOptions.welcomeMessage)
.build(); .build();
proto.addChatInfo(welcomeMessage);
proto.addChatInfo(welcomeMotd);
} }
this.setData(proto); this.setData(proto);
......
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.QueryCodexMonsterBeKilledNumRspOuterClass.QueryCodexMonsterBeKilledNumRsp;
import java.util.List;
public class PacketQueryCodexMonsterBeKilledNumRsp extends BasePacket {
public PacketQueryCodexMonsterBeKilledNumRsp(Player player, List<Integer> codexList) {
super(PacketOpcodes.QueryCodexMonsterBeKilledNumRsp);
QueryCodexMonsterBeKilledNumRsp.Builder proto = QueryCodexMonsterBeKilledNumRsp.newBuilder();
codexList.forEach(animal -> {
if(player.getCodex().getUnlockedAnimal().containsKey(animal)){
proto.addCodexIdList(animal)
.addBeKilledNumList(player.getCodex().getUnlockedAnimal().get(animal))
.addCHPBKCLKPCJ(0);
}
});
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.quest.GameMainQuest;
import emu.grasscutter.game.quest.QuestManager;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.QuestListNotifyOuterClass.QuestListNotify;
public class PacketQuestListNotify extends BasePacket {
public PacketQuestListNotify(Player player) {
super(PacketOpcodes.QuestListNotify, true);
QuestListNotify.Builder proto = QuestListNotify.newBuilder();
player.getQuestManager().forEachQuest(quest -> {
proto.addQuestList(quest.toProto());
});
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.quest.GameMainQuest;
import emu.grasscutter.game.quest.GameQuest;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.QuestListUpdateNotifyOuterClass.QuestListUpdateNotify;
public class PacketQuestListUpdateNotify extends BasePacket {
public PacketQuestListUpdateNotify(GameQuest quest) {
super(PacketOpcodes.QuestListUpdateNotify);
QuestListUpdateNotify proto = QuestListUpdateNotify.newBuilder()
.addQuestList(quest.toProto())
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.quest.GameMainQuest;
import emu.grasscutter.game.quest.GameQuest;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.QuestProgressUpdateNotifyOuterClass.QuestProgressUpdateNotify;
public class PacketQuestProgressUpdateNotify extends BasePacket {
public PacketQuestProgressUpdateNotify(GameQuest quest) {
super(PacketOpcodes.QuestProgressUpdateNotify);
QuestProgressUpdateNotify.Builder proto = QuestProgressUpdateNotify.newBuilder().setQuestId(quest.getQuestId());
if (quest.getFinishProgressList() != null) {
for (int i : quest.getFinishProgressList()) {
proto.addFinishProgressList(i);
}
}
if (quest.getFailProgressList() != null) {
for (int i : quest.getFailProgressList()) {
proto.addFailProgressList(i);
}
}
this.setData(proto);
}
}
...@@ -15,7 +15,7 @@ public class PacketSceneEntityAppearNotify extends BasePacket { ...@@ -15,7 +15,7 @@ public class PacketSceneEntityAppearNotify extends BasePacket {
super(PacketOpcodes.SceneEntityAppearNotify, true); super(PacketOpcodes.SceneEntityAppearNotify, true);
SceneEntityAppearNotify.Builder proto = SceneEntityAppearNotify.newBuilder() SceneEntityAppearNotify.Builder proto = SceneEntityAppearNotify.newBuilder()
.setAppearType(VisionType.VISION_BORN) .setAppearType(VisionType.VISION_TYPE_BORN)
.addEntityList(entity.toProto()); .addEntityList(entity.toProto());
this.setData(proto.build()); this.setData(proto.build());
......
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.data.GameData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.custom.ScenePointEntry; import emu.grasscutter.data.binout.ScenePointEntry;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
......
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