Commit 01b190bc authored by Magix's avatar Magix Committed by GitHub
Browse files

UPGRADE TO 1.1.0 POG

Merge `development` into `stable`
parents 6b81b888 1beddf16
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.database.DatabaseHelper;
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.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PlayerLoginReqOuterClass.PlayerLoginReq;
......@@ -10,6 +10,7 @@ import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.game.GameSession.SessionState;
import emu.grasscutter.server.packet.send.PacketPlayerLoginRsp;
import emu.grasscutter.server.packet.send.PacketTakeAchievementRewardReq;
@Opcodes(PacketOpcodes.PlayerLoginReq) // Sends initial data packets
public class HandlerPlayerLoginReq extends PacketHandler {
......@@ -30,12 +31,12 @@ public class HandlerPlayerLoginReq extends PacketHandler {
}
// Load character from db
GenshinPlayer player = DatabaseHelper.getPlayerById(session.getAccount().getPlayerUid());
Player player = DatabaseHelper.getPlayerById(session.getAccount().getPlayerUid());
if (player == null) {
// Send packets
session.setState(SessionState.PICKING_CHARACTER);
session.send(new GenshinPacket(PacketOpcodes.DoSetPlayerBornDataNotify));
session.send(new BasePacket(PacketOpcodes.DoSetPlayerBornDataNotify));
} else {
// Set character
session.setPlayer(player);
......@@ -47,6 +48,7 @@ public class HandlerPlayerLoginReq extends PacketHandler {
// Final packet to tell client logging in is done
session.send(new PacketPlayerLoginRsp(session));
session.send(new PacketTakeAchievementRewardReq(session));
}
}
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.PlayerQuitDungeonReq)
public class HandlerPlayerQuitDungeonReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
session.getPlayer().getServer().getDungeonManager().exitDungeon(session.getPlayer());
}
}
......@@ -19,8 +19,6 @@ public class HandlerPrivateChatReq extends PacketHandler {
} else if (content == PrivateChatReq.ContentCase.ICON) {
session.getServer().getChatManager().sendPrivateMessage(session.getPlayer(), req.getTargetUid(), req.getIcon());
}
//session.send(new GenshinPacket(PacketOpcodes.PrivateChatRsp)); // Unused by server
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.game.mail.Mail;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.GetAllMailReqOuterClass;
import emu.grasscutter.net.proto.ReadMailNotifyOuterClass;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketMailChangeNotify;
import java.util.ArrayList;
import java.util.List;
@Opcodes(PacketOpcodes.ReadMailNotify)
public class HandlerReadMailNotify extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
ReadMailNotifyOuterClass.ReadMailNotify req = ReadMailNotifyOuterClass.ReadMailNotify.parseFrom(payload);
List<Mail> updatedMail = new ArrayList<>();
for (int mailId : req.getMailIdListList()) {
Mail message = session.getPlayer().getMail(mailId);
message.isRead = true;
session.getPlayer().replaceMailByIndex(mailId, message);
updatedMail.add(message);
}
session.send(new PacketMailChangeNotify(session.getPlayer(), updatedMail));
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.game.entity.EntityAvatar;
import emu.grasscutter.game.entity.EntityMonster;
import emu.grasscutter.game.entity.GameEntity;
import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.game.props.LifeState;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.SceneEntityDrownReqOuterClass.SceneEntityDrownReq;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketSceneEntityDrownRsp;
@Opcodes(PacketOpcodes.SceneEntityDrownReq)
public class HandlerSceneEntityDrownReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
SceneEntityDrownReq req = SceneEntityDrownReq.parseFrom(payload);
GameEntity entity = session.getPlayer().getScene().getEntityById(req.getEntityId());
if (entity == null || !(entity instanceof EntityMonster || entity instanceof EntityAvatar)) {
return;
}
entity.setFightProperty(FightProperty.FIGHT_PROP_CUR_HP, 0);
//TODO: make a list somewhere of all entities to remove per tick rather than one by one
session.getPlayer().getScene().killEntity(entity, 0);
session.getPlayer().getScene().broadcastPacket(new PacketSceneEntityDrownRsp(req.getEntityId()));
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.game.GenshinPlayer.SceneLoadState;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.game.player.Player.SceneLoadState;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.packet.PacketHandler;
......@@ -31,7 +31,7 @@ public class HandlerSceneInitFinishReq extends PacketHandler {
session.send(new PacketWorldPlayerInfoNotify(session.getPlayer().getWorld()));
session.send(new PacketWorldDataNotify(session.getPlayer().getWorld()));
session.send(new PacketSceneUnlockInfoNotify());
session.send(new GenshinPacket(PacketOpcodes.SceneForceUnlockNotify));
session.send(new BasePacket(PacketOpcodes.SceneForceUnlockNotify));
session.send(new PacketHostPlayerNotify(session.getPlayer().getWorld()));
session.send(new PacketSceneTimeNotify(session.getPlayer()));
......
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.data.GenshinData;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.custom.ScenePointEntry;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
......@@ -19,7 +19,7 @@ public class HandlerSceneTransToPointReq extends PacketHandler {
SceneTransToPointReq req = SceneTransToPointReq.parseFrom(payload);
String code = req.getSceneId() + "_" + req.getPointId();
ScenePointEntry scenePointEntry = GenshinData.getScenePointEntries().get(code);
ScenePointEntry scenePointEntry = GameData.getScenePointEntries().get(code);
if (scenePointEntry != null) {
float x = scenePointEntry.getPointData().getTranPos().getX();
......
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.game.entity.EntityGadget;
import emu.grasscutter.game.entity.GameEntity;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.SelectWorktopOptionReqOuterClass.SelectWorktopOptionReq;
import emu.grasscutter.scripts.constants.EventType;
import emu.grasscutter.scripts.data.ScriptArgs;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketSelectWorktopOptionRsp;
@Opcodes(PacketOpcodes.SelectWorktopOptionReq)
public class HandlerSelectWorktopOptionReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
SelectWorktopOptionReq req = SelectWorktopOptionReq.parseFrom(payload);
try {
GameEntity entity = session.getPlayer().getScene().getEntityById(req.getGadgetEntityId());
if (entity == null || !(entity instanceof EntityGadget)) {
return;
}
session.getPlayer().getScene().getScriptManager().callEvent(
EventType.EVENT_SELECT_OPTION,
new ScriptArgs(entity.getConfigId(), req.getOptionId())
);
} finally {
// Always send packet
session.send(new PacketSelectWorktopOptionRsp(req.getGadgetEntityId(), req.getOptionId()));
}
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.SetEntityClientDataNotifyOuterClass.SetEntityClientDataNotify;
......@@ -20,7 +20,7 @@ public class HandlerSetEntityClientDataNotify extends PacketHandler {
// Make sure packet is a valid proto before replaying it to the other players
SetEntityClientDataNotify notif = SetEntityClientDataNotify.parseFrom(payload);
GenshinPacket packet = new GenshinPacket(PacketOpcodes.SetEntityClientDataNotify, true);
BasePacket packet = new BasePacket(PacketOpcodes.SetEntityClientDataNotify, true);
packet.setData(notif);
session.getPlayer().getScene().broadcastPacketToOthers(session.getPlayer(), packet);
......
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq;
import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketGetPlayerSocialDetailRsp;
import emu.grasscutter.server.packet.send.PacketSetPlayerBirthdayRsp;
@Opcodes(PacketOpcodes.SetPlayerBirthdayReq)
public class HandlerSetPlayerBirthdayReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
SetPlayerBirthdayReq req = SetPlayerBirthdayReq.parseFrom(payload);
// RET_BIRTHDAY_CANNOT_BE_SET_TWICE = 7009
if (session.getPlayer().hasBirthday()) {
session.send(new PacketSetPlayerBirthdayRsp(7009));
return;
}
int month = req.getBirthday().getMonth();
int day = req.getBirthday().getDay();
// RET_BIRTHDAY_FORMAT_ERROR = 7022
if (!isValidBirthday(month, day)) {
session.send(new PacketSetPlayerBirthdayRsp(7022));
return;
}
// Update birthday value
session.getPlayer().setBirthday(day, month);
// Save birthday month and day
session.getPlayer().save();
SocialDetail.Builder detail = session.getPlayer().getSocialDetail();
session.send(new PacketSetPlayerBirthdayRsp(session.getPlayer()));
session.send(new PacketGetPlayerSocialDetailRsp(detail));
}
private boolean isValidBirthday(int month, int day) {
switch (month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
return day > 0 & day <= 31;
case 4:
case 6:
case 9:
case 11:
return day > 0 && day <= 30;
case 2:
return day > 0 & day <= 29;
}
return false;
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.GenshinConstants;
import emu.grasscutter.GameConstants;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GenshinData;
import emu.grasscutter.command.commands.SendMailCommand.MailBuilder;
import emu.grasscutter.data.GameData;
import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.avatar.GenshinAvatar;
import emu.grasscutter.net.packet.GenshinPacket;
import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.mail.Mail;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.SetPlayerBornDataReqOuterClass.SetPlayerBornDataReq;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.server.event.game.PlayerCreationEvent;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.game.GameSession.SessionState;
import java.util.Arrays;
@Opcodes(PacketOpcodes.SetPlayerBornDataReq)
public class HandlerSetPlayerBornDataReq extends PacketHandler {
......@@ -23,22 +28,31 @@ public class HandlerSetPlayerBornDataReq extends PacketHandler {
// Sanity checks
int avatarId = req.getAvatarId();
int startingSkillDepot = 0;
if (avatarId == GenshinConstants.MAIN_CHARACTER_MALE) {
int startingSkillDepot;
if (avatarId == GameConstants.MAIN_CHARACTER_MALE) {
startingSkillDepot = 504;
} else if (avatarId == GenshinConstants.MAIN_CHARACTER_FEMALE) {
} else if (avatarId == GameConstants.MAIN_CHARACTER_FEMALE) {
startingSkillDepot = 704;
} else {
return;
}
// Make sure resources folder is set
if (!GameData.getAvatarDataMap().containsKey(avatarId)) {
Grasscutter.getLogger().error("No avatar data found! Please check your ExcelBinOutput folder.");
session.close();
return;
}
String nickname = req.getNickName();
if (nickname == null) {
nickname = "Traveler";
}
// Create character
GenshinPlayer player = new GenshinPlayer(session);
// Call creation event.
PlayerCreationEvent event = new PlayerCreationEvent(session, Player.class); event.call();
// Create player instance from event.
Player player = event.getPlayerClass().getDeclaredConstructor(GameSession.class).newInstance(session);
player.setNickname(nickname);
try {
......@@ -47,8 +61,8 @@ public class HandlerSetPlayerBornDataReq extends PacketHandler {
// Create avatar
if (player.getAvatars().getAvatarCount() == 0) {
GenshinAvatar mainCharacter = new GenshinAvatar(avatarId);
mainCharacter.setSkillDepot(GenshinData.getAvatarSkillDepotDataMap().get(startingSkillDepot));
Avatar mainCharacter = new Avatar(avatarId);
mainCharacter.setSkillDepot(GameData.getAvatarSkillDepotDataMap().get(startingSkillDepot));
player.addAvatar(mainCharacter);
player.setMainCharacterId(avatarId);
player.setHeadImage(avatarId);
......@@ -68,11 +82,20 @@ public class HandlerSetPlayerBornDataReq extends PacketHandler {
session.setState(SessionState.ACTIVE);
// Born resp packet
session.send(new GenshinPacket(PacketOpcodes.SetPlayerBornDataRsp));
session.send(new BasePacket(PacketOpcodes.SetPlayerBornDataRsp));
// Default mail
MailBuilder mailBuilder = new MailBuilder(player.getUid(), new Mail());
mailBuilder.mail.mailContent.title = Grasscutter.getConfig().GameServer.WelcomeMailTitle;
mailBuilder.mail.mailContent.sender = Grasscutter.getConfig().GameServer.WelcomeMailSender;
// Please credit Grasscutter if changing something here. We don't condone commercial use of the project.
mailBuilder.mail.mailContent.content = Grasscutter.getConfig().GameServer.WelcomeMailContent + "\n<type=\"browser\" text=\"GitHub\" href=\"https://github.com/Melledy/Grasscutter\"/>";
mailBuilder.mail.itemList.addAll(Arrays.asList(Grasscutter.getConfig().GameServer.WelcomeMailItems));
mailBuilder.mail.importance = 1;
player.sendMail(mailBuilder.mail);
} catch (Exception e) {
Grasscutter.getLogger().error("Error creating player object: ", e);
session.close();
}
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.props.PlayerProperty;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PropValueOuterClass.PropValue;
import emu.grasscutter.net.proto.SetPlayerPropReqOuterClass.SetPlayerPropReq;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketSetPlayerPropRsp;
import java.util.ArrayList;
import java.util.List;
@Opcodes(PacketOpcodes.SetPlayerPropReq)
public class HandlerSetPlayerPropReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
// Auto template
SetPlayerPropReq req = SetPlayerPropReq.parseFrom(payload);
Player player = session.getPlayer();
List<PropValue> propList = req.getPropListList();
for (int i = 0; i < propList.size(); i++) {
PlayerProperty prop = PlayerProperty.getPropById(propList.get(i).getType());
if (prop == PlayerProperty.PROP_IS_MP_MODE_AVAILABLE) {
if (!player.setProperty(prop, (int)propList.get(i).getVal())) {
session.send(new PacketSetPlayerPropRsp(1));
return;
}
}
}
player.save();
session.send(new PacketSetPlayerPropRsp(0));
}
}
package emu.grasscutter.server.packet.recv;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GameData;
import emu.grasscutter.data.common.RewardItemData;
import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.props.ActionReason;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.TakePlayerLevelRewardReqOuterClass.TakePlayerLevelRewardReq;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketItemAddHintNotify;
import emu.grasscutter.server.packet.send.PacketTakePlayerLevelRewardRsp;
@Opcodes(PacketOpcodes.TakePlayerLevelRewardReq)
public class HandlerTakePlayerLevelRewardReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
TakePlayerLevelRewardReq req = TakePlayerLevelRewardReq.parseFrom(payload);
int level = req.getLevel();
int rewardId = GameData.getPlayerLevelDataMap().get(level).getRewardId();
if (rewardId != 0) {
List<RewardItemData> rewardItems = GameData.getRewardDataMap().get(rewardId).getRewardItemList();
List<GameItem> items = new LinkedList<>();
for (RewardItemData rewardItem : rewardItems) {
if (rewardItem != null) {
if (rewardItem.getItemId() != 0) {
items.add(new GameItem(rewardItem.getItemId(), rewardItem.getItemCount()));
}
}
}
session.getPlayer().getInventory().addItems(items);
session.getPlayer().sendPacket(new PacketItemAddHintNotify(items, ActionReason.PlayerUpgradeReward));
Set<Integer> rewardedLevels = session.getPlayer().getRewardedLevels();
rewardedLevels.add(level);
session.getPlayer().setRewardedLevels(rewardedLevels);
}
session.send(new PacketTakePlayerLevelRewardRsp(level, rewardId));
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.TowerEnterLevelReqOuterClass.TowerEnterLevelReq;
import emu.grasscutter.server.game.GameSession;
@Opcodes(PacketOpcodes.TowerEnterLevelReq)
public class HandlerTowerEnterLevelReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
TowerEnterLevelReq req = TowerEnterLevelReq.parseFrom(payload);
//session.send(new PacketTowerCurLevelRecordChangeNotify());
session.getPlayer().getTowerManager().enterLevel(req.getEnterPointId());
//session.send(new PacketTowerLevelStarCondNotify());
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.TowerTeamOuterClass;
import emu.grasscutter.net.proto.TowerTeamSelectReqOuterClass.TowerTeamSelectReq;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketTowerTeamSelectRsp;
@Opcodes(PacketOpcodes.TowerTeamSelectReq)
public class HandlerTowerTeamSelectReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
TowerTeamSelectReq req = TowerTeamSelectReq.parseFrom(payload);
var towerTeams = req.getTowerTeamListList().stream()
.map(TowerTeamOuterClass.TowerTeam::getAvatarGuidListList)
.toList();
session.getPlayer().getTowerManager().teamSelect(req.getFloorId(), towerTeams);
session.send(new PacketTowerTeamSelectRsp());
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.UpdatePlayerShowAvatarListReqOuterClass;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketUpdatePlayerShowAvatarListRsp;
@Opcodes(PacketOpcodes.UpdatePlayerShowAvatarListReq)
public class HandlerUpdatePlayerShowAvatarListReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
UpdatePlayerShowAvatarListReqOuterClass.UpdatePlayerShowAvatarListReq req = UpdatePlayerShowAvatarListReqOuterClass.UpdatePlayerShowAvatarListReq.parseFrom(payload);
session.getPlayer().setShowAvatars(req.getIsShowAvatar());
session.getPlayer().setShowAvatarList(req.getShowAvatarIdListList());
session.send(new PacketUpdatePlayerShowAvatarListRsp(req.getIsShowAvatar(), req.getShowAvatarIdListList()));
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.game.inventory.GenshinItem;
import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.UseItemReqOuterClass.UseItemReq;
......@@ -15,7 +15,7 @@ public class HandlerUseItemReq extends PacketHandler {
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
UseItemReq req = UseItemReq.parseFrom(payload);
GenshinItem useItem = session.getServer().getInventoryManager().useItem(session.getPlayer(), req.getTargetGuid(), req.getGuid(), req.getCount());
GameItem useItem = session.getServer().getInventoryManager().useItem(session.getPlayer(), req.getTargetGuid(), req.getGuid(), req.getCount(), req.getOptionIdx());
if (useItem != null) {
session.send(new PacketUseItemRsp(req.getTargetGuid(), useItem));
} else {
......
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.VehicleInteractReqOuterClass;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketVehicleInteractRsp;
@Opcodes(PacketOpcodes.VehicleInteractReq)
public class HandlerVehicleInteractReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
VehicleInteractReqOuterClass.VehicleInteractReq req = VehicleInteractReqOuterClass.VehicleInteractReq.parseFrom(payload);
session.send(new PacketVehicleInteractRsp(session.getPlayer(), req.getEntityId(), req.getInteractType()));
}
}
package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.VehicleSpawnReqOuterClass;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketVehicleSpawnRsp;
import emu.grasscutter.utils.Position;
@Opcodes(PacketOpcodes.VehicleSpawnReq)
public class HandlerVehicleSpawnReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
VehicleSpawnReqOuterClass.VehicleSpawnReq req = VehicleSpawnReqOuterClass.VehicleSpawnReq.parseFrom(payload);
session.send(new PacketVehicleSpawnRsp(session.getPlayer(), req.getVehicleId(), req.getPointId(), new Position(req.getPos()), new Position(req.getRot())));
}
}
......@@ -3,7 +3,9 @@ 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.net.proto.WorldPlayerDieNotifyOuterClass;
import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketWorldPlayerReviveRsp;
@Opcodes(PacketOpcodes.WorldPlayerReviveReq)
public class HandlerWorldPlayerReviveReq extends PacketHandler {
......@@ -11,6 +13,7 @@ public class HandlerWorldPlayerReviveReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
session.getPlayer().getTeamManager().respawnTeam();
session.send(new PacketWorldPlayerReviveRsp());
}
}
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