Merge packet handlers from quests/quests

This commit is contained in:
KingRainbow44 2023-04-14 21:59:15 -04:00
parent b5190bca45
commit 7bdcf4e0d2
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
11 changed files with 243 additions and 229 deletions

2
gradlew.bat vendored
View File

@ -33,7 +33,7 @@ set APP_HOME=%DIRNAME%
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" set DEFAULT_JVM_OPTS="-Xmx4G" "-Xms64m"
@rem Find java.exe @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome

View File

@ -15,6 +15,6 @@ public class HandlerChangeGameTimeReq extends PacketHandler {
var req = ChangeGameTimeReq.parseFrom(payload); var req = ChangeGameTimeReq.parseFrom(payload);
session.getPlayer().getWorld().changeTime(req.getGameTime(), req.getExtraDays()); session.getPlayer().getWorld().changeTime(req.getGameTime(), req.getExtraDays());
session.getPlayer().sendPacket(new PacketChangeGameTimeRsp(session.getPlayer())); session.getPlayer().sendPacket(new PacketChangeGameTimeRsp(session.getPlayer(), req.getExtraDays()));
} }
} }

View File

@ -24,6 +24,6 @@ public class HandlerEvtDoSkillSuccNotify extends PacketHandler {
// Handle skill notify in other managers. // Handle skill notify in other managers.
player.getStaminaManager().handleEvtDoSkillSuccNotify(session, skillId, casterId); player.getStaminaManager().handleEvtDoSkillSuccNotify(session, skillId, casterId);
player.getEnergyManager().handleEvtDoSkillSuccNotify(session, skillId, casterId); player.getEnergyManager().handleEvtDoSkillSuccNotify(session, skillId, casterId);
player.getQuestManager().queueEvent(QuestContent.QUEST_CONTENT_SKILL, skillId, 0); player.getQuestManager().queueEvent(QuestContent.QUEST_CONTENT_SKILL, skillId);
} }
} }

View File

@ -3,6 +3,7 @@ package emu.grasscutter.server.packet.recv;
import emu.grasscutter.data.GameData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.binout.MainQuestData; import emu.grasscutter.data.binout.MainQuestData;
import emu.grasscutter.data.binout.MainQuestData.TalkData; import emu.grasscutter.data.binout.MainQuestData.TalkData;
import emu.grasscutter.game.quest.enums.QuestCond;
import emu.grasscutter.game.quest.enums.QuestContent; import emu.grasscutter.game.quest.enums.QuestContent;
import emu.grasscutter.net.packet.Opcodes; import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.net.packet.PacketHandler;
@ -20,7 +21,7 @@ public class HandlerNpcTalkReq extends PacketHandler {
// Check if mainQuest exists // Check if mainQuest exists
// remove last 2 digits to get a mainQuestId // remove last 2 digits to get a mainQuestId
int talkId = req.getTalkId(); int talkId = req.getTalkId();
int mainQuestId = talkId / 100; int mainQuestId = GameData.getQuestTalkMap().getOrDefault(talkId, talkId / 100);
MainQuestData mainQuestData = GameData.getMainQuestDataMap().get(mainQuestId); MainQuestData mainQuestData = GameData.getMainQuestDataMap().get(mainQuestId);
if (mainQuestData != null) { if (mainQuestData != null) {
@ -36,30 +37,17 @@ public class HandlerNpcTalkReq extends PacketHandler {
} }
// Add to the list of done talks for this quest. // Add to the list of done talks for this quest.
var mainQuest = session.getPlayer().getQuestManager().getMainQuestById(mainQuestId); var questManager = session.getPlayer().getQuestManager();
var mainQuest = questManager.getMainQuestByTalkId(talkId);
if (mainQuest != null) { if (mainQuest != null) {
session mainQuest.getTalks().put(talkId, talkForQuest);
.getPlayer()
.getQuestManager()
.getMainQuestById(mainQuestId)
.getTalks()
.put(talkId, talkForQuest);
} }
// Fire quest triggers. // Fire quest triggers.
session questManager.queueEvent(QuestContent.QUEST_CONTENT_COMPLETE_ANY_TALK, talkId, 0, 0);
.getPlayer() questManager.queueEvent(QuestContent.QUEST_CONTENT_COMPLETE_TALK, talkId, 0);
.getQuestManager() questManager.queueEvent(QuestContent.QUEST_CONTENT_FINISH_PLOT, talkId, 0);
.queueEvent( questManager.queueEvent(QuestCond.QUEST_COND_COMPLETE_TALK, talkId, 0);
QuestContent.QUEST_CONTENT_COMPLETE_ANY_TALK, String.valueOf(req.getTalkId()), 0, 0);
session
.getPlayer()
.getQuestManager()
.queueEvent(QuestContent.QUEST_CONTENT_COMPLETE_TALK, req.getTalkId(), 0);
session
.getPlayer()
.getQuestManager()
.queueEvent(QuestContent.QUEST_CONTENT_FINISH_PLOT, req.getTalkId(), 0);
} }
session.send(new PacketNpcTalkRsp(req.getNpcEntityId(), req.getTalkId(), req.getEntityId())); session.send(new PacketNpcTalkRsp(req.getNpcEntityId(), req.getTalkId(), req.getEntityId()));

View File

