mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-29 14:06:30 +01:00
Add generator command.
This commit is contained in:
parent
5413b92ce2
commit
391ba7b4fa
@ -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));
|
||||
|
@ -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<String> 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());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user