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
02c85271
Commit
02c85271
authored
Apr 22, 2022
by
Melledy
Committed by
GitHub
Apr 22, 2022
Browse files
Merge pull request #136 from miyucchi/development
Save birthday date
parents
3ed6a994
539970fd
Changes
4
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/GenshinPlayer.java
View file @
02c85271
...
@@ -18,6 +18,7 @@ import emu.grasscutter.game.friends.PlayerProfile;
...
@@ -18,6 +18,7 @@ import emu.grasscutter.game.friends.PlayerProfile;
import
emu.grasscutter.game.gacha.PlayerGachaInfo
;
import
emu.grasscutter.game.gacha.PlayerGachaInfo
;
import
emu.grasscutter.game.inventory.GenshinItem
;
import
emu.grasscutter.game.inventory.GenshinItem
;
import
emu.grasscutter.game.inventory.Inventory
;
import
emu.grasscutter.game.inventory.Inventory
;
import
emu.grasscutter.game.player.PlayerBirthday
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.GenshinPacket
;
...
@@ -73,6 +74,7 @@ public class GenshinPlayer {
...
@@ -73,6 +74,7 @@ public class GenshinPlayer {
private
int
nameCardId
=
210001
;
private
int
nameCardId
=
210001
;
private
Position
pos
;
private
Position
pos
;
private
Position
rotation
;
private
Position
rotation
;
private
PlayerBirthday
birthday
;
private
Map
<
Integer
,
Integer
>
properties
;
private
Map
<
Integer
,
Integer
>
properties
;
private
Set
<
Integer
>
nameCardList
;
private
Set
<
Integer
>
nameCardList
;
...
@@ -139,6 +141,8 @@ public class GenshinPlayer {
...
@@ -139,6 +141,8 @@ public class GenshinPlayer {
this
.
combatInvokeHandler
=
new
InvokeHandler
(
PacketCombatInvocationsNotify
.
class
);
this
.
combatInvokeHandler
=
new
InvokeHandler
(
PacketCombatInvocationsNotify
.
class
);
this
.
abilityInvokeHandler
=
new
InvokeHandler
(
PacketAbilityInvocationsNotify
.
class
);
this
.
abilityInvokeHandler
=
new
InvokeHandler
(
PacketAbilityInvocationsNotify
.
class
);
this
.
clientAbilityInitFinishHandler
=
new
InvokeHandler
(
PacketClientAbilityInitFinishNotify
.
class
);
this
.
clientAbilityInitFinishHandler
=
new
InvokeHandler
(
PacketClientAbilityInitFinishNotify
.
class
);
this
.
birthday
=
new
PlayerBirthday
();
}
}
// On player creation
// On player creation
...
@@ -150,6 +154,7 @@ public class GenshinPlayer {
...
@@ -150,6 +154,7 @@ public class GenshinPlayer {
this
.
nickname
=
"Traveler"
;
this
.
nickname
=
"Traveler"
;
this
.
signature
=
""
;
this
.
signature
=
""
;
this
.
teamManager
=
new
TeamManager
(
this
);
this
.
teamManager
=
new
TeamManager
(
this
);
this
.
birthday
=
new
PlayerBirthday
();
this
.
setProperty
(
PlayerProperty
.
PROP_PLAYER_LEVEL
,
1
);
this
.
setProperty
(
PlayerProperty
.
PROP_PLAYER_LEVEL
,
1
);
this
.
setProperty
(
PlayerProperty
.
PROP_IS_SPRING_AUTO_USE
,
1
);
this
.
setProperty
(
PlayerProperty
.
PROP_IS_SPRING_AUTO_USE
,
1
);
this
.
setProperty
(
PlayerProperty
.
PROP_SPRING_AUTO_USE_PERCENT
,
50
);
this
.
setProperty
(
PlayerProperty
.
PROP_SPRING_AUTO_USE_PERCENT
,
50
);
...
@@ -642,6 +647,15 @@ public class GenshinPlayer {
...
@@ -642,6 +647,15 @@ public class GenshinPlayer {
return
onlineInfo
.
build
();
return
onlineInfo
.
build
();
}
}
public
PlayerBirthday
getBirthday
(){
return
this
.
birthday
;
}
public
void
setBirthday
(
int
d
,
int
m
)
{
this
.
birthday
=
new
PlayerBirthday
(
d
,
m
);
this
.
updateProfile
();
}
public
SocialDetail
.
Builder
getSocialDetail
()
{
public
SocialDetail
.
Builder
getSocialDetail
()
{
SocialDetail
.
Builder
social
=
SocialDetail
.
newBuilder
()
SocialDetail
.
Builder
social
=
SocialDetail
.
newBuilder
()
.
setUid
(
this
.
getUid
())
.
setUid
(
this
.
getUid
())
...
@@ -649,7 +663,7 @@ public class GenshinPlayer {
...
@@ -649,7 +663,7 @@ public class GenshinPlayer {
.
setNickname
(
this
.
getNickname
())
.
setNickname
(
this
.
getNickname
())
.
setSignature
(
this
.
getSignature
())
.
setSignature
(
this
.
getSignature
())
.
setLevel
(
this
.
getLevel
())
.
setLevel
(
this
.
getLevel
())
.
setBirthday
(
Birthday
.
newBuilder
())
.
setBirthday
(
this
.
getBirthday
().
getFilledProtoWhenNotEmpty
())
.
setWorldLevel
(
this
.
getWorldLevel
())
.
setWorldLevel
(
this
.
getWorldLevel
())
.
setUnk1
(
1
)
.
setUnk1
(
1
)
.
setUnk3
(
1
)
.
setUnk3
(
1
)
...
...
src/main/java/emu/grasscutter/game/player/PlayerBirthday.java
0 → 100644
View file @
02c85271
package
emu.grasscutter.game.player
;
import
emu.grasscutter.net.proto.BirthdayOuterClass.Birthday
;
public
class
PlayerBirthday
{
private
int
day
;
private
int
month
;
public
PlayerBirthday
(){
this
.
day
=
0
;
this
.
month
=
0
;
}
public
PlayerBirthday
(
int
day
,
int
month
){
this
.
day
=
day
;
this
.
month
=
month
;
}
public
PlayerBirthday
set
(
PlayerBirthday
birth
){
this
.
day
=
birth
.
day
;
this
.
month
=
birth
.
month
;
return
this
;
}
public
PlayerBirthday
set
(
int
d
,
int
m
){
this
.
day
=
d
;
this
.
month
=
m
;
return
this
;
}
public
PlayerBirthday
setDay
(
int
value
){
this
.
day
=
value
;
return
this
;
}
public
PlayerBirthday
setMonth
(
int
value
){
this
.
month
=
value
;
return
this
;
}
public
int
getDay
(){
return
this
.
day
;
}
public
int
getMonth
(){
return
this
.
month
;
}
public
Birthday
toProto
(){
return
Birthday
.
newBuilder
()
.
setDay
(
this
.
getDay
())
.
setMonth
(
this
.
getMonth
())
.
build
();
}
public
Birthday
.
Builder
getFilledProtoWhenNotEmpty
(){
if
(
this
.
getDay
()
>
0
)
{
return
Birthday
.
newBuilder
()
.
setDay
(
this
.
getDay
())
.
setMonth
(
this
.
getMonth
());
}
return
Birthday
.
newBuilder
();
}
}
\ No newline at end of file
src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java
0 → 100644
View file @
02c85271
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketGetPlayerSocialDetailRsp
;
import
emu.grasscutter.server.packet.send.PacketSetPlayerBirthdayRsp
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail
;
import
emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq
;
import
com.google.gson.Gson
;
@Opcodes
(
PacketOpcodes
.
SetPlayerBirthdayReq
)
public
class
HandlerSetPlayerBirthdayReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
SetPlayerBirthdayReq
req
=
SetPlayerBirthdayReq
.
parseFrom
(
payload
);
if
(
req
.
getBirth
()
!=
null
&&
req
.
getBirth
().
getDay
()
>
0
&&
req
.
getBirth
().
getMonth
()
>
0
)
{
int
day
=
req
.
getBirth
().
getDay
();
int
month
=
req
.
getBirth
().
getMonth
();
// Update birthday value
session
.
getPlayer
().
setBirthday
(
day
,
month
);
// Save birthday month and day
session
.
getPlayer
().
save
();
SocialDetail
.
Builder
detail
=
session
.
getPlayer
().
getSocialDetail
();
session
.
send
(
new
PacketSetPlayerBirthdayRsp
(
session
.
getPlayer
()));
session
.
send
(
new
PacketGetPlayerSocialDetailRsp
(
detail
));
}
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketSetPlayerBirthdayRsp.java
0 → 100644
View file @
02c85271
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp
;
import
emu.grasscutter.net.proto.BirthdayOuterClass.Birthday
;
public
class
PacketSetPlayerBirthdayRsp
extends
GenshinPacket
{
public
PacketSetPlayerBirthdayRsp
(
GenshinPlayer
player
)
{
super
(
PacketOpcodes
.
SetPlayerBirthdayRsp
);
SetPlayerBirthdayRsp
proto
=
SetPlayerBirthdayRsp
.
newBuilder
()
.
setBirth
(
player
.
getBirthday
().
toProto
())
.
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