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
dce13cf6
Commit
dce13cf6
authored
Apr 25, 2022
by
Magix
Committed by
GitHub
Apr 25, 2022
Browse files
Merge branch 'development' into plugin-system
parents
832c460a
b6fedcf2
Changes
48
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java
View file @
dce13cf6
package
emu.grasscutter.server.packet.recv
;
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.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail
;
import
emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq
;
import
emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq
;
import
emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail
;
import
com.google.gson.Gson
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketGetPlayerSocialDetailRsp
;
import
emu.grasscutter.server.packet.send.PacketSetPlayerBirthdayRsp
;
@Opcodes
(
PacketOpcodes
.
SetPlayerBirthdayReq
)
@Opcodes
(
PacketOpcodes
.
SetPlayerBirthdayReq
)
public
class
HandlerSetPlayerBirthdayReq
extends
PacketHandler
{
public
class
HandlerSetPlayerBirthdayReq
extends
PacketHandler
{
...
@@ -19,20 +15,53 @@ public class HandlerSetPlayerBirthdayReq extends PacketHandler {
...
@@ -19,20 +15,53 @@ public class HandlerSetPlayerBirthdayReq extends PacketHandler {
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
SetPlayerBirthdayReq
req
=
SetPlayerBirthdayReq
.
parseFrom
(
payload
);
SetPlayerBirthdayReq
req
=
SetPlayerBirthdayReq
.
parseFrom
(
payload
);
if
(
req
.
getBirth
()
!=
null
&&
req
.
getBirth
().
getDay
()
>
0
&&
req
.
getBirth
().
getMonth
()
>
0
)
// RET_BIRTHDAY_CANNOT_BE_SET_TWICE = 7009
{
if
(
session
.
getPlayer
().
hasBirthday
())
{
int
day
=
req
.
getBirth
().
getDay
();
session
.
send
(
new
PacketSetPlayerBirthdayRsp
(
7009
));
int
month
=
req
.
getBirth
().
getMonth
();
return
;
}
int
month
=
req
.
getBirthday
().
getMonth
();
int
day
=
req
.
getBirthday
().
getDay
();
// RET_BIRTHDAY_FORMAT_ERROR = 7022
if
(!
isValidBirthday
(
month
,
day
))
{
session
.
send
(
new
PacketSetPlayerBirthdayRsp
(
7022
));
return
;
}
// Update birthday value
// Update birthday value
session
.
getPlayer
().
setBirthday
(
day
,
month
);
session
.
getPlayer
().
setBirthday
(
day
,
month
);
// Save birthday month and day
// Save birthday month and day
session
.
getPlayer
().
save
();
session
.
getPlayer
().
save
();
SocialDetail
.
Builder
detail
=
session
.
getPlayer
().
getSocialDetail
();
SocialDetail
.
Builder
detail
=
session
.
getPlayer
().
getSocialDetail
();
session
.
send
(
new
PacketSetPlayerBirthdayRsp
(
session
.
getPlayer
()));
session
.
send
(
new
PacketSetPlayerBirthdayRsp
(
session
.
getPlayer
()));
session
.
send
(
new
PacketGetPlayerSocialDetailRsp
(
detail
));
session
.
send
(
new
PacketGetPlayerSocialDetailRsp
(
detail
));
}
private
boolean
isValidBirthday
(
int
month
,
int
day
)
{
switch
(
month
)
{
case
1
:
case
3
:
case
5
:
case
7
:
case
8
:
case
10
:
case
12
:
return
day
>
0
&
day
<=
31
;
case
4
:
case
6
:
case
9
:
case
11
:
return
day
>
0
&&
day
<=
30
;
case
2
:
return
day
>
0
&
day
<=
29
;
}
}
return
false
;
}
}
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerTakePlayerLevelRewardReq.java
0 → 100644
View file @
dce13cf6
package
emu.grasscutter.server.packet.recv
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Set
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.GenshinData
;
import
emu.grasscutter.data.common.RewardItemData
;
import
emu.grasscutter.game.inventory.GenshinItem
;
import
emu.grasscutter.game.props.ActionReason
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.TakePlayerLevelRewardReqOuterClass.TakePlayerLevelRewardReq
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketItemAddHintNotify
;
import
emu.grasscutter.server.packet.send.PacketTakePlayerLevelRewardRsp
;
@Opcodes
(
PacketOpcodes
.
TakePlayerLevelRewardReq
)
public
class
HandlerTakePlayerLevelRewardReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
TakePlayerLevelRewardReq
req
=
TakePlayerLevelRewardReq
.
parseFrom
(
payload
);
int
level
=
req
.
getLevel
();
int
rewardId
=
GenshinData
.
getPlayerLevelDataMap
().
get
(
level
).
getRewardId
();
if
(
rewardId
!=
0
)
{
List
<
RewardItemData
>
rewardItems
=
GenshinData
.
getRewardDataMap
().
get
(
rewardId
).
getRewardItemList
();
List
<
GenshinItem
>
items
=
new
LinkedList
<>();
for
(
RewardItemData
rewardItem
:
rewardItems
)
{
if
(
rewardItem
!=
null
)
{
if
(
rewardItem
.
getItemId
()
!=
0
)
{
items
.
add
(
new
GenshinItem
(
rewardItem
.
getItemId
(),
rewardItem
.
getItemCount
()));
}
}
}
session
.
getPlayer
().
getInventory
().
addItems
(
items
);
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
));
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketAvatarFetterDataNotify.java
0 → 100644
View file @
dce13cf6
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.avatar.GenshinAvatar
;
import
emu.grasscutter.game.props.FetterState
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.AvatarFetterDataNotifyOuterClass.AvatarFetterDataNotify
;
import
emu.grasscutter.net.proto.AvatarFetterInfoOuterClass.AvatarFetterInfo
;
import
emu.grasscutter.net.proto.FetterDataOuterClass.FetterData
;
public
class
PacketAvatarFetterDataNotify
extends
GenshinPacket
{
public
PacketAvatarFetterDataNotify
(
GenshinAvatar
avatar
)
{
super
(
PacketOpcodes
.
AvatarFetterDataNotify
);
int
fetterLevel
=
avatar
.
getFetterLevel
();
AvatarFetterInfo
.
Builder
avatarFetter
=
AvatarFetterInfo
.
newBuilder
()
.
setExpLevel
(
avatar
.
getFetterLevel
());
if
(
fetterLevel
!=
10
)
{
avatarFetter
.
setExpNumber
(
avatar
.
getFetterExp
());
}
if
(
avatar
.
getFetterList
()
!=
null
)
{
for
(
int
i
=
0
;
i
<
avatar
.
getFetterList
().
size
();
i
++)
{
avatarFetter
.
addFetterList
(
FetterData
.
newBuilder
()
.
setFetterId
(
avatar
.
getFetterList
().
get
(
i
))
.
setFetterState
(
FetterState
.
FINISH
.
getValue
())
);
}
}
int
cardId
=
avatar
.
getNameCardId
();
if
(
avatar
.
getPlayer
().
getNameCardList
().
contains
(
cardId
))
{
avatarFetter
.
addRewardedFetterLevelList
(
10
);
}
AvatarFetterInfo
avatarFetterInfo
=
avatarFetter
.
build
();
AvatarFetterDataNotify
proto
=
AvatarFetterDataNotify
.
newBuilder
()
.
putFetterInfoMap
(
avatar
.
getGuid
(),
avatarFetterInfo
)
.
build
();
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketAvatarFetterLevelRewardRsp.java
0 → 100644
View file @
dce13cf6
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.AvatarFetterLevelRewardRspOuterClass.AvatarFetterLevelRewardRsp
;
public
class
PacketAvatarFetterLevelRewardRsp
extends
GenshinPacket
{
public
PacketAvatarFetterLevelRewardRsp
(
long
guid
,
int
fetterLevel
,
int
rewardId
)
{
super
(
PacketOpcodes
.
AvatarFetterLevelRewardRsp
);
AvatarFetterLevelRewardRsp
proto
=
AvatarFetterLevelRewardRsp
.
newBuilder
()
.
setAvatarGuid
(
guid
)
.
setFetterLevel
(
fetterLevel
)
.
setRetcode
(
0
)
.
setRewardId
(
rewardId
)
.
build
();
this
.
setData
(
proto
);
}
public
PacketAvatarFetterLevelRewardRsp
(
long
guid
,
int
fetterLevel
)
{
super
(
PacketOpcodes
.
AvatarFetterLevelRewardRsp
);
AvatarFetterLevelRewardRsp
proto
=
AvatarFetterLevelRewardRsp
.
newBuilder
()
.
setAvatarGuid
(
guid
)
.
setFetterLevel
(
fetterLevel
)
.
setRetcode
(
1
)
.
setRewardId
(
0
)
.
build
();
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketPlayerLevelRewardUpdateNotify.java
0 → 100644
View file @
dce13cf6
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
());
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketSetPlayerBirthdayRsp.java
View file @
dce13cf6
package
emu.grasscutter.server.packet.send
;
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp
;
import
emu.grasscutter.net.proto.SetPlayerBirthdayRspOuterClass.SetPlayerBirthdayRsp
;
import
emu.grasscutter.net.proto.BirthdayOuterClass.Birthday
;
public
class
PacketSetPlayerBirthdayRsp
extends
GenshinPacket
{
public
class
PacketSetPlayerBirthdayRsp
extends
GenshinPacket
{
public
PacketSetPlayerBirthdayRsp
(
GenshinPlayer
player
)
{
super
(
PacketOpcodes
.
SetPlayerBirthdayRsp
);
SetPlayerBirthdayRsp
proto
=
SetPlayerBirthdayRsp
.
newBuilder
()
public
PacketSetPlayerBirthdayRsp
(
int
retCode
)
{
.
setBirth
(
player
.
getBirthday
().
toProto
())
super
(
PacketOpcodes
.
SetPlayerBirthdayRsp
);
.
build
();
this
.
setData
(
proto
);
SetPlayerBirthdayRsp
proto
=
SetPlayerBirthdayRsp
.
newBuilder
()
}
.
setRetcode
(
retCode
)
.
build
();
this
.
setData
(
proto
);
}
public
PacketSetPlayerBirthdayRsp
(
GenshinPlayer
player
)
{
super
(
PacketOpcodes
.
SetPlayerBirthdayRsp
);
SetPlayerBirthdayRsp
proto
=
SetPlayerBirthdayRsp
.
newBuilder
()
.
setBirthday
(
player
.
getBirthday
().
toProto
())
.
build
();
this
.
setData
(
proto
);
}
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketTakePlayerLevelRewardRsp.java
0 → 100644
View file @
dce13cf6
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.TakePlayerLevelRewardRspOuterClass.TakePlayerLevelRewardRsp
;
public
class
PacketTakePlayerLevelRewardRsp
extends
GenshinPacket
{
public
PacketTakePlayerLevelRewardRsp
(
int
level
,
int
rewardId
)
{
super
(
PacketOpcodes
.
TakePlayerLevelRewardRsp
);
int
retcode
=
0
;
if
(
rewardId
==
0
)
{
retcode
=
1
;
}
TakePlayerLevelRewardRsp
proto
=
TakePlayerLevelRewardRsp
.
newBuilder
()
.
setLevel
(
level
)
.
setRewardId
(
rewardId
)
.
setRetcode
(
retcode
)
.
build
();
this
.
setData
(
proto
);
}
}
start.cmd
View file @
dce13cf6
...
@@ -74,10 +74,11 @@ for /f "tokens=2*" %%a in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVe
...
@@ -74,10 +74,11 @@ for /f "tokens=2*" %%a in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVe
@rem TODO: External proxy when ORIG_PROXY_ENABLE == 0x1
@rem TODO: External proxy when ORIG_PROXY_ENABLE == 0x1
echo
set
ws
=
createobject
(
"wscript.shell"
)
>
"
%temp%
\proxy.vbs"
echo
set
ws
=
createobject
(
"wscript.shell"
)
>
"
%temp%
\proxy.vbs"
if
not
"
%MITMDUMP_PATH%
"
==
""
(
if
not
"
%MITMDUMP_PATH%
"
==
""
(
echo
ws
.currentdirectory
=
"
%MITMDUMP_PATH%
"
>>
"
%temp%
\proxy.vbs"
echo
ws
.currentdirectory
=
"
%MITMDUMP_PATH%
"
>>
"
%temp%
\proxy.vbs"
)
)
echo
ws
.run
"cmd /c mitmdump.exe -s "
^&
chr
(
34
)
^&
"
%PROXY_SCRIPT_NAME%
"
^&
chr
(
34
)
^&
" -k
"
,
0
>>
"
%temp%
\proxy.vbs"
echo
ws
.run
"cmd /c mitmdump.exe -s "
^&
chr
(
34
)
^&
"
%
CUR_PATH%%
PROXY_SCRIPT_NAME
%
"
^&
chr
(
34
)
^&
" -k
--allow-hosts "
^&
chr
(
34
)
^&
".*\.yuanshen\.com|.*\.mihoyo\.com|.*\.hoyoverse\.com"
^&
chr
(
34
)
,
0
>>
"
%temp%
\proxy.vbs"
"
%temp%
\proxy.vbs"
"
%temp%
\proxy.vbs"
del
/f /q
"
%temp%
\proxy.vbs"
>
nul
2
>
nul
del
/f /q
"
%temp%
\proxy.vbs"
>
nul
2
>
nul
...
@@ -161,4 +162,4 @@ call :LOG [INFO] See you again :)
...
@@ -161,4 +162,4 @@ call :LOG [INFO] See you again :)
goto
:EOF
goto
:EOF
:LOG
:LOG
echo
[
%time
:
~
0
,
8
%
]
%
*
echo
[
%time
:
~
0
,
8
%
]
%
*
\ No newline at end of file
Prev
1
2
3
Next
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