Add missing command completions for BungeeCord
This commit is contained in:
parent
7128b45ade
commit
0ed2b567c8
5 changed files with 23 additions and 8 deletions
|
|
@ -56,14 +56,7 @@ public class ServerUtils extends JavaPlugin implements CommandExecutor {
|
|||
completions.registerAsyncCompletion("plugins", context -> manager.getPluginNames());
|
||||
completions.registerAsyncCompletion("pluginJars", context -> manager.getPluginFileNames());
|
||||
completions.registerAsyncCompletion("supportedConfigs", context -> CommandServerUtils.getSupportedConfigs());
|
||||
completions.registerAsyncCompletion("commands", context -> {
|
||||
try {
|
||||
return RCommandMap.getKnownCommands(RCraftServer.getCommandMap()).keySet();
|
||||
} catch (IllegalAccessException | InvocationTargetException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
});
|
||||
completions.registerAsyncCompletion("commands", context -> manager.getCommands());
|
||||
reload();
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new BukkitListener(), this);
|
||||
|
|
|
|||
|
|
@ -3,8 +3,10 @@ package net.frankheijden.serverutils.bukkit.managers;
|
|||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
|
@ -338,6 +340,13 @@ public class BukkitPluginManager extends AbstractPluginManager<Plugin> {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getCommands() {
|
||||
Map<String, Command> knownCommands = getKnownCommands();
|
||||
if (knownCommands == null) return Collections.emptySet();
|
||||
return knownCommands.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getPluginsFolder() {
|
||||
return plugin.getDataFolder().getParentFile();
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ public class ServerUtils extends Plugin {
|
|||
CommandCompletions<BungeeCommandCompletionContext> commandCompletions = commandManager.getCommandCompletions();
|
||||
commandCompletions.registerAsyncCompletion("plugins", context -> manager.getPluginNames());
|
||||
commandCompletions.registerAsyncCompletion("pluginJars", context -> manager.getPluginFileNames());
|
||||
commandCompletions.registerAsyncCompletion("commands", context -> manager.getCommands());
|
||||
|
||||
reload();
|
||||
getProxy().getPluginManager().registerListener(this, new BungeeListener());
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
|
|
@ -186,6 +188,13 @@ public class BungeePluginManager extends AbstractPluginManager<Plugin> {
|
|||
return plugin.getFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getCommands() {
|
||||
return proxy.getPluginManager().getCommands().stream()
|
||||
.map(Map.Entry::getKey)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the PluginDescription of a (plugin's) File.
|
||||
* @param file The file.
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import java.io.File;
|
|||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class PluginProvider<T> {
|
||||
|
|
@ -16,6 +17,8 @@ public abstract class PluginProvider<T> {
|
|||
|
||||
public abstract File getPluginFile(T plugin);
|
||||
|
||||
public abstract Set<String> getCommands();
|
||||
|
||||
/**
|
||||
* Retrieves a list of plugins, sorted by name.
|
||||
* @return The list of plugins.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue