@@ -6,6 +6,7 @@ import me.rojo8399.placeholderapi.PlaceholderService
6
6
import org.spongepowered.api.Sponge
7
7
import org.spongepowered.api.command.CommandResult
8
8
import org.spongepowered.api.command.CommandSource
9
+ import org.spongepowered.api.scheduler.Task
9
10
import org.spongepowered.api.text.Text
10
11
import org.spongepowered.api.text.serializer.TextSerializers
11
12
@@ -15,7 +16,8 @@ fun executeCommand(
15
16
command : String ,
16
17
commandSource : CommandSource ,
17
18
replacements : Map <String , String > = emptyMap(),
18
- doPlaceholderProcessing : Boolean = true): CommandResult {
19
+ doPlaceholderProcessing : Boolean = true,
20
+ commandResultCallback : (CommandResult ) -> Unit = { }) {
19
21
20
22
val unprefixedCommand = command.removePrefix(EXECUTE_AS_CONSOLE_PREFIX )
21
23
val executeAsConsole = command.startsWith(EXECUTE_AS_CONSOLE_PREFIX )
@@ -28,7 +30,14 @@ fun executeCommand(
28
30
val replacedCommand = processedCommand.replace(replacements)
29
31
30
32
val finalCommandSource = if (executeAsConsole) Sponge .getServer().console else commandSource
31
- return finalCommandSource.executeCommand(replacedCommand)
33
+
34
+ Task .builder()
35
+ .execute { ->
36
+ val commandResult = finalCommandSource.executeCommand(replacedCommand)
37
+ commandResultCallback(commandResult)
38
+ }
39
+ .delayTicks(1 )
40
+ .submit(CommandUtils .INSTANCE )
32
41
}
33
42
34
43
/* *
0 commit comments