use of org.spongepowered.plugin.PluginContainer in project SpongeCommon by SpongePowered.
the class SpongePlatform method createPlatformMetadata.
protected void createPlatformMetadata() {
final PluginContainer apiPlugin = Launch.instance().apiPlugin();
final PluginContainer commonPlugin = Launch.instance().commonPlugin();
final PluginContainer platformPlugin = Launch.instance().platformPlugin();
this.platformMap.put("Type", this.type());
this.platformMap.put("APIName", apiPlugin.metadata().name());
this.platformMap.put("APIVersion", apiPlugin.metadata().version());
this.platformMap.put("CommonName", commonPlugin.metadata().name());
this.platformMap.put("CommonVersion", commonPlugin.metadata().version());
this.platformMap.put("PlatformName", platformPlugin.metadata().name());
this.platformMap.put("PlatformVersion", platformPlugin.metadata().version());
this.platformMap.put("MinecraftVersion", this.minecraftVersion());
}
use of org.spongepowered.plugin.PluginContainer in project SpongeCommon by SpongePowered.
the class SpongeCommand method pluginsInfoSubcommand.
@NonNull
private CommandResult pluginsInfoSubcommand(final CommandContext context) {
final PluginContainer pluginContainer = context.requireOne(this.pluginContainerKey);
context.sendMessage(Identity.nil(), this.createContainerMeta(pluginContainer.metadata()));
return CommandResult.success();
}
use of org.spongepowered.plugin.PluginContainer 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();
}
use of org.spongepowered.plugin.PluginContainer in project SpongeCommon by SpongePowered.
the class SpongeCommand method versionExecutor.
@NonNull
private CommandResult versionExecutor(final CommandContext context) {
if (this.versionText == null) {
final PluginContainer platformPlugin = Launch.instance().platformPlugin();
final TextComponent.Builder builder = Component.text().append(Component.text(platformPlugin.metadata().name().get(), Style.style(NamedTextColor.YELLOW, TextDecoration.BOLD)));
final Component colon = Component.text(": ", NamedTextColor.GRAY);
for (final PluginContainer container : Launch.instance().launcherPlugins()) {
final PluginMetadata metadata = container.metadata();
builder.append(Component.newline(), SpongeCommand.INDENT_COMPONENT, Component.text(metadata.name().orElseGet(metadata::id), NamedTextColor.GRAY), colon, Component.text(container.metadata().version().toString()));
}
final String arch = System.getProperty("sun.arch.data.model");
final String javaArch = arch != null ? arch + "-bit" : "UNKNOWN";
final String javaVendor = System.getProperty("java.vendor");
final String javaVersion = System.getProperty("java.version");
final String osName = System.getProperty("os.name");
final String osVersion = System.getProperty("os.version");
final String osArch = System.getProperty("os.arch");
builder.append(Component.newline(), SpongeCommand.INDENT_COMPONENT, Component.text("JVM", NamedTextColor.GRAY), colon, Component.text(javaVersion + "/" + javaArch + " (" + javaVendor + ")"), Component.newline(), SpongeCommand.INDENT_COMPONENT, Component.text("OS", NamedTextColor.GRAY), colon, Component.text(osName + "/" + osVersion + " (" + osArch + ")"));
this.versionText = builder.build();
}
context.sendMessage(Identity.nil(), this.versionText);
return CommandResult.success();
}
use of org.spongepowered.plugin.PluginContainer in project SpongeCommon by SpongePowered.
the class SpongeCommand method rootCommand.
@NonNull
private CommandResult rootCommand(final CommandContext context) {
final PluginContainer platformPlugin = Launch.instance().platformPlugin();
final PluginContainer apiPlugin = Launch.instance().apiPlugin();
final PluginContainer minecraftPlugin = Launch.instance().minecraftPlugin();
context.sendMessage(Identity.nil(), Component.text().append(Component.text("SpongePowered", NamedTextColor.YELLOW, TextDecoration.BOLD).append(Component.space()), Component.text("Plugin Platform (running on Minecraft " + minecraftPlugin.metadata().version() + ")"), Component.newline(), Component.text(apiPlugin.metadata().name().get() + ": " + apiPlugin.metadata().version()), Component.newline(), Component.text(platformPlugin.metadata().name().get() + ": " + platformPlugin.metadata().version())).build());
final Optional<Command.Parameterized> parameterized = context.executedCommand();
if (parameterized.isPresent()) {
final String subcommands = parameterized.get().subcommands().stream().filter(x -> x.command().canExecute(context.cause())).flatMap(x -> x.aliases().stream()).collect(Collectors.joining(", "));
if (!subcommands.isEmpty()) {
context.sendMessage(Identity.nil(), Component.text().append(Component.newline(), Component.text("Available subcommands:"), Component.newline(), Component.text(subcommands)).build());
}
}
return CommandResult.success();
}
Aggregations