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
d3925e8c
Commit
d3925e8c
authored
Apr 27, 2022
by
Melledy
Committed by
GitHub
Apr 27, 2022
Browse files
Merge pull request #318 from Yazawazi/development
Implementing the `Player Show Avatars`
parents
96dbc2fb
0cbfcdda
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/player/Player.java
View file @
d3925e8c
...
@@ -35,6 +35,7 @@ import emu.grasscutter.net.proto.PlayerLocationInfoOuterClass.PlayerLocationInfo
...
@@ -35,6 +35,7 @@ import emu.grasscutter.net.proto.PlayerLocationInfoOuterClass.PlayerLocationInfo
import
emu.grasscutter.net.proto.PlayerWorldLocationInfoOuterClass
;
import
emu.grasscutter.net.proto.PlayerWorldLocationInfoOuterClass
;
import
emu.grasscutter.net.proto.ProfilePictureOuterClass.ProfilePicture
;
import
emu.grasscutter.net.proto.ProfilePictureOuterClass.ProfilePicture
;
import
emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail
;
import
emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail
;
import
emu.grasscutter.net.proto.SocialShowAvatarInfoOuterClass
;
import
emu.grasscutter.server.game.GameServer
;
import
emu.grasscutter.server.game.GameServer
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.*
;
import
emu.grasscutter.server.packet.send.*
;
...
@@ -93,6 +94,9 @@ public class Player {
...
@@ -93,6 +94,9 @@ public class Player {
private
int
moonCardDuration
;
private
int
moonCardDuration
;
private
Set
<
Date
>
moonCardGetTimes
;
private
Set
<
Date
>
moonCardGetTimes
;
private
List
<
Integer
>
showAvatarList
;
private
boolean
showAvatars
;
@Transient
private
boolean
paused
;
@Transient
private
boolean
paused
;
@Transient
private
int
enterSceneToken
;
@Transient
private
int
enterSceneToken
;
@Transient
private
SceneLoadState
sceneState
;
@Transient
private
SceneLoadState
sceneState
;
...
@@ -513,6 +517,22 @@ public class Player {
...
@@ -513,6 +517,22 @@ public class Player {
this
.
regionId
=
regionId
;
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
()
{
public
boolean
inMoonCard
()
{
return
moonCard
;
return
moonCard
;
}
}
...
@@ -832,6 +852,38 @@ public class Player {
...
@@ -832,6 +852,38 @@ public class Player {
}
}
public
SocialDetail
.
Builder
getSocialDetail
()
{
public
SocialDetail
.
Builder
getSocialDetail
()
{
List
<
SocialShowAvatarInfoOuterClass
.
SocialShowAvatarInfo
>
socialShowAvatarInfoList
=
new
ArrayList
<>();
if
(
this
.
isOnline
())
{
if
(
this
.
getShowAvatarList
()
!=
null
)
{
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
()
);
}
}
}
else
{
List
<
Integer
>
showAvatarList
=
DatabaseHelper
.
getPlayerById
(
id
).
getShowAvatarList
();
AvatarStorage
avatars
=
DatabaseHelper
.
getPlayerById
(
id
).
getAvatars
();
avatars
.
loadFromDatabase
();
if
(
showAvatarList
!=
null
)
{
for
(
int
avatarId
:
showAvatarList
)
{
socialShowAvatarInfoList
.
add
(
socialShowAvatarInfoList
.
size
(),
SocialShowAvatarInfoOuterClass
.
SocialShowAvatarInfo
.
newBuilder
()
.
setAvatarId
(
avatarId
)
.
setLevel
(
avatars
.
getAvatarById
(
avatarId
).
getLevel
())
.
setCostumeId
(
avatars
.
getAvatarById
(
avatarId
).
getCostume
())
.
build
()
);
}
}
}
SocialDetail
.
Builder
social
=
SocialDetail
.
newBuilder
()
SocialDetail
.
Builder
social
=
SocialDetail
.
newBuilder
()
.
setUid
(
this
.
getUid
())
.
setUid
(
this
.
getUid
())
.
setProfilePicture
(
ProfilePicture
.
newBuilder
().
setAvatarId
(
this
.
getHeadImage
()))
.
setProfilePicture
(
ProfilePicture
.
newBuilder
().
setAvatarId
(
this
.
getHeadImage
()))
...
@@ -841,6 +893,8 @@ public class Player {
...
@@ -841,6 +893,8 @@ public class Player {
.
setBirthday
(
this
.
getBirthday
().
getFilledProtoWhenNotEmpty
())
.
setBirthday
(
this
.
getBirthday
().
getFilledProtoWhenNotEmpty
())
.
setWorldLevel
(
this
.
getWorldLevel
())
.
setWorldLevel
(
this
.
getWorldLevel
())
.
setNameCardId
(
this
.
getNameCardId
())
.
setNameCardId
(
this
.
getNameCardId
())
.
setIsShowAvatar
(
this
.
isShowAvatars
())
.
addAllShowAvatarInfoList
(
socialShowAvatarInfoList
)
.
setFinishAchievementNum
(
0
);
.
setFinishAchievementNum
(
0
);
return
social
;
return
social
;
}
}
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerUpdatePlayerShowAvatarListReq.java
0 → 100644
View file @
d3925e8c
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 @
d3925e8c
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.UpdatePlayerShowAvatarListRspOuterClass.UpdatePlayerShowAvatarListRsp
;
import
java.util.List
;
public
class
PacketUpdatePlayerShowAvatarListRsp
extends
BasePacket
{
public
PacketUpdatePlayerShowAvatarListRsp
(
boolean
isShowAvatar
,
List
<
Integer
>
avatarIds
)
{
super
(
PacketOpcodes
.
UpdatePlayerShowAvatarListRsp
);
UpdatePlayerShowAvatarListRsp
proto
=
UpdatePlayerShowAvatarListRsp
.
newBuilder
()
.
setIsShowAvatar
(
isShowAvatar
)
.
addAllShowAvatarIdList
(
avatarIds
)
.
setRetcode
(
0
)
.
build
();
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