mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-01-03 22:08:28 +00:00
Tab-complete plugin names in /help (#3713)
Plugin names are accepted as input to `/essentials:help`, but they are not completed. This makes it easier to lookup plugin commands.
This commit is contained in:
parent
4f8c040d06
commit
e2f17f11d3
2 changed files with 18 additions and 1 deletions
|
@ -10,6 +10,7 @@ import com.earth2me.essentials.textreader.TextPager;
|
|||
import com.earth2me.essentials.utils.NumberUtil;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
@ -57,7 +58,9 @@ public class Commandhelp extends EssentialsCommand {
|
|||
@Override
|
||||
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
return getCommands(server);
|
||||
final List<String> suggestions = new ArrayList<>(getCommands(server));
|
||||
suggestions.addAll(getPlugins(server));
|
||||
return suggestions;
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
|
|
@ -324,6 +324,20 @@ public abstract class EssentialsCommand implements IEssentialsCommand {
|
|||
return commands;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all plugin names
|
||||
*
|
||||
* @param server Server instance
|
||||
* @return List of plugin names
|
||||
*/
|
||||
protected final List<String> getPlugins(final Server server) {
|
||||
final List<String> plugins = Lists.newArrayList();
|
||||
for (final Plugin p : server.getPluginManager().getPlugins()) {
|
||||
plugins.add(p.getName());
|
||||
}
|
||||
return plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to tab-complete a command or its arguments.
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue