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
a4932c75
Commit
a4932c75
authored
Apr 18, 2022
by
KingRainbow44
Browse files
Refactor method names & add `/` prefix
parent
c162632f
Changes
3
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/managers/ChatManager.java
View file @
a4932c75
...
...
@@ -7,7 +7,12 @@ import emu.grasscutter.server.game.GameServer;
import
emu.grasscutter.server.packet.send.PacketPlayerChatNotify
;
import
emu.grasscutter.server.packet.send.PacketPrivateChatNotify
;
import
java.util.Arrays
;
import
java.util.List
;
public
class
ChatManager
{
static
final
List
<
Character
>
PREFIXES
=
Arrays
.
asList
(
'/'
,
'!'
);
private
final
GameServer
server
;
public
ChatManager
(
GameServer
server
)
{
...
...
@@ -18,14 +23,14 @@ public class ChatManager {
return
server
;
}
public
void
sendPriv
Ch
at
(
GenshinPlayer
player
,
int
targetUid
,
String
message
)
{
public
void
sendPrivat
eMessage
(
GenshinPlayer
player
,
int
targetUid
,
String
message
)
{
// Sanity checks
if
(
message
==
null
||
message
.
length
()
==
0
)
{
return
;
}
// Check if command
if
(
message
.
charAt
(
0
)
==
'!'
)
{
if
(
PREFIXES
.
contains
(
message
.
charAt
(
0
)
)
)
{
CommandMap
.
getInstance
().
invoke
(
player
,
message
);
return
;
}
...
...
@@ -44,7 +49,7 @@ public class ChatManager {
target
.
sendPacket
(
packet
);
}
public
void
sendPriv
Ch
at
(
GenshinPlayer
player
,
int
targetUid
,
int
emote
)
{
public
void
sendPrivat
eMessage
(
GenshinPlayer
player
,
int
targetUid
,
int
emote
)
{
// Get target
GenshinPlayer
target
=
getServer
().
getPlayerById
(
targetUid
);
...
...
@@ -59,14 +64,14 @@ public class ChatManager {
target
.
sendPacket
(
packet
);
}
public
void
sendTeam
Chat
(
GenshinPlayer
player
,
int
channel
,
String
message
)
{
public
void
sendTeam
Message
(
GenshinPlayer
player
,
int
channel
,
String
message
)
{
// Sanity checks
if
(
message
==
null
||
message
.
length
()
==
0
)
{
return
;
}
// Check if command
if
(
message
.
charAt
(
0
)
==
'!'
)
{
if
(
PREFIXES
.
contains
(
message
.
charAt
(
0
)
)
)
{
CommandMap
.
getInstance
().
invoke
(
player
,
message
);
return
;
}
...
...
@@ -75,7 +80,7 @@ public class ChatManager {
player
.
getWorld
().
broadcastPacket
(
new
PacketPlayerChatNotify
(
player
,
channel
,
message
));
}
public
void
sendTeam
Chat
(
GenshinPlayer
player
,
int
channel
,
int
icon
)
{
public
void
sendTeam
Message
(
GenshinPlayer
player
,
int
channel
,
int
icon
)
{
// Create and send chat packet
player
.
getWorld
().
broadcastPacket
(
new
PacketPlayerChatNotify
(
player
,
channel
,
icon
));
}
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerChatReq.java
View file @
a4932c75
...
...
@@ -17,9 +17,9 @@ public class HandlerPlayerChatReq extends PacketHandler {
ChatInfo
.
ContentCase
content
=
req
.
getChatInfo
().
getContentCase
();
if
(
content
==
ChatInfo
.
ContentCase
.
TEXT
)
{
session
.
getServer
().
getChatManager
().
sendTeam
Chat
(
session
.
getPlayer
(),
req
.
getChannelId
(),
req
.
getChatInfo
().
getText
());
session
.
getServer
().
getChatManager
().
sendTeam
Message
(
session
.
getPlayer
(),
req
.
getChannelId
(),
req
.
getChatInfo
().
getText
());
}
else
if
(
content
==
ChatInfo
.
ContentCase
.
ICON
)
{
session
.
getServer
().
getChatManager
().
sendTeam
Chat
(
session
.
getPlayer
(),
req
.
getChannelId
(),
req
.
getChatInfo
().
getIcon
());
session
.
getServer
().
getChatManager
().
sendTeam
Message
(
session
.
getPlayer
(),
req
.
getChannelId
(),
req
.
getChatInfo
().
getIcon
());
}
session
.
send
(
new
PacketPlayerChatRsp
());
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerPrivateChatReq.java
View file @
a4932c75
...
...
@@ -15,9 +15,9 @@ public class HandlerPrivateChatReq extends PacketHandler {
PrivateChatReq
.
ContentCase
content
=
req
.
getContentCase
();
if
(
content
==
PrivateChatReq
.
ContentCase
.
TEXT
)
{
session
.
getServer
().
getChatManager
().
sendPriv
Ch
at
(
session
.
getPlayer
(),
req
.
getTargetUid
(),
req
.
getText
());
session
.
getServer
().
getChatManager
().
sendPrivat
eMessage
(
session
.
getPlayer
(),
req
.
getTargetUid
(),
req
.
getText
());
}
else
if
(
content
==
PrivateChatReq
.
ContentCase
.
ICON
)
{
session
.
getServer
().
getChatManager
().
sendPriv
Ch
at
(
session
.
getPlayer
(),
req
.
getTargetUid
(),
req
.
getIcon
());
session
.
getServer
().
getChatManager
().
sendPrivat
eMessage
(
session
.
getPlayer
(),
req
.
getTargetUid
(),
req
.
getIcon
());
}
//session.send(new GenshinPacket(PacketOpcodes.PrivateChatRsp)); // Unused by server
...
...
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