Skip to content

Commit

Permalink
fix command error output (1.12.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
RacoonDog committed Jul 28, 2023
1 parent 6f23506 commit 8a8cc83
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,10 @@ public void parse(PermissibleCommandSource source, CommandArgs args, CommandCont

if (ex instanceof ArgumentParseException.WithUsage) {
// This indicates a previous child failed, so we just prepend our child
throw new ArgumentParseException.WithUsage(ex, new LiteralText(key + " " + ((ArgumentParseException.WithUsage) ex).getUsage()));
throw new ArgumentParseException.WithUsage(ex, new LiteralText(key + " " + ((ArgumentParseException.WithUsage) ex).getUsage().computeValue()));
}

throw new ArgumentParseException.WithUsage(ex, new LiteralText(key + " " + mapping.getCallable().getUsage(source)));
throw new ArgumentParseException.WithUsage(ex, new LiteralText(key + " " + mapping.getCallable().getUsage(source).computeValue()));
}
} else {
// Not a child, so let's continue with the fallback.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public boolean canComplete() {
*/
public String peek() throws ArgumentParseException {
if (!this.hasNext()) {
throw this.createError(new LiteralText("Not enough arguments"));
throw this.createError(new LiteralText("Not enough arguments!"));
}

return this.args.get(this.index + 1).getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void parse(PermissibleCommandSource source, CommandArgs args, CommandCont
* @return The formatted usage
*/
public Text getUsage(PermissibleCommandSource src) {
return this.getKey() == null ? new LiteralText("") : new LiteralText("<" + this.getKey() + ">");
return this.getKey() == null ? new LiteralText("") : new LiteralText("<" + this.getKey().computeValue() + ">");
}

public MinecraftServer getServer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ public Optional<Text> getHelp(PermissibleCommandSource source) {
Preconditions.checkNotNull(source, "source");
StringBuilder builder = new StringBuilder();
this.getShortDescription(source).ifPresent((a) -> builder.append(a.asUnformattedString()).append("\n"));
builder.append(this.getUsage(source));
builder.append(this.getUsage(source).computeValue());
this.getExtendedDescription(source).ifPresent((a) -> builder.append(a.asUnformattedString()).append("\n"));
return Optional.of(new LiteralText(builder.toString()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public CommandResult process(PermissibleCommandSource source, String command) {
usage = mapping.get().getCallable().getUsage(source);
}

source.sendMessage(CommandMessageFormatting.error(new LiteralText(String.format("Usage: /%s %s", argSplit[0], usage))));
source.sendMessage(CommandMessageFormatting.error(new LiteralText(String.format("Usage: /%s %s", argSplit[0], usage.computeValue()))));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void method_3279(MinecraftServer minecraftServer, CommandSource source, S
usage = this.mapping.getCallable().getUsage((PermissibleCommandSource) source);
}

source.sendMessage(CommandMessageFormatting.error(new LiteralText(String.format("Usage: /%s %s", this.getCommandName(), usage))));
source.sendMessage(CommandMessageFormatting.error(new LiteralText(String.format("Usage: /%s %s", this.getCommandName(), usage.computeValue()))));
}
}
} catch (Throwable t) {
Expand Down

0 comments on commit 8a8cc83

Please sign in to comment.