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
01b190bc
Commit
01b190bc
authored
May 07, 2022
by
Magix
Committed by
GitHub
May 07, 2022
Browse files
UPGRADE TO 1.1.0 POG
Merge `development` into `stable`
parents
6b81b888
1beddf16
Changes
497
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerLoginReq.java
View file @
01b190bc
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.game.
Genshin
Player
;
import
emu.grasscutter.net.packet.
Genshin
Packet
;
import
emu.grasscutter.game.
player.
Player
;
import
emu.grasscutter.net.packet.
Base
Packet
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.PlayerLoginReqOuterClass.PlayerLoginReq
;
...
...
@@ -10,6 +10,7 @@ import emu.grasscutter.net.packet.PacketHandler;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.game.GameSession.SessionState
;
import
emu.grasscutter.server.packet.send.PacketPlayerLoginRsp
;
import
emu.grasscutter.server.packet.send.PacketTakeAchievementRewardReq
;
@Opcodes
(
PacketOpcodes
.
PlayerLoginReq
)
// Sends initial data packets
public
class
HandlerPlayerLoginReq
extends
PacketHandler
{
...
...
@@ -30,12 +31,12 @@ public class HandlerPlayerLoginReq extends PacketHandler {
}
// Load character from db
Genshin
Player
player
=
DatabaseHelper
.
getPlayerById
(
session
.
getAccount
().
getPlayerUid
());
Player
player
=
DatabaseHelper
.
getPlayerById
(
session
.
getAccount
().
getPlayerUid
());
if
(
player
==
null
)
{
// Send packets
session
.
setState
(
SessionState
.
PICKING_CHARACTER
);
session
.
send
(
new
Genshin
Packet
(
PacketOpcodes
.
DoSetPlayerBornDataNotify
));
session
.
send
(
new
Base
Packet
(
PacketOpcodes
.
DoSetPlayerBornDataNotify
));
}
else
{
// Set character
session
.
setPlayer
(
player
);
...
...
@@ -47,6 +48,7 @@ public class HandlerPlayerLoginReq extends PacketHandler {
// Final packet to tell client logging in is done
session
.
send
(
new
PacketPlayerLoginRsp
(
session
));
session
.
send
(
new
PacketTakeAchievementRewardReq
(
session
));
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerPlayerQuitDungeonReq.java
0 → 100644
View file @
01b190bc
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.server.game.GameSession
;
@Opcodes
(
PacketOpcodes
.
PlayerQuitDungeonReq
)
public
class
HandlerPlayerQuitDungeonReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
session
.
getPlayer
().
getServer
().
getDungeonManager
().
exitDungeon
(
session
.
getPlayer
());
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerPrivateChatReq.java
View file @
01b190bc
...
...
@@ -19,8 +19,6 @@ public class HandlerPrivateChatReq extends PacketHandler {
}
else
if
(
content
==
PrivateChatReq
.
ContentCase
.
ICON
)
{
session
.
getServer
().
getChatManager
().
sendPrivateMessage
(
session
.
getPlayer
(),
req
.
getTargetUid
(),
req
.
getIcon
());
}
//session.send(new GenshinPacket(PacketOpcodes.PrivateChatRsp)); // Unused by server
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerReadMailNotify.java
0 → 100644
View file @
01b190bc
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.game.mail.Mail
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.GetAllMailReqOuterClass
;
import
emu.grasscutter.net.proto.ReadMailNotifyOuterClass
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketMailChangeNotify
;
import
java.util.ArrayList
;
import
java.util.List
;
@Opcodes
(
PacketOpcodes
.
ReadMailNotify
)
public
class
HandlerReadMailNotify
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
ReadMailNotifyOuterClass
.
ReadMailNotify
req
=
ReadMailNotifyOuterClass
.
ReadMailNotify
.
parseFrom
(
payload
);
List
<
Mail
>
updatedMail
=
new
ArrayList
<>();
for
(
int
mailId
:
req
.
getMailIdListList
())
{
Mail
message
=
session
.
getPlayer
().
getMail
(
mailId
);
message
.
isRead
=
true
;
session
.
getPlayer
().
replaceMailByIndex
(
mailId
,
message
);
updatedMail
.
add
(
message
);
}
session
.
send
(
new
PacketMailChangeNotify
(
session
.
getPlayer
(),
updatedMail
));
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerSceneEntityDrownReq.java
0 → 100644
View file @
01b190bc
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.game.entity.EntityAvatar
;
import
emu.grasscutter.game.entity.EntityMonster
;
import
emu.grasscutter.game.entity.GameEntity
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.game.props.LifeState
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.SceneEntityDrownReqOuterClass.SceneEntityDrownReq
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketSceneEntityDrownRsp
;
@Opcodes
(
PacketOpcodes
.
SceneEntityDrownReq
)
public
class
HandlerSceneEntityDrownReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
SceneEntityDrownReq
req
=
SceneEntityDrownReq
.
parseFrom
(
payload
);
GameEntity
entity
=
session
.
getPlayer
().
getScene
().
getEntityById
(
req
.
getEntityId
());
if
(
entity
==
null
||
!(
entity
instanceof
EntityMonster
||
entity
instanceof
EntityAvatar
))
{
return
;
}
entity
.
setFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
,
0
);
//TODO: make a list somewhere of all entities to remove per tick rather than one by one
session
.
getPlayer
().
getScene
().
killEntity
(
entity
,
0
);
session
.
getPlayer
().
getScene
().
broadcastPacket
(
new
PacketSceneEntityDrownRsp
(
req
.
getEntityId
()));
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerSceneInitFinishReq.java
View file @
01b190bc
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.game.
Genshin
Player.SceneLoadState
;
import
emu.grasscutter.net.packet.
Genshin
Packet
;
import
emu.grasscutter.game.
player.
Player.SceneLoadState
;
import
emu.grasscutter.net.packet.
Base
Packet
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
...
...
@@ -31,7 +31,7 @@ public class HandlerSceneInitFinishReq extends PacketHandler {
session
.
send
(
new
PacketWorldPlayerInfoNotify
(
session
.
getPlayer
().
getWorld
()));
session
.
send
(
new
PacketWorldDataNotify
(
session
.
getPlayer
().
getWorld
()));
session
.
send
(
new
PacketSceneUnlockInfoNotify
());
session
.
send
(
new
Genshin
Packet
(
PacketOpcodes
.
SceneForceUnlockNotify
));
session
.
send
(
new
Base
Packet
(
PacketOpcodes
.
SceneForceUnlockNotify
));
session
.
send
(
new
PacketHostPlayerNotify
(
session
.
getPlayer
().
getWorld
()));
session
.
send
(
new
PacketSceneTimeNotify
(
session
.
getPlayer
()));
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerSceneTransToPointReq.java
View file @
01b190bc
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.data.G
enshin
Data
;
import
emu.grasscutter.data.G
ame
Data
;
import
emu.grasscutter.data.custom.ScenePointEntry
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
...
...
@@ -19,7 +19,7 @@ public class HandlerSceneTransToPointReq extends PacketHandler {
SceneTransToPointReq
req
=
SceneTransToPointReq
.
parseFrom
(
payload
);
String
code
=
req
.
getSceneId
()
+
"_"
+
req
.
getPointId
();
ScenePointEntry
scenePointEntry
=
G
enshin
Data
.
getScenePointEntries
().
get
(
code
);
ScenePointEntry
scenePointEntry
=
G
ame
Data
.
getScenePointEntries
().
get
(
code
);
if
(
scenePointEntry
!=
null
)
{
float
x
=
scenePointEntry
.
getPointData
().
getTranPos
().
getX
();
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerSelectWorktopOptionReq.java
0 → 100644
View file @
01b190bc
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.game.entity.EntityGadget
;
import
emu.grasscutter.game.entity.GameEntity
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.SelectWorktopOptionReqOuterClass.SelectWorktopOptionReq
;
import
emu.grasscutter.scripts.constants.EventType
;
import
emu.grasscutter.scripts.data.ScriptArgs
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketSelectWorktopOptionRsp
;
@Opcodes
(
PacketOpcodes
.
SelectWorktopOptionReq
)
public
class
HandlerSelectWorktopOptionReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
SelectWorktopOptionReq
req
=
SelectWorktopOptionReq
.
parseFrom
(
payload
);
try
{
GameEntity
entity
=
session
.
getPlayer
().
getScene
().
getEntityById
(
req
.
getGadgetEntityId
());
if
(
entity
==
null
||
!(
entity
instanceof
EntityGadget
))
{
return
;
}
session
.
getPlayer
().
getScene
().
getScriptManager
().
callEvent
(
EventType
.
EVENT_SELECT_OPTION
,
new
ScriptArgs
(
entity
.
getConfigId
(),
req
.
getOptionId
())
);
}
finally
{
// Always send packet
session
.
send
(
new
PacketSelectWorktopOptionRsp
(
req
.
getGadgetEntityId
(),
req
.
getOptionId
()));
}
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerSetEntityClientDataNotify.java
View file @
01b190bc
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.net.packet.
Genshin
Packet
;
import
emu.grasscutter.net.packet.
Base
Packet
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.SetEntityClientDataNotifyOuterClass.SetEntityClientDataNotify
;
...
...
@@ -20,7 +20,7 @@ public class HandlerSetEntityClientDataNotify extends PacketHandler {
// Make sure packet is a valid proto before replaying it to the other players
SetEntityClientDataNotify
notif
=
SetEntityClientDataNotify
.
parseFrom
(
payload
);
Genshin
Packet
packet
=
new
Genshin
Packet
(
PacketOpcodes
.
SetEntityClientDataNotify
,
true
);
Base
Packet
packet
=
new
Base
Packet
(
PacketOpcodes
.
SetEntityClientDataNotify
,
true
);
packet
.
setData
(
notif
);
session
.
getPlayer
().
getScene
().
broadcastPacketToOthers
(
session
.
getPlayer
(),
packet
);
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerBirthdayReq.java
0 → 100644
View file @
01b190bc
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.SetPlayerBirthdayReqOuterClass.SetPlayerBirthdayReq
;
import
emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketGetPlayerSocialDetailRsp
;
import
emu.grasscutter.server.packet.send.PacketSetPlayerBirthdayRsp
;
@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
);
// RET_BIRTHDAY_CANNOT_BE_SET_TWICE = 7009
if
(
session
.
getPlayer
().
hasBirthday
())
{
session
.
send
(
new
PacketSetPlayerBirthdayRsp
(
7009
));
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
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
));
}
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/HandlerSetPlayerBornDataReq.java
View file @
01b190bc
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.G
enshin
Constants
;
import
emu.grasscutter.G
ame
Constants
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.GenshinData
;
import
emu.grasscutter.command.commands.SendMailCommand.MailBuilder
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.database.DatabaseHelper
;
import
emu.grasscutter.game.GenshinPlayer
;
import
emu.grasscutter.game.avatar.GenshinAvatar
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.mail.Mail
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.net.packet.BasePacket
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.SetPlayerBornDataReqOuterClass.SetPlayerBornDataReq
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.server.event.game.PlayerCreationEvent
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.game.GameSession.SessionState
;
import
java.util.Arrays
;
@Opcodes
(
PacketOpcodes
.
SetPlayerBornDataReq
)
public
class
HandlerSetPlayerBornDataReq
extends
PacketHandler
{
...
...
@@ -23,22 +28,31 @@ public class HandlerSetPlayerBornDataReq extends PacketHandler {
// Sanity checks
int
avatarId
=
req
.
getAvatarId
();
int
startingSkillDepot
=
0
;
if
(
avatarId
==
G
enshin
Constants
.
MAIN_CHARACTER_MALE
)
{
int
startingSkillDepot
;
if
(
avatarId
==
G
ame
Constants
.
MAIN_CHARACTER_MALE
)
{
startingSkillDepot
=
504
;
}
else
if
(
avatarId
==
G
enshin
Constants
.
MAIN_CHARACTER_FEMALE
)
{
}
else
if
(
avatarId
==
G
ame
Constants
.
MAIN_CHARACTER_FEMALE
)
{
startingSkillDepot
=
704
;
}
else
{
return
;
}
// Make sure resources folder is set
if
(!
GameData
.
getAvatarDataMap
().
containsKey
(
avatarId
))
{
Grasscutter
.
getLogger
().
error
(
"No avatar data found! Please check your ExcelBinOutput folder."
);
session
.
close
();
return
;
}
String
nickname
=
req
.
getNickName
();
if
(
nickname
==
null
)
{
nickname
=
"Traveler"
;
}
// Create character
GenshinPlayer
player
=
new
GenshinPlayer
(
session
);
// Call creation event.
PlayerCreationEvent
event
=
new
PlayerCreationEvent
(
session
,
Player
.
class
);
event
.
call
();
// Create player instance from event.
Player
player
=
event
.
getPlayerClass
().
getDeclaredConstructor
(
GameSession
.
class
).
newInstance
(
session
);
player
.
setNickname
(
nickname
);
try
{
...
...
@@ -47,8 +61,8 @@ public class HandlerSetPlayerBornDataReq extends PacketHandler {
// Create avatar
if
(
player
.
getAvatars
().
getAvatarCount
()
==
0
)
{
Genshin
Avatar
mainCharacter
=
new
Genshin
Avatar
(
avatarId
);
mainCharacter
.
setSkillDepot
(
G
enshin
Data
.
getAvatarSkillDepotDataMap
().
get
(
startingSkillDepot
));
Avatar
mainCharacter
=
new
Avatar
(
avatarId
);
mainCharacter
.
setSkillDepot
(
G
ame
Data
.
getAvatarSkillDepotDataMap
().
get
(
startingSkillDepot
));
player
.
addAvatar
(
mainCharacter
);
player
.
setMainCharacterId
(
avatarId
);
player
.
setHeadImage
(
avatarId
);
...
...
@@ -68,11 +82,20 @@ public class HandlerSetPlayerBornDataReq extends PacketHandler {
session
.
setState
(
SessionState
.
ACTIVE
);
// Born resp packet
session
.
send
(
new
GenshinPacket
(
PacketOpcodes
.
SetPlayerBornDataRsp
));
session
.
send
(
new
BasePacket
(
PacketOpcodes
.
SetPlayerBornDataRsp
));
// Default mail
MailBuilder
mailBuilder
=
new
MailBuilder
(
player
.
getUid
(),
new
Mail
());
mailBuilder
.
mail
.
mailContent
.
title
=
Grasscutter
.
getConfig
().
GameServer
.
WelcomeMailTitle
;
mailBuilder
.
mail
.
mailContent
.
sender
=
Grasscutter
.
getConfig
().
GameServer
.
WelcomeMailSender
;
// Please credit Grasscutter if changing something here. We don't condone commercial use of the project.
mailBuilder
.
mail
.
mailContent
.
content
=
Grasscutter
.
getConfig
().
GameServer
.
WelcomeMailContent
+
"\n<type=\"browser\" text=\"GitHub\" href=\"https://github.com/Melledy/Grasscutter\"/>"
;
mailBuilder
.
mail
.
itemList
.
addAll
(
Arrays
.
asList
(
Grasscutter
.
getConfig
().
GameServer
.
WelcomeMailItems
));
mailBuilder
.
mail
.
importance
=
1
;
player
.
sendMail
(
mailBuilder
.
mail
);
}
catch
(
Exception
e
)
{
Grasscutter
.
getLogger
().
error
(
"Error creating player object: "
,
e
);
session
.
close
();
}
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerSetPlayerPropReq.java
0 → 100644
View file @
01b190bc
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.props.PlayerProperty
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.PropValueOuterClass.PropValue
;
import
emu.grasscutter.net.proto.SetPlayerPropReqOuterClass.SetPlayerPropReq
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketSetPlayerPropRsp
;
import
java.util.ArrayList
;
import
java.util.List
;
@Opcodes
(
PacketOpcodes
.
SetPlayerPropReq
)
public
class
HandlerSetPlayerPropReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
// Auto template
SetPlayerPropReq
req
=
SetPlayerPropReq
.
parseFrom
(
payload
);
Player
player
=
session
.
getPlayer
();
List
<
PropValue
>
propList
=
req
.
getPropListList
();
for
(
int
i
=
0
;
i
<
propList
.
size
();
i
++)
{
PlayerProperty
prop
=
PlayerProperty
.
getPropById
(
propList
.
get
(
i
).
getType
());
if
(
prop
==
PlayerProperty
.
PROP_IS_MP_MODE_AVAILABLE
)
{
if
(!
player
.
setProperty
(
prop
,
(
int
)
propList
.
get
(
i
).
getVal
()))
{
session
.
send
(
new
PacketSetPlayerPropRsp
(
1
));
return
;
}
}
}
player
.
save
();
session
.
send
(
new
PacketSetPlayerPropRsp
(
0
));
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerTakePlayerLevelRewardReq.java
0 → 100644
View file @
01b190bc
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.GameData
;
import
emu.grasscutter.data.common.RewardItemData
;
import
emu.grasscutter.game.inventory.GameItem
;
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
=
GameData
.
getPlayerLevelDataMap
().
get
(
level
).
getRewardId
();
if
(
rewardId
!=
0
)
{
List
<
RewardItemData
>
rewardItems
=
GameData
.
getRewardDataMap
().
get
(
rewardId
).
getRewardItemList
();
List
<
GameItem
>
items
=
new
LinkedList
<>();
for
(
RewardItemData
rewardItem
:
rewardItems
)
{
if
(
rewardItem
!=
null
)
{
if
(
rewardItem
.
getItemId
()
!=
0
)
{
items
.
add
(
new
GameItem
(
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/recv/HandlerTowerEnterLevelReq.java
0 → 100644
View file @
01b190bc
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.TowerEnterLevelReqOuterClass.TowerEnterLevelReq
;
import
emu.grasscutter.server.game.GameSession
;
@Opcodes
(
PacketOpcodes
.
TowerEnterLevelReq
)
public
class
HandlerTowerEnterLevelReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
TowerEnterLevelReq
req
=
TowerEnterLevelReq
.
parseFrom
(
payload
);
//session.send(new PacketTowerCurLevelRecordChangeNotify());
session
.
getPlayer
().
getTowerManager
().
enterLevel
(
req
.
getEnterPointId
());
//session.send(new PacketTowerLevelStarCondNotify());
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerTowerTeamSelectReq.java
0 → 100644
View file @
01b190bc
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.TowerTeamOuterClass
;
import
emu.grasscutter.net.proto.TowerTeamSelectReqOuterClass.TowerTeamSelectReq
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketTowerTeamSelectRsp
;
@Opcodes
(
PacketOpcodes
.
TowerTeamSelectReq
)
public
class
HandlerTowerTeamSelectReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
TowerTeamSelectReq
req
=
TowerTeamSelectReq
.
parseFrom
(
payload
);
var
towerTeams
=
req
.
getTowerTeamListList
().
stream
()
.
map
(
TowerTeamOuterClass
.
TowerTeam
::
getAvatarGuidListList
)
.
toList
();
session
.
getPlayer
().
getTowerManager
().
teamSelect
(
req
.
getFloorId
(),
towerTeams
);
session
.
send
(
new
PacketTowerTeamSelectRsp
());
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerUpdatePlayerShowAvatarListReq.java
0 → 100644
View file @
01b190bc
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/recv/HandlerUseItemReq.java
View file @
01b190bc
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.game.inventory.G
enshin
Item
;
import
emu.grasscutter.game.inventory.G
ame
Item
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.UseItemReqOuterClass.UseItemReq
;
...
...
@@ -15,7 +15,7 @@ public class HandlerUseItemReq extends PacketHandler {
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
UseItemReq
req
=
UseItemReq
.
parseFrom
(
payload
);
G
enshin
Item
useItem
=
session
.
getServer
().
getInventoryManager
().
useItem
(
session
.
getPlayer
(),
req
.
getTargetGuid
(),
req
.
getGuid
(),
req
.
getCount
());
G
ame
Item
useItem
=
session
.
getServer
().
getInventoryManager
().
useItem
(
session
.
getPlayer
(),
req
.
getTargetGuid
(),
req
.
getGuid
(),
req
.
getCount
()
,
req
.
getOptionIdx
()
);
if
(
useItem
!=
null
)
{
session
.
send
(
new
PacketUseItemRsp
(
req
.
getTargetGuid
(),
useItem
));
}
else
{
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerVehicleInteractReq.java
0 → 100644
View file @
01b190bc
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.VehicleInteractReqOuterClass
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketVehicleInteractRsp
;
@Opcodes
(
PacketOpcodes
.
VehicleInteractReq
)
public
class
HandlerVehicleInteractReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
VehicleInteractReqOuterClass
.
VehicleInteractReq
req
=
VehicleInteractReqOuterClass
.
VehicleInteractReq
.
parseFrom
(
payload
);
session
.
send
(
new
PacketVehicleInteractRsp
(
session
.
getPlayer
(),
req
.
getEntityId
(),
req
.
getInteractType
()));
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerVehicleSpawnReq.java
0 → 100644
View file @
01b190bc
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.VehicleSpawnReqOuterClass
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketVehicleSpawnRsp
;
import
emu.grasscutter.utils.Position
;
@Opcodes
(
PacketOpcodes
.
VehicleSpawnReq
)
public
class
HandlerVehicleSpawnReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
VehicleSpawnReqOuterClass
.
VehicleSpawnReq
req
=
VehicleSpawnReqOuterClass
.
VehicleSpawnReq
.
parseFrom
(
payload
);
session
.
send
(
new
PacketVehicleSpawnRsp
(
session
.
getPlayer
(),
req
.
getVehicleId
(),
req
.
getPointId
(),
new
Position
(
req
.
getPos
()),
new
Position
(
req
.
getRot
())));
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerWorldPlayerReviveReq.java
View file @
01b190bc
...
...
@@ -3,7 +3,9 @@ package emu.grasscutter.server.packet.recv;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.proto.WorldPlayerDieNotifyOuterClass
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketWorldPlayerReviveRsp
;
@Opcodes
(
PacketOpcodes
.
WorldPlayerReviveReq
)
public
class
HandlerWorldPlayerReviveReq
extends
PacketHandler
{
...
...
@@ -11,6 +13,7 @@ public class HandlerWorldPlayerReviveReq extends PacketHandler {
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
session
.
getPlayer
().
getTeamManager
().
respawnTeam
();
session
.
send
(
new
PacketWorldPlayerReviveRsp
());
}
}
Prev
1
…
11
12
13
14
15
16
17
18
19
…
25
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