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
555937d2
Commit
555937d2
authored
Apr 27, 2022
by
Melledy
Browse files
Fixed concurrency issue in killall
parent
8bf17a8b
Changes
1
Show whitespace changes
Inline
Side-by-side
src/main/java/emu/grasscutter/command/commands/KillAllCommand.java
View file @
555937d2
...
...
@@ -4,6 +4,7 @@ import emu.grasscutter.Grasscutter;
import
emu.grasscutter.command.Command
;
import
emu.grasscutter.command.CommandHandler
;
import
emu.grasscutter.game.entity.EntityMonster
;
import
emu.grasscutter.game.entity.GameEntity
;
import
emu.grasscutter.game.player.Player
;
import
emu.grasscutter.game.world.Scene
;
...
...
@@ -53,10 +54,12 @@ public final class KillAllCommand implements CommandHandler {
return
;
}
mainScene
.
getEntities
().
values
().
stream
()
// Separate into list to avoid concurrency issue
List
<
GameEntity
>
toKill
=
mainScene
.
getEntities
().
values
().
stream
()
.
filter
(
entity
->
entity
instanceof
EntityMonster
)
.
forEach
(
entity
->
mainScene
.
killEntity
(
entity
,
0
));
CommandHandler
.
sendMessage
(
sender
,
"Killing all monsters in scene "
+
mainScene
.
getId
());
.
toList
();
toKill
.
stream
().
forEach
(
entity
->
mainScene
.
killEntity
(
entity
,
0
));
CommandHandler
.
sendMessage
(
sender
,
"Killing "
+
toKill
.
size
()
+
" monsters in scene "
+
mainScene
.
getId
());
}
catch
(
NumberFormatException
ignored
)
{
CommandHandler
.
sendMessage
(
sender
,
"Invalid arguments."
);
}
...
...
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