From 5861f9fe6a08c8fb77272be6f9f74f9569e33702 Mon Sep 17 00:00:00 2001 From: Sxtanna Date: Sat, 25 Jul 2020 12:02:34 -0400 Subject: [PATCH] updated register command to attempt registration on the main thread. (event bullshit I think) --- .../impl/local/CommandExpansionRegister.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandExpansionRegister.java b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandExpansionRegister.java index 44c2bdd..d1c504b 100644 --- a/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandExpansionRegister.java +++ b/src/main/java/me/clip/placeholderapi/commands/impl/local/CommandExpansionRegister.java @@ -5,6 +5,7 @@ import me.clip.placeholderapi.commands.PlaceholderCommand; import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.manager.LocalExpansionManager; import me.clip.placeholderapi.util.Msg; +import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Unmodifiable; @@ -44,7 +45,7 @@ public final class CommandExpansionRegister extends PlaceholderCommand return; } - manager.findExpansionsInFile(file).whenCompleteAsync((classes, exception) -> { + manager.findExpansionsInFile(file).whenComplete((classes, exception) -> { if (exception != null) { Msg.msg(sender, @@ -61,16 +62,18 @@ public final class CommandExpansionRegister extends PlaceholderCommand return; } - final Optional expansion = manager.register(classes.get(0)); - if (!expansion.isPresent()) - { - Msg.msg(sender, - "&cFailed to register expansion from &f" + params.get(0)); - return; - } + Bukkit.getScheduler().runTask(plugin, () -> { + final Optional expansion = manager.register(classes.get(0)); + if (!expansion.isPresent()) + { + Msg.msg(sender, + "&cFailed to register expansion from &f" + params.get(0)); + return; + } - Msg.msg(sender, - "&aSuccessfully registered expansion: &f" + expansion.get().getName()); + Msg.msg(sender, + "&aSuccessfully registered expansion: &f" + expansion.get().getName()); + }); }); }