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
2f39aff4
Commit
2f39aff4
authored
Apr 29, 2022
by
memetrollsXD
Committed by
GitHub
Apr 29, 2022
Browse files
Merge pull request #355 from Grasscutters/dungeon-scripts
Implemented Dungeon Support
parents
789e5f57
6d987430
Changes
55
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/server/packet/recv/HandlerDungeonEntryInfoReq.java
View file @
2f39aff4
...
@@ -2,6 +2,7 @@ package emu.grasscutter.server.packet.recv;
...
@@ -2,6 +2,7 @@ package emu.grasscutter.server.packet.recv;
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.proto.DungeonEntryInfoReqOuterClass.DungeonEntryInfoReq
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.game.GameSession
;
...
@@ -10,7 +11,9 @@ public class HandlerDungeonEntryInfoReq extends PacketHandler {
...
@@ -10,7 +11,9 @@ public class HandlerDungeonEntryInfoReq 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
{
DungeonEntryInfoReq
req
=
DungeonEntryInfoReq
.
parseFrom
(
payload
);
session
.
getServer
().
getDungeonManager
().
getEntryInfo
(
session
.
getPlayer
(),
req
.
getPointId
());
}
}
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerEnterDungeonReq.java
0 → 100644
View file @
2f39aff4
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.PlayerEnterDungeonReqOuterClass.PlayerEnterDungeonReq
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.server.game.GameSession
;
@Opcodes
(
PacketOpcodes
.
PlayerEnterDungeonReq
)
public
class
HandlerPlayerEnterDungeonReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
// Auto template
PlayerEnterDungeonReq
req
=
PlayerEnterDungeonReq
.
parseFrom
(
payload
);
session
.
getServer
().
getDungeonManager
().
enterDungeon
(
session
.
getPlayer
(),
req
.
getPointId
(),
req
.
getDungeonId
());
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerQuitDungeonReq.java
0 → 100644
View file @
2f39aff4
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
());
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerSelectWorktopOptionReq.java
0 → 100644
View file @
2f39aff4
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
()));
}
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketChallengeDataNotify.java
0 → 100644
View file @
2f39aff4
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.dungeons.DungeonChallenge
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.ChallengeDataNotifyOuterClass.ChallengeDataNotify
;
public
class
PacketChallengeDataNotify
extends
BasePacket
{
public
PacketChallengeDataNotify
(
DungeonChallenge
challenge
,
int
index
,
int
value
)
{
super
(
PacketOpcodes
.
ChallengeDataNotify
);
ChallengeDataNotify
proto
=
ChallengeDataNotify
.
newBuilder
()
.
setChallengeIndex
(
challenge
.
getChallengeIndex
())
.
setParamIndex
(
index
)
.
setValue
(
value
)
.
build
();
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketDungeonChallengeBeginNotify.java
0 → 100644
View file @
2f39aff4
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.dungeons.DungeonChallenge
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.DungeonChallengeBeginNotifyOuterClass.DungeonChallengeBeginNotify
;
public
class
PacketDungeonChallengeBeginNotify
extends
BasePacket
{
public
PacketDungeonChallengeBeginNotify
(
DungeonChallenge
challenge
)
{
super
(
PacketOpcodes
.
DungeonChallengeBeginNotify
);
DungeonChallengeBeginNotify
proto
=
DungeonChallengeBeginNotify
.
newBuilder
()
.
setChallengeId
(
challenge
.
getChallengeId
())
.
setChallengeIndex
(
challenge
.
getChallengeIndex
())
.
setGroupId
(
challenge
.
getGroup
().
id
)
.
build
();
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketDungeonChallengeFinishNotify.java
0 → 100644
View file @
2f39aff4
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.dungeons.DungeonChallenge
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.DungeonChallengeFinishNotifyOuterClass.DungeonChallengeFinishNotify
;
public
class
PacketDungeonChallengeFinishNotify
extends
BasePacket
{
public
PacketDungeonChallengeFinishNotify
(
DungeonChallenge
challenge
)
{
super
(
PacketOpcodes
.
DungeonChallengeFinishNotify
);
DungeonChallengeFinishNotify
proto
=
DungeonChallengeFinishNotify
.
newBuilder
()
.
setChallengeIndex
(
challenge
.
getChallengeIndex
())
.
setIsSuccess
(
challenge
.
isSuccess
())
.
setUnk1
(
challenge
.
getChallengeId
())
.
setUnk2
(
30
)
.
build
();
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketDungeonEntryInfoRsp.java
0 → 100644
View file @
2f39aff4
package
emu.grasscutter.server.packet.send
;
import
java.util.Arrays
;
import
emu.grasscutter.data.common.PointData
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.DungeonEntryInfoOuterClass.DungeonEntryInfo
;
import
emu.grasscutter.net.proto.DungeonEntryInfoRspOuterClass.DungeonEntryInfoRsp
;
public
class
PacketDungeonEntryInfoRsp
extends
BasePacket
{
public
PacketDungeonEntryInfoRsp
(
Player
player
,
PointData
pointData
)
{
super
(
PacketOpcodes
.
DungeonEntryInfoRsp
);
DungeonEntryInfoRsp
.
Builder
proto
=
DungeonEntryInfoRsp
.
newBuilder
()
.
setPointId
(
pointData
.
getId
());
for
(
int
dungeonId
:
pointData
.
getDungeonIds
())
{
DungeonEntryInfo
info
=
DungeonEntryInfo
.
newBuilder
().
setDungeonId
(
dungeonId
).
build
();
proto
.
addDungeonEntryList
(
info
);
}
this
.
setData
(
proto
);
}
public
PacketDungeonEntryInfoRsp
()
{
super
(
PacketOpcodes
.
DungeonEntryInfoRsp
);
DungeonEntryInfoRsp
proto
=
DungeonEntryInfoRsp
.
newBuilder
()
.
setRetcode
(
1
)
.
build
();
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketGadgetInteractRsp.java
View file @
2f39aff4
package
emu.grasscutter.server.packet.send
;
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.entity.EntityGadget
;
import
emu.grasscutter.game.entity.Entity
Base
Gadget
;
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.GadgetInteractRspOuterClass.GadgetInteractRsp
;
import
emu.grasscutter.net.proto.GadgetInteractRspOuterClass.GadgetInteractRsp
;
...
@@ -8,7 +8,7 @@ import emu.grasscutter.net.proto.InteractTypeOuterClass.InteractType;
...
@@ -8,7 +8,7 @@ import emu.grasscutter.net.proto.InteractTypeOuterClass.InteractType;
import
emu.grasscutter.net.proto.RetcodeOuterClass
;
import
emu.grasscutter.net.proto.RetcodeOuterClass
;
public
class
PacketGadgetInteractRsp
extends
BasePacket
{
public
class
PacketGadgetInteractRsp
extends
BasePacket
{
public
PacketGadgetInteractRsp
(
EntityGadget
gadget
,
InteractType
interact
)
{
public
PacketGadgetInteractRsp
(
Entity
Base
Gadget
gadget
,
InteractType
interact
)
{
super
(
PacketOpcodes
.
GadgetInteractRsp
);
super
(
PacketOpcodes
.
GadgetInteractRsp
);
GadgetInteractRsp
proto
=
GadgetInteractRsp
.
newBuilder
()
GadgetInteractRsp
proto
=
GadgetInteractRsp
.
newBuilder
()
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketGadgetStateNotify.java
0 → 100644
View file @
2f39aff4
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.entity.EntityGadget
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.GadgetStateNotifyOuterClass.GadgetStateNotify
;
public
class
PacketGadgetStateNotify
extends
BasePacket
{
public
PacketGadgetStateNotify
(
EntityGadget
gadget
,
int
newState
)
{
super
(
PacketOpcodes
.
GadgetStateNotify
);
GadgetStateNotify
proto
=
GadgetStateNotify
.
newBuilder
()
.
setGadgetEntityId
(
gadget
.
getId
())
.
setGadgetState
(
newState
)
.
setIsEnableInteract
(
true
)
.
build
();
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketPathfindingEnterSceneRsp.java
View file @
2f39aff4
...
@@ -7,7 +7,5 @@ public class PacketPathfindingEnterSceneRsp extends BasePacket {
...
@@ -7,7 +7,5 @@ public class PacketPathfindingEnterSceneRsp extends BasePacket {
public
PacketPathfindingEnterSceneRsp
(
int
clientSequence
)
{
public
PacketPathfindingEnterSceneRsp
(
int
clientSequence
)
{
super
(
PacketOpcodes
.
PathfindingEnterSceneRsp
);
super
(
PacketOpcodes
.
PathfindingEnterSceneRsp
);
this
.
buildHeader
(
clientSequence
);
}
}
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketPlayerEnterDungeonRsp.java
0 → 100644
View file @
2f39aff4
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.PlayerEnterDungeonRspOuterClass.PlayerEnterDungeonRsp
;
public
class
PacketPlayerEnterDungeonRsp
extends
BasePacket
{
public
PacketPlayerEnterDungeonRsp
(
int
pointId
,
int
dungeonId
)
{
super
(
PacketOpcodes
.
PlayerEnterDungeonRsp
);
PlayerEnterDungeonRsp
proto
=
PlayerEnterDungeonRsp
.
newBuilder
()
.
setPointId
(
pointId
)
.
setDungeonId
(
dungeonId
)
.
build
();
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketSelectWorktopOptionRsp.java
0 → 100644
View file @
2f39aff4
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.SelectWorktopOptionRspOuterClass.SelectWorktopOptionRsp
;
public
class
PacketSelectWorktopOptionRsp
extends
BasePacket
{
public
PacketSelectWorktopOptionRsp
(
int
entityId
,
int
optionId
)
{
super
(
PacketOpcodes
.
SelectWorktopOptionRsp
);
SelectWorktopOptionRsp
proto
=
SelectWorktopOptionRsp
.
newBuilder
()
.
setGadgetEntityId
(
entityId
)
.
setOptionId
(
optionId
)
.
build
();
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketWorktopOptionNotify.java
0 → 100644
View file @
2f39aff4
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.entity.EntityGadget
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.WorktopOptionNotifyOuterClass.WorktopOptionNotify
;
public
class
PacketWorktopOptionNotify
extends
BasePacket
{
public
PacketWorktopOptionNotify
(
EntityGadget
gadget
)
{
super
(
PacketOpcodes
.
WorktopOptionNotify
);
WorktopOptionNotify
.
Builder
proto
=
WorktopOptionNotify
.
newBuilder
()
.
setGadgetEntityId
(
gadget
.
getId
());
if
(
gadget
.
getWorktopOptions
()
!=
null
)
{
proto
.
addAllOptionList
(
gadget
.
getWorktopOptions
());
}
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/utils/Utils.java
View file @
2f39aff4
...
@@ -67,6 +67,7 @@ public final class Utils {
...
@@ -67,6 +67,7 @@ public final class Utils {
private
static
final
char
[]
HEX_ARRAY
=
"0123456789abcdef"
.
toCharArray
();
private
static
final
char
[]
HEX_ARRAY
=
"0123456789abcdef"
.
toCharArray
();
public
static
String
bytesToHex
(
byte
[]
bytes
)
{
public
static
String
bytesToHex
(
byte
[]
bytes
)
{
if
(
bytes
==
null
)
return
""
;
char
[]
hexChars
=
new
char
[
bytes
.
length
*
2
];
char
[]
hexChars
=
new
char
[
bytes
.
length
*
2
];
for
(
int
j
=
0
;
j
<
bytes
.
length
;
j
++)
{
for
(
int
j
=
0
;
j
<
bytes
.
length
;
j
++)
{
int
v
=
bytes
[
j
]
&
0xFF
;
int
v
=
bytes
[
j
]
&
0xFF
;
...
...
Prev
1
2
3
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