|
29 | 29 | import java.io.StringWriter; |
30 | 30 | import java.util.function.BiConsumer; |
31 | 31 | import java.util.function.Function; |
| 32 | +import java.util.stream.Collectors; |
32 | 33 | import net.minecraft.ChatFormatting; |
33 | 34 | import net.minecraft.commands.CommandSourceStack; |
34 | 35 | import net.minecraft.commands.SharedSuggestionProvider; |
@@ -169,11 +170,15 @@ M extends CommandManager<C> & BrigadierManagerHolder<C, S>> void registerDefault |
169 | 170 | )); |
170 | 171 | }); |
171 | 172 | ctx.registerHandler(InvalidCommandSenderException.class, (source, exceptionContext) -> { |
| 173 | + final boolean multiple = exceptionContext.exception().requiredSenderTypes().size() > 1; |
| 174 | + final String expected = multiple |
| 175 | + ? exceptionContext.exception().requiredSenderTypes().stream().map(TypeUtils::simpleName).collect(Collectors.joining(", ")) |
| 176 | + : TypeUtils.simpleName(exceptionContext.exception().requiredSenderTypes().iterator().next()); |
172 | 177 | sendError.accept(source, exceptionContext.context().formatCaption( |
173 | 178 | captionFormatter, |
174 | | - StandardCaptionKeys.EXCEPTION_INVALID_SENDER, |
| 179 | + multiple ? StandardCaptionKeys.EXCEPTION_INVALID_SENDER_LIST : StandardCaptionKeys.EXCEPTION_INVALID_SENDER, |
175 | 180 | CaptionVariable.of("actual", exceptionContext.context().sender().getClass().getSimpleName()), |
176 | | - CaptionVariable.of("expected", TypeUtils.simpleName(exceptionContext.exception().requiredSender())) |
| 181 | + CaptionVariable.of("expected", expected) |
177 | 182 | )); |
178 | 183 | }); |
179 | 184 | ctx.registerHandler(InvalidSyntaxException.class, (source, exceptionContext) -> { |
|
0 commit comments