Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
ziqian zhang
Grasscutter
Commits
8050f0cc
Commit
8050f0cc
authored
Jul 23, 2022
by
akatatsu27
Browse files
and misc bug fixes
parent
02a56fce
Changes
28
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/server/packet/recv/HandlerEnterSceneDoneReq.java
View file @
8050f0cc
package
emu.grasscutter.server.packet.recv
;
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.game.player.Player.SceneLoadState
;
import
emu.grasscutter.game.player.Player.SceneLoadState
;
import
emu.grasscutter.game.quest.QuestGroupSuite
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketHandler
;
...
@@ -16,7 +18,7 @@ public class HandlerEnterSceneDoneReq extends PacketHandler {
...
@@ -16,7 +18,7 @@ public class HandlerEnterSceneDoneReq extends PacketHandler {
session
.
getPlayer
().
setSceneLoadState
(
SceneLoadState
.
LOADED
);
session
.
getPlayer
().
setSceneLoadState
(
SceneLoadState
.
LOADED
);
// Done
// Done
session
.
send
(
new
PacketEnterSceneDoneRsp
(
session
.
getPlayer
()));
session
.
send
(
new
PacketPlayerTimeNotify
(
session
.
getPlayer
()));
// Probably not the right place
session
.
send
(
new
PacketPlayerTimeNotify
(
session
.
getPlayer
()));
// Probably not the right place
// Spawn player in world
// Spawn player in world
...
@@ -35,11 +37,15 @@ public class HandlerEnterSceneDoneReq extends PacketHandler {
...
@@ -35,11 +37,15 @@ public class HandlerEnterSceneDoneReq extends PacketHandler {
// notify client to load the npc for quest
// notify client to load the npc for quest
var
questGroupSuites
=
session
.
getPlayer
().
getQuestManager
().
getSceneGroupSuite
(
session
.
getPlayer
().
getSceneId
());
var
questGroupSuites
=
session
.
getPlayer
().
getQuestManager
().
getSceneGroupSuite
(
session
.
getPlayer
().
getSceneId
());
session
.
getPlayer
().
getScene
().
loadGroupForQuest
(
questGroupSuites
);
session
.
getPlayer
().
getScene
().
loadGroupForQuest
(
questGroupSuites
);
Grasscutter
.
getLogger
().
debug
(
"Loaded Scene {} Quest(s) Groupsuite(s): {}"
,
session
.
getPlayer
().
getSceneId
(),
questGroupSuites
);
session
.
send
(
new
PacketGroupSuiteNotify
(
questGroupSuites
));
session
.
send
(
new
PacketGroupSuiteNotify
(
questGroupSuites
));
// Reset timer for sending player locations
// Reset timer for sending player locations
session
.
getPlayer
().
resetSendPlayerLocTime
();
session
.
getPlayer
().
resetSendPlayerLocTime
();
//Rsp
session
.
send
(
new
PacketEnterSceneDoneRsp
(
session
.
getPlayer
()));
}
}
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerNpcTalkReq.java
View file @
8050f0cc
package
emu.grasscutter.server.packet.recv
;
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.binout.MainQuestData
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.quest.GameMainQuest
;
import
emu.grasscutter.game.quest.enums.ParentQuestState
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
import
emu.grasscutter.game.quest.enums.QuestTrigger
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
...
@@ -11,16 +15,28 @@ import emu.grasscutter.server.packet.send.PacketNpcTalkRsp;
...
@@ -11,16 +15,28 @@ import emu.grasscutter.server.packet.send.PacketNpcTalkRsp;
@Opcodes
(
PacketOpcodes
.
NpcTalkReq
)
@Opcodes
(
PacketOpcodes
.
NpcTalkReq
)
public
class
HandlerNpcTalkReq
extends
PacketHandler
{
public
class
HandlerNpcTalkReq
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
{
NpcTalkReq
req
=
NpcTalkReq
.
parseFrom
(
payload
);
NpcTalkReq
req
=
NpcTalkReq
.
parseFrom
(
payload
);
//Check if mainQuest exists
// Why are there 2 quest triggers that do the same thing...
int
talkId
=
req
.
getTalkId
();
session
.
getPlayer
().
getQuestManager
().
triggerEvent
(
QuestTrigger
.
QUEST_CONTENT_COMPLETE_TALK
,
req
.
getTalkId
());
//remove last 2 digits to get a mainQuestId
session
.
getPlayer
().
getQuestManager
().
triggerEvent
(
QuestTrigger
.
QUEST_CONTENT_FINISH_PLOT
,
req
.
getTalkId
());
int
mainQuestId
=
talkId
/
100
;
MainQuestData
mainQuestData
=
GameData
.
getMainQuestDataMap
().
get
(
mainQuestId
);
if
(
mainQuestData
!=
null
)
{
MainQuestData
.
TalkData
talk
=
mainQuestData
.
getTalks
().
stream
().
filter
(
p
->
p
.
getId
()
==
talkId
).
toList
().
get
(
0
);
if
(
talk
!=
null
)
{
//talk is finished
session
.
getPlayer
().
getQuestManager
().
getMainQuestById
(
mainQuestId
).
getTalks
().
put
(
Integer
.
valueOf
(
talkId
),
talk
);
session
.
getPlayer
().
getQuestManager
().
triggerEvent
(
QuestTrigger
.
QUEST_CONTENT_COMPLETE_ANY_TALK
,
String
.
valueOf
(
req
.
getTalkId
()),
0
,
0
);
// Why are there 2 quest triggers that do the same thing...
session
.
getPlayer
().
getQuestManager
().
triggerEvent
(
QuestTrigger
.
QUEST_CONTENT_COMPLETE_TALK
,
req
.
getTalkId
(),
0
);
session
.
getPlayer
().
getQuestManager
().
triggerEvent
(
QuestTrigger
.
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
()));
}
}
}
}
\ No newline at end of file
src/main/java/emu/grasscutter/server/packet/recv/HandlerPostEnterSceneReq.java
View file @
8050f0cc
...
@@ -14,7 +14,7 @@ public class HandlerPostEnterSceneReq extends PacketHandler {
...
@@ -14,7 +14,7 @@ public class HandlerPostEnterSceneReq 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
{
if
(
session
.
getPlayer
().
getScene
().
getSceneType
()
==
SceneType
.
SCENE_ROOM
){
if
(
session
.
getPlayer
().
getScene
().
getSceneType
()
==
SceneType
.
SCENE_ROOM
){
session
.
getPlayer
().
getQuestManager
().
triggerEvent
(
QuestTrigger
.
QUEST_CONTENT_ENTER_ROOM
,
session
.
getPlayer
().
getSceneId
());
session
.
getPlayer
().
getQuestManager
().
triggerEvent
(
QuestTrigger
.
QUEST_CONTENT_ENTER_ROOM
,
session
.
getPlayer
().
getSceneId
()
,
0
);
}
}
session
.
send
(
new
PacketPostEnterSceneRsp
(
session
.
getPlayer
()));
session
.
send
(
new
PacketPostEnterSceneRsp
(
session
.
getPlayer
()));
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketFinishedParentQuestNotify.java
View file @
8050f0cc
...
@@ -2,21 +2,25 @@ package emu.grasscutter.server.packet.send;
...
@@ -2,21 +2,25 @@ package emu.grasscutter.server.packet.send;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.quest.GameMainQuest
;
import
emu.grasscutter.game.quest.GameMainQuest
;
import
emu.grasscutter.game.quest.enums.ParentQuestState
;
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.FinishedParentQuestNotifyOuterClass.FinishedParentQuestNotify
;
import
emu.grasscutter.net.proto.FinishedParentQuestNotifyOuterClass.FinishedParentQuestNotify
;
public
class
PacketFinishedParentQuestNotify
extends
BasePacket
{
public
class
PacketFinishedParentQuestNotify
extends
BasePacket
{
public
PacketFinishedParentQuestNotify
(
Player
player
)
{
public
PacketFinishedParentQuestNotify
(
Player
player
)
{
super
(
PacketOpcodes
.
FinishedParentQuestNotify
,
true
);
super
(
PacketOpcodes
.
FinishedParentQuestNotify
,
true
);
FinishedParentQuestNotify
.
Builder
proto
=
FinishedParentQuestNotify
.
newBuilder
();
FinishedParentQuestNotify
.
Builder
proto
=
FinishedParentQuestNotify
.
newBuilder
();
for
(
GameMainQuest
mainQuest
:
player
.
getQuestManager
().
getQuests
().
values
())
{
for
(
GameMainQuest
mainQuest
:
player
.
getQuestManager
().
getMainQuests
().
values
())
{
proto
.
addParentQuestList
(
mainQuest
.
toProto
());
//Canceled Quests do not appear in this packet
if
(
mainQuest
.
getState
()
!=
ParentQuestState
.
PARENT_QUEST_STATE_CANCELED
)
{
proto
.
addParentQuestList
(
mainQuest
.
toProto
());
}
}
}
this
.
setData
(
proto
);
this
.
setData
(
proto
);
}
}
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketFinishedParentQuestUpdateNotify.java
View file @
8050f0cc
...
@@ -5,15 +5,29 @@ import emu.grasscutter.net.packet.BasePacket;
...
@@ -5,15 +5,29 @@ import emu.grasscutter.net.packet.BasePacket;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.FinishedParentQuestUpdateNotifyOuterClass.FinishedParentQuestUpdateNotify
;
import
emu.grasscutter.net.proto.FinishedParentQuestUpdateNotifyOuterClass.FinishedParentQuestUpdateNotify
;
import
java.util.List
;
public
class
PacketFinishedParentQuestUpdateNotify
extends
BasePacket
{
public
class
PacketFinishedParentQuestUpdateNotify
extends
BasePacket
{
public
PacketFinishedParentQuestUpdateNotify
(
GameMainQuest
quest
)
{
public
PacketFinishedParentQuestUpdateNotify
(
GameMainQuest
quest
)
{
super
(
PacketOpcodes
.
FinishedParentQuestUpdateNotify
);
super
(
PacketOpcodes
.
FinishedParentQuestUpdateNotify
);
FinishedParentQuestUpdateNotify
proto
=
FinishedParentQuestUpdateNotify
.
newBuilder
()
FinishedParentQuestUpdateNotify
proto
=
FinishedParentQuestUpdateNotify
.
newBuilder
()
.
addParentQuestList
(
quest
.
toProto
())
.
addParentQuestList
(
quest
.
toProto
())
.
build
();
.
build
();
this
.
setData
(
proto
);
this
.
setData
(
proto
);
}
}
public
PacketFinishedParentQuestUpdateNotify
(
List
<
GameMainQuest
>
quests
)
{
super
(
PacketOpcodes
.
FinishedParentQuestUpdateNotify
);
var
proto
=
FinishedParentQuestUpdateNotify
.
newBuilder
();
for
(
GameMainQuest
mainQuest
:
quests
)
{
proto
.
addParentQuestList
(
mainQuest
.
toProto
());
}
proto
.
build
();
this
.
setData
(
proto
);
}
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketPersonalLineAllDataRsp.java
View file @
8050f0cc
...
@@ -23,7 +23,7 @@ public class PacketPersonalLineAllDataRsp extends BasePacket {
...
@@ -23,7 +23,7 @@ public class PacketPersonalLineAllDataRsp extends BasePacket {
.
map
(
GameMainQuest:
:
getChildQuests
)
.
map
(
GameMainQuest:
:
getChildQuests
)
.
map
(
Map:
:
values
)
.
map
(
Map:
:
values
)
.
flatMap
(
Collection:
:
stream
)
.
flatMap
(
Collection:
:
stream
)
.
map
(
GameQuest:
:
getQuestId
)
.
map
(
GameQuest:
:
get
Sub
QuestId
)
.
collect
(
Collectors
.
toSet
());
.
collect
(
Collectors
.
toSet
());
GameData
.
getPersonalLineDataMap
().
values
().
stream
()
GameData
.
getPersonalLineDataMap
().
values
().
stream
()
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketQuestListNotify.java
View file @
8050f0cc
...
@@ -3,21 +3,24 @@ package emu.grasscutter.server.packet.send;
...
@@ -3,21 +3,24 @@ package emu.grasscutter.server.packet.send;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.quest.GameMainQuest
;
import
emu.grasscutter.game.quest.GameMainQuest
;
import
emu.grasscutter.game.quest.QuestManager
;
import
emu.grasscutter.game.quest.QuestManager
;
import
emu.grasscutter.game.quest.enums.QuestState
;
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.QuestListNotifyOuterClass.QuestListNotify
;
import
emu.grasscutter.net.proto.QuestListNotifyOuterClass.QuestListNotify
;
public
class
PacketQuestListNotify
extends
BasePacket
{
public
class
PacketQuestListNotify
extends
BasePacket
{
public
PacketQuestListNotify
(
Player
player
)
{
public
PacketQuestListNotify
(
Player
player
)
{
super
(
PacketOpcodes
.
QuestListNotify
,
true
);
super
(
PacketOpcodes
.
QuestListNotify
,
true
);
QuestListNotify
.
Builder
proto
=
QuestListNotify
.
newBuilder
();
QuestListNotify
.
Builder
proto
=
QuestListNotify
.
newBuilder
();
player
.
getQuestManager
().
forEachQuest
(
quest
->
{
player
.
getQuestManager
().
forEachQuest
(
quest
->
{
proto
.
addQuestList
(
quest
.
toProto
());
if
(
quest
.
getState
()
!=
QuestState
.
QUEST_STATE_UNSTARTED
)
{
proto
.
addQuestList
(
quest
.
toProto
());
}
});
});
this
.
setData
(
proto
);
this
.
setData
(
proto
);
}
}
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketQuestListUpdateNotify.java
View file @
8050f0cc
...
@@ -6,15 +6,28 @@ import emu.grasscutter.net.packet.BasePacket;
...
@@ -6,15 +6,28 @@ import emu.grasscutter.net.packet.BasePacket;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.QuestListUpdateNotifyOuterClass.QuestListUpdateNotify
;
import
emu.grasscutter.net.proto.QuestListUpdateNotifyOuterClass.QuestListUpdateNotify
;
import
java.util.List
;
public
class
PacketQuestListUpdateNotify
extends
BasePacket
{
public
class
PacketQuestListUpdateNotify
extends
BasePacket
{
public
PacketQuestListUpdateNotify
(
GameQuest
quest
)
{
public
PacketQuestListUpdateNotify
(
GameQuest
quest
)
{
super
(
PacketOpcodes
.
QuestListUpdateNotify
);
super
(
PacketOpcodes
.
QuestListUpdateNotify
);
QuestListUpdateNotify
proto
=
QuestListUpdateNotify
.
newBuilder
()
QuestListUpdateNotify
proto
=
QuestListUpdateNotify
.
newBuilder
()
.
addQuestList
(
quest
.
toProto
())
.
addQuestList
(
quest
.
toProto
())
.
build
();
.
build
();
this
.
setData
(
proto
);
this
.
setData
(
proto
);
}
}
public
PacketQuestListUpdateNotify
(
List
<
GameQuest
>
quests
)
{
super
(
PacketOpcodes
.
QuestListUpdateNotify
);
var
proto
=
QuestListUpdateNotify
.
newBuilder
();
for
(
GameQuest
quest
:
quests
)
{
proto
.
addQuestList
(
quest
.
toProto
());
}
proto
.
build
();
this
.
setData
(
proto
);
}
}
}
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment