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
56a1ab64
Commit
56a1ab64
authored
Apr 24, 2022
by
Yazawazi
Committed by
GitHub
Apr 24, 2022
Browse files
Player Level Reward Update Notify Support!
parent
b2840b17
Changes
3
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/GenshinPlayer.java
View file @
56a1ab64
...
@@ -52,6 +52,7 @@ import emu.grasscutter.server.packet.send.PacketPlayerPropNotify;
...
@@ -52,6 +52,7 @@ import emu.grasscutter.server.packet.send.PacketPlayerPropNotify;
import
emu.grasscutter.server.packet.send.PacketPlayerStoreNotify
;
import
emu.grasscutter.server.packet.send.PacketPlayerStoreNotify
;
import
emu.grasscutter.server.packet.send.PacketPrivateChatNotify
;
import
emu.grasscutter.server.packet.send.PacketPrivateChatNotify
;
import
emu.grasscutter.server.packet.send.PacketScenePlayerLocationNotify
;
import
emu.grasscutter.server.packet.send.PacketScenePlayerLocationNotify
;
import
emu.grasscutter.server.packet.send.PacketPlayerLevelRewardUpdateNotify
;
import
emu.grasscutter.server.packet.send.PacketSetNameCardRsp
;
import
emu.grasscutter.server.packet.send.PacketSetNameCardRsp
;
import
emu.grasscutter.server.packet.send.PacketStoreWeightLimitNotify
;
import
emu.grasscutter.server.packet.send.PacketStoreWeightLimitNotify
;
import
emu.grasscutter.server.packet.send.PacketUnlockNameCardNotify
;
import
emu.grasscutter.server.packet.send.PacketUnlockNameCardNotify
;
...
@@ -96,6 +97,7 @@ public class GenshinPlayer {
...
@@ -96,6 +97,7 @@ public class GenshinPlayer {
private
MpSettingType
mpSetting
=
MpSettingType
.
MpSettingEnterAfterApply
;
private
MpSettingType
mpSetting
=
MpSettingType
.
MpSettingEnterAfterApply
;
private
boolean
showAvatar
;
private
boolean
showAvatar
;
private
ArrayList
<
AvatarProfileData
>
shownAvatars
;
private
ArrayList
<
AvatarProfileData
>
shownAvatars
;
private
Set
<
Integer
>
rewardedLevels
;
private
int
sceneId
;
private
int
sceneId
;
private
int
regionId
;
private
int
regionId
;
...
@@ -143,6 +145,7 @@ public class GenshinPlayer {
...
@@ -143,6 +145,7 @@ public class GenshinPlayer {
this
.
clientAbilityInitFinishHandler
=
new
InvokeHandler
(
PacketClientAbilityInitFinishNotify
.
class
);
this
.
clientAbilityInitFinishHandler
=
new
InvokeHandler
(
PacketClientAbilityInitFinishNotify
.
class
);
this
.
birthday
=
new
PlayerBirthday
();
this
.
birthday
=
new
PlayerBirthday
();
this
.
rewardedLevels
=
new
HashSet
<>();
}
}
// On player creation
// On player creation
...
@@ -656,6 +659,14 @@ public class GenshinPlayer {
...
@@ -656,6 +659,14 @@ public class GenshinPlayer {
this
.
updateProfile
();
this
.
updateProfile
();
}
}
public
Set
<
Integer
>
getRewardedLevels
()
{
return
rewardedLevels
;
}
public
void
setRewardedLevels
(
Set
<
Integer
>
rewardedLevels
)
{
this
.
rewardedLevels
=
rewardedLevels
;
}
public
SocialDetail
.
Builder
getSocialDetail
()
{
public
SocialDetail
.
Builder
getSocialDetail
()
{
SocialDetail
.
Builder
social
=
SocialDetail
.
newBuilder
()
SocialDetail
.
Builder
social
=
SocialDetail
.
newBuilder
()
.
setUid
(
this
.
getUid
())
.
setUid
(
this
.
getUid
())
...
@@ -773,6 +784,7 @@ public class GenshinPlayer {
...
@@ -773,6 +784,7 @@ public class GenshinPlayer {
session
.
send
(
new
PacketAvatarDataNotify
(
this
));
session
.
send
(
new
PacketAvatarDataNotify
(
this
));
session
.
send
(
new
PacketPlayerEnterSceneNotify
(
this
));
// Enter game world
session
.
send
(
new
PacketPlayerEnterSceneNotify
(
this
));
// Enter game world
session
.
send
(
new
PacketPlayerLevelRewardUpdateNotify
(
rewardedLevels
));
session
.
send
(
new
PacketOpenStateUpdateNotify
());
session
.
send
(
new
PacketOpenStateUpdateNotify
());
// First notify packets sent
// First notify packets sent
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerTakePlayerLevelRewardReq.java
View file @
56a1ab64
...
@@ -2,7 +2,9 @@ package emu.grasscutter.server.packet.recv;
...
@@ -2,7 +2,9 @@ package emu.grasscutter.server.packet.recv;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.GenshinData
;
import
emu.grasscutter.data.GenshinData
;
import
emu.grasscutter.data.common.RewardItemData
;
import
emu.grasscutter.data.common.RewardItemData
;
import
emu.grasscutter.game.inventory.GenshinItem
;
import
emu.grasscutter.game.inventory.GenshinItem
;
...
@@ -36,6 +38,9 @@ public class HandlerTakePlayerLevelRewardReq extends PacketHandler {
...
@@ -36,6 +38,9 @@ public class HandlerTakePlayerLevelRewardReq extends PacketHandler {
}
}
session
.
getPlayer
().
getInventory
().
addItems
(
items
);
session
.
getPlayer
().
getInventory
().
addItems
(
items
);
session
.
getPlayer
().
sendPacket
(
new
PacketItemAddHintNotify
(
items
,
ActionReason
.
PlayerUpgradeReward
));
session
.
getPlayer
().
sendPacket
(
new
PacketItemAddHintNotify
(
items
,
ActionReason
.
PlayerUpgradeReward
));
Set
<
Integer
>
rewardedLevels
=
session
.
getPlayer
().
getRewardedLevels
();
rewardedLevels
.
add
(
level
);
session
.
getPlayer
().
setRewardedLevels
(
rewardedLevels
);
}
}
session
.
send
(
new
PacketTakePlayerLevelRewardRsp
(
level
,
rewardId
));
session
.
send
(
new
PacketTakePlayerLevelRewardRsp
(
level
,
rewardId
));
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketPlayerLevelRewardUpdateNotify.java
0 → 100644
View file @
56a1ab64
package
emu.grasscutter.server.packet.send
;
import
java.util.Set
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.PlayerLevelRewardUpdateNotifyOuterClass.PlayerLevelRewardUpdateNotify
;
public
class
PacketPlayerLevelRewardUpdateNotify
extends
GenshinPacket
{
public
PacketPlayerLevelRewardUpdateNotify
(
Set
<
Integer
>
rewardedLevels
)
{
super
(
PacketOpcodes
.
PlayerLevelRewardUpdateNotify
);
PlayerLevelRewardUpdateNotify
.
Builder
proto
=
PlayerLevelRewardUpdateNotify
.
newBuilder
();
for
(
Integer
level
:
rewardedLevels
)
{
proto
.
addLevelList
(
level
);
}
this
.
setData
(
proto
.
build
());
}
}
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