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,16 +62,18 @@ public final class CommandExpansionRegister extends PlaceholderCommand
return; return;
} }
final Optional<PlaceholderExpansion> expansion = manager.register(classes.get(0)); Bukkit.getScheduler().runTask(plugin, () -> {
if (!expansion.isPresent()) final Optional<PlaceholderExpansion> expansion = manager.register(classes.get(0));
{ if (!expansion.isPresent())
Msg.msg(sender, {
"&cFailed to register expansion from &f" + params.get(0)); Msg.msg(sender,
return; "&cFailed to register expansion from &f" + params.get(0));
} return;
}
Msg.msg(sender, Msg.msg(sender,
"&aSuccessfully registered expansion: &f" + expansion.get().getName()); "&aSuccessfully registered expansion: &f" + expansion.get().getName());
});
}); });
} }