updated register command to attempt registration on the main thread. (event bullshit I think)

This commit is contained in:
Sxtanna 2020-07-25 12:02:34 -04:00
parent b6ec478dd6
commit 5861f9fe6a

View File

@ -5,6 +5,7 @@ import me.clip.placeholderapi.commands.PlaceholderCommand;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import me.clip.placeholderapi.expansion.manager.LocalExpansionManager; import me.clip.placeholderapi.expansion.manager.LocalExpansionManager;
import me.clip.placeholderapi.util.Msg; import me.clip.placeholderapi.util.Msg;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Unmodifiable; import org.jetbrains.annotations.Unmodifiable;
@ -44,7 +45,7 @@ public final class CommandExpansionRegister extends PlaceholderCommand
return; return;
} }
manager.findExpansionsInFile(file).whenCompleteAsync((classes, exception) -> { manager.findExpansionsInFile(file).whenComplete((classes, exception) -> {
if (exception != null) if (exception != null)
{ {
Msg.msg(sender, Msg.msg(sender,
@ -61,6 +62,7 @@ public final class CommandExpansionRegister extends PlaceholderCommand
return; return;
} }
Bukkit.getScheduler().runTask(plugin, () -> {
final Optional<PlaceholderExpansion> expansion = manager.register(classes.get(0)); final Optional<PlaceholderExpansion> expansion = manager.register(classes.get(0));
if (!expansion.isPresent()) if (!expansion.isPresent())
{ {
@ -72,6 +74,7 @@ public final class CommandExpansionRegister extends PlaceholderCommand
Msg.msg(sender, Msg.msg(sender,
"&aSuccessfully registered expansion: &f" + expansion.get().getName()); "&aSuccessfully registered expansion: &f" + expansion.get().getName());
}); });
});
} }
@Override @Override