diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index ec80e60e..59878190 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -36,6 +36,7 @@ import com.onarandombox.MultiverseCore.commands_acf.CoordCommand; import com.onarandombox.MultiverseCore.commands_acf.CreateCommand; import com.onarandombox.MultiverseCore.commands_acf.GameRuleCommand; import com.onarandombox.MultiverseCore.commands_acf.GamerulesCommand; +import com.onarandombox.MultiverseCore.commands_acf.GeneratorCommand; import com.onarandombox.MultiverseCore.commands_acf.ListCommand; import com.onarandombox.MultiverseCore.commands_acf.ReloadCommand; import com.onarandombox.MultiverseCore.commands_acf.RemoveCommand; @@ -747,6 +748,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core { this.commandHandler.registerCommand(new RemoveCommand(this)); this.commandHandler.registerCommand(new ListCommand(this)); this.commandHandler.registerCommand(new ScriptCommand(this)); + this.commandHandler.registerCommand(new GeneratorCommand(this)); //TODO: Can combine both gamerules class into one. this.commandHandler.registerCommand(new GamerulesCommand(this)); this.commandHandler.registerCommand(new GameRuleCommand(this)); diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands_acf/GeneratorCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands_acf/GeneratorCommand.java new file mode 100644 index 00000000..9678b754 --- /dev/null +++ b/src/main/java/com/onarandombox/MultiverseCore/commands_acf/GeneratorCommand.java @@ -0,0 +1,57 @@ +package com.onarandombox.MultiverseCore.commands_acf; + +import co.aikar.commands.annotation.CommandAlias; +import co.aikar.commands.annotation.CommandCompletion; +import co.aikar.commands.annotation.CommandPermission; +import co.aikar.commands.annotation.Description; +import co.aikar.commands.annotation.Subcommand; +import co.aikar.commands.annotation.Syntax; +import com.dumptruckman.minecraft.util.Logging; +import com.onarandombox.MultiverseCore.MultiverseCore; +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.Plugin; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +@CommandAlias("mv") +public class GeneratorCommand extends MultiverseCommand { + + public GeneratorCommand(MultiverseCore plugin) { + super(plugin); + } + + @Subcommand("gens|generators") + @CommandPermission("multiverse.core.generator") + @Description("Shows a list of Loaded Generator Plugins.") + public void onGeneratorCommand(CommandSender sender) { + //TODO: Figure out why this loggin message exist... + Logging.info("PLEASE IGNORE the 'Plugin X does not contain any generators' message below!"); + + List generators = Arrays.stream(this.plugin.getServer().getPluginManager().getPlugins()) + .filter(Plugin::isEnabled) + .filter(p -> p.getDefaultWorldGenerator("world", "") != null) + .map(p -> p.getDescription().getName()) + .collect(Collectors.toList()); + + if (generators.size() == 0) { + sender.sendMessage(ChatColor.RED + "No Generator Plugins found."); + return; + } + + StringBuilder loadedGens = new StringBuilder(); + boolean altColor = false; + for (String s : generators) { + loadedGens.append(altColor ? ChatColor.YELLOW : ChatColor.WHITE) + .append(s) + .append(' '); + altColor ^= true; + } + + sender.sendMessage(ChatColor.AQUA + "--- Loaded Generator Plugins ---"); + sender.sendMessage(loadedGens.toString()); + } +}