Fix format parsing for command usage strings

This commit is contained in:
Josh Roy 2024-02-09 20:13:02 -05:00
parent d4ecfd2263
commit 4134b5fb99
2 changed files with 2 additions and 3 deletions

View File

@ -45,7 +45,7 @@ public class Commandhelp extends EssentialsCommand {
final IEssentialsCommand essCommand = isEssCommand ? ess.getCommandMap().get(knownCmd.getValue().getName()) : null;
if (essCommand != null && !essCommand.getUsageStrings().isEmpty()) {
for (Map.Entry<String, String> usage : essCommand.getUsageStrings().entrySet()) {
user.sendTl("commandHelpLineUsage", usage.getKey().replace("<command>", cmd), AdventureUtil.parsed(usage.getValue()));
user.sendTl("commandHelpLineUsage", AdventureUtil.parsed(usage.getKey().replace("<command>", cmd)), AdventureUtil.parsed(usage.getValue()));
}
} else {
user.sendMessage(knownCmd.getValue().getUsage());

View File

@ -10,7 +10,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.ess3.api.IEssentials;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -67,7 +66,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand {
final Matcher matcher = ARGUMENT_PATTERN.matcher(usage);
while (matcher.find()) {
final String color = matcher.group(3).equals("<") ? tlLiteral("commandArgumentRequired") : tlLiteral("commandArgumentOptional");
matcher.appendReplacement(buffer, "$1" + color + matcher.group(2).replace("|", tlLiteral("commandArgumentOr") + "|" + color) + ChatColor.RESET);
matcher.appendReplacement(buffer, "$1" + color + matcher.group(2).replace("|", tlLiteral("commandArgumentOr") + "|" + color) + "<reset>");
}
matcher.appendTail(buffer);
usageStrings.put(buffer.toString(), description);