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
efd7467a
Commit
efd7467a
authored
May 15, 2022
by
AnimeGitB
Committed by
Melledy
May 15, 2022
Browse files
Fix targeting on Join and Remove commands
parent
05e13d81
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/command/commands/JoinCommand.java
View file @
efd7467a
...
...
@@ -18,6 +18,11 @@ public class JoinCommand implements CommandHandler {
@Override
public
void
execute
(
Player
sender
,
Player
targetPlayer
,
List
<
String
>
args
)
{
if
(
targetPlayer
==
null
)
{
CommandHandler
.
sendMessage
(
sender
,
translate
(
sender
,
"commands.execution.need_target"
));
return
;
}
List
<
Integer
>
avatarIds
=
new
ArrayList
<>();
for
(
String
arg
:
args
)
{
try
{
...
...
@@ -32,18 +37,18 @@ public class JoinCommand implements CommandHandler {
for
(
int
i
=
0
;
i
<
args
.
size
();
i
++)
{
Avatar
avatar
=
send
er
.
getAvatars
().
getAvatarById
(
avatarIds
.
get
(
i
));
Avatar
avatar
=
targetPlay
er
.
getAvatars
().
getAvatarById
(
avatarIds
.
get
(
i
));
if
(
avatar
==
null
)
{
CommandHandler
.
sendMessage
(
sender
,
translate
(
"commands.generic.invalid.avatarId"
));
return
;
}
if
(
send
er
.
getTeamManager
().
getCurrentTeamInfo
().
contains
(
avatar
)){
if
(
targetPlay
er
.
getTeamManager
().
getCurrentTeamInfo
().
contains
(
avatar
)){
continue
;
}
send
er
.
getTeamManager
().
getCurrentTeamInfo
().
addAvatar
(
avatar
);
targetPlay
er
.
getTeamManager
().
getCurrentTeamInfo
().
addAvatar
(
avatar
);
}
// Packet
send
er
.
getTeamManager
().
updateTeamEntities
(
new
PacketChangeMpTeamAvatarRsp
(
sender
,
send
er
.
getTeamManager
().
getCurrentTeamInfo
()));
targetPlay
er
.
getTeamManager
().
updateTeamEntities
(
new
PacketChangeMpTeamAvatarRsp
(
targetPlayer
,
targetPlay
er
.
getTeamManager
().
getCurrentTeamInfo
()));
}
}
src/main/java/emu/grasscutter/command/commands/RemoveCommand.java
View file @
efd7467a
...
...
@@ -19,6 +19,11 @@ public class RemoveCommand implements CommandHandler {
@Override
public
void
execute
(
Player
sender
,
Player
targetPlayer
,
List
<
String
>
args
)
{
if
(
targetPlayer
==
null
)
{
CommandHandler
.
sendMessage
(
sender
,
translate
(
sender
,
"commands.execution.need_target"
));
return
;
}
List
<
Integer
>
avatarIndexList
=
new
ArrayList
<>();
for
(
String
arg
:
args
)
{
try
{
...
...
@@ -34,14 +39,14 @@ public class RemoveCommand implements CommandHandler {
Collections
.
reverse
(
avatarIndexList
);
for
(
int
i
=
0
;
i
<
avatarIndexList
.
size
();
i
++)
{
if
(
avatarIndexList
.
get
(
i
)
>
send
er
.
getTeamManager
().
getCurrentTeamInfo
().
getAvatars
().
size
()
||
avatarIndexList
.
get
(
i
)
<=
0
)
{
CommandHandler
.
sendMessage
(
send
er
,
translate
(
"commands.remove.invalid_index"
));
if
(
avatarIndexList
.
get
(
i
)
>
targetPlay
er
.
getTeamManager
().
getCurrentTeamInfo
().
getAvatars
().
size
()
||
avatarIndexList
.
get
(
i
)
<=
0
)
{
CommandHandler
.
sendMessage
(
targetPlay
er
,
translate
(
"commands.remove.invalid_index"
));
return
;
}
send
er
.
getTeamManager
().
getCurrentTeamInfo
().
removeAvatar
(
avatarIndexList
.
get
(
i
)
-
1
);
targetPlay
er
.
getTeamManager
().
getCurrentTeamInfo
().
removeAvatar
(
avatarIndexList
.
get
(
i
)
-
1
);
}
// Packet
send
er
.
getTeamManager
().
updateTeamEntities
(
new
PacketChangeMpTeamAvatarRsp
(
sender
,
send
er
.
getTeamManager
().
getCurrentTeamInfo
()));
targetPlay
er
.
getTeamManager
().
updateTeamEntities
(
new
PacketChangeMpTeamAvatarRsp
(
targetPlayer
,
targetPlay
er
.
getTeamManager
().
getCurrentTeamInfo
()));
}
}
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