mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-28 20:17:55 +01:00
Create a copy of args for command timeout catcher
This commit is contained in:
parent
9647b7de43
commit
c948632dfa
@ -68,6 +68,7 @@ import net.kyori.adventure.text.Component;
|
|||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -134,6 +135,7 @@ public class CommandManager {
|
|||||||
|
|
||||||
public CompletableFuture<CommandResult> executeCommand(Sender sender, String label, List<String> args) {
|
public CompletableFuture<CommandResult> executeCommand(Sender sender, String label, List<String> args) {
|
||||||
SchedulerAdapter scheduler = this.plugin.getBootstrap().getScheduler();
|
SchedulerAdapter scheduler = this.plugin.getBootstrap().getScheduler();
|
||||||
|
List<String> argsCopy = new ArrayList<>(args);
|
||||||
|
|
||||||
// schedule a future to execute the command
|
// schedule a future to execute the command
|
||||||
AtomicReference<Thread> thread = new AtomicReference<>();
|
AtomicReference<Thread> thread = new AtomicReference<>();
|
||||||
@ -156,7 +158,7 @@ public class CommandManager {
|
|||||||
}, scheduler.async());
|
}, scheduler.async());
|
||||||
|
|
||||||
// catch if the command doesn't complete within a given time
|
// catch if the command doesn't complete within a given time
|
||||||
scheduler.awaitTimeout(future, 10, TimeUnit.SECONDS, () -> handleCommandTimeout(thread, args));
|
scheduler.awaitTimeout(future, 10, TimeUnit.SECONDS, () -> handleCommandTimeout(thread, argsCopy));
|
||||||
|
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user