Skip to content

Commit 2e95010

Browse files
authored
session: Set EmoteFlagMuteChat if emote chat muted. (#1116)
1 parent a03ca4a commit 2e95010

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

server/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@ func (srv *Server) createPlayer(id uuid.UUID, conn session.Conn, conf player.Con
547547
s := session.Config{
548548
Log: srv.conf.Log,
549549
MaxChunkRadius: srv.conf.MaxChunkRadius,
550+
EmoteChatMuted: srv.conf.MuteEmoteChat,
550551
JoinMessage: srv.conf.JoinMessage,
551552
QuitMessage: srv.conf.QuitMessage,
552553
HandleStop: srv.handleSessionClose,

server/session/session.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ type Session struct {
4747
chunkLoader *world.Loader
4848
chunkRadius, maxChunkRadius int32
4949

50+
emoteChatMuted bool
51+
5052
teleportPos atomic.Pointer[mgl64.Vec3]
5153

5254
entityMutex sync.RWMutex
@@ -144,6 +146,8 @@ type Config struct {
144146

145147
MaxChunkRadius int
146148

149+
EmoteChatMuted bool
150+
147151
JoinMessage, QuitMessage chat.Translation
148152

149153
HandleStop func(*world.Tx, Controllable)
@@ -172,6 +176,7 @@ func (conf Config) New(conn Conn) *Session {
172176
blobs: map[uint64][]byte{},
173177
chunkRadius: int32(r),
174178
maxChunkRadius: int32(conf.MaxChunkRadius),
179+
emoteChatMuted: conf.EmoteChatMuted,
175180
conn: conn,
176181
currentEntityRuntimeID: 1,
177182
heldSlot: new(uint32),

server/session/world.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,10 +1206,14 @@ func (s *Session) ViewBlockAction(pos cube.Pos, a world.BlockAction) {
12061206

12071207
// ViewEmote ...
12081208
func (s *Session) ViewEmote(player world.Entity, emote uuid.UUID) {
1209+
flags := byte(packet.EmoteFlagServerSide)
1210+
if s.emoteChatMuted {
1211+
flags |= packet.EmoteFlagMuteChat
1212+
}
12091213
s.writePacket(&packet.Emote{
12101214
EntityRuntimeID: s.entityRuntimeID(player),
12111215
EmoteID: emote.String(),
1212-
Flags: packet.EmoteFlagServerSide,
1216+
Flags: flags,
12131217
})
12141218
}
12151219

0 commit comments

Comments
 (0)