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
a8293102
Commit
a8293102
authored
Jun 07, 2022
by
Melledy
Committed by
GitHub
Jun 07, 2022
Browse files
Merge branch 'development' into stable
parents
304b9cb8
ecf7a81a
Changes
410
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/server/packet/send/PacketGetMailItemRsp.java
View file @
a8293102
...
@@ -18,52 +18,60 @@ public class PacketGetMailItemRsp extends BasePacket {
...
@@ -18,52 +18,60 @@ public class PacketGetMailItemRsp extends BasePacket {
public
PacketGetMailItemRsp
(
Player
player
,
List
<
Integer
>
mailList
)
{
public
PacketGetMailItemRsp
(
Player
player
,
List
<
Integer
>
mailList
)
{
super
(
PacketOpcodes
.
GetMailItemRsp
);
super
(
PacketOpcodes
.
GetMailItemRsp
);
List
<
Mail
>
claimedMessages
=
new
ArrayList
<>();
List
<
Mail
>
claimedMessages
=
new
ArrayList
<>();
List
<
EquipParamOuterClass
.
EquipParam
>
claimedItems
=
new
ArrayList
<>();
List
<
EquipParamOuterClass
.
EquipParam
>
claimedItems
=
new
ArrayList
<>();
GetMailItemRsp
.
Builder
proto
=
GetMailItemRsp
.
newBuilder
();
GetMailItemRsp
.
Builder
proto
=
GetMailItemRsp
.
newBuilder
();
for
(
int
mailId
:
mailList
)
{
synchronized
(
player
)
{
Mail
message
=
player
.
getMail
(
mailId
);
boolean
modified
=
false
;
for
(
int
mailId
:
mailList
)
{
Mail
message
=
player
.
getMail
(
mailId
);
if
(!
message
.
isAttachmentGot
)
{
//No duplicated item
for
(
Mail
.
MailItem
mailItem
:
message
.
itemList
)
{
EquipParamOuterClass
.
EquipParam
.
Builder
item
=
EquipParamOuterClass
.
EquipParam
.
newBuilder
();
int
promoteLevel
=
0
;
for
(
Mail
.
MailItem
mailItem
:
message
.
itemList
)
{
if
(
mailItem
.
itemLevel
>
80
)
{
// 80/90
EquipParamOuterClass
.
EquipParam
.
Builder
item
=
EquipParamOuterClass
.
EquipParam
.
newBuilder
();
promoteLevel
=
6
;
int
promoteLevel
=
0
;
}
else
if
(
mailItem
.
itemLevel
>
70
)
{
// 70/80
if
(
mailItem
.
itemLevel
>
20
)
{
// 20/40
promoteLevel
=
5
;
promoteLevel
=
1
;
}
else
if
(
mailItem
.
itemLevel
>
60
)
{
// 60/70
}
else
if
(
mailItem
.
itemLevel
>
40
)
{
// 40/50
promoteLevel
=
4
;
promoteLevel
=
2
;
}
else
if
(
mailItem
.
itemLevel
>
50
)
{
// 50/60
}
else
if
(
mailItem
.
itemLevel
>
50
)
{
// 50/60
promoteLevel
=
3
;
promoteLevel
=
3
;
}
else
if
(
mailItem
.
itemLevel
>
40
)
{
// 40/50
}
else
if
(
mailItem
.
itemLevel
>
60
)
{
// 60/70
promoteLevel
=
2
;
promoteLevel
=
4
;
}
else
if
(
mailItem
.
itemLevel
>
20
)
{
// 20/40
}
else
if
(
mailItem
.
itemLevel
>
70
)
{
// 70/80
promoteLevel
=
1
;
promoteLevel
=
5
;
}
}
else
if
(
mailItem
.
itemLevel
>
80
)
{
// 80/90
promoteLevel
=
6
;
}
item
.
setItemId
(
mailItem
.
itemId
);
item
.
setItemId
(
mailItem
.
itemId
);
item
.
setItemNum
(
mailItem
.
itemCount
);
item
.
setItemNum
(
mailItem
.
itemCount
);
item
.
setItemLevel
(
mailItem
.
itemLevel
);
item
.
setItemLevel
(
mailItem
.
itemLevel
);
item
.
setPromoteLevel
(
promoteLevel
);
item
.
setPromoteLevel
(
promoteLevel
);
claimedItems
.
add
(
item
.
build
());
claimedItems
.
add
(
item
.
build
());
GameItem
gameItem
=
new
GameItem
(
GameData
.
getItemDataMap
().
get
(
mailItem
.
itemId
));
GameItem
gameItem
=
new
GameItem
(
GameData
.
getItemDataMap
().
get
(
mailItem
.
itemId
));
gameItem
.
setCount
(
mailItem
.
itemCount
);
gameItem
.
setCount
(
mailItem
.
itemCount
);
gameItem
.
setLevel
(
mailItem
.
itemLevel
);
gameItem
.
setLevel
(
mailItem
.
itemLevel
);
gameItem
.
setPromoteLevel
(
promoteLevel
);
gameItem
.
setPromoteLevel
(
promoteLevel
);
player
.
getInventory
().
addItem
(
gameItem
,
ActionReason
.
MailAttachment
);
player
.
getInventory
().
addItem
(
gameItem
,
ActionReason
.
MailAttachment
);
}
}
message
.
isAttachmentGot
=
true
;
message
.
isAttachmentGot
=
true
;
claimedMessages
.
add
(
message
);
claimedMessages
.
add
(
message
);
player
.
replaceMailByIndex
(
mailId
,
message
);
player
.
replaceMailByIndex
(
mailId
,
message
);
modified
=
true
;
}
}
if
(
modified
)
{
player
.
save
();
}
}
}
proto
.
addAllMailIdList
(
claimedMessages
.
stream
().
map
(
message
->
player
.
getMailId
(
message
)
).
collect
(
Collectors
.
toList
()));
proto
.
addAllMailIdList
(
claimedMessages
.
stream
().
map
(
player
:
:
getMailId
).
collect
(
Collectors
.
toList
()));
proto
.
addAllItemList
(
claimedItems
);
proto
.
addAllItemList
(
claimedItems
);
this
.
setData
(
proto
.
build
());
this
.
setData
(
proto
.
build
());
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerFriendListRsp.java
View file @
a8293102
package
emu.grasscutter.server.packet.send
;
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.GameConstants
;
import
emu.grasscutter.GameConstants
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.game.friends.Friendship
;
import
emu.grasscutter.game.friends.Friendship
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.BasePacket
;
...
@@ -12,24 +11,27 @@ import emu.grasscutter.net.proto.GetPlayerFriendListRspOuterClass.GetPlayerFrien
...
@@ -12,24 +11,27 @@ import emu.grasscutter.net.proto.GetPlayerFriendListRspOuterClass.GetPlayerFrien
import
emu.grasscutter.net.proto.ProfilePictureOuterClass.ProfilePicture
;
import
emu.grasscutter.net.proto.ProfilePictureOuterClass.ProfilePicture
;
import
emu.grasscutter.net.proto.PlatformTypeOuterClass
;
import
emu.grasscutter.net.proto.PlatformTypeOuterClass
;
import
static
emu
.
grasscutter
.
Configuration
.*;
public
class
PacketGetPlayerFriendListRsp
extends
BasePacket
{
public
class
PacketGetPlayerFriendListRsp
extends
BasePacket
{
public
PacketGetPlayerFriendListRsp
(
Player
player
)
{
public
PacketGetPlayerFriendListRsp
(
Player
player
)
{
super
(
PacketOpcodes
.
GetPlayerFriendListRsp
);
super
(
PacketOpcodes
.
GetPlayerFriendListRsp
);
var
serverAccount
=
GAME_INFO
.
serverAccount
;
FriendBrief
serverFriend
=
FriendBrief
.
newBuilder
()
FriendBrief
serverFriend
=
FriendBrief
.
newBuilder
()
.
setUid
(
GameConstants
.
SERVER_CONSOLE_UID
)
.
setUid
(
GameConstants
.
SERVER_CONSOLE_UID
)
.
setNickname
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
ServerN
ick
n
ame
)
.
setNickname
(
serverAccount
.
n
ick
N
ame
)
.
setLevel
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
ServerLevel
)
.
setLevel
(
serverAccount
.
adventureRank
)
.
setProfilePicture
(
ProfilePicture
.
newBuilder
().
setAvatarId
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
ServerA
vatarId
))
.
setProfilePicture
(
ProfilePicture
.
newBuilder
().
setAvatarId
(
serverAccount
.
a
vatarId
))
.
setWorldLevel
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
ServerW
orldLevel
)
.
setWorldLevel
(
serverAccount
.
w
orldLevel
)
.
setSignature
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
ServerS
ignature
)
.
setSignature
(
serverAccount
.
s
ignature
)
.
setLastActiveTime
((
int
)
(
System
.
currentTimeMillis
()
/
1000
f
))
.
setLastActiveTime
((
int
)
(
System
.
currentTimeMillis
()
/
1000
f
))
.
setNameCardId
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
ServerN
ameCardId
)
.
setNameCardId
(
serverAccount
.
n
ameCardId
)
.
setOnlineState
(
FriendOnlineState
.
FRIEND_ONLINE
)
.
setOnlineState
(
FriendOnlineState
.
FRIEND_ONLINE
_STATE_ONLINE
)
.
setParam
(
1
)
.
setParam
(
1
)
.
setIsGameSource
(
true
)
.
setIsGameSource
(
true
)
.
setPlatformType
(
PlatformTypeOuterClass
.
PlatformType
.
PC
)
.
setPlatformType
(
PlatformTypeOuterClass
.
PlatformType
.
PLATFORM_TYPE_
PC
)
.
build
();
.
build
();
GetPlayerFriendListRsp
.
Builder
proto
=
GetPlayerFriendListRsp
.
newBuilder
().
addFriendList
(
serverFriend
);
GetPlayerFriendListRsp
.
Builder
proto
=
GetPlayerFriendListRsp
.
newBuilder
().
addFriendList
(
serverFriend
);
...
@@ -37,10 +39,12 @@ public class PacketGetPlayerFriendListRsp extends BasePacket {
...
@@ -37,10 +39,12 @@ public class PacketGetPlayerFriendListRsp extends BasePacket {
for
(
Friendship
friendship
:
player
.
getFriendsList
().
getFriends
().
values
())
{
for
(
Friendship
friendship
:
player
.
getFriendsList
().
getFriends
().
values
())
{
proto
.
addFriendList
(
friendship
.
toProto
());
proto
.
addFriendList
(
friendship
.
toProto
());
}
}
for
(
Friendship
friendship
:
player
.
getFriendsList
().
getPendingFriends
().
values
())
{
for
(
Friendship
friendship
:
player
.
getFriendsList
().
getPendingFriends
().
values
())
{
if
(
friendship
.
getAskerId
()
==
player
.
getUid
())
{
if
(
friendship
.
getAskerId
()
==
player
.
getUid
())
{
continue
;
continue
;
}
}
proto
.
addAskFriendList
(
friendship
.
toProto
());
proto
.
addAskFriendList
(
friendship
.
toProto
());
}
}
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketGetPlayerTokenRsp.java
View file @
a8293102
...
@@ -10,16 +10,16 @@ import emu.grasscutter.utils.Crypto;
...
@@ -10,16 +10,16 @@ import emu.grasscutter.utils.Crypto;
public
class
PacketGetPlayerTokenRsp
extends
BasePacket
{
public
class
PacketGetPlayerTokenRsp
extends
BasePacket
{
public
PacketGetPlayerTokenRsp
(
GameSession
session
,
boolean
doesPlayerExist
)
{
public
PacketGetPlayerTokenRsp
(
GameSession
session
)
{
super
(
PacketOpcodes
.
GetPlayerTokenRsp
,
true
);
super
(
PacketOpcodes
.
GetPlayerTokenRsp
,
true
);
this
.
setUseDispatchKey
(
true
);
this
.
setUseDispatchKey
(
true
);
GetPlayerTokenRsp
p
=
GetPlayerTokenRsp
.
newBuilder
()
GetPlayerTokenRsp
p
=
GetPlayerTokenRsp
.
newBuilder
()
.
setUid
(
session
.
get
Account
().
get
PlayerUid
())
.
setUid
(
session
.
getPlayer
().
get
Uid
())
.
setToken
(
session
.
getAccount
().
getToken
())
.
setToken
(
session
.
getAccount
().
getToken
())
.
setAccountType
(
1
)
.
setAccountType
(
1
)
.
setIsProficientPlayer
(
doesPlayerExist
)
// Not sure where this goes
.
setIsProficientPlayer
(
session
.
getPlayer
().
getAvatars
().
getAvatarCount
()
>
0
)
// Not sure where this goes
.
setSecretKeySeed
(
Crypto
.
ENCRYPT_SEED
)
.
setSecretKeySeed
(
Crypto
.
ENCRYPT_SEED
)
.
setSecurityCmdBuffer
(
ByteString
.
copyFrom
(
Crypto
.
ENCRYPT_SEED_BUFFER
))
.
setSecurityCmdBuffer
(
ByteString
.
copyFrom
(
Crypto
.
ENCRYPT_SEED_BUFFER
))
.
setPlatformType
(
3
)
.
setPlatformType
(
3
)
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketGetWidgetSlotRsp.java
0 → 100644
View file @
a8293102
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.GetWidgetSlotRspOuterClass
;
import
emu.grasscutter.net.proto.WidgetSlotDataOuterClass
;
import
emu.grasscutter.net.proto.WidgetSlotTagOuterClass
;
import
java.util.List
;
public
class
PacketGetWidgetSlotRsp
extends
BasePacket
{
public
PacketGetWidgetSlotRsp
(
Player
player
)
{
super
(
PacketOpcodes
.
GetWidgetSlotRsp
);
GetWidgetSlotRspOuterClass
.
GetWidgetSlotRsp
.
Builder
proto
=
GetWidgetSlotRspOuterClass
.
GetWidgetSlotRsp
.
newBuilder
();
if
(
player
.
getWidgetId
()
==
null
)
{
proto
.
addAllSlotList
(
List
.
of
());
}
else
{
proto
.
addSlotList
(
WidgetSlotDataOuterClass
.
WidgetSlotData
.
newBuilder
()
.
setIsActive
(
true
)
.
setMaterialId
(
player
.
getWidgetId
())
.
build
()
);
proto
.
addSlotList
(
WidgetSlotDataOuterClass
.
WidgetSlotData
.
newBuilder
()
.
setTag
(
WidgetSlotTagOuterClass
.
WidgetSlotTag
.
WIDGET_SLOT_TAG_ATTACH_AVATAR
)
.
build
()
);
}
GetWidgetSlotRspOuterClass
.
GetWidgetSlotRsp
protoData
=
proto
.
build
();
this
.
setData
(
protoData
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketHomeChooseModuleRsp.java
0 → 100644
View file @
a8293102
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.HomeChooseModuleRspOuterClass
;
public
class
PacketHomeChooseModuleRsp
extends
BasePacket
{
public
PacketHomeChooseModuleRsp
(
int
moduleId
)
{
super
(
PacketOpcodes
.
HomeChooseModuleRsp
);
HomeChooseModuleRspOuterClass
.
HomeChooseModuleRsp
proto
=
HomeChooseModuleRspOuterClass
.
HomeChooseModuleRsp
.
newBuilder
()
.
setRetcode
(
0
)
.
setModuleId
(
moduleId
)
.
build
();
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketHomeComfortInfoNotify.java
0 → 100644
View file @
a8293102
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.HomeComfortInfoNotifyOuterClass
;
import
emu.grasscutter.net.proto.HomeModuleComfortInfoOuterClass
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
PacketHomeComfortInfoNotify
extends
BasePacket
{
public
PacketHomeComfortInfoNotify
(
Player
player
)
{
super
(
PacketOpcodes
.
HomeComfortInfoNotify
);
if
(
player
.
getRealmList
()
==
null
)
{
// Do not send
return
;
}
List
<
HomeModuleComfortInfoOuterClass
.
HomeModuleComfortInfo
>
comfortInfoList
=
new
ArrayList
<>();
for
(
int
moduleId
:
player
.
getRealmList
())
{
comfortInfoList
.
add
(
HomeModuleComfortInfoOuterClass
.
HomeModuleComfortInfo
.
newBuilder
()
.
setModuleId
(
moduleId
)
.
build
()
);
}
HomeComfortInfoNotifyOuterClass
.
HomeComfortInfoNotify
proto
=
HomeComfortInfoNotifyOuterClass
.
HomeComfortInfoNotify
.
newBuilder
()
.
addAllModuleInfoList
(
comfortInfoList
)
.
build
();
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketMailChangeNotify.java
View file @
a8293102
...
@@ -37,10 +37,10 @@ public class PacketMailChangeNotify extends BasePacket {
...
@@ -37,10 +37,10 @@ public class PacketMailChangeNotify extends BasePacket {
for
(
Mail
.
MailItem
item
:
message
.
itemList
)
{
for
(
Mail
.
MailItem
item
:
message
.
itemList
)
{
MailItemOuterClass
.
MailItem
.
Builder
mailItem
=
MailItemOuterClass
.
MailItem
.
newBuilder
();
MailItemOuterClass
.
MailItem
.
Builder
mailItem
=
MailItemOuterClass
.
MailItem
.
newBuilder
();
Item
ParamOuterClass
.
Item
Param
.
Builder
itemParam
=
Item
ParamOuterClass
.
Item
Param
.
newBuilder
();
Equip
ParamOuterClass
.
Equip
Param
.
Builder
itemParam
=
Equip
ParamOuterClass
.
Equip
Param
.
newBuilder
();
itemParam
.
setItemId
(
item
.
itemId
);
itemParam
.
setItemId
(
item
.
itemId
);
itemParam
.
set
Count
(
item
.
itemCount
);
itemParam
.
set
ItemNum
(
item
.
itemCount
);
mailItem
.
set
Item
Param
(
itemParam
.
build
());
mailItem
.
set
Equip
Param
(
itemParam
.
build
());
mailItems
.
add
(
mailItem
.
build
());
mailItems
.
add
(
mailItem
.
build
());
}
}
...
@@ -54,7 +54,7 @@ public class PacketMailChangeNotify extends BasePacket {
...
@@ -54,7 +54,7 @@ public class PacketMailChangeNotify extends BasePacket {
mailData
.
setImportance
(
message
.
importance
);
mailData
.
setImportance
(
message
.
importance
);
mailData
.
setIsRead
(
message
.
isRead
);
mailData
.
setIsRead
(
message
.
isRead
);
mailData
.
setIsAttachmentGot
(
message
.
isAttachmentGot
);
mailData
.
setIsAttachmentGot
(
message
.
isAttachmentGot
);
mailData
.
set
State
Value
(
message
.
stateValue
);
mailData
.
set
BHCAHLJIKFF
Value
(
message
.
stateValue
);
proto
.
addMailList
(
mailData
.
build
());
proto
.
addMailList
(
mailData
.
build
());
}
}
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketMarkMapRsp.java
View file @
a8293102
...
@@ -10,7 +10,7 @@ import java.util.*;
...
@@ -10,7 +10,7 @@ import java.util.*;
public
class
PacketMarkMapRsp
extends
BasePacket
{
public
class
PacketMarkMapRsp
extends
BasePacket
{
public
PacketMarkMapRsp
(
Player
player
,
HashMap
<
String
,
MapMark
>
mapMarks
)
{
public
PacketMarkMapRsp
(
HashMap
<
String
,
MapMark
>
mapMarks
)
{
super
(
PacketOpcodes
.
MarkMapRsp
);
super
(
PacketOpcodes
.
MarkMapRsp
);
MarkMapRspOuterClass
.
MarkMapRsp
.
Builder
proto
=
MarkMapRspOuterClass
.
MarkMapRsp
.
newBuilder
();
MarkMapRspOuterClass
.
MarkMapRsp
.
Builder
proto
=
MarkMapRspOuterClass
.
MarkMapRsp
.
newBuilder
();
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketPlayerEnterSceneNotify.java
View file @
a8293102
...
@@ -23,7 +23,7 @@ public class PacketPlayerEnterSceneNotify extends BasePacket {
...
@@ -23,7 +23,7 @@ public class PacketPlayerEnterSceneNotify extends BasePacket {
.
setSceneId
(
player
.
getSceneId
())
.
setSceneId
(
player
.
getSceneId
())
.
setPos
(
player
.
getPos
().
toProto
())
.
setPos
(
player
.
getPos
().
toProto
())
.
setSceneBeginTime
(
System
.
currentTimeMillis
())
.
setSceneBeginTime
(
System
.
currentTimeMillis
())
.
setType
(
EnterType
.
ENTER_SELF
)
.
setType
(
EnterType
.
ENTER_
TYPE_
SELF
)
.
setTargetUid
(
player
.
getUid
())
.
setTargetUid
(
player
.
getUid
())
.
setEnterSceneToken
(
player
.
getEnterSceneToken
())
.
setEnterSceneToken
(
player
.
getEnterSceneToken
())
.
setWorldLevel
(
player
.
getWorldLevel
())
.
setWorldLevel
(
player
.
getWorldLevel
())
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketPlayerHomeCompInfoNotify.java
0 → 100644
View file @
a8293102
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.PlayerHomeCompInfoNotifyOuterClass
;
import
emu.grasscutter.net.proto.PlayerHomeCompInfoOuterClass
;
import
java.util.List
;
public
class
PacketPlayerHomeCompInfoNotify
extends
BasePacket
{
public
PacketPlayerHomeCompInfoNotify
(
Player
player
)
{
super
(
PacketOpcodes
.
PlayerHomeCompInfoNotify
);
if
(
player
.
getRealmList
()
==
null
)
{
// Do not send
return
;
}
PlayerHomeCompInfoNotifyOuterClass
.
PlayerHomeCompInfoNotify
proto
=
PlayerHomeCompInfoNotifyOuterClass
.
PlayerHomeCompInfoNotify
.
newBuilder
()
.
setCompInfo
(
PlayerHomeCompInfoOuterClass
.
PlayerHomeCompInfo
.
newBuilder
()
.
addAllUnlockedModuleIdList
(
player
.
getRealmList
())
.
addAllLevelupRewardGotLevelList
(
List
.
of
(
1
))
// Hardcoded
.
build
()
)
.
build
();
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketPlayerLoginRsp.java
View file @
a8293102
...
@@ -2,7 +2,6 @@ package emu.grasscutter.server.packet.send;
...
@@ -2,7 +2,6 @@ package emu.grasscutter.server.packet.send;
import
com.google.protobuf.ByteString
;
import
com.google.protobuf.ByteString
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.Grasscutter.ServerDebugMode
;
import
emu.grasscutter.Grasscutter.ServerRunMode
;
import
emu.grasscutter.Grasscutter.ServerRunMode
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
...
@@ -10,11 +9,15 @@ import emu.grasscutter.net.proto.PlayerLoginRspOuterClass.PlayerLoginRsp;
...
@@ -10,11 +9,15 @@ import emu.grasscutter.net.proto.PlayerLoginRspOuterClass.PlayerLoginRsp;
import
emu.grasscutter.net.proto.QueryCurrRegionHttpRspOuterClass
;
import
emu.grasscutter.net.proto.QueryCurrRegionHttpRspOuterClass
;
import
emu.grasscutter.net.proto.RegionInfoOuterClass.RegionInfo
;
import
emu.grasscutter.net.proto.RegionInfoOuterClass.RegionInfo
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.http.dispatch.RegionHandler
;
import
emu.grasscutter.utils.Crypto
;
import
emu.grasscutter.utils.FileUtils
;
import
emu.grasscutter.utils.FileUtils
;
import
java.io.File
;
import
java.io.File
;
import
java.net.URL
;
import
java.util.Base64
;
import
java.util.Base64
;
import
java.util.Objects
;
import
static
emu
.
grasscutter
.
Configuration
.*;
public
class
PacketPlayerLoginRsp
extends
BasePacket
{
public
class
PacketPlayerLoginRsp
extends
BasePacket
{
...
@@ -27,27 +30,17 @@ public class PacketPlayerLoginRsp extends BasePacket {
...
@@ -27,27 +30,17 @@ public class PacketPlayerLoginRsp extends BasePacket {
RegionInfo
info
;
RegionInfo
info
;
if
(
Grasscutter
.
getConfig
().
R
unMode
==
ServerRunMode
.
GAME_ONLY
)
{
if
(
SERVER
.
r
unMode
==
ServerRunMode
.
GAME_ONLY
)
{
if
(
regionCache
==
null
)
{
if
(
regionCache
==
null
)
{
try
{
try
{
File
file
=
new
File
(
Grasscutter
.
getConfig
().
DATA_FOLDER
+
"query_cur_region.txt"
);
// todo: we might want to push custom config to client
String
query_cur_region
=
""
;
RegionInfo
serverRegion
=
RegionInfo
.
newBuilder
()
if
(
file
.
exists
())
{
.
setGateserverIp
(
lr
(
GAME_INFO
.
accessAddress
,
GAME_INFO
.
bindAddress
))
query_cur_region
=
new
String
(
FileUtils
.
read
(
file
));
.
setGateserverPort
(
lr
(
GAME_INFO
.
accessPort
,
GAME_INFO
.
bindPort
))
}
else
{
.
setSecretKey
(
ByteString
.
copyFrom
(
Crypto
.
DISPATCH_SEED
))
Grasscutter
.
getLogger
().
warn
(
"query_cur_region not found! Using default current region."
);
}
byte
[]
decodedCurRegion
=
Base64
.
getDecoder
().
decode
(
query_cur_region
);
QueryCurrRegionHttpRspOuterClass
.
QueryCurrRegionHttpRsp
regionQuery
=
QueryCurrRegionHttpRspOuterClass
.
QueryCurrRegionHttpRsp
.
parseFrom
(
decodedCurRegion
);
RegionInfo
serverRegion
=
regionQuery
.
getRegionInfo
().
toBuilder
()
.
setGateserverIp
((
Grasscutter
.
getConfig
().
getGameServerOptions
().
PublicIp
.
isEmpty
()
?
Grasscutter
.
getConfig
().
getGameServerOptions
().
Ip
:
Grasscutter
.
getConfig
().
getGameServerOptions
().
PublicIp
))
.
setGateserverPort
(
Grasscutter
.
getConfig
().
getGameServerOptions
().
PublicPort
!=
0
?
Grasscutter
.
getConfig
().
getGameServerOptions
().
PublicPort
:
Grasscutter
.
getConfig
().
getGameServerOptions
().
Port
)
.
setSecretKey
(
ByteString
.
copyFrom
(
FileUtils
.
read
(
Grasscutter
.
getConfig
().
KEY_FOLDER
+
"dispatchSeed.bin"
)))
.
build
();
.
build
();
regionCache
=
regionQuery
.
to
Builder
().
setRegionInfo
(
serverRegion
).
build
();
regionCache
=
QueryCurrRegionHttpRspOuterClass
.
QueryCurrRegionHttpRsp
.
new
Builder
().
setRegionInfo
(
serverRegion
).
build
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Grasscutter
.
getLogger
().
error
(
"Error while initializing region cache!"
,
e
);
Grasscutter
.
getLogger
().
error
(
"Error while initializing region cache!"
,
e
);
}
}
...
@@ -55,7 +48,7 @@ public class PacketPlayerLoginRsp extends BasePacket {
...
@@ -55,7 +48,7 @@ public class PacketPlayerLoginRsp extends BasePacket {
info
=
regionCache
.
getRegionInfo
();
info
=
regionCache
.
getRegionInfo
();
}
else
{
}
else
{
info
=
Grasscutter
.
getDispatchServer
()
.
getCurrRegion
().
getRegionInfo
();
info
=
Objects
.
requireNonNull
(
RegionHandler
.
getCurr
ent
Region
()
)
.
getRegionInfo
();
}
}
PlayerLoginRsp
p
=
PlayerLoginRsp
.
newBuilder
()
PlayerLoginRsp
p
=
PlayerLoginRsp
.
newBuilder
()
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketPlayerStoreNotify.java
View file @
a8293102
package
emu.grasscutter.server.packet.send
;
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.GameConstants
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.BasePacket
;
...
@@ -10,6 +8,8 @@ import emu.grasscutter.net.proto.ItemOuterClass.Item;
...
@@ -10,6 +8,8 @@ import emu.grasscutter.net.proto.ItemOuterClass.Item;
import
emu.grasscutter.net.proto.PlayerStoreNotifyOuterClass.PlayerStoreNotify
;
import
emu.grasscutter.net.proto.PlayerStoreNotifyOuterClass.PlayerStoreNotify
;
import
emu.grasscutter.net.proto.StoreTypeOuterClass.StoreType
;
import
emu.grasscutter.net.proto.StoreTypeOuterClass.StoreType
;
import
static
emu
.
grasscutter
.
Configuration
.*;
public
class
PacketPlayerStoreNotify
extends
BasePacket
{
public
class
PacketPlayerStoreNotify
extends
BasePacket
{
public
PacketPlayerStoreNotify
(
Player
player
)
{
public
PacketPlayerStoreNotify
(
Player
player
)
{
...
@@ -18,8 +18,8 @@ public class PacketPlayerStoreNotify extends BasePacket {
...
@@ -18,8 +18,8 @@ public class PacketPlayerStoreNotify extends BasePacket {
this
.
buildHeader
(
2
);
this
.
buildHeader
(
2
);
PlayerStoreNotify
.
Builder
p
=
PlayerStoreNotify
.
newBuilder
()
PlayerStoreNotify
.
Builder
p
=
PlayerStoreNotify
.
newBuilder
()
.
setStoreType
(
StoreType
.
STORE_PACK
)
.
setStoreType
(
StoreType
.
STORE_
TYPE_
PACK
)
.
setWeightLimit
(
G
rasscutter
.
getConfig
().
getGameServerOptions
().
I
nventoryLimit
A
ll
);
.
setWeightLimit
(
G
AME_OPTIONS
.
i
nventoryLimit
s
.
a
ll
);
for
(
GameItem
item
:
player
.
getInventory
())
{
for
(
GameItem
item
:
player
.
getInventory
())
{
Item
itemProto
=
item
.
toProto
();
Item
itemProto
=
item
.
toProto
();
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketPlayerWorldSceneInfoListNotify.java
0 → 100644
View file @
a8293102
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.PlayerWorldSceneInfoListNotifyOuterClass.PlayerWorldSceneInfoListNotify
;
import
emu.grasscutter.net.proto.PlayerWorldSceneInfoOuterClass
;
import
emu.grasscutter.net.proto.SceneUnlockInfoOuterClass.SceneUnlockInfo
;
import
static
emu
.
grasscutter
.
net
.
proto
.
PlayerWorldSceneInfoOuterClass
.*;
public
class
PacketPlayerWorldSceneInfoListNotify
extends
BasePacket
{
public
PacketPlayerWorldSceneInfoListNotify
()
{
super
(
PacketOpcodes
.
PlayerWorldSceneInfoListNotify
);
// Rename opcode later
PlayerWorldSceneInfoListNotify
proto
=
PlayerWorldSceneInfoListNotify
.
newBuilder
()
.
addInfoList
(
PlayerWorldSceneInfo
.
newBuilder
()
.
setSceneId
(
1
)
.
setIsLocked
(
false
)
.
build
()
)
.
addInfoList
(
PlayerWorldSceneInfo
.
newBuilder
()
.
setSceneId
(
3
)
.
setIsLocked
(
false
)
.
addSceneTagIdList
(
102
)
.
addSceneTagIdList
(
113
)
.
addSceneTagIdList
(
117
)
.
build
()
)
.
addInfoList
(
PlayerWorldSceneInfo
.
newBuilder
()
.
setSceneId
(
4
)
.
setIsLocked
(
false
)
.
addSceneTagIdList
(
106
)
.
addSceneTagIdList
(
109
)
.
addSceneTagIdList
(
117
)
.
build
()
)
.
addInfoList
(
PlayerWorldSceneInfo
.
newBuilder
()
.
setSceneId
(
5
)
.
setIsLocked
(
false
)
.
build
()
)
.
addInfoList
(
PlayerWorldSceneInfo
.
newBuilder
()
.
setSceneId
(
6
)
.
setIsLocked
(
false
)
.
build
()
)
.
addInfoList
(
PlayerWorldSceneInfo
.
newBuilder
()
.
setSceneId
(
7
)
.
setIsLocked
(
false
)
.
build
()
)
.
build
();
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketPullRecentChatRsp.java
View file @
a8293102
package
emu.grasscutter.server.packet.send
;
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.Config.GameServerOptions
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.GameConstants
;
import
emu.grasscutter.GameConstants
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.ChatInfoOuterClass.ChatInfo
;
import
emu.grasscutter.net.proto.ChatInfoOuterClass.ChatInfo
;
import
emu.grasscutter.net.proto.PullRecentChatRspOuterClass.PullRecentChatRsp
;
import
emu.grasscutter.net.proto.PullRecentChatRspOuterClass.PullRecentChatRsp
;
import
emu.grasscutter.utils.Utils
;
import
emu.grasscutter.utils.Utils
;
import
static
emu
.
grasscutter
.
Configuration
.*;
public
class
PacketPullRecentChatRsp
extends
BasePacket
{
public
class
PacketPullRecentChatRsp
extends
BasePacket
{
public
PacketPullRecentChatRsp
(
Player
player
)
{
public
PacketPullRecentChatRsp
(
Player
player
)
{
super
(
PacketOpcodes
.
PullRecentChatRsp
);
super
(
PacketOpcodes
.
PullRecentChatRsp
);
GameServerOptions
serverOptions
=
Grasscutter
.
getConfig
().
getGameServer
Options
()
;
var
joinOptions
=
GAME_INFO
.
join
Options
;
PullRecentChatRsp
.
Builder
proto
=
PullRecentChatRsp
.
newBuilder
();
PullRecentChatRsp
.
Builder
proto
=
PullRecentChatRsp
.
newBuilder
();
if
(
server
Options
.
W
elcomeEmotes
!=
null
&&
server
Options
.
W
elcomeEmotes
.
length
>
0
)
{
if
(
join
Options
.
w
elcomeEmotes
!=
null
&&
join
Options
.
w
elcomeEmotes
.
length
>
0
)
{
ChatInfo
welcomeEmote
=
ChatInfo
.
newBuilder
()
ChatInfo
welcomeEmote
=
ChatInfo
.
newBuilder
()
.
setTime
((
int
)
(
System
.
currentTimeMillis
()
/
1000
))
.
setTime
((
int
)
(
System
.
currentTimeMillis
()
/
1000
))
.
setUid
(
GameConstants
.
SERVER_CONSOLE_UID
)
.
setUid
(
GameConstants
.
SERVER_CONSOLE_UID
)
.
setToUid
(
player
.
getUid
())
.
setToUid
(
player
.
getUid
())
.
setIcon
(
server
Options
.
W
elcomeEmotes
[
Utils
.
randomRange
(
0
,
server
Options
.
W
elcomeEmotes
.
length
-
1
)])
.
setIcon
(
join
Options
.
w
elcomeEmotes
[
Utils
.
randomRange
(
0
,
join
Options
.
w
elcomeEmotes
.
length
-
1
)])
.
build
();
.
build
();
proto
.
addChatInfo
(
welcomeEmote
);
proto
.
addChatInfo
(
welcomeEmote
);
}
}
if
(
server
Options
.
W
elcomeM
otd
!=
null
&&
server
Options
.
W
elcomeM
otd
.
length
()
>
0
)
{
if
(
join
Options
.
w
elcomeM
essage
!=
null
&&
join
Options
.
w
elcomeM
essage
.
length
()
>
0
)
{
ChatInfo
welcomeM
otd
=
ChatInfo
.
newBuilder
()
ChatInfo
welcomeM
essage
=
ChatInfo
.
newBuilder
()
.
setTime
((
int
)
(
System
.
currentTimeMillis
()
/
1000
))
.
setTime
((
int
)
(
System
.
currentTimeMillis
()
/
1000
))
.
setUid
(
GameConstants
.
SERVER_CONSOLE_UID
)
.
setUid
(
GameConstants
.
SERVER_CONSOLE_UID
)
.
setToUid
(
player
.
getUid
())
.
setToUid
(
player
.
getUid
())
.
setText
(
Grasscutter
.
getConfig
().
getGameServer
Options
().
W
elcomeM
otd
)
.
setText
(
join
Options
.
w
elcomeM
essage
)
.
build
();
.
build
();
proto
.
addChatInfo
(
welcomeMessage
);
proto
.
addChatInfo
(
welcomeMotd
);
}
}
this
.
setData
(
proto
);
this
.
setData
(
proto
);
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketQueryCodexMonsterBeKilledNumRsp.java
0 → 100644
View file @
a8293102
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.QueryCodexMonsterBeKilledNumRspOuterClass.QueryCodexMonsterBeKilledNumRsp
;
import
java.util.List
;
public
class
PacketQueryCodexMonsterBeKilledNumRsp
extends
BasePacket
{
public
PacketQueryCodexMonsterBeKilledNumRsp
(
Player
player
,
List
<
Integer
>
codexList
)
{
super
(
PacketOpcodes
.
QueryCodexMonsterBeKilledNumRsp
);
QueryCodexMonsterBeKilledNumRsp
.
Builder
proto
=
QueryCodexMonsterBeKilledNumRsp
.
newBuilder
();
codexList
.
forEach
(
animal
->
{
if
(
player
.
getCodex
().
getUnlockedAnimal
().
containsKey
(
animal
)){
proto
.
addCodexIdList
(
animal
)
.
addBeKilledNumList
(
player
.
getCodex
().
getUnlockedAnimal
().
get
(
animal
))
.
addCHPBKCLKPCJ
(
0
);
}
});
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketQuestListNotify.java
0 → 100644
View file @
a8293102
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.quest.GameMainQuest
;
import
emu.grasscutter.game.quest.QuestManager
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.QuestListNotifyOuterClass.QuestListNotify
;
public
class
PacketQuestListNotify
extends
BasePacket
{
public
PacketQuestListNotify
(
Player
player
)
{
super
(
PacketOpcodes
.
QuestListNotify
,
true
);
QuestListNotify
.
Builder
proto
=
QuestListNotify
.
newBuilder
();
player
.
getQuestManager
().
forEachQuest
(
quest
->
{
proto
.
addQuestList
(
quest
.
toProto
());
});
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketQuestListUpdateNotify.java
0 → 100644
View file @
a8293102
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.quest.GameMainQuest
;
import
emu.grasscutter.game.quest.GameQuest
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.QuestListUpdateNotifyOuterClass.QuestListUpdateNotify
;
public
class
PacketQuestListUpdateNotify
extends
BasePacket
{
public
PacketQuestListUpdateNotify
(
GameQuest
quest
)
{
super
(
PacketOpcodes
.
QuestListUpdateNotify
);
QuestListUpdateNotify
proto
=
QuestListUpdateNotify
.
newBuilder
()
.
addQuestList
(
quest
.
toProto
())
.
build
();
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketQuestProgressUpdateNotify.java
0 → 100644
View file @
a8293102
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.game.quest.GameMainQuest
;
import
emu.grasscutter.game.quest.GameQuest
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.QuestProgressUpdateNotifyOuterClass.QuestProgressUpdateNotify
;
public
class
PacketQuestProgressUpdateNotify
extends
BasePacket
{
public
PacketQuestProgressUpdateNotify
(
GameQuest
quest
)
{
super
(
PacketOpcodes
.
QuestProgressUpdateNotify
);
QuestProgressUpdateNotify
.
Builder
proto
=
QuestProgressUpdateNotify
.
newBuilder
().
setQuestId
(
quest
.
getQuestId
());
if
(
quest
.
getFinishProgressList
()
!=
null
)
{
for
(
int
i
:
quest
.
getFinishProgressList
())
{
proto
.
addFinishProgressList
(
i
);
}
}
if
(
quest
.
getFailProgressList
()
!=
null
)
{
for
(
int
i
:
quest
.
getFailProgressList
())
{
proto
.
addFailProgressList
(
i
);
}
}
this
.
setData
(
proto
);
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketSceneEntityAppearNotify.java
View file @
a8293102
...
@@ -15,7 +15,7 @@ public class PacketSceneEntityAppearNotify extends BasePacket {
...
@@ -15,7 +15,7 @@ public class PacketSceneEntityAppearNotify extends BasePacket {
super
(
PacketOpcodes
.
SceneEntityAppearNotify
,
true
);
super
(
PacketOpcodes
.
SceneEntityAppearNotify
,
true
);
SceneEntityAppearNotify
.
Builder
proto
=
SceneEntityAppearNotify
.
newBuilder
()
SceneEntityAppearNotify
.
Builder
proto
=
SceneEntityAppearNotify
.
newBuilder
()
.
setAppearType
(
VisionType
.
VISION_BORN
)
.
setAppearType
(
VisionType
.
VISION_
TYPE_
BORN
)
.
addEntityList
(
entity
.
toProto
());
.
addEntityList
(
entity
.
toProto
());
this
.
setData
(
proto
.
build
());
this
.
setData
(
proto
.
build
());
...
...
src/main/java/emu/grasscutter/server/packet/send/PacketSceneTransToPointRsp.java
View file @
a8293102
package
emu.grasscutter.server.packet.send
;
package
emu.grasscutter.server.packet.send
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.
custom
.ScenePointEntry
;
import
emu.grasscutter.data.
binout
.ScenePointEntry
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
...
...
Prev
1
…
13
14
15
16
17
18
19
20
21
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