Fixes tab-completion when editing default messages
This commit is contained in:
parent
b38cfbe710
commit
4d740521f3
@ -31,6 +31,11 @@ public class BlackSmithConfigTabCompleter implements TabCompleter {
|
|||||||
|
|
||||||
//Arguments: <setting> [new value/material or enchantment] []
|
//Arguments: <setting> [new value/material or enchantment] []
|
||||||
|
|
||||||
|
//Prevent tab-completion when typing messages with spaces
|
||||||
|
if (skipCompletionForSpacedMessage(args) != null) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
List<String> availableCommands = new ArrayList<>();
|
List<String> availableCommands = new ArrayList<>();
|
||||||
availableCommands.add("reload");
|
availableCommands.add("reload");
|
||||||
@ -55,6 +60,28 @@ public class BlackSmithConfigTabCompleter implements TabCompleter {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether to tab-complete nothing because a message containing spaces is being written
|
||||||
|
*
|
||||||
|
* @param args <p>The arguments given by the user</p>
|
||||||
|
* @return <p>Null if not writing a spaced message</p>
|
||||||
|
*/
|
||||||
|
private List<String> skipCompletionForSpacedMessage(String[] args) {
|
||||||
|
if (args.length > 2) {
|
||||||
|
NPCSetting npcSetting = null;
|
||||||
|
for (NPCSetting setting : NPCSetting.values()) {
|
||||||
|
if (setting.getCommandName().equalsIgnoreCase(args[0])) {
|
||||||
|
npcSetting = setting;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (npcSetting != null && npcSetting.getPath().startsWith("defaults.messages")) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets tab-completions for a selected material or enchantment
|
* Gets tab-completions for a selected material or enchantment
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user