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
a2069c00
Commit
a2069c00
authored
Apr 26, 2022
by
Benjamin Elsdon
Browse files
Merge remote-tracking branch 'upstream/development' into dev-mail
parents
a5677a8e
c4bdcc38
Changes
28
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/server/event/dispatch/QueryAllRegionsEvent.java
0 → 100644
View file @
a2069c00
package
emu.grasscutter.server.event.dispatch
;
import
emu.grasscutter.server.event.ServerEvent
;
public
final
class
QueryAllRegionsEvent
extends
ServerEvent
{
private
String
regionList
;
public
QueryAllRegionsEvent
(
String
regionList
)
{
super
(
Type
.
DISPATCH
);
this
.
regionList
=
regionList
;
}
public
void
setRegionList
(
String
regionList
)
{
this
.
regionList
=
regionList
;
}
public
String
getRegionList
()
{
return
this
.
regionList
;
}
}
src/main/java/emu/grasscutter/server/event/dispatch/QueryCurrentRegionEvent.java
0 → 100644
View file @
a2069c00
package
emu.grasscutter.server.event.dispatch
;
import
emu.grasscutter.server.event.ServerEvent
;
public
final
class
QueryCurrentRegionEvent
extends
ServerEvent
{
private
String
regionInfo
;
public
QueryCurrentRegionEvent
(
String
regionInfo
)
{
super
(
Type
.
DISPATCH
);
this
.
regionInfo
=
regionInfo
;
}
public
void
setRegionInfo
(
String
regionInfo
)
{
this
.
regionInfo
=
regionInfo
;
}
public
String
getRegionInfo
()
{
return
this
.
regionInfo
;
}
}
src/main/java/emu/grasscutter/server/event/game/ReceivePacketEvent.java
0 → 100644
View file @
a2069c00
package
emu.grasscutter.server.event.game
;
import
emu.grasscutter.server.event.Cancellable
;
import
emu.grasscutter.server.event.ServerEvent
;
import
emu.grasscutter.server.game.GameSession
;
public
final
class
ReceivePacketEvent
extends
ServerEvent
implements
Cancellable
{
private
final
GameSession
gameSession
;
private
final
int
packetId
;
private
byte
[]
packetData
;
public
ReceivePacketEvent
(
GameSession
gameSession
,
int
packetId
,
byte
[]
packetData
)
{
super
(
Type
.
GAME
);
this
.
gameSession
=
gameSession
;
this
.
packetId
=
packetId
;
this
.
packetData
=
packetData
;
}
public
GameSession
getGameSession
()
{
return
this
.
gameSession
;
}
public
int
getPacketId
()
{
return
this
.
packetId
;
}
public
void
setPacketData
(
byte
[]
packetData
)
{
this
.
packetData
=
packetData
;
}
public
byte
[]
getPacketData
()
{
return
this
.
packetData
;
}
}
src/main/java/emu/grasscutter/server/event/game/SendPacketEvent.java
0 → 100644
View file @
a2069c00
package
emu.grasscutter.server.event.game
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.server.event.Cancellable
;
import
emu.grasscutter.server.event.ServerEvent
;
import
emu.grasscutter.server.game.GameSession
;
public
final
class
SendPacketEvent
extends
ServerEvent
implements
Cancellable
{
private
final
GameSession
gameSession
;
private
GenshinPacket
packet
;
public
SendPacketEvent
(
GameSession
gameSession
,
GenshinPacket
packet
)
{
super
(
Type
.
GAME
);
this
.
gameSession
=
gameSession
;
this
.
packet
=
packet
;
}
public
GameSession
getGameSession
()
{
return
this
.
gameSession
;
}
public
void
setPacket
(
GenshinPacket
packet
)
{
this
.
packet
=
packet
;
}
public
GenshinPacket
getPacket
()
{
return
this
.
packet
;
}
}
src/main/java/emu/grasscutter/server/game/GameServerPacketHandler.java
View file @
a2069c00
...
...
@@ -2,6 +2,7 @@ package emu.grasscutter.server.game;
import
java.util.Set
;
import
emu.grasscutter.server.event.game.ReceivePacketEvent
;
import
org.reflections.Reflections
;
import
emu.grasscutter.Grasscutter
;
...
...
@@ -48,9 +49,7 @@ public class GameServerPacketHandler {
}
public
void
handle
(
GameSession
session
,
int
opcode
,
byte
[]
header
,
byte
[]
payload
)
{
PacketHandler
handler
=
null
;
handler
=
this
.
handlers
.
get
(
opcode
);
PacketHandler
handler
=
this
.
handlers
.
get
(
opcode
);
if
(
handler
!=
null
)
{
try
{
...
...
@@ -77,8 +76,10 @@ public class GameServerPacketHandler {
}
}
// Handle
handler
.
handle
(
session
,
header
,
payload
);
// Invoke event.
ReceivePacketEvent
event
=
new
ReceivePacketEvent
(
session
,
opcode
,
payload
);
event
.
call
();
if
(!
event
.
isCanceled
())
// If event is not canceled, continue.
handler
.
handle
(
session
,
header
,
event
.
getPacketData
());
}
catch
(
Exception
ex
)
{
// TODO Remove this when no more needed
ex
.
printStackTrace
();
...
...
src/main/java/emu/grasscutter/server/game/GameSession.java
View file @
a2069c00
...
...
@@ -10,6 +10,7 @@ import emu.grasscutter.game.GenshinPlayer;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.PacketOpcodesUtil
;
import
emu.grasscutter.netty.MihoyoKcpChannel
;
import
emu.grasscutter.server.event.game.SendPacketEvent
;
import
emu.grasscutter.utils.Crypto
;
import
emu.grasscutter.utils.FileUtils
;
import
emu.grasscutter.utils.Utils
;
...
...
@@ -161,16 +162,15 @@ public class GameSession extends MihoyoKcpChannel {
genshinPacket
.
buildHeader
(
this
.
getNextClientSequence
());
}
// Build packet
byte
[]
data
=
genshinPacket
.
build
();
// Log
if
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
LOG_PACKETS
)
{
logPacket
(
genshinPacket
);
}
// Send
send
(
data
);
// Invoke event.
SendPacketEvent
event
=
new
SendPacketEvent
(
this
,
genshinPacket
);
event
.
call
();
if
(!
event
.
isCanceled
())
// If event is not cancelled, continue.
this
.
send
(
event
.
getPacket
().
build
());
}
private
void
logPacket
(
int
opcode
)
{
...
...
src/main/java/emu/grasscutter/utils/Utils.java
View file @
a2069c00
...
...
@@ -137,6 +137,15 @@ public final class Utils {
return
nonNull
!=
null
?
nonNull
:
fallback
;
}
/**
* Logs an object to the console.
* @param object The object to log.
*/
public
static
void
logObject
(
Object
object
)
{
String
asJson
=
Grasscutter
.
getGsonFactory
().
toJson
(
object
);
Grasscutter
.
getLogger
().
info
(
asJson
);
}
/**
* Checks for required files and folders before startup.
*/
...
...
src/main/
java
/META-INF/MANIFEST.MF
→
src/main/
resources
/META-INF/MANIFEST.MF
View file @
a2069c00
File moved
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