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
f8f4d89c
Commit
f8f4d89c
authored
Apr 29, 2022
by
Melledy
Browse files
Optimize GetOnlinePlayerListRsp
parent
66c2743d
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/player/Player.java
View file @
f8f4d89c
...
...
@@ -822,7 +822,7 @@ public class Player {
.
setProfilePicture
(
ProfilePicture
.
newBuilder
().
setAvatarId
(
this
.
getHeadImage
()));
if
(
this
.
getWorld
()
!=
null
)
{
onlineInfo
.
setCurPlayerNumInWorld
(
this
.
getWorld
().
getPlayer
s
().
indexOf
(
this
)
+
1
);
onlineInfo
.
setCurPlayerNumInWorld
(
getWorld
().
getPlayer
Count
()
);
}
else
{
onlineInfo
.
setCurPlayerNumInWorld
(
1
);
}
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketGetOnlinePlayerListRsp.java
View file @
f8f4d89c
...
...
@@ -18,36 +18,19 @@ import java.util.Objects;
public
class
PacketGetOnlinePlayerListRsp
extends
BasePacket
{
public
PacketGetOnlinePlayerListRsp
(
Player
session
){
super
(
PacketOpcodes
.
GetOnlinePlayerListRsp
);
Map
<
Integer
,
Player
>
playersMap
=
Grasscutter
.
getGameServer
().
getPlayers
();
List
<
Player
>
players
=
Grasscutter
.
getGameServer
().
getPlayers
().
values
().
stream
().
limit
(
50
).
toList
();
GetOnlinePlayerListRsp
.
Builder
proto
=
GetOnlinePlayerListRsp
.
newBuilder
();
if
(
playersMap
.
size
()
!=
0
){
List
<
OnlinePlayerInfo
>
playerInfoList
=
new
ArrayList
<>();
for
(
Player
player:
playersMap
.
values
()){
ProfilePicture
.
Builder
picture
=
ProfilePicture
.
newBuilder
();
OnlinePlayerInfo
.
Builder
playerInfo
=
OnlinePlayerInfo
.
newBuilder
();
if
(
player
.
getUid
()
==
session
.
getUid
())
continue
;
picture
.
setAvatarId
(
player
.
getProfile
().
getAvatarId
())
.
build
();
System
.
out
.
println
(
player
.
getHeadImage
());
playerInfo
.
setUid
(
player
.
getUid
())
.
setNickname
(
player
.
getNickname
())
.
setPlayerLevel
(
player
.
getLevel
())
.
setMpSettingType
(
MpSettingTypeOuterClass
.
MpSettingType
.
MP_SETTING_ENTER_AFTER_APPLY
)
.
setCurPlayerNumInWorld
(
player
.
getWorld
().
getPlayerCount
())
.
setWorldLevel
(
player
.
getWorldLevel
())
.
setNameCardId
(
player
.
getNameCardId
())
.
setProfilePicture
(
picture
);
if
(!
Objects
.
equals
(
player
.
getSignature
(),
""
)){
playerInfo
.
setSignature
(
player
.
getSignature
());
}
playerInfoList
.
add
(
playerInfo
.
build
());
}
for
(
OnlinePlayerInfo
onlinePlayerInfo
:
playerInfoList
)
{
proto
.
addPlayerInfoList
(
onlinePlayerInfo
).
build
();
if
(
players
.
size
()
!=
0
)
{
for
(
Player
player
:
players
)
{
if
(
player
.
getUid
()
==
session
.
getUid
())
continue
;
proto
.
addPlayerInfoList
(
player
.
getOnlinePlayerInfo
());
}
}
this
.
setData
(
proto
);
}
}
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