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
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/server/
dispatch/json
/ComboTokenReqJson.java
→
src/main/java/emu/grasscutter/server/
http/objects
/ComboTokenReqJson.java
View file @
a8293102
package
emu.grasscutter.server.
dispatch.json
;
package
emu.grasscutter.server.
http.objects
;
public
class
ComboTokenReqJson
{
public
int
app_id
;
...
...
src/main/java/emu/grasscutter/server/
dispatch/json
/ComboTokenResJson.java
→
src/main/java/emu/grasscutter/server/
http/objects
/ComboTokenResJson.java
View file @
a8293102
package
emu.grasscutter.server.
dispatch.json
;
package
emu.grasscutter.server.
http.objects
;
public
class
ComboTokenResJson
{
public
String
message
;
...
...
src/main/java/emu/grasscutter/server/
dispatch/DispatchHttpJsonHandler
.java
→
src/main/java/emu/grasscutter/server/
http/objects/HttpJsonResponse
.java
View file @
a8293102
package
emu.grasscutter.server.
dispatch
;
package
emu.grasscutter.server.
http.objects
;
import
java.io.IOException
;
import
java.util.Arrays
;
...
...
@@ -11,8 +11,9 @@ import express.http.Request;
import
express.http.Response
;
import
static
emu
.
grasscutter
.
utils
.
Language
.
translate
;
import
static
emu
.
grasscutter
.
Configuration
.*;
public
final
class
DispatchHttpJsonHandler
implements
HttpContextHandler
{
public
final
class
HttpJsonResponse
implements
HttpContextHandler
{
private
final
String
response
;
private
final
String
[]
missingRoutes
=
{
// TODO: When http requests for theses routes are found please remove it from this list and update the route request type in the DispatchServer
"/common/hk4e_global/announcement/api/getAlertPic"
,
...
...
@@ -27,15 +28,15 @@ public final class DispatchHttpJsonHandler implements HttpContextHandler {
"/crash/dataUpload"
};
public
DispatchHttpJsonHandler
(
String
response
)
{
public
HttpJsonResponse
(
String
response
)
{
this
.
response
=
response
;
}
@Override
public
void
handle
(
Request
req
,
Response
res
)
throws
IOException
{
// Checking for ALL here isn't required as when ALL is enabled enableDevLogging() gets enabled
if
(
Grasscutter
.
getConfig
().
DebugMode
==
ServerDebugMode
.
MISSING
&&
Arrays
.
stream
(
missingRoutes
).
anyMatch
(
x
->
Objects
.
equals
(
x
,
req
.
baseUrl
())))
{
Grasscutter
.
getLogger
().
info
(
translate
(
"messages.dispatch.request"
,
req
.
ip
(),
req
.
method
(),
req
.
baseUrl
())
+
(
Grasscutter
.
getConfig
().
DebugMode
==
ServerDebugMode
.
MISSING
?
"(MISSING)"
:
""
));
if
(
SERVER
.
debugLevel
==
ServerDebugMode
.
MISSING
&&
Arrays
.
stream
(
missingRoutes
).
anyMatch
(
x
->
Objects
.
equals
(
x
,
req
.
baseUrl
())))
{
Grasscutter
.
getLogger
().
info
(
translate
(
"messages.dispatch.request"
,
req
.
ip
(),
req
.
method
(),
req
.
baseUrl
())
+
(
SERVER
.
debugLevel
==
ServerDebugMode
.
MISSING
?
"(MISSING)"
:
""
));
}
res
.
send
(
response
);
}
...
...
src/main/java/emu/grasscutter/server/
dispatch/json
/LoginAccountRequestJson.java
→
src/main/java/emu/grasscutter/server/
http/objects
/LoginAccountRequestJson.java
View file @
a8293102
package
emu.grasscutter.server.
dispatch.json
;
package
emu.grasscutter.server.
http.objects
;
public
class
LoginAccountRequestJson
{
public
String
account
;
...
...
src/main/java/emu/grasscutter/server/
dispatch/json
/LoginResultJson.java
→
src/main/java/emu/grasscutter/server/
http/objects
/LoginResultJson.java
View file @
a8293102
package
emu.grasscutter.server.
dispatch.json
;
package
emu.grasscutter.server.
http.objects
;
public
class
LoginResultJson
{
public
String
message
;
...
...
src/main/java/emu/grasscutter/server/
dispatch/json
/LoginTokenRequestJson.java
→
src/main/java/emu/grasscutter/server/
http/objects
/LoginTokenRequestJson.java
View file @
a8293102
package
emu.grasscutter.server.
dispatch.json
;
package
emu.grasscutter.server.
http.objects
;
public
class
LoginTokenRequestJson
{
public
String
uid
;
...
...
src/main/java/emu/grasscutter/server/http/objects/WebStaticVersionResponse.java
0 → 100644
View file @
a8293102
package
emu.grasscutter.server.http.objects
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.data.DataLoader
;
import
emu.grasscutter.utils.FileUtils
;
import
emu.grasscutter.utils.Utils
;
import
express.http.HttpContextHandler
;
import
express.http.MediaType
;
import
express.http.Request
;
import
express.http.Response
;
import
io.javalin.core.util.FileUtil
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
static
emu
.
grasscutter
.
Configuration
.
DATA
;
public
class
WebStaticVersionResponse
implements
HttpContextHandler
{
@Override
public
void
handle
(
Request
request
,
Response
response
)
throws
IOException
{
String
requestFor
=
request
.
path
().
substring
(
request
.
path
().
lastIndexOf
(
"-"
)
+
1
);
getPageResources
(
"/webstatic/"
+
requestFor
,
response
);
return
;
}
private
static
void
getPageResources
(
String
path
,
Response
response
)
{
try
(
InputStream
filestream
=
FileUtils
.
readResourceAsStream
(
path
))
{
MediaType
fromExtension
=
MediaType
.
getByExtension
(
path
.
substring
(
path
.
lastIndexOf
(
"."
)
+
1
));
response
.
type
((
fromExtension
!=
null
)
?
fromExtension
.
getMIME
()
:
"application/octet-stream"
);
response
.
send
(
filestream
.
readAllBytes
());
}
catch
(
Exception
e
)
{
if
(
Grasscutter
.
getConfig
().
server
.
debugLevel
.
equals
(
Grasscutter
.
ServerDebugMode
.
MISSING
))
{
Grasscutter
.
getLogger
().
warn
(
"Webstatic File Missing: "
+
path
);
}
response
.
status
(
404
);
}
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerAbilityInvocationsNotify.java
View file @
a8293102
...
...
@@ -6,6 +6,7 @@ import emu.grasscutter.net.proto.AbilityInvocationsNotifyOuterClass.AbilityInvoc
import
emu.grasscutter.net.proto.AbilityInvokeEntryOuterClass.AbilityInvokeEntry
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.utils.Utils
;
@Opcodes
(
PacketOpcodes
.
AbilityInvocationsNotify
)
public
class
HandlerAbilityInvocationsNotify
extends
PacketHandler
{
...
...
@@ -15,13 +16,9 @@ public class HandlerAbilityInvocationsNotify extends PacketHandler {
AbilityInvocationsNotify
notif
=
AbilityInvocationsNotify
.
parseFrom
(
payload
);
for
(
AbilityInvokeEntry
entry
:
notif
.
getInvokesList
())
{
//System.out.println(entry.getArgumentType() + ": " + Utils.bytesToHex(entry.getAbilityData().toByteArray())
);
session
.
getPlayer
().
getAbilityManager
().
onAbilityInvoke
(
entry
);
session
.
getPlayer
().
getAbilityInvokeHandler
().
addEntry
(
entry
.
getForwardType
(),
entry
);
}
if
(
notif
.
getInvokesList
().
size
()
>
0
)
{
session
.
getPlayer
().
getAbilityInvokeHandler
().
update
(
session
.
getPlayer
());
}
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerAvatarFetterLevelRewardReq.java
View file @
a8293102
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.data.GameData
;
import
emu.grasscutter.data.
def
.RewardData
;
import
emu.grasscutter.data.
excels
.RewardData
;
import
emu.grasscutter.game.avatar.Avatar
;
import
emu.grasscutter.game.inventory.GameItem
;
import
emu.grasscutter.game.props.ActionReason
;
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerBuyGoodsReq.java
View file @
a8293102
...
...
@@ -18,9 +18,10 @@ import emu.grasscutter.server.packet.send.PacketBuyGoodsRsp;
import
emu.grasscutter.server.packet.send.PacketStoreItemChangeNotify
;
import
emu.grasscutter.utils.Utils
;
import
java.util.
HashMap
;
import
java.util.
ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.stream.Stream
;
@Opcodes
(
PacketOpcodes
.
BuyGoodsReq
)
public
class
HandlerBuyGoodsReq
extends
PacketHandler
{
...
...
@@ -33,7 +34,7 @@ public class HandlerBuyGoodsReq extends PacketHandler {
return
;
// Don't trust your users' input
List
<
Integer
>
targetShopGoodsId
=
buyGoodsReq
.
getGoods
ListList
().
stream
().
map
(
ShopGoodsOuterClass
.
ShopGoods
::
getGoodsId
).
toList
();
List
<
Integer
>
targetShopGoodsId
=
List
.
of
(
buyGoodsReq
.
getGoods
().
getGoodsId
(
)
);
for
(
int
goodsId
:
targetShopGoodsId
)
{
Optional
<
ShopInfo
>
sg2
=
configShop
.
stream
().
filter
(
x
->
x
.
getGoodsId
()
==
goodsId
).
findFirst
();
if
(
sg2
.
isEmpty
())
...
...
@@ -52,46 +53,23 @@ public class HandlerBuyGoodsReq extends PacketHandler {
session
.
getPlayer
().
save
();
}
if
((
bought
+
buyGoodsReq
.
getB
oughtNum
()
>
sg
.
getBuyLimit
())
&&
sg
.
getBuyLimit
()
!=
0
)
{
if
((
bought
+
buyGoodsReq
.
getB
uyCount
()
>
sg
.
getBuyLimit
())
&&
sg
.
getBuyLimit
()
!=
0
)
{
return
;
}
if
(
sg
.
getScoin
()
>
0
&&
session
.
getPlayer
().
getMora
()
<
buyGoodsReq
.
getBoughtNum
()
*
sg
.
getScoin
())
{
List
<
ItemParamData
>
costs
=
new
ArrayList
<
ItemParamData
>(
sg
.
getCostItemList
());
// Can this even be null?
costs
.
add
(
new
ItemParamData
(
202
,
sg
.
getScoin
()));
costs
.
add
(
new
ItemParamData
(
201
,
sg
.
getHcoin
()));
costs
.
add
(
new
ItemParamData
(
203
,
sg
.
getMcoin
()));
if
(!
session
.
getPlayer
().
getInventory
().
payItems
(
costs
.
toArray
(
new
ItemParamData
[
0
]),
buyGoodsReq
.
getBuyCount
()))
{
return
;
}
if
(
sg
.
getHcoin
()
>
0
&&
session
.
getPlayer
().
getPrimogems
()
<
buyGoodsReq
.
getBoughtNum
()
*
sg
.
getHcoin
())
{
return
;
}
if
(
sg
.
getMcoin
()
>
0
&&
session
.
getPlayer
().
getCrystals
()
<
buyGoodsReq
.
getBoughtNum
()
*
sg
.
getMcoin
())
{
return
;
}
HashMap
<
GameItem
,
Integer
>
itemsCache
=
new
HashMap
<>();
if
(
sg
.
getCostItemList
()
!=
null
)
{
for
(
ItemParamData
p
:
sg
.
getCostItemList
())
{
Optional
<
GameItem
>
invItem
=
session
.
getPlayer
().
getInventory
().
getItems
().
values
().
stream
().
filter
(
x
->
x
.
getItemId
()
==
p
.
getId
()).
findFirst
();
if
(
invItem
.
isEmpty
()
||
invItem
.
get
().
getCount
()
<
p
.
getCount
())
return
;
itemsCache
.
put
(
invItem
.
get
(),
p
.
getCount
()
*
buyGoodsReq
.
getBoughtNum
());
}
}
session
.
getPlayer
().
setMora
(
session
.
getPlayer
().
getMora
()
-
buyGoodsReq
.
getBoughtNum
()
*
sg
.
getScoin
());
session
.
getPlayer
().
setPrimogems
(
session
.
getPlayer
().
getPrimogems
()
-
buyGoodsReq
.
getBoughtNum
()
*
sg
.
getHcoin
());
session
.
getPlayer
().
setCrystals
(
session
.
getPlayer
().
getCrystals
()
-
buyGoodsReq
.
getBoughtNum
()
*
sg
.
getMcoin
());
if
(!
itemsCache
.
isEmpty
())
{
for
(
GameItem
gi
:
itemsCache
.
keySet
())
{
session
.
getPlayer
().
getInventory
().
removeItem
(
gi
,
itemsCache
.
get
(
gi
));
}
itemsCache
.
clear
();
}
session
.
getPlayer
().
addShopLimit
(
sg
.
getGoodsId
(),
buyGoodsReq
.
getB
oughtNum
(),
ShopManager
.
getShopNextRefreshTime
(
sg
));
session
.
getPlayer
().
addShopLimit
(
sg
.
getGoodsId
(),
buyGoodsReq
.
getB
uyCount
(),
ShopManager
.
getShopNextRefreshTime
(
sg
));
GameItem
item
=
new
GameItem
(
GameData
.
getItemDataMap
().
get
(
sg
.
getGoodsItem
().
getId
()));
item
.
setCount
(
buyGoodsReq
.
getB
oughtNum
()
*
sg
.
getGoodsItem
().
getCount
());
item
.
setCount
(
buyGoodsReq
.
getB
uyCount
()
*
sg
.
getGoodsItem
().
getCount
());
session
.
getPlayer
().
getInventory
().
addItem
(
item
,
ActionReason
.
Shop
,
true
);
// fix: not notify when got virtual item from shop
session
.
send
(
new
PacketBuyGoodsRsp
(
buyGoodsReq
.
getShopType
(),
session
.
getPlayer
().
getGoodsLimit
(
sg
.
getGoodsId
()).
getHasBoughtInPeriod
(),
buyGoodsReq
.
getGoods
ListList
().
stream
().
filter
(
x
->
x
.
getGoodsId
()
==
goodsId
).
findFirst
().
get
()));
session
.
send
(
new
PacketBuyGoodsRsp
(
buyGoodsReq
.
getShopType
(),
session
.
getPlayer
().
getGoodsLimit
(
sg
.
getGoodsId
()).
getHasBoughtInPeriod
(),
Stream
.
of
(
buyGoodsReq
.
getGoods
(
)
).
filter
(
x
->
x
.
getGoodsId
()
==
goodsId
).
findFirst
().
get
()));
}
session
.
getPlayer
().
save
();
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilityInitFinishNotify.java
View file @
a8293102
...
...
@@ -6,6 +6,7 @@ import emu.grasscutter.net.proto.AbilityInvokeEntryOuterClass.AbilityInvokeEntry
import
emu.grasscutter.net.proto.ClientAbilityInitFinishNotifyOuterClass.ClientAbilityInitFinishNotify
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.utils.Utils
;
@Opcodes
(
PacketOpcodes
.
ClientAbilityInitFinishNotify
)
public
class
HandlerClientAbilityInitFinishNotify
extends
PacketHandler
{
...
...
@@ -15,6 +16,7 @@ public class HandlerClientAbilityInitFinishNotify extends PacketHandler {
ClientAbilityInitFinishNotify
notif
=
ClientAbilityInitFinishNotify
.
parseFrom
(
payload
);
for
(
AbilityInvokeEntry
entry
:
notif
.
getInvokesList
())
{
session
.
getPlayer
().
getAbilityManager
().
onAbilityInvoke
(
entry
);
session
.
getPlayer
().
getClientAbilityInitFinishHandler
().
addEntry
(
entry
.
getForwardType
(),
entry
);
}
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerCombatInvocationsNotify.java
View file @
a8293102
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.game.entity.GameEntity
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.CombatInvocationsNotifyOuterClass.CombatInvocationsNotify
;
...
...
@@ -8,27 +10,63 @@ import emu.grasscutter.net.proto.CombatInvokeEntryOuterClass.CombatInvokeEntry;
import
emu.grasscutter.net.proto.EntityMoveInfoOuterClass.EntityMoveInfo
;
import
emu.grasscutter.net.proto.EvtBeingHitInfoOuterClass.EvtBeingHitInfo
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.proto.MotionInfoOuterClass.MotionInfo
;
import
emu.grasscutter.net.proto.MotionStateOuterClass.MotionState
;
import
emu.grasscutter.net.proto.PlayerDieTypeOuterClass
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify
;
@Opcodes
(
PacketOpcodes
.
CombatInvocationsNotify
)
public
class
HandlerCombatInvocationsNotify
extends
PacketHandler
{
private
float
cachedLandingSpeed
=
0
;
private
long
cachedLandingTimeMillisecond
=
0
;
private
boolean
monitorLandingEvent
=
false
;
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
CombatInvocationsNotify
notif
=
CombatInvocationsNotify
.
parseFrom
(
payload
);
for
(
CombatInvokeEntry
entry
:
notif
.
getInvokeListList
())
{
switch
(
entry
.
getArgumentType
())
{
case
COMBAT_EVT_BEING_HIT:
case
COMBAT_
TYPE_ARGUMENT_
EVT_BEING_HIT:
// Handle damage
EvtBeingHitInfo
hitInfo
=
EvtBeingHitInfo
.
parseFrom
(
entry
.
getCombatData
());
session
.
getPlayer
().
getAttackResults
().
add
(
hitInfo
.
getAttackResult
());
session
.
getPlayer
().
getEnergyManager
().
handleAttackHit
(
hitInfo
);
break
;
case
ENTITY_MOVE:
case
COMBAT_TYPE_ARGUMENT_
ENTITY_MOVE:
// Handle movement
EntityMoveInfo
moveInfo
=
EntityMoveInfo
.
parseFrom
(
entry
.
getCombatData
());
GameEntity
entity
=
session
.
getPlayer
().
getScene
().
getEntityById
(
moveInfo
.
getEntityId
());
if
(
entity
!=
null
)
{
session
.
getPlayer
().
getMovementManager
().
handle
(
session
,
moveInfo
,
entity
);
// Move player
MotionInfo
motionInfo
=
moveInfo
.
getMotionInfo
();
entity
.
getPosition
().
set
(
motionInfo
.
getPos
());
entity
.
getRotation
().
set
(
motionInfo
.
getRot
());
entity
.
setLastMoveSceneTimeMs
(
moveInfo
.
getSceneTime
());
entity
.
setLastMoveReliableSeq
(
moveInfo
.
getReliableSeq
());
MotionState
motionState
=
motionInfo
.
getState
();
entity
.
setMotionState
(
motionState
);
session
.
getPlayer
().
getStaminaManager
().
handleCombatInvocationsNotify
(
session
,
moveInfo
,
entity
);
// TODO: handle MOTION_FIGHT landing which has a different damage factor
// Also, for plunge attacks, LAND_SPEED is always -30 and is not useful.
// May need the height when starting plunge attack.
// MOTION_LAND_SPEED and MOTION_FALL_ON_GROUND arrive in different packets.
// Cache land speed for later use.
if
(
motionState
==
MotionState
.
MOTION_STATE_LAND_SPEED
)
{
cachedLandingSpeed
=
motionInfo
.
getSpeed
().
getY
();
cachedLandingTimeMillisecond
=
System
.
currentTimeMillis
();
monitorLandingEvent
=
true
;
}
if
(
monitorLandingEvent
)
{
if
(
motionState
==
MotionState
.
MOTION_STATE_FALL_ON_GROUND
)
{
monitorLandingEvent
=
false
;
handleFallOnGround
(
session
,
entity
,
motionState
);
}
}
}
break
;
default
:
...
...
@@ -37,15 +75,53 @@ public class HandlerCombatInvocationsNotify extends PacketHandler {
session
.
getPlayer
().
getCombatInvokeHandler
().
addEntry
(
entry
.
getForwardType
(),
entry
);
}
}
if
(
notif
.
getInvokeListList
().
size
()
>
0
)
{
session
.
getPlayer
().
getCombatInvokeHandler
().
update
(
session
.
getPlayer
());
private
void
handleFallOnGround
(
GameSession
session
,
GameEntity
entity
,
MotionState
motionState
)
{
if
(
session
.
getPlayer
().
inGodmode
())
{
return
;
}
// Handle attack results last
while
(!
session
.
getPlayer
().
getAttackResults
().
isEmpty
())
{
session
.
getPlayer
().
getScene
().
handleAttack
(
session
.
getPlayer
().
getAttackResults
().
poll
());
// People have reported that after plunge attack (client sends a FIGHT instead of FALL_ON_GROUND) they will die
// if they talk to an NPC (this is when the client sends a FALL_ON_GROUND) without jumping again.
// A dirty patch: if not received immediately after MOTION_LAND_SPEED, discard this packet.
// 200ms seems to be a reasonable delay.
int
maxDelay
=
200
;
long
actualDelay
=
System
.
currentTimeMillis
()
-
cachedLandingTimeMillisecond
;
Grasscutter
.
getLogger
().
trace
(
"MOTION_FALL_ON_GROUND received after "
+
actualDelay
+
"/"
+
maxDelay
+
"ms."
+
(
actualDelay
>
maxDelay
?
" Discard"
:
""
));
if
(
actualDelay
>
maxDelay
)
{
return
;
}
float
currentHP
=
entity
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
);
float
maxHP
=
entity
.
getFightProperty
(
FightProperty
.
FIGHT_PROP_MAX_HP
);
float
damageFactor
=
0
;
if
(
cachedLandingSpeed
<
-
23.5
)
{
damageFactor
=
0.33f
;
}
if
(
cachedLandingSpeed
<
-
25
)
{
damageFactor
=
0.5f
;
}
if
(
cachedLandingSpeed
<
-
26.5
)
{
damageFactor
=
0.66f
;
}
if
(
cachedLandingSpeed
<
-
28
)
{
damageFactor
=
1
f
;
}
float
damage
=
maxHP
*
damageFactor
;
float
newHP
=
currentHP
-
damage
;
if
(
newHP
<
0
)
{
newHP
=
0
;
}
if
(
damageFactor
>
0
)
{
Grasscutter
.
getLogger
().
debug
(
currentHP
+
"/"
+
maxHP
+
"\tLandingSpeed: "
+
cachedLandingSpeed
+
"\tDamageFactor: "
+
damageFactor
+
"\tDamage: "
+
damage
+
"\tNewHP: "
+
newHP
);
}
else
{
Grasscutter
.
getLogger
().
trace
(
currentHP
+
"/"
+
maxHP
+
"\tLandingSpeed: 0\tNo damage"
);
}
entity
.
setFightProperty
(
FightProperty
.
FIGHT_PROP_CUR_HP
,
newHP
);
entity
.
getWorld
().
broadcastPacket
(
new
PacketEntityFightPropUpdateNotify
(
entity
,
FightProperty
.
FIGHT_PROP_CUR_HP
));
if
(
newHP
==
0
)
{
session
.
getPlayer
().
getStaminaManager
().
killAvatar
(
session
,
entity
,
PlayerDieTypeOuterClass
.
PlayerDieType
.
PLAYER_DIE_TYPE_FALL
);
}
cachedLandingSpeed
=
0
;
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerCombineReq.java
View file @
a8293102
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.data.def.CombineData
;
import
emu.grasscutter.data.common.ItemParamData
;
import
emu.grasscutter.data.excels.CombineData
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
...
...
@@ -35,7 +36,7 @@ public class HandlerCombineReq extends PacketHandler {
toItemParamList
(
result
.
getBack
())));
}
private
List
<
ItemParamOuterClass
.
ItemParam
>
toItemParamList
(
List
<
CombineData
.
CombineItemPair
>
list
){
private
List
<
ItemParamOuterClass
.
ItemParam
>
toItemParamList
(
List
<
ItemParamData
>
list
){
return
list
.
stream
()
.
map
(
item
->
ItemParamOuterClass
.
ItemParam
.
newBuilder
()
.
setItemId
(
item
.
getId
())
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerVehicle
Spawn
Req.java
→
src/main/java/emu/grasscutter/server/packet/recv/Handler
Create
VehicleReq.java
View file @
a8293102
...
...
@@ -3,19 +3,19 @@ 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.Vehicle
Spawn
ReqOuterClass
;
import
emu.grasscutter.net.proto.
Create
VehicleReqOuterClass
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketVehicle
Spawn
Rsp
;
import
emu.grasscutter.server.packet.send.Packet
Create
VehicleRsp
;
import
emu.grasscutter.utils.Position
;
@Opcodes
(
PacketOpcodes
.
Vehicle
Spawn
Req
)
public
class
HandlerVehicle
Spawn
Req
extends
PacketHandler
{
@Opcodes
(
PacketOpcodes
.
Create
VehicleReq
)
public
class
Handler
Create
VehicleReq
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
Vehicle
Spawn
ReqOuterClass
.
Vehicle
Spawn
Req
req
=
Vehicle
Spawn
ReqOuterClass
.
Vehicle
Spawn
Req
.
parseFrom
(
payload
);
session
.
send
(
new
PacketVehicle
Spawn
Rsp
(
session
.
getPlayer
(),
req
.
getVehicleId
(),
req
.
getPointId
(),
new
Position
(
req
.
getPos
()),
new
Position
(
req
.
getRot
())));
Create
VehicleReqOuterClass
.
Create
VehicleReq
req
=
Create
VehicleReqOuterClass
.
Create
VehicleReq
.
parseFrom
(
payload
);
session
.
send
(
new
Packet
Create
VehicleRsp
(
session
.
getPlayer
(),
req
.
getVehicleId
(),
req
.
get
Scene
PointId
(),
new
Position
(
req
.
getPos
()),
new
Position
(
req
.
getRot
())));
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerDoGachaReq.java
View file @
a8293102
...
...
@@ -12,6 +12,6 @@ public class HandlerDoGachaReq extends PacketHandler {
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
DoGachaReq
req
=
DoGachaReq
.
parseFrom
(
payload
);
session
.
getServer
().
getGachaManager
().
doPulls
(
session
.
getPlayer
(),
req
.
getGacha
Type
(),
req
.
getGachaTimes
());
session
.
getServer
().
getGachaManager
().
doPulls
(
session
.
getPlayer
(),
req
.
getGacha
ScheduleId
(),
req
.
getGachaTimes
());
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerEnterTransPointRegionNotify.java
View file @
a8293102
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.game.managers.SotSManager
.SotSManager
;
import
emu.grasscutter.game.managers.SotSManager
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.props.FightProperty
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.ChangeHpReasonOuterClass.ChangeHpReason
;
import
emu.grasscutter.net.proto.PropChangeReasonOuterClass.PropChangeReason
;
import
emu.grasscutter.server.game.GameSession
;
import
emu.grasscutter.server.packet.send.PacketAvatarFightPropUpdateNotify
;
import
emu.grasscutter.server.packet.send.PacketAvatarLifeStateChangeNotify
;
import
emu.grasscutter.server.packet.send.PacketEntityFightPropChangeReasonNotify
;
import
emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify
;
import
java.util.List
;
@Opcodes
(
PacketOpcodes
.
EnterTransPointRegionNotify
)
public
class
HandlerEnterTransPointRegionNotify
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
Player
player
=
session
.
getPlayer
();
SotSManager
sotsManager
=
player
.
getSotSManager
();
sotsManager
.
refillSpringVolume
();
sotsManager
.
autoRevive
(
session
);
sotsManager
.
scheduleAutoRecover
(
session
);
// TODO: allow interaction with the SotS?
session
.
getPlayer
().
getSotSManager
().
handleEnterTransPointRegionNotify
();
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerEvtCreateGadgetNotify.java
View file @
a8293102
...
...
@@ -14,11 +14,6 @@ public class HandlerEvtCreateGadgetNotify extends PacketHandler {
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
EvtCreateGadgetNotify
notify
=
EvtCreateGadgetNotify
.
parseFrom
(
payload
);
// Dont handle in singleplayer
if
(!
session
.
getPlayer
().
getWorld
().
isMultiplayer
())
{
return
;
}
// Sanity check - dont add duplicate entities
if
(
session
.
getPlayer
().
getScene
().
getEntityById
(
notify
.
getEntityId
())
!=
null
)
{
return
;
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerEvtDestroyGadgetNotify.java
View file @
a8293102
...
...
@@ -13,11 +13,6 @@ public class HandlerEvtDestroyGadgetNotify extends PacketHandler {
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
EvtDestroyGadgetNotify
notify
=
EvtDestroyGadgetNotify
.
parseFrom
(
payload
);
// Dont handle in singleplayer
if
(!
session
.
getPlayer
().
getWorld
().
isMultiplayer
())
{
return
;
}
session
.
getPlayer
().
getScene
().
onPlayerDestroyGadget
(
notify
.
getEntityId
());
}
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerEvtDoSkillSuccNotify.java
View file @
a8293102
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
;
...
...
@@ -13,12 +12,10 @@ public class HandlerEvtDoSkillSuccNotify extends PacketHandler {
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
EvtDoSkillSuccNotify
notify
=
EvtDoSkillSuccNotify
.
parseFrom
(
payload
);
// TODO: Will be used for deducting stamina for charged skills.
int
caster
=
notify
.
getCasterId
();
int
skillId
=
notify
.
getSkillId
();
int
casterId
=
notify
.
getCasterId
();
session
.
getPlayer
().
getMovementManager
().
notifySkill
(
caster
,
skillId
);
session
.
getPlayer
().
getStaminaManager
().
handleEvtDoSkillSuccNotify
(
session
,
skillId
,
casterId
);
session
.
getPlayer
().
getEnergyManager
().
handleEvtDoSkillSuccNotify
(
session
,
skillId
,
casterId
);
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerExitTransPointRegionNotify.java
View file @
a8293102
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.game.managers.SotSManager.SotSManager
;
import
emu.grasscutter.Grasscutter
;
import
emu.grasscutter.game.managers.SotSManager
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
...
...
@@ -11,8 +12,6 @@ import emu.grasscutter.server.game.GameSession;
public
class
HandlerExitTransPointRegionNotify
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
Player
player
=
session
.
getPlayer
();
SotSManager
sotsManager
=
player
.
getSotSManager
();
sotsManager
.
cancelAutoRecover
();
session
.
getPlayer
().
getSotSManager
().
handleExitTransPointRegionNotify
();
}
}
Prev
1
…
10
11
12
13
14
15
16
17
18
…
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