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

178
gradlew.bat vendored
View File

@ -1,89 +1,89 @@
@rem @rem
@rem Copyright 2015 the original author or authors. @rem Copyright 2015 the original author or authors.
@rem @rem
@rem Licensed under the Apache License, Version 2.0 (the "License"); @rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License. @rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at @rem You may obtain a copy of the License at
@rem @rem
@rem https://www.apache.org/licenses/LICENSE-2.0 @rem https://www.apache.org/licenses/LICENSE-2.0
@rem @rem
@rem Unless required by applicable law or agreed to in writing, software @rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS, @rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and @rem See the License for the specific language governing permissions and
@rem limitations under the License. @rem limitations under the License.
@rem @rem
@if "%DEBUG%" == "" @echo off @if "%DEBUG%" == "" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Gradle startup script for Windows @rem Gradle startup script for Windows
@rem @rem
@rem ########################################################################## @rem ##########################################################################
@rem Set local scope for the variables with windows NT shell @rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=. if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter. @rem Resolve any "." and ".." in APP_HOME to make it shorter.
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
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute if "%ERRORLEVEL%" == "0" goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo. echo.
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation. echo location of your Java installation.
goto fail goto fail
:findJavaFromJavaHome :findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute if exist "%JAVA_EXE%" goto execute
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo. echo.
echo Please set the JAVA_HOME variable in your environment to match the echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation. echo location of your Java installation.
goto fail goto fail
:execute :execute
@rem Setup the command line @rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd if "%ERRORLEVEL%"=="0" goto mainEnd
:fail :fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code! rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1 exit /b 1
:mainEnd :mainEnd
if "%OS%"=="Windows_NT" endlocal if "%OS%"=="Windows_NT" endlocal
:omega :omega

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

@ -1,22 +1,26 @@
package emu.grasscutter.server.packet.recv; package emu.grasscutter.server.packet.recv;
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.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)
public class HandlerPlayerEnterDungeonReq extends PacketHandler { @Opcodes(PacketOpcodes.PlayerEnterDungeonReq)
public class HandlerPlayerEnterDungeonReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { @Override
// Auto template public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
PlayerEnterDungeonReq req = PlayerEnterDungeonReq.parseFrom(payload); // Auto template
PlayerEnterDungeonReq req = PlayerEnterDungeonReq.parseFrom(payload);
session
.getServer() var success = session
.getDungeonSystem() .getServer()
.enterDungeon(session.getPlayer(), req.getPointId(), req.getDungeonId()); .getDungeonSystem()
} .enterDungeon(session.getPlayer(), req.getPointId(), req.getDungeonId());
} session
.getPlayer()
.sendPacket(new PacketPlayerEnterDungeonRsp(req.getPointId(), req.getDungeonId(), success));
}
}

View File

@ -1,15 +1,17 @@
package emu.grasscutter.server.packet.recv; package emu.grasscutter.server.packet.recv;
import emu.grasscutter.net.packet.Opcodes; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketHandler; import emu.grasscutter.net.packet.Opcodes;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketHandler;
import emu.grasscutter.server.game.GameSession; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.server.game.GameSession;
@Opcodes(PacketOpcodes.PlayerQuitDungeonReq)
public class HandlerPlayerQuitDungeonReq extends PacketHandler { @Opcodes(PacketOpcodes.PlayerQuitDungeonReq)
public class HandlerPlayerQuitDungeonReq extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { @Override
session.getPlayer().getServer().getDungeonSystem().exitDungeon(session.getPlayer()); 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));
}
}

View File

@ -1,27 +1,27 @@
package emu.grasscutter.server.packet.recv; package emu.grasscutter.server.packet.recv;
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.PacketHeadOuterClass.PacketHead; import emu.grasscutter.net.proto.PacketHeadOuterClass.PacketHead;
import emu.grasscutter.net.proto.PlayerSetPauseReqOuterClass.PlayerSetPauseReq; import emu.grasscutter.net.proto.PlayerSetPauseReqOuterClass.PlayerSetPauseReq;
import emu.grasscutter.server.game.GameSession; import emu.grasscutter.server.game.GameSession;
import emu.grasscutter.server.packet.send.PacketPlayerSetPauseRsp; import emu.grasscutter.server.packet.send.PacketPlayerSetPauseRsp;
import emu.grasscutter.server.packet.send.PacketPlayerTimeNotify; import emu.grasscutter.server.packet.send.PacketPlayerTimeNotify;
import emu.grasscutter.server.packet.send.PacketSceneTimeNotify; import emu.grasscutter.server.packet.send.PacketSceneTimeNotify;
@Opcodes(PacketOpcodes.PlayerSetPauseReq) @Opcodes(PacketOpcodes.PlayerSetPauseReq)
public class HandlerPlayerSetPauseReq extends PacketHandler { public class HandlerPlayerSetPauseReq 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 {
PacketHead head = PacketHead.parseFrom(header); PacketHead head = PacketHead.parseFrom(header);
PlayerSetPauseReq req = PlayerSetPauseReq.parseFrom(payload); PlayerSetPauseReq req = PlayerSetPauseReq.parseFrom(payload);
session.send(new PacketPlayerSetPauseRsp(head.getClientSequenceId())); session.send(new PacketPlayerSetPauseRsp(head.getClientSequenceId()));
session.getPlayer().setPaused(req.getIsPaused()); session.getPlayer().setPaused(req.getIsPaused());
session.send(new PacketPlayerTimeNotify(session.getPlayer())); session.send(new PacketPlayerTimeNotify(session.getPlayer()));
session.send(new PacketSceneTimeNotify(session.getPlayer())); session.send(new PacketSceneTimeNotify(session.getPlayer()));
} }
} }

View File

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

View File

@ -1,22 +1,36 @@
package emu.grasscutter.server.packet.send; package emu.grasscutter.server.packet.send;
import emu.grasscutter.game.avatar.Avatar; import emu.grasscutter.game.avatar.Avatar;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
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.AvatarFightPropUpdateNotifyOuterClass.AvatarFightPropUpdateNotify; import emu.grasscutter.net.proto.AvatarFightPropUpdateNotifyOuterClass.AvatarFightPropUpdateNotify;
public class PacketAvatarFightPropUpdateNotify extends BasePacket { import java.util.Map;
public PacketAvatarFightPropUpdateNotify(Avatar avatar, FightProperty prop) { public class PacketAvatarFightPropUpdateNotify extends BasePacket {
super(PacketOpcodes.AvatarFightPropUpdateNotify);
public PacketAvatarFightPropUpdateNotify(Avatar avatar, FightProperty prop) {
AvatarFightPropUpdateNotify proto = super(PacketOpcodes.AvatarFightPropUpdateNotify);
AvatarFightPropUpdateNotify.newBuilder()
.setAvatarGuid(avatar.getGuid()) AvatarFightPropUpdateNotify proto =
.putFightPropMap(prop.getId(), avatar.getFightProperty(prop)) AvatarFightPropUpdateNotify.newBuilder()
.build(); .setAvatarGuid(avatar.getGuid())
.putFightPropMap(prop.getId(), avatar.getFightProperty(prop))
this.setData(proto); .build();
}
} 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 {