| 1 | package net.minecraft.commands;
|
| 2 |
|
| 3 | import com.mojang.brigadier.exceptions.BuiltInExceptionProvider;
|
| 4 | import com.mojang.brigadier.exceptions.Dynamic2CommandExceptionType;
|
| 5 | import com.mojang.brigadier.exceptions.DynamicCommandExceptionType;
|
| 6 | import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
| 7 | import net.minecraft.network.chat.Component;
|
| 8 |
|
| 9 | public class BrigadierExceptions implements BuiltInExceptionProvider {
|
| 10 | private static final Dynamic2CommandExceptionType DOUBLE_TOO_SMALL = new Dynamic2CommandExceptionType(
|
| 11 | (found, min) -> Component.translatableEscape("argument.double.low", min, found)
|
| 12 | );
|
| 13 | private static final Dynamic2CommandExceptionType DOUBLE_TOO_BIG = new Dynamic2CommandExceptionType(
|
| 14 | (found, max) -> Component.translatableEscape("argument.double.big", max, found)
|
| 15 | );
|
| 16 | private static final Dynamic2CommandExceptionType FLOAT_TOO_SMALL = new Dynamic2CommandExceptionType(
|
| 17 | (found, min) -> Component.translatableEscape("argument.float.low", min, found)
|
| 18 | );
|
| 19 | private static final Dynamic2CommandExceptionType FLOAT_TOO_BIG = new Dynamic2CommandExceptionType(
|
| 20 | (found, max) -> Component.translatableEscape("argument.float.big", max, found)
|
| 21 | );
|
| 22 | private static final Dynamic2CommandExceptionType INTEGER_TOO_SMALL = new Dynamic2CommandExceptionType(
|
| 23 | (found, min) -> Component.translatableEscape("argument.integer.low", min, found)
|
| 24 | );
|
| 25 | private static final Dynamic2CommandExceptionType INTEGER_TOO_BIG = new Dynamic2CommandExceptionType(
|
| 26 | (found, max) -> Component.translatableEscape("argument.integer.big", max, found)
|
| 27 | );
|
| 28 | private static final Dynamic2CommandExceptionType LONG_TOO_SMALL = new Dynamic2CommandExceptionType(
|
| 29 | (found, min) -> Component.translatableEscape("argument.long.low", min, found)
|
| 30 | );
|
| 31 | private static final Dynamic2CommandExceptionType LONG_TOO_BIG = new Dynamic2CommandExceptionType(
|
| 32 | (found, max) -> Component.translatableEscape("argument.long.big", max, found)
|
| 33 | );
|
| 34 | private static final DynamicCommandExceptionType LITERAL_INCORRECT = new DynamicCommandExceptionType(
|
| 35 | expected -> Component.translatableEscape("argument.literal.incorrect", expected)
|
| 36 | );
|
| 37 | private static final SimpleCommandExceptionType READER_EXPECTED_START_OF_QUOTE = new SimpleCommandExceptionType(
|
| 38 | Component.translatable("parsing.quote.expected.start")
|
| 39 | );
|
| 40 | private static final SimpleCommandExceptionType READER_EXPECTED_END_OF_QUOTE = new SimpleCommandExceptionType(
|
| 41 | Component.translatable("parsing.quote.expected.end")
|
| 42 | );
|
| 43 | private static final DynamicCommandExceptionType READER_INVALID_ESCAPE = new DynamicCommandExceptionType(
|
| 44 | character -> Component.translatableEscape("parsing.quote.escape", character)
|
| 45 | );
|
| 46 | private static final DynamicCommandExceptionType READER_INVALID_BOOL = new DynamicCommandExceptionType(
|
| 47 | value -> Component.translatableEscape("parsing.bool.invalid", value)
|
| 48 | );
|
| 49 | private static final DynamicCommandExceptionType READER_INVALID_INT = new DynamicCommandExceptionType(
|
| 50 | value -> Component.translatableEscape("parsing.int.invalid", value)
|
| 51 | );
|
| 52 | private static final SimpleCommandExceptionType READER_EXPECTED_INT = new SimpleCommandExceptionType(Component.translatable("parsing.int.expected"));
|
| 53 | private static final DynamicCommandExceptionType READER_INVALID_LONG = new DynamicCommandExceptionType(
|
| 54 | value -> Component.translatableEscape("parsing.long.invalid", value)
|
| 55 | );
|
| 56 | private static final SimpleCommandExceptionType READER_EXPECTED_LONG = new SimpleCommandExceptionType(Component.translatable("parsing.long.expected"));
|
| 57 | private static final DynamicCommandExceptionType READER_INVALID_DOUBLE = new DynamicCommandExceptionType(
|
| 58 | value -> Component.translatableEscape("parsing.double.invalid", value)
|
| 59 | );
|
| 60 | private static final SimpleCommandExceptionType READER_EXPECTED_DOUBLE = new SimpleCommandExceptionType(Component.translatable("parsing.double.expected"));
|
| 61 | private static final DynamicCommandExceptionType READER_INVALID_FLOAT = new DynamicCommandExceptionType(
|
| 62 | value -> Component.translatableEscape("parsing.float.invalid", value)
|
| 63 | );
|
| 64 | private static final SimpleCommandExceptionType READER_EXPECTED_FLOAT = new SimpleCommandExceptionType(Component.translatable("parsing.float.expected"));
|
| 65 | private static final SimpleCommandExceptionType READER_EXPECTED_BOOL = new SimpleCommandExceptionType(Component.translatable("parsing.bool.expected"));
|
| 66 | private static final DynamicCommandExceptionType READER_EXPECTED_SYMBOL = new DynamicCommandExceptionType(
|
| 67 | symbol -> Component.translatableEscape("parsing.expected", symbol)
|
| 68 | );
|
| 69 | private static final SimpleCommandExceptionType DISPATCHER_UNKNOWN_COMMAND = new SimpleCommandExceptionType(Component.translatable("command.unknown.command"));
|
| 70 | private static final SimpleCommandExceptionType DISPATCHER_UNKNOWN_ARGUMENT = new SimpleCommandExceptionType(
|
| 71 | Component.translatable("command.unknown.argument")
|
| 72 | );
|
| 73 | private static final SimpleCommandExceptionType DISPATCHER_EXPECTED_ARGUMENT_SEPARATOR = new SimpleCommandExceptionType(
|
| 74 | Component.translatable("command.expected.separator")
|
| 75 | );
|
| 76 | private static final DynamicCommandExceptionType DISPATCHER_PARSE_EXCEPTION = new DynamicCommandExceptionType(
|
| 77 | message -> Component.translatableEscape("command.exception", message)
|
| 78 | );
|
| 79 |
|
| 80 | @Override
|
| 81 | public Dynamic2CommandExceptionType doubleTooLow() {
|
| 82 | return DOUBLE_TOO_SMALL;
|
| 83 | }
|
| 84 |
|
| 85 | @Override
|
| 86 | public Dynamic2CommandExceptionType doubleTooHigh() {
|
| 87 | return DOUBLE_TOO_BIG;
|
| 88 | }
|
| 89 |
|
| 90 | @Override
|
| 91 | public Dynamic2CommandExceptionType floatTooLow() {
|
| 92 | return FLOAT_TOO_SMALL;
|
| 93 | }
|
| 94 |
|
| 95 | @Override
|
| 96 | public Dynamic2CommandExceptionType floatTooHigh() {
|
| 97 | return FLOAT_TOO_BIG;
|
| 98 | }
|
| 99 |
|
| 100 | @Override
|
| 101 | public Dynamic2CommandExceptionType integerTooLow() {
|
| 102 | return INTEGER_TOO_SMALL;
|
| 103 | }
|
| 104 |
|
| 105 | @Override
|
| 106 | public Dynamic2CommandExceptionType integerTooHigh() {
|
| 107 | return INTEGER_TOO_BIG;
|
| 108 | }
|
| 109 |
|
| 110 | @Override
|
| 111 | public Dynamic2CommandExceptionType longTooLow() {
|
| 112 | return LONG_TOO_SMALL;
|
| 113 | }
|
| 114 |
|
| 115 | @Override
|
| 116 | public Dynamic2CommandExceptionType longTooHigh() {
|
| 117 | return LONG_TOO_BIG;
|
| 118 | }
|
| 119 |
|
| 120 | @Override
|
| 121 | public DynamicCommandExceptionType literalIncorrect() {
|
| 122 | return LITERAL_INCORRECT;
|
| 123 | }
|
| 124 |
|
| 125 | @Override
|
| 126 | public SimpleCommandExceptionType readerExpectedStartOfQuote() {
|
| 127 | return READER_EXPECTED_START_OF_QUOTE;
|
| 128 | }
|
| 129 |
|
| 130 | @Override
|
| 131 | public SimpleCommandExceptionType readerExpectedEndOfQuote() {
|
| 132 | return READER_EXPECTED_END_OF_QUOTE;
|
| 133 | }
|
| 134 |
|
| 135 | @Override
|
| 136 | public DynamicCommandExceptionType readerInvalidEscape() {
|
| 137 | return READER_INVALID_ESCAPE;
|
| 138 | }
|
| 139 |
|
| 140 | @Override
|
| 141 | public DynamicCommandExceptionType readerInvalidBool() {
|
| 142 | return READER_INVALID_BOOL;
|
| 143 | }
|
| 144 |
|
| 145 | @Override
|
| 146 | public DynamicCommandExceptionType readerInvalidInt() {
|
| 147 | return READER_INVALID_INT;
|
| 148 | }
|
| 149 |
|
| 150 | @Override
|
| 151 | public SimpleCommandExceptionType readerExpectedInt() {
|
| 152 | return READER_EXPECTED_INT;
|
| 153 | }
|
| 154 |
|
| 155 | @Override
|
| 156 | public DynamicCommandExceptionType readerInvalidLong() {
|
| 157 | return READER_INVALID_LONG;
|
| 158 | }
|
| 159 |
|
| 160 | @Override
|
| 161 | public SimpleCommandExceptionType readerExpectedLong() {
|
| 162 | return READER_EXPECTED_LONG;
|
| 163 | }
|
| 164 |
|
| 165 | @Override
|
| 166 | public DynamicCommandExceptionType readerInvalidDouble() {
|
| 167 | return READER_INVALID_DOUBLE;
|
| 168 | }
|
| 169 |
|
| 170 | @Override
|
| 171 | public SimpleCommandExceptionType readerExpectedDouble() {
|
| 172 | return READER_EXPECTED_DOUBLE;
|
| 173 | }
|
| 174 |
|
| 175 | @Override
|
| 176 | public DynamicCommandExceptionType readerInvalidFloat() {
|
| 177 | return READER_INVALID_FLOAT;
|
| 178 | }
|
| 179 |
|
| 180 | @Override
|
| 181 | public SimpleCommandExceptionType readerExpectedFloat() {
|
| 182 | return READER_EXPECTED_FLOAT;
|
| 183 | }
|
| 184 |
|
| 185 | @Override
|
| 186 | public SimpleCommandExceptionType readerExpectedBool() {
|
| 187 | return READER_EXPECTED_BOOL;
|
| 188 | }
|
| 189 |
|
| 190 | @Override
|
| 191 | public DynamicCommandExceptionType readerExpectedSymbol() {
|
| 192 | return READER_EXPECTED_SYMBOL;
|
| 193 | }
|
| 194 |
|
| 195 | @Override
|
| 196 | public SimpleCommandExceptionType dispatcherUnknownCommand() {
|
| 197 | return DISPATCHER_UNKNOWN_COMMAND;
|
| 198 | }
|
| 199 |
|
| 200 | @Override
|
| 201 | public SimpleCommandExceptionType dispatcherUnknownArgument() {
|
| 202 | return DISPATCHER_UNKNOWN_ARGUMENT;
|
| 203 | }
|
| 204 |
|
| 205 | @Override
|
| 206 | public SimpleCommandExceptionType dispatcherExpectedArgumentSeparator() {
|
| 207 | return DISPATCHER_EXPECTED_ARGUMENT_SEPARATOR;
|
| 208 | }
|
| 209 |
|
| 210 | @Override
|
| 211 | public DynamicCommandExceptionType dispatcherParseException() {
|
| 212 | return DISPATCHER_PARSE_EXCEPTION;
|
| 213 | }
|
| 214 | }
|
| 215 |
|