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
7fc587e7
Commit
7fc587e7
authored
Apr 20, 2022
by
Melledy
Committed by
GitHub
Apr 20, 2022
Browse files
Merge pull request #49 from Grasscutters/dev-abilities
Fix character abilities not showing for others in co-op/lasting too long
parents
b2cec3b8
5a09c22a
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/game/GenshinPlayer.java
View file @
7fc587e7
...
@@ -38,6 +38,7 @@ import emu.grasscutter.server.packet.send.PacketAvatarAddNotify;
...
@@ -38,6 +38,7 @@ import emu.grasscutter.server.packet.send.PacketAvatarAddNotify;
import
emu.grasscutter.server.packet.send.PacketAvatarDataNotify
;
import
emu.grasscutter.server.packet.send.PacketAvatarDataNotify
;
import
emu.grasscutter.server.packet.send.PacketAvatarGainCostumeNotify
;
import
emu.grasscutter.server.packet.send.PacketAvatarGainCostumeNotify
;
import
emu.grasscutter.server.packet.send.PacketAvatarGainFlycloakNotify
;
import
emu.grasscutter.server.packet.send.PacketAvatarGainFlycloakNotify
;
import
emu.grasscutter.server.packet.send.PacketClientAbilityInitFinishNotify
;
import
emu.grasscutter.server.packet.send.PacketCombatInvocationsNotify
;
import
emu.grasscutter.server.packet.send.PacketCombatInvocationsNotify
;
import
emu.grasscutter.server.packet.send.PacketGadgetInteractRsp
;
import
emu.grasscutter.server.packet.send.PacketGadgetInteractRsp
;
import
emu.grasscutter.server.packet.send.PacketItemAddHintNotify
;
import
emu.grasscutter.server.packet.send.PacketItemAddHintNotify
;
...
@@ -104,6 +105,7 @@ public class GenshinPlayer {
...
@@ -104,6 +105,7 @@ public class GenshinPlayer {
@Transient
private
final
Int2ObjectMap
<
CoopRequest
>
coopRequests
;
@Transient
private
final
Int2ObjectMap
<
CoopRequest
>
coopRequests
;
@Transient
private
final
InvokeHandler
<
CombatInvokeEntry
>
combatInvokeHandler
;
@Transient
private
final
InvokeHandler
<
CombatInvokeEntry
>
combatInvokeHandler
;
@Transient
private
final
InvokeHandler
<
AbilityInvokeEntry
>
abilityInvokeHandler
;
@Transient
private
final
InvokeHandler
<
AbilityInvokeEntry
>
abilityInvokeHandler
;
@Transient
private
final
InvokeHandler
<
AbilityInvokeEntry
>
clientAbilityInitFinishHandler
;
@Deprecated
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
// Morphia only!
@Deprecated
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
// Morphia only!
public
GenshinPlayer
()
{
public
GenshinPlayer
()
{
...
@@ -126,6 +128,7 @@ public class GenshinPlayer {
...
@@ -126,6 +128,7 @@ public class GenshinPlayer {
this
.
coopRequests
=
new
Int2ObjectOpenHashMap
<>();
this
.
coopRequests
=
new
Int2ObjectOpenHashMap
<>();
this
.
combatInvokeHandler
=
new
InvokeHandler
(
PacketCombatInvocationsNotify
.
class
);
this
.
combatInvokeHandler
=
new
InvokeHandler
(
PacketCombatInvocationsNotify
.
class
);
this
.
abilityInvokeHandler
=
new
InvokeHandler
(
PacketAbilityInvocationsNotify
.
class
);
this
.
abilityInvokeHandler
=
new
InvokeHandler
(
PacketAbilityInvocationsNotify
.
class
);
this
.
clientAbilityInitFinishHandler
=
new
InvokeHandler
(
PacketClientAbilityInitFinishNotify
.
class
);
}
}
// On player creation
// On player creation
...
@@ -389,6 +392,10 @@ public class GenshinPlayer {
...
@@ -389,6 +392,10 @@ public class GenshinPlayer {
return
this
.
abilityInvokeHandler
;
return
this
.
abilityInvokeHandler
;
}
}
public
InvokeHandler
<
AbilityInvokeEntry
>
getClientAbilityInitFinishHandler
()
{
return
clientAbilityInitFinishHandler
;
}
public
void
setMpSetting
(
MpSettingType
mpSetting
)
{
public
void
setMpSetting
(
MpSettingType
mpSetting
)
{
this
.
mpSetting
=
mpSetting
;
this
.
mpSetting
=
mpSetting
;
}
}
...
...
src/main/java/emu/grasscutter/server/packet/recv/HandlerClientAbilityInitFinishNotify.java
0 → 100644
View file @
7fc587e7
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
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
;
@Opcodes
(
PacketOpcodes
.
ClientAbilityInitFinishNotify
)
public
class
HandlerClientAbilityInitFinishNotify
extends
PacketHandler
{
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
ClientAbilityInitFinishNotify
notif
=
ClientAbilityInitFinishNotify
.
parseFrom
(
payload
);
for
(
AbilityInvokeEntry
entry
:
notif
.
getInvokesList
())
{
session
.
getPlayer
().
getClientAbilityInitFinishHandler
().
addEntry
(
entry
.
getForwardType
(),
entry
);
}
if
(
notif
.
getInvokesList
().
size
()
>
0
)
{
session
.
getPlayer
().
getClientAbilityInitFinishHandler
().
update
(
session
.
getPlayer
());
}
}
}
src/main/java/emu/grasscutter/server/packet/recv/HandlerSetEntityClientDataNotify.java
View file @
7fc587e7
package
emu.grasscutter.server.packet.recv
;
package
emu.grasscutter.server.packet.recv
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.Opcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.packet.PacketHandler
;
import
emu.grasscutter.net.packet.PacketHandler
;
...
@@ -10,7 +11,15 @@ public class HandlerSetEntityClientDataNotify extends PacketHandler {
...
@@ -10,7 +11,15 @@ public class HandlerSetEntityClientDataNotify extends PacketHandler {
@Override
@Override
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
public
void
handle
(
GameSession
session
,
byte
[]
header
,
byte
[]
payload
)
throws
Exception
{
// Auto template
// Skip if there is no one to broadcast it too
if
(
session
.
getPlayer
().
getScene
().
getPlayerCount
()
<=
1
)
{
return
;
}
GenshinPacket
packet
=
new
GenshinPacket
(
PacketOpcodes
.
SetEntityClientDataNotify
,
true
);
packet
.
setData
(
payload
);
session
.
getPlayer
().
getScene
().
broadcastPacketToOthers
(
session
.
getPlayer
(),
packet
);
}
}
}
}
src/main/java/emu/grasscutter/server/packet/send/PacketClientAbilityInitFinishNotify.java
0 → 100644
View file @
7fc587e7
package
emu.grasscutter.server.packet.send
;
import
java.util.List
;
import
emu.grasscutter.net.packet.GenshinPacket
;
import
emu.grasscutter.net.packet.PacketOpcodes
;
import
emu.grasscutter.net.proto.AbilityInvokeEntryOuterClass.AbilityInvokeEntry
;
import
emu.grasscutter.net.proto.ClientAbilityInitFinishNotifyOuterClass.ClientAbilityInitFinishNotify
;
public
class
PacketClientAbilityInitFinishNotify
extends
GenshinPacket
{
public
PacketClientAbilityInitFinishNotify
(
List
<
AbilityInvokeEntry
>
entries
)
{
super
(
PacketOpcodes
.
ClientAbilityInitFinishNotify
,
true
);
int
entityId
=
0
;
if
(
entries
.
size
()
>
0
)
{
AbilityInvokeEntry
entry
=
entries
.
get
(
0
);
entityId
=
entry
.
getEntityId
();
}
ClientAbilityInitFinishNotify
proto
=
ClientAbilityInitFinishNotify
.
newBuilder
()
.
setEntityId
(
entityId
)
.
addAllInvokes
(
entries
)
.
build
();
this
.
setData
(
proto
);
}
}
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