Commit 7925d1cd authored by Melledy's avatar Melledy
Browse files

Initial commit

parents
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.server.game.GameSession;
@Opcodes(PacketOpcodes.WorldPlayerReviveReq)
public class HandlerWorldPlayerReviveReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
session.getPlayer().getTeamManager().respawnTeam();
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
public class Packet extends GenshinPacket {
public Packet() {
super(PacketOpcodes.NONE);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.entity.EntityAvatar;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AbilityChangeNotifyOuterClass.AbilityChangeNotify;
public class PacketAbilityChangeNotify extends GenshinPacket {
public PacketAbilityChangeNotify(EntityAvatar entity) {
super(PacketOpcodes.AbilityChangeNotify);
AbilityChangeNotify proto = AbilityChangeNotify.newBuilder()
.setEntityId(entity.getId())
.setAbilityControlBlock(entity.getAbilityControlBlock())
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import java.util.List;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AbilityInvocationsNotifyOuterClass.AbilityInvocationsNotify;
import emu.grasscutter.net.proto.AbilityInvokeEntryOuterClass.AbilityInvokeEntry;
public class PacketAbilityInvocationsNotify extends GenshinPacket {
public PacketAbilityInvocationsNotify(AbilityInvokeEntry entry) {
super(PacketOpcodes.AbilityInvocationsNotify, true);
AbilityInvocationsNotify proto = AbilityInvocationsNotify.newBuilder()
.addInvokes(entry)
.build();
this.setData(proto);
}
public PacketAbilityInvocationsNotify(List<AbilityInvokeEntry> entries) {
super(PacketOpcodes.AbilityInvocationsNotify, true);
AbilityInvocationsNotify proto = AbilityInvocationsNotify.newBuilder()
.addAllInvokes(entries)
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.friends.Friendship;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AskAddFriendNotifyOuterClass.AskAddFriendNotify;
public class PacketAskAddFriendNotify extends GenshinPacket {
public PacketAskAddFriendNotify(Friendship friendship) {
super(PacketOpcodes.AskAddFriendNotify);
AskAddFriendNotify proto = AskAddFriendNotify.newBuilder()
.setTargetUid(friendship.getFriendId())
.setTargetFriendBrief(friendship.toProto())
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AskAddFriendRspOuterClass.AskAddFriendRsp;
public class PacketAskAddFriendRsp extends GenshinPacket {
public PacketAskAddFriendRsp(int targetUid) {
super(PacketOpcodes.AskAddFriendRsp);
AskAddFriendRsp proto = AskAddFriendRsp.newBuilder()
.setTargetUid(targetUid)
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.avatar.GenshinAvatar;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarAddNotifyOuterClass.AvatarAddNotify;
public class PacketAvatarAddNotify extends GenshinPacket {
public PacketAvatarAddNotify(GenshinAvatar avatar, boolean addedToTeam) {
super(PacketOpcodes.AvatarAddNotify);
AvatarAddNotify proto = AvatarAddNotify.newBuilder()
.setAvatar(avatar.toProto())
.setIsInTeam(addedToTeam)
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.entity.EntityAvatar;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarChangeCostumeNotifyOuterClass.AvatarChangeCostumeNotify;
public class PacketAvatarChangeCostumeNotify extends GenshinPacket {
public PacketAvatarChangeCostumeNotify(EntityAvatar entity) {
super(PacketOpcodes.AvatarChangeCostumeNotify);
AvatarChangeCostumeNotify proto = AvatarChangeCostumeNotify.newBuilder()
.setEntity(entity.toProto())
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarChangeCostumeRspOuterClass.AvatarChangeCostumeRsp;
public class PacketAvatarChangeCostumeRsp extends GenshinPacket {
public PacketAvatarChangeCostumeRsp(long avatarGuid, int costumeId) {
super(PacketOpcodes.AvatarChangeCostumeRsp);
AvatarChangeCostumeRsp proto = AvatarChangeCostumeRsp.newBuilder()
.setAvatarGuid(avatarGuid)
.setCostumeId(costumeId)
.build();
this.setData(proto);
}
public PacketAvatarChangeCostumeRsp() {
super(PacketOpcodes.AvatarChangeCostumeRsp);
AvatarChangeCostumeRsp proto = AvatarChangeCostumeRsp.newBuilder()
.setRetcode(1)
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import java.util.Map.Entry;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.TeamInfo;
import emu.grasscutter.game.avatar.GenshinAvatar;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarDataNotifyOuterClass.AvatarDataNotify;
import emu.grasscutter.net.proto.AvatarTeamOuterClass.AvatarTeam;
public class PacketAvatarDataNotify extends GenshinPacket {
public PacketAvatarDataNotify(GenshinPlayer player) {
super(PacketOpcodes.AvatarDataNotify, 2);
AvatarDataNotify.Builder proto = AvatarDataNotify.newBuilder()
.setCurAvatarTeamId(player.getTeamManager().getCurrentTeamId())
.setChooseAvatarGuid(player.getTeamManager().getCurrentCharacterGuid())
.addAllOwnedFlycloakList(player.getFlyCloakList())
.addAllOwnedCostumeList(player.getCostumeList());
for (GenshinAvatar avatar : player.getAvatars()) {
proto.addAvatarList(avatar.toProto());
}
for (Entry<Integer, TeamInfo> entry : player.getTeamManager().getTeams().entrySet()) {
TeamInfo teamInfo = entry.getValue();
AvatarTeam.Builder avatarTeam = AvatarTeam.newBuilder()
.setTeamName(teamInfo.getName());
for (int i = 0; i < teamInfo.getAvatars().size(); i++) {
GenshinAvatar avatar = player.getAvatars().getAvatarById(teamInfo.getAvatars().get(i));
avatarTeam.addAvatarGuidList(avatar.getGuid());
}
proto.putAvatarTeamMap(entry.getKey(), avatarTeam.build());
}
this.setData(proto.build());
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarDieAnimationEndRspOuterClass.AvatarDieAnimationEndRsp;
public class PacketAvatarDieAnimationEndRsp extends GenshinPacket {
public PacketAvatarDieAnimationEndRsp(long dieGuid, int skillId) {
super(PacketOpcodes.AvatarDieAnimationEndRsp);
AvatarDieAnimationEndRsp proto = AvatarDieAnimationEndRsp.newBuilder()
.setDieGuid(dieGuid)
.setSkillId(skillId)
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.avatar.GenshinAvatar;
import emu.grasscutter.game.inventory.EquipType;
import emu.grasscutter.game.inventory.GenshinItem;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarEquipChangeNotifyOuterClass.AvatarEquipChangeNotify;
public class PacketAvatarEquipChangeNotify extends GenshinPacket {
public PacketAvatarEquipChangeNotify(GenshinAvatar avatar, GenshinItem item) {
super(PacketOpcodes.AvatarEquipChangeNotify);
AvatarEquipChangeNotify.Builder proto = AvatarEquipChangeNotify.newBuilder()
.setAvatarGuid(avatar.getGuid())
.setEquipType(item.getEquipSlot())
.setItemId(item.getItemId())
.setEquipGuid(item.getGuid());
if (item.getItemData().getEquipType() == EquipType.EQUIP_WEAPON) {
proto.setWeapon(item.createSceneWeaponInfo());
} else {
proto.setReliquary(item.createSceneReliquaryInfo());
}
this.setData(proto);
}
public PacketAvatarEquipChangeNotify(GenshinAvatar avatar, EquipType slot) {
super(PacketOpcodes.AvatarEquipChangeNotify);
AvatarEquipChangeNotify.Builder proto = AvatarEquipChangeNotify.newBuilder()
.setAvatarGuid(avatar.getGuid())
.setEquipType(slot.getValue());
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.avatar.GenshinAvatar;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarFightPropNotifyOuterClass.AvatarFightPropNotify;
public class PacketAvatarFightPropNotify extends GenshinPacket {
public PacketAvatarFightPropNotify(GenshinAvatar avatar) {
super(PacketOpcodes.AvatarFightPropNotify);
AvatarFightPropNotify proto = AvatarFightPropNotify.newBuilder()
.setAvatarGuid(avatar.getGuid())
.putAllFightPropMap(avatar.getFightProperties())
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.avatar.GenshinAvatar;
import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarFightPropUpdateNotifyOuterClass.AvatarFightPropUpdateNotify;
public class PacketAvatarFightPropUpdateNotify extends GenshinPacket {
public PacketAvatarFightPropUpdateNotify(GenshinAvatar avatar, FightProperty prop) {
super(PacketOpcodes.AvatarFightPropUpdateNotify);
AvatarFightPropUpdateNotify proto = AvatarFightPropUpdateNotify.newBuilder()
.setAvatarGuid(avatar.getGuid())
.putFightPropMap(prop.getId(), avatar.getFightProperty(prop))
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.avatar.GenshinAvatar;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarFlycloakChangeNotifyOuterClass.AvatarFlycloakChangeNotify;
public class PacketAvatarFlycloakChangeNotify extends GenshinPacket {
public PacketAvatarFlycloakChangeNotify(GenshinAvatar avatar) {
super(PacketOpcodes.AvatarFlycloakChangeNotify);
AvatarFlycloakChangeNotify proto = AvatarFlycloakChangeNotify.newBuilder()
.setAvatarGuid(avatar.getGuid())
.setFlycloakId(avatar.getFlyCloak())
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarGainCostumeNotifyOuterClass.AvatarGainCostumeNotify;
public class PacketAvatarGainCostumeNotify extends GenshinPacket {
public PacketAvatarGainCostumeNotify(int costumeId) {
super(PacketOpcodes.AvatarGainCostumeNotify);
AvatarGainCostumeNotify proto = AvatarGainCostumeNotify.newBuilder()
.setCostumeId(costumeId)
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarGainFlycloakNotifyOuterClass.AvatarGainFlycloakNotify;
public class PacketAvatarGainFlycloakNotify extends GenshinPacket {
public PacketAvatarGainFlycloakNotify(int flycloak) {
super(PacketOpcodes.AvatarGainFlycloakNotify);
AvatarGainFlycloakNotify proto = AvatarGainFlycloakNotify.newBuilder()
.setFlycloakId(flycloak)
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.avatar.GenshinAvatar;
import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.game.props.LifeState;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarLifeStateChangeNotifyOuterClass.AvatarLifeStateChangeNotify;
public class PacketAvatarLifeStateChangeNotify extends GenshinPacket {
public PacketAvatarLifeStateChangeNotify(GenshinAvatar avatar) {
super(PacketOpcodes.AvatarLifeStateChangeNotify);
AvatarLifeStateChangeNotify proto = AvatarLifeStateChangeNotify.newBuilder()
.setAvatarGuid(avatar.getGuid())
.setLifeState(avatar.getFightProperty(FightProperty.FIGHT_PROP_CUR_HP) > 0 ? LifeState.LIFE_ALIVE.getValue() : LifeState.LIFE_DEAD.getValue())
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.avatar.GenshinAvatar;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarPromoteRspOuterClass.AvatarPromoteRsp;
public class PacketAvatarPromoteRsp extends GenshinPacket {
public PacketAvatarPromoteRsp(GenshinAvatar avatar) {
super(PacketOpcodes.AvatarPromoteRsp);
AvatarPromoteRsp proto = AvatarPromoteRsp.newBuilder()
.setGuid(avatar.getGuid())
.build();
this.setData(proto);
}
}
package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.avatar.GenshinAvatar;
import emu.grasscutter.game.props.PlayerProperty;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarPropNotifyOuterClass.AvatarPropNotify;
public class PacketAvatarPropNotify extends GenshinPacket {
public PacketAvatarPropNotify(GenshinAvatar avatar) {
super(PacketOpcodes.AvatarPropNotify);
AvatarPropNotify proto = AvatarPropNotify.newBuilder()
.setAvatarGuid(avatar.getGuid())
.putPropMap(PlayerProperty.PROP_LEVEL.getId(), avatar.getLevel())
.putPropMap(PlayerProperty.PROP_EXP.getId(), avatar.getExp())
.putPropMap(PlayerProperty.PROP_BREAK_LEVEL.getId(), avatar.getPromoteLevel())
.putPropMap(PlayerProperty.PROP_SATIATION_VAL.getId(), 0)
.putPropMap(PlayerProperty.PROP_SATIATION_PENALTY_TIME.getId(), 0)
.build();
this.setData(proto);
}
public PacketAvatarPropNotify(GenshinAvatar avatar, PlayerProperty prop, int value) {
super(PacketOpcodes.AvatarPropNotify);
AvatarPropNotify proto = AvatarPropNotify.newBuilder()
.setAvatarGuid(avatar.getGuid())
.putPropMap(prop.getId(), value)
.build();
this.setData(proto);
}
}
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