mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-01 05:58:00 +01:00
Added auto suggestion in the reload command
This commit is contained in:
parent
69f424eb6a
commit
8c8ba37947
@ -8,14 +8,29 @@ import net.minestom.server.command.builder.arguments.Argument;
|
|||||||
import net.minestom.server.command.builder.arguments.ArgumentType;
|
import net.minestom.server.command.builder.arguments.ArgumentType;
|
||||||
import net.minestom.server.extensions.Extension;
|
import net.minestom.server.extensions.Extension;
|
||||||
import net.minestom.server.extensions.ExtensionManager;
|
import net.minestom.server.extensions.ExtensionManager;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class ReloadExtensionCommand extends Command {
|
public class ReloadExtensionCommand extends Command {
|
||||||
|
|
||||||
|
// the extensions name as an array
|
||||||
|
private static String[] extensionsName;
|
||||||
|
|
||||||
|
static {
|
||||||
|
List<String> extensionsName = MinecraftServer.getExtensionManager().getExtensions()
|
||||||
|
.stream()
|
||||||
|
.map(extension -> extension.getDescription().getName())
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
ReloadExtensionCommand.extensionsName = extensionsName.toArray(new String[0]);
|
||||||
|
}
|
||||||
|
|
||||||
public ReloadExtensionCommand() {
|
public ReloadExtensionCommand() {
|
||||||
super("reload");
|
super("reload");
|
||||||
|
|
||||||
@ -63,6 +78,12 @@ public class ReloadExtensionCommand extends Command {
|
|||||||
sender.sendMessage("'" + extension + "' is not a valid extension name!");
|
sender.sendMessage("'" + extension + "' is not a valid extension name!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public String[] onDynamicWrite(@NotNull String text) {
|
||||||
|
return extensionsName;
|
||||||
|
}
|
||||||
|
|
||||||
private String join(String[] extensionNameParts) {
|
private String join(String[] extensionNameParts) {
|
||||||
StringBuilder b = new StringBuilder();
|
StringBuilder b = new StringBuilder();
|
||||||
for (int i = 0; i < extensionNameParts.length; i++) {
|
for (int i = 0; i < extensionNameParts.length; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user