UnquotedStringParseRule .java

net.minecraft.util.parsing.packrat.commands.UnquotedStringParseRule (class): members: minSize, error, parse. imports: Rule, DelayedException, ParseState.

net.minecraft.util.parsing.packrat.commandsclass31 linescommon1.0 KB

Implements

API Surface (0)

No public/protected methods detected (fields or constants only).

Fields & Constants (2)

minSize
error

Code Graph: Dependencies (3)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

UnquotedStringParseRule.java31 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.parsing.packrat.commands;
2
3
import com.mojang.brigadier.StringReader;
4
import com.mojang.brigadier.exceptions.CommandSyntaxException;
5
import net.minecraft.util.parsing.packrat.DelayedException;
6
import net.minecraft.util.parsing.packrat.ParseState;
7
import net.minecraft.util.parsing.packrat.Rule;
8
import org.jspecify.annotations.Nullable;
9
10
public class UnquotedStringParseRule implements Rule<StringReader, String> {
11
	private final int minSize;
12
	private final DelayedException<CommandSyntaxException> error;
13
14
	public UnquotedStringParseRule(final int minSize, final DelayedException<CommandSyntaxException> error) {
15
		this.minSize = minSize;
16
		this.error = error;
17
	}
18
19
	public @Nullable String parse(final ParseState<StringReader> state) {
20
		state.input().skipWhitespace();
21
		int cursor = state.mark();
22
		String value = state.input().readUnquotedString();
23
		if (value.length() < this.minSize) {
24
			state.errorCollector().store(cursor, this.error);
25
			return null;
26
		} else {
27
			return value;
28
		}
29
	}
30
}
31

Decompiled Minecraft 26.3 source of UnquotedStringParseRule (net/minecraft/util/parsing/packrat/commands/UnquotedStringParseRule.java) with Mojang official mappings, stored verbatim on the site.