@ -5,6 +5,7 @@ import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PlayerEnterDungeonReqOuterClass.PlayerEnterDungeonReq; import emu.grasscutter.net.proto.PlayerEnterDungeonReqOuterClass.PlayerEnterDungeonReq;
import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketPlayerEnterDungeonRsp;
@Opcodes(PacketOpcodes.PlayerEnterDungeonReq) @Opcodes(PacketOpcodes.PlayerEnterDungeonReq)
public class HandlerPlayerEnterDungeonReq extends PacketHandler { public class HandlerPlayerEnterDungeonReq extends PacketHandler {
@ -14,9 +15,12 @@ public class HandlerPlayerEnterDungeonReq extends PacketHandler {
// Auto template // Auto template
PlayerEnterDungeonReq req = PlayerEnterDungeonReq.parseFrom(payload); PlayerEnterDungeonReq req = PlayerEnterDungeonReq.parseFrom(payload);
session var success = session
.getServer() .getServer()
.getDungeonSystem() .getDungeonSystem()
.enterDungeon(session.getPlayer(), req.getPointId(), req.getDungeonId()); .enterDungeon(session.getPlayer(), req.getPointId(), req.getDungeonId());
session
.getPlayer()
.sendPacket(new PacketPlayerEnterDungeonRsp(req.getPointId(), req.getDungeonId(), success));
} }
} }

View File

@ -1,5 +1,6 @@
package emu.grasscutter.server.packet.recv; package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.Opcodes; import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
@ -11,5 +12,6 @@ public class HandlerPlayerQuitDungeonReq extends PacketHandler {
@Override @Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
session.getPlayer().getServer().getDungeonSystem().exitDungeon(session.getPlayer()); session.getPlayer().getServer().getDungeonSystem().exitDungeon(session.getPlayer());
session.getPlayer().sendPacket(new BasePacket(PacketOpcodes.PlayerQuitDungeonRsp));
} }
} }

View File

@ -4,7 +4,8 @@ import emu.grasscutter.data.GameData;
import emu.grasscutter.net.packet.Opcodes; import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.UnlockPersonalLineReqOuterClass; import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
import emu.grasscutter.net.proto.UnlockPersonalLineReqOuterClass.UnlockPersonalLineReq;
import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketUnlockPersonalLineRsp; import emu.grasscutter.server.packet.send.PacketUnlockPersonalLineRsp;
@ -13,13 +14,17 @@ public class HandlerUnlockPersonalLineReq extends PacketHandler {
@Override @Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
var req = UnlockPersonalLineReqOuterClass.UnlockPersonalLineReq.parseFrom(payload); var req = UnlockPersonalLineReq.parseFrom(payload);
var data = GameData.getPersonalLineDataMap().get(req.getPersonalLineId()); var data = GameData.getPersonalLineDataMap().get(req.getPersonalLineId());
if (data == null) { if (data == null) {
session.send(
new PacketUnlockPersonalLineRsp(
req.getPersonalLineId(), Retcode.RET_FAIL));
return; return;
} }
session.getPlayer().getQuestManager().addQuest(data.getStartQuestId()); session.getPlayer().getQuestManager().addQuest(data.getStartQuestId());
session.getPlayer().addPersonalLine(data.getId());
session.getPlayer().useLegendaryKey(1); session.getPlayer().useLegendaryKey(1);
session.send(new PacketUnlockPersonalLineRsp(data.getId(), 1, data.getChapterId())); session.send(new PacketUnlockPersonalLineRsp(data.getId(), 1, data.getChapterId()));

View File

@ -6,6 +6,8 @@ import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.AvatarFightPropUpdateNotifyOuterClass.AvatarFightPropUpdateNotify; import emu.grasscutter.net.proto.AvatarFightPropUpdateNotifyOuterClass.AvatarFightPropUpdateNotify;
import java.util.Map;
public class PacketAvatarFightPropUpdateNotify extends BasePacket { public class PacketAvatarFightPropUpdateNotify extends BasePacket {
public PacketAvatarFightPropUpdateNotify(Avatar avatar, FightProperty prop) { public PacketAvatarFightPropUpdateNotify(Avatar avatar, FightProperty prop) {
@ -19,4 +21,16 @@ public class PacketAvatarFightPropUpdateNotify extends BasePacket {
this.setData(proto); this.setData(proto);
} }
public PacketAvatarFightPropUpdateNotify(Avatar avatar, Map<Integer, Float> propUpdateList) {
super(PacketOpcodes.AvatarFightPropUpdateNotify);
AvatarFightPropUpdateNotify proto =
AvatarFightPropUpdateNotify.newBuilder()
.setAvatarGuid(avatar.getGuid())
.putAllFightPropMap(propUpdateList)
.build();
this.setData(proto);
}
} }

View File

@ -7,11 +7,14 @@ import emu.grasscutter.net.proto.ChangeGameTimeRspOuterClass.ChangeGameTimeRsp;
public class PacketChangeGameTimeRsp extends BasePacket { public class PacketChangeGameTimeRsp extends BasePacket {
public PacketChangeGameTimeRsp(Player player) { public PacketChangeGameTimeRsp(Player player, int extraDays) {
super(PacketOpcodes.ChangeGameTimeRsp); super(PacketOpcodes.ChangeGameTimeRsp);
ChangeGameTimeRsp proto = ChangeGameTimeRsp proto =
ChangeGameTimeRsp.newBuilder().setCurGameTime(player.getWorld().getGameTime()).build(); ChangeGameTimeRsp.newBuilder()
.setCurGameTime(player.getWorld().getGameTime())
.setExtraDays(extraDays)
.build();
this.setData(proto); this.setData(proto);
} }

View File

@ -2,8 +2,6 @@ package emu.grasscutter.server.packet.send;
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.PlayerSetPauseRspOuterClass.PlayerSetPauseRsp;
import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
public class PacketPlayerSetPauseRsp extends BasePacket { public class PacketPlayerSetPauseRsp extends BasePacket {