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
f16d33b4
Commit
f16d33b4
authored
Apr 28, 2022
by
Yazawazi
Committed by
GitHub
Apr 28, 2022
Browse files
Player show avatar list
parent
5b55df69
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/player/Player.java
View file @
f16d33b4
...
...
@@ -93,6 +93,9 @@ public class Player {
private
int
moonCardDuration
;
private
Set
<
Date
>
moonCardGetTimes
;
private
List
<
Integer
>
showAvatarList
;
private
boolean
showAvatars
;
@Transient
private
boolean
paused
;
@Transient
private
int
enterSceneToken
;
@Transient
private
SceneLoadState
sceneState
;
...
...
@@ -513,6 +516,22 @@ public class Player {
this
.
regionId
=
regionId
;
}
public
void
setShowAvatars
(
boolean
showAvatars
)
{
this
.
showAvatars
=
showAvatars
;
}
public
boolean
isShowAvatars
()
{
return
showAvatars
;
}
public
void
setShowAvatarList
(
List
<
Integer
>
showAvatarList
)
{
this
.
showAvatarList
=
showAvatarList
;
}
public
List
<
Integer
>
getShowAvatarList
()
{
return
showAvatarList
;
}
public
boolean
inMoonCard
()
{
return
moonCard
;
}
...
...
@@ -832,15 +851,29 @@ public class Player {
}
public
SocialDetail
.
Builder
getSocialDetail
()
{
List
<
SocialShowAvatarInfoOuterClass
.
SocialShowAvatarInfo
>
socialShowAvatarInfoList
=
new
ArrayList
<>();
for
(
int
avatarId
:
this
.
getShowAvatarList
())
{
socialShowAvatarInfoList
.
add
(
socialShowAvatarInfoList
.
size
(),
SocialShowAvatarInfoOuterClass
.
SocialShowAvatarInfo
.
newBuilder
()
.
setAvatarId
(
avatarId
)
.
setLevel
(
getAvatars
().
getAvatarById
(
avatarId
).
getLevel
())
.
setCostumeId
(
getAvatars
().
getAvatarById
(
avatarId
).
getCostume
())
.
build
()
);
}
SocialDetail
.
Builder
social
=
SocialDetail
.
newBuilder
()
.
setUid
(
this
.
getUid
())
.
set
ProfilePicture
(
ProfilePictur
e
.
newBuilder
().
setAvatarId
(
this
.
getHeadImage
()))
.
set
AvatarId
(
HeadImag
e
.
newBuilder
().
setAvatarId
(
this
.
getHeadImage
())
.
getAvatarId
()
)
.
setNickname
(
this
.
getNickname
())
.
setSignature
(
this
.
getSignature
())
.
setLevel
(
this
.
getLevel
())
.
setBirthday
(
this
.
getBirthday
().
getFilledProtoWhenNotEmpty
())
.
setWorldLevel
(
this
.
getWorldLevel
())
.
setNameCardId
(
this
.
getNameCardId
())
.
setIsShowAvatar
(
this
.
isShowAvatars
())
.
addAllShowAvatarInfoList
(
socialShowAvatarInfoList
)
.
setFinishAchievementNum
(
0
);
return
social
;
}
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerUpdatePlayerShowAvatarListReq.java
0 → 100644
View file @
f16d33b4
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.UpdatePlayerShowAvatarListReqOuterClass
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketUpdatePlayerShowAvatarListRsp
;
@Opcodes
(
PacketOpcodes
.
UpdatePlayerShowAvatarListReq
)
public
class
HandlerUpdatePlayerShowAvatarListReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
UpdatePlayerShowAvatarListReqOuterClass
.
UpdatePlayerShowAvatarListReq
req
=
UpdatePlayerShowAvatarListReqOuterClass
.
UpdatePlayerShowAvatarListReq
.
parseFrom
(
payload
);
session
.
getPlayer
().
setShowAvatars
(
req
.
getIsShowAvatar
());
session
.
getPlayer
().
setShowAvatarList
(
req
.
getShowAvatarIdListList
());
session
.
send
(
new
PacketUpdatePlayerShowAvatarListRsp
(
req
.
getIsShowAvatar
(),
req
.
getShowAvatarIdListList
()));
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketUpdatePlayerShowAvatarListRsp.java
0 → 100644
View file @
f16d33b4
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.UpdatePlayerShowAvatarListReqOuterClass
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketUpdatePlayerShowAvatarListRsp
;
@Opcodes
(
PacketOpcodes
.
UpdatePlayerShowAvatarListReq
)
public
class
HandlerUpdatePlayerShowAvatarListReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
UpdatePlayerShowAvatarListReqOuterClass
.
UpdatePlayerShowAvatarListReq
req
=
UpdatePlayerShowAvatarListReqOuterClass
.
UpdatePlayerShowAvatarListReq
.
parseFrom
(
payload
);
session
.
getPlayer
().
setShowAvatars
(
req
.
getIsShowAvatar
());
session
.
getPlayer
().
setShowAvatarList
(
req
.
getShowAvatarIdListList
());
session
.
send
(
new
PacketUpdatePlayerShowAvatarListRsp
(
req
.
getIsShowAvatar
(),
req
.
getShowAvatarIdListList
()));
}
}
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