mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-22 01:55:34 +00:00
Merge packet handlers from quests/quests
This commit is contained in:
parent
b5190bca45
commit
7bdcf4e0d2
2
gradlew.bat
vendored
2
gradlew.bat
vendored
@ -33,7 +33,7 @@ set APP_HOME=%DIRNAME%
|
||||
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.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
set DEFAULT_JVM_OPTS="-Xmx4G" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
@ -15,6 +15,6 @@ public class HandlerChangeGameTimeReq extends PacketHandler {
|
||||
var req = ChangeGameTimeReq.parseFrom(payload);
|
||||
|
||||
session.getPlayer().getWorld().changeTime(req.getGameTime(), req.getExtraDays());
|
||||
session.getPlayer().sendPacket(new PacketChangeGameTimeRsp(session.getPlayer()));
|
||||
session.getPlayer().sendPacket(new PacketChangeGameTimeRsp(session.getPlayer(), req.getExtraDays()));
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,6 @@ public class HandlerEvtDoSkillSuccNotify extends PacketHandler {
|
||||
// Handle skill notify in other managers.
|
||||
player.getStaminaManager().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);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package emu.grasscutter.server.packet.recv;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.binout.MainQuestData;
|
||||
import emu.grasscutter.data.binout.MainQuestData.TalkData;
|
||||
import emu.grasscutter.game.quest.enums.QuestCond;
|
||||
import emu.grasscutter.game.quest.enums.QuestContent;
|
||||
import emu.grasscutter.net.packet.Opcodes;
|
||||
import emu.grasscutter.net.packet.PacketHandler;
|
||||
@ -20,7 +21,7 @@ public class HandlerNpcTalkReq extends PacketHandler {
|
||||
// Check if mainQuest exists
|
||||
// remove last 2 digits to get a mainQuestId
|
||||
int talkId = req.getTalkId();
|
||||
int mainQuestId = talkId / 100;
|
||||
int mainQuestId = GameData.getQuestTalkMap().getOrDefault(talkId, talkId / 100);
|
||||
MainQuestData mainQuestData = GameData.getMainQuestDataMap().get(mainQuestId);
|
||||
|
||||
if (mainQuestData != null) {
|
||||
@ -36,30 +37,17 @@ public class HandlerNpcTalkReq extends PacketHandler {
|
||||
}
|
||||
|
||||
// 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) {
|
||||
session
|
||||
.getPlayer()
|
||||
.getQuestManager()
|
||||
.getMainQuestById(mainQuestId)
|
||||
.getTalks()
|
||||
.put(talkId, talkForQuest);
|
||||
mainQuest.getTalks().put(talkId, talkForQuest);
|
||||
}
|
||||
|
||||
// Fire quest triggers.
|
||||
session
|
||||
.getPlayer()
|
||||
.getQuestManager()
|
||||
.queueEvent(
|
||||
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);
|
||||
questManager.queueEvent(QuestContent.QUEST_CONTENT_COMPLETE_ANY_TALK, talkId, 0, 0);
|
||||
questManager.queueEvent(QuestContent.QUEST_CONTENT_COMPLETE_TALK, talkId, 0);
|
||||
questManager.queueEvent(QuestContent.QUEST_CONTENT_FINISH_PLOT, talkId, 0);
|
||||
questManager.queueEvent(QuestCond.QUEST_COND_COMPLETE_TALK, talkId, 0);
|
||||
}
|
||||
|
||||
session.send(new PacketNpcTalkRsp(req.getNpcEntityId(), req.getTalkId(), req.getEntityId()));
|
||||
|
@ -5,6 +5,7 @@ import emu.grasscutter.net.packet.PacketHandler;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.PlayerEnterDungeonReqOuterClass.PlayerEnterDungeonReq;
|
||||
import emu.grasscutter.server.game.GameSession;
|
||||
import emu.grasscutter.server.packet.send.PacketPlayerEnterDungeonRsp;
|
||||
|
||||
@Opcodes(PacketOpcodes.PlayerEnterDungeonReq)
|
||||
public class HandlerPlayerEnterDungeonReq extends PacketHandler {
|
||||
@ -14,9 +15,12 @@ public class HandlerPlayerEnterDungeonReq extends PacketHandler {
|
||||
// Auto template
|
||||
PlayerEnterDungeonReq req = PlayerEnterDungeonReq.parseFrom(payload);
|
||||
|
||||
session
|
||||
var success = session
|
||||
.getServer()
|
||||
.getDungeonSystem()
|
||||
.enterDungeon(session.getPlayer(), req.getPointId(), req.getDungeonId());
|
||||
session
|
||||
.getPlayer()
|
||||
.sendPacket(new PacketPlayerEnterDungeonRsp(req.getPointId(), req.getDungeonId(), success));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package emu.grasscutter.server.packet.recv;
|
||||
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.packet.Opcodes;
|
||||
import emu.grasscutter.net.packet.PacketHandler;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
@ -11,5 +12,6 @@ public class HandlerPlayerQuitDungeonReq extends PacketHandler {
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
session.getPlayer().getServer().getDungeonSystem().exitDungeon(session.getPlayer());
|
||||
session.getPlayer().sendPacket(new BasePacket(PacketOpcodes.PlayerQuitDungeonRsp));
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,8 @@ import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.net.packet.Opcodes;
|
||||
import emu.grasscutter.net.packet.PacketHandler;
|
||||
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.packet.send.PacketUnlockPersonalLineRsp;
|
||||
|
||||
@ -13,13 +14,17 @@ public class HandlerUnlockPersonalLineReq extends PacketHandler {
|
||||
|
||||
@Override
|
||||
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());
|
||||
if (data == null) {
|
||||
session.send(
|
||||
new PacketUnlockPersonalLineRsp(
|
||||
req.getPersonalLineId(), Retcode.RET_FAIL));
|
||||
return;
|
||||
}
|
||||
|
||||
session.getPlayer().getQuestManager().addQuest(data.getStartQuestId());
|
||||
session.getPlayer().addPersonalLine(data.getId());
|
||||
session.getPlayer().useLegendaryKey(1);
|
||||
|
||||
session.send(new PacketUnlockPersonalLineRsp(data.getId(), 1, data.getChapterId()));
|
||||
|
@ -6,6 +6,8 @@ import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.AvatarFightPropUpdateNotifyOuterClass.AvatarFightPropUpdateNotify;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class PacketAvatarFightPropUpdateNotify extends BasePacket {
|
||||
|
||||
public PacketAvatarFightPropUpdateNotify(Avatar avatar, FightProperty prop) {
|
||||
@ -19,4 +21,16 @@ public class PacketAvatarFightPropUpdateNotify extends BasePacket {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -7,11 +7,14 @@ import emu.grasscutter.net.proto.ChangeGameTimeRspOuterClass.ChangeGameTimeRsp;
|
||||
|
||||
public class PacketChangeGameTimeRsp extends BasePacket {
|
||||
|
||||
public PacketChangeGameTimeRsp(Player player) {
|
||||
public PacketChangeGameTimeRsp(Player player, int extraDays) {
|
||||
super(PacketOpcodes.ChangeGameTimeRsp);
|
||||
|
||||
ChangeGameTimeRsp proto =
|
||||
ChangeGameTimeRsp.newBuilder().setCurGameTime(player.getWorld().getGameTime()).build();
|
||||
ChangeGameTimeRsp.newBuilder()
|
||||
.setCurGameTime(player.getWorld().getGameTime())
|
||||
.setExtraDays(extraDays)
|
||||
.build();
|
||||
|
||||
this.setData(proto);
|
||||
}
|
||||
|
@ -2,8 +2,6 @@ package emu.grasscutter.server.packet.send;
|
||||
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
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 {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user