use of org.spongepowered.api.event.lifecycle.RefreshGameEvent in project SpongeCommon by SpongePowered.
the class SpongeCommand method pluginsRefreshSubcommandExecutor.
@NonNull
private CommandResult pluginsRefreshSubcommandExecutor(final CommandContext context) {
final Optional<PluginContainer> pluginContainer = context.one(this.pluginContainerKey);
final RefreshGameEvent event = SpongeEventFactory.createRefreshGameEvent(PhaseTracker.getCauseStackManager().currentCause(), SpongeCommon.game());
if (pluginContainer.isPresent()) {
// just send the reload event to that
context.sendMessage(Identity.nil(), Component.text("Sending refresh event to " + pluginContainer.get().metadata().id() + ", please wait..."));
((SpongeEventManager) SpongeCommon.game().eventManager()).postToPlugin(event, pluginContainer.get());
} else {
context.sendMessage(Identity.nil(), Component.text("Sending refresh event to all plugins, please wait..."));
SpongeCommon.game().eventManager().post(event);
}
context.sendMessage(Identity.nil(), Component.text("Completed plugin refresh."));
return CommandResult.success();
}
Aggregations