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
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.Grasscutter;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.shop.ShopInfo;
import emu.grasscutter.game.shop.ShopManager;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GetShopRspOuterClass.GetShopRsp;
import emu.grasscutter.net.proto.GetShopRspOuterClass;
import emu.grasscutter.net.proto.ItemParamOuterClass;
import emu.grasscutter.net.proto.ShopGoodsOuterClass.ShopGoods;
import emu.grasscutter.net.proto.ShopOuterClass.Shop;
public class PacketGetShopRsp extends GenshinPacket {
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
public PacketGetShopRsp(int shopType) {
public class PacketGetShopRsp extends BasePacket {
public PacketGetShopRsp(Player inv, int shopType) {
super(PacketOpcodes.GetShopRsp);
GetShopRsp proto = GetShopRsp.newBuilder()
.setShop(Shop.newBuilder().setShopType(shopType))
.build();
// TODO: CityReputationLevel
Shop.Builder shop = Shop.newBuilder()
.setShopType(shopType)
.setCityId(1) //mock
.setCityReputationLevel(10); //mock
ShopManager manager = Grasscutter.getGameServer().getShopManager();
if (manager.getShopData().get(shopType) != null) {
List<ShopInfo> list = manager.getShopData().get(shopType);
List<ShopGoods> goodsList = new ArrayList<>();
for (ShopInfo info : list) {
ShopGoods.Builder goods = ShopGoods.newBuilder()
.setGoodsId(info.getGoodsId())
.setGoodsItem(ItemParamOuterClass.ItemParam.newBuilder().setItemId(info.getGoodsItem().getId()).setCount(info.getGoodsItem().getCount()).build())
.setScoin(info.getScoin())
.setHcoin(info.getHcoin())
.setBoughtNum(inv.getGoodsLimitNum(info.getGoodsId()))
.setBuyLimit(info.getBuyLimit())
.setBeginTime(info.getBeginTime())
.setEndTime(info.getEndTime())
.setNextRefreshTime(info.getNextRefreshTime())
.setMinLevel(info.getMinLevel())
.setMaxLevel(info.getMaxLevel())
.addAllPreGoodsIdList(info.getPreGoodsIdList())
.setMcoin(info.getMcoin())
.setDisableType(info.getDisableType())
.setSecondarySheetId(info.getSecondarySheetId());
if (info.getCostItemList() != null) {
goods.addAllCostItemList(info.getCostItemList().stream().map(x -> ItemParamOuterClass.ItemParam.newBuilder().setItemId(x.getId()).setCount(x.getCount()).build()).collect(Collectors.toList()));
}
goodsList.add(goods.build());
}
shop.addAllGoodsList(goodsList);
}
this.setData(proto);
this.setData(GetShopRspOuterClass.GetShopRsp.newBuilder().setShop(shop).build());
}
}
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);
......
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.World;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.game.world.World;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GetWorldMpInfoRspOuterClass.GetWorldMpInfoRsp;
public class PacketGetWorldMpInfoRsp extends GenshinPacket {
public class PacketGetWorldMpInfoRsp extends BasePacket {
public PacketGetWorldMpInfoRsp(World world) {
super(PacketOpcodes.GetWorldMpInfoRsp);
......
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.H5ActivityIdsNotifyOuterClass.H5ActivityIdsNotify;
public class PacketH5ActivityIdsNotify extends GenshinPacket {
public class PacketH5ActivityIdsNotify extends BasePacket {
public PacketH5ActivityIdsNotify() {
super(PacketOpcodes.H5ActivityIdsNotify);
......
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.World;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.game.world.World;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.HostPlayerNotifyOuterClass.HostPlayerNotify;
public class PacketHostPlayerNotify extends GenshinPacket {
public class PacketHostPlayerNotify extends BasePacket {
public PacketHostPlayerNotify(World world) {
super(PacketOpcodes.HostPlayerNotify);
......
package emu.grasscutter.server.packet.send;
import java.util.Collection;
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.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
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);
ItemAddHintNotify proto = ItemAddHintNotify.newBuilder()
......@@ -21,13 +22,13 @@ public class PacketItemAddHintNotify extends GenshinPacket {
this.setData(proto);
}
public PacketItemAddHintNotify(List<GenshinItem> items, ActionReason reason) {
public PacketItemAddHintNotify(Collection<GameItem> items, ActionReason reason) {
super(PacketOpcodes.ItemAddHintNotify);
ItemAddHintNotify.Builder proto = ItemAddHintNotify.newBuilder()
.setReason(reason.getValue());
for (GenshinItem item : items) {
for (GameItem item : items) {
proto.addItemList(item.toItemHintProto());
}
......
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.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.LifeStateChangeNotifyOuterClass.LifeStateChangeNotify;
public class PacketLifeStateChangeNotify extends GenshinPacket {
public PacketLifeStateChangeNotify(GenshinEntity attacker, GenshinEntity target, LifeState lifeState) {
public class PacketLifeStateChangeNotify extends BasePacket {
public PacketLifeStateChangeNotify(GameEntity attacker, GameEntity target, LifeState lifeState) {
super(PacketOpcodes.LifeStateChangeNotify);
LifeStateChangeNotify proto = LifeStateChangeNotify.newBuilder()
......@@ -18,7 +18,7 @@ public class PacketLifeStateChangeNotify extends GenshinPacket {
this.setData(proto);
}
public PacketLifeStateChangeNotify(int attackerId, GenshinEntity target, LifeState lifeState) {
public PacketLifeStateChangeNotify(int attackerId, GameEntity target, LifeState lifeState) {
super(PacketOpcodes.LifeStateChangeNotify);
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;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
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) {
super(PacketOpcodes.NpcTalkRsp);
......
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.props.OpenState;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.OpenStateUpdateNotifyOuterClass.OpenStateUpdateNotify;
public class PacketOpenStateUpdateNotify extends GenshinPacket {
public class PacketOpenStateUpdateNotify extends BasePacket {
public PacketOpenStateUpdateNotify() {
super(PacketOpcodes.OpenStateUpdateNotify);
......
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
public class PacketPathfindingEnterSceneRsp extends GenshinPacket {
public class PacketPathfindingEnterSceneRsp extends BasePacket {
public PacketPathfindingEnterSceneRsp(int clientSequence) {
super(PacketOpcodes.PathfindingEnterSceneRsp);
......
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.PingRspOuterClass.PingRsp;
public class PacketPingRsp extends GenshinPacket {
public class PacketPingRsp extends BasePacket {
public PacketPingRsp(int clientSeq, int time) {
super(PacketOpcodes.PingRsp, clientSeq);
......
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.PlayerApplyEnterMpNotifyOuterClass.PlayerApplyEnterMpNotify;
public class PacketPlayerApplyEnterMpNotify extends GenshinPacket {
public class PacketPlayerApplyEnterMpNotify extends BasePacket {
public PacketPlayerApplyEnterMpNotify(GenshinPlayer srcPlayer) {
public PacketPlayerApplyEnterMpNotify(Player srcPlayer) {
super(PacketOpcodes.PlayerApplyEnterMpNotify);
PlayerApplyEnterMpNotify proto = PlayerApplyEnterMpNotify.newBuilder()
......
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.PlayerApplyEnterMpReasonOuterClass.PlayerApplyEnterMpReason;
import emu.grasscutter.net.proto.PlayerApplyEnterMpResultNotifyOuterClass;
import emu.grasscutter.net.proto.PlayerApplyEnterMpResultNotifyOuterClass.PlayerApplyEnterMpResultNotify;
public class PacketPlayerApplyEnterMpResultNotify extends GenshinPacket {
public class PacketPlayerApplyEnterMpResultNotify extends BasePacket {
public PacketPlayerApplyEnterMpResultNotify(GenshinPlayer target, boolean isAgreed, PlayerApplyEnterMpReason reason) {
public PacketPlayerApplyEnterMpResultNotify(Player target, boolean isAgreed, PlayerApplyEnterMpResultNotifyOuterClass.PlayerApplyEnterMpResultNotify.Reason reason) {
super(PacketOpcodes.PlayerApplyEnterMpResultNotify);
PlayerApplyEnterMpResultNotify proto = PlayerApplyEnterMpResultNotify.newBuilder()
......@@ -21,7 +22,7 @@ public class PacketPlayerApplyEnterMpResultNotify extends GenshinPacket {
this.setData(proto);
}
public PacketPlayerApplyEnterMpResultNotify(int targetId, String targetName, boolean isAgreed, PlayerApplyEnterMpReason reason) {
public PacketPlayerApplyEnterMpResultNotify(int targetId, String targetName, boolean isAgreed, PlayerApplyEnterMpResultNotify.Reason reason) {
super(PacketOpcodes.PlayerApplyEnterMpResultNotify);
PlayerApplyEnterMpResultNotify proto = PlayerApplyEnterMpResultNotify.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.PlayerApplyEnterMpResultRspOuterClass.PlayerApplyEnterMpResultRsp;
public class PacketPlayerApplyEnterMpResultRsp extends GenshinPacket {
public class PacketPlayerApplyEnterMpResultRsp extends BasePacket {
public PacketPlayerApplyEnterMpResultRsp(int applyUid, boolean isAgreed) {
super(PacketOpcodes.PlayerApplyEnterMpResultRsp);
......
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.PlayerApplyEnterMpRspOuterClass.PlayerApplyEnterMpRsp;
public class PacketPlayerApplyEnterMpRsp extends GenshinPacket {
public class PacketPlayerApplyEnterMpRsp extends BasePacket {
public PacketPlayerApplyEnterMpRsp(int targetUid) {
super(PacketOpcodes.PlayerApplyEnterMpRsp);
......
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.ChatInfoOuterClass.ChatInfo;
import emu.grasscutter.net.proto.PlayerChatNotifyOuterClass.PlayerChatNotify;
import emu.grasscutter.net.proto.SystemHintOuterClass.SystemHint;
public class PacketPlayerChatNotify extends GenshinPacket {
public class PacketPlayerChatNotify extends BasePacket {
public PacketPlayerChatNotify(GenshinPlayer sender, int channelId, String message) {
public PacketPlayerChatNotify(Player sender, int channelId, String message) {
super(PacketOpcodes.PlayerChatNotify);
ChatInfo info = ChatInfo.newBuilder()
......@@ -26,7 +26,7 @@ public class PacketPlayerChatNotify extends GenshinPacket {
this.setData(proto);
}
public PacketPlayerChatNotify(GenshinPlayer sender, int channelId, int emote) {
public PacketPlayerChatNotify(Player sender, int channelId, int emote) {
super(PacketOpcodes.PlayerChatNotify);
ChatInfo info = ChatInfo.newBuilder()
......@@ -43,7 +43,7 @@ public class PacketPlayerChatNotify extends GenshinPacket {
this.setData(proto);
}
public PacketPlayerChatNotify(GenshinPlayer sender, int channelId, SystemHint systemHint) {
public PacketPlayerChatNotify(Player sender, int channelId, ChatInfo.SystemHint systemHint) {
super(PacketOpcodes.PlayerChatNotify);
ChatInfo info = ChatInfo.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.PlayerChatRspOuterClass.PlayerChatRsp;
public class PacketPlayerChatRsp extends GenshinPacket {
public class PacketPlayerChatRsp extends BasePacket {
public PacketPlayerChatRsp() {
super(PacketOpcodes.PlayerChatRsp);
......
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.PlayerDataNotifyOuterClass.PlayerDataNotify;
import emu.grasscutter.net.proto.PropValueOuterClass.PropValue;
public class PacketPlayerDataNotify extends GenshinPacket {
public class PacketPlayerDataNotify extends BasePacket {
public PacketPlayerDataNotify(GenshinPlayer player) {
public PacketPlayerDataNotify(Player player) {
super(PacketOpcodes.PlayerDataNotify, 2);
PlayerDataNotify.Builder p = PlayerDataNotify.newBuilder()
.setNickName(player.getNickname())
.setClientTime(System.currentTimeMillis())
.setServerTime(System.currentTimeMillis())
.setIsFirstLoginToday(true)
.setRegionId(player.getRegionId());
......
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