Fixes list paid signs tab completion

This commit is contained in:
Kristian Knarvik 2022-02-27 14:51:37 +01:00
parent 3b7268d2ff
commit 990339499a
2 changed files with 8 additions and 4 deletions

View File

@ -47,7 +47,7 @@ public class ListCommand extends TokenizedCommand {
} else {
short signLine;
try {
signLine = Short.parseShort(arguments.get(1));
signLine = (short) (Short.parseShort(arguments.get(1)) - 1);
} catch (NumberFormatException exception) {
sender.sendMessage("Invalid number given");
return false;
@ -57,7 +57,7 @@ public class ListCommand extends TokenizedCommand {
return false;
}
PaidSignCondition condition = paidSign.getConditions().get(signLine);
displayPaidSignCondition(sender, paidSign.getName(), condition);
displayPaidSignCondition(sender, paidSign.getName(), signLine, condition);
}
return true;
}
@ -67,11 +67,14 @@ public class ListCommand extends TokenizedCommand {
*
* @param sender <p>The command sender to display the information to</p>
* @param signName <p>The name of the sign to display the condition for</p>
* @param signLine <p>The line the condition is for</p>
* @param condition <p>The condition to display information about</p>
*/
private void displayPaidSignCondition(CommandSender sender, String signName, PaidSignCondition condition) {
private void displayPaidSignCondition(CommandSender sender, String signName, short signLine,
PaidSignCondition condition) {
sender.sendMessage("Paid sign condition info: ");
sender.sendMessage("Paid sign name: " + signName);
sender.sendMessage("Condition line: " + signLine);
sender.sendMessage("Condition match string: " + condition.getStringToMatch());
sender.sendMessage("Execute RegEx: " + condition.executeRegex());
sender.sendMessage("Ignore case: " + condition.ignoreCase());
@ -94,7 +97,7 @@ public class ListCommand extends TokenizedCommand {
sender.sendMessage("Sign conditions: ");
Map<Short, PaidSignCondition> conditions = paidSign.getConditions();
for (short lineIndex : conditions.keySet()) {
sender.sendMessage(" | " + lineIndex + ". " + conditions.get(lineIndex).getStringToMatch());
sender.sendMessage(" | " + (lineIndex + 1) + ". " + conditions.get(lineIndex).getStringToMatch());
}
}

View File

@ -20,6 +20,7 @@ public class ListTabCompleter extends TokenizedTabCompleter {
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias,
@NotNull String[] args) {
super.onTabComplete(sender, command, alias, args);
if (argumentSize == 1) {
return TabCompleteHelper.filterMatchingStartsWith(TabCompleteHelper.getPaidSignNames(), arguments.get(0));
} else if (argumentSize == 2) {