Add packs list command.

This commit is contained in:
dfsek
2020-12-04 00:34:09 -07:00
parent 47b3278f96
commit b3e76f6485
3 changed files with 62 additions and 1 deletions

View File

@@ -0,0 +1,56 @@
package com.dfsek.terra.command;
import com.dfsek.terra.config.base.ConfigPackTemplate;
import com.dfsek.terra.config.lang.LangUtil;
import com.dfsek.terra.registry.ConfigRegistry;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.polydev.gaea.command.Command;
import java.util.Collections;
import java.util.List;
public class PacksCommand extends Command {
public PacksCommand(Command parent) {
super(parent);
}
@Override
public String getName() {
return "packs";
}
@Override
public List<Command> getSubCommands() {
return Collections.emptyList();
}
@Override
public boolean execute(@NotNull CommandSender commandSender, org.bukkit.command.@NotNull Command command, @NotNull String s, @NotNull String[] strings) {
ConfigRegistry registry = ConfigRegistry.getRegistry();
if(registry.entries().size() == 0) {
LangUtil.send("command.packs.none", commandSender);
return true;
}
LangUtil.send("command.packs.main", commandSender);
registry.entries().forEach(entry -> {
ConfigPackTemplate template = entry.getTemplate();
LangUtil.send("command.packs.pack", commandSender, template.getID(), template.getAuthor());
});
return true;
}
@Override
public int arguments() {
return 0;
}
@Override
public List<String> getTabCompletions(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) {
return Collections.emptyList();
}
}

View File

@@ -25,7 +25,8 @@ public class TerraCommand extends Command {
new ImageCommand(this),
new GeometryCommand(this),
new FixChunkCommand(this),
new VersionCommand(this));
new VersionCommand(this),
new PacksCommand(this));
public TerraCommand(GaeaPlugin main) {
super(main);

View File

@@ -28,6 +28,10 @@ command:
invalid-radius: "Invalid radius: \"%s\""
invalid: "Invalid Biome ID: \"%s\""
in: "You are in \"%s\""
packs:
main: "Currently installed config packs:"
pack: " - %1$s by %2$s"
none: "No config packs are installed."
ore:
main-menu:
- "---------------Terra/ore---------------"