41 lines
1.3 KiB
Java
41 lines
1.3 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.mojang.brigadier.StringReader
|
|
* com.mojang.brigadier.exceptions.CommandSyntaxException
|
|
* org.jspecify.annotations.Nullable
|
|
*/
|
|
package net.minecraft.util.parsing.packrat.commands;
|
|
|
|
import com.mojang.brigadier.StringReader;
|
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
|
import net.minecraft.util.parsing.packrat.DelayedException;
|
|
import net.minecraft.util.parsing.packrat.ParseState;
|
|
import net.minecraft.util.parsing.packrat.Rule;
|
|
import org.jspecify.annotations.Nullable;
|
|
|
|
public class UnquotedStringParseRule
|
|
implements Rule<StringReader, String> {
|
|
private final int minSize;
|
|
private final DelayedException<CommandSyntaxException> error;
|
|
|
|
public UnquotedStringParseRule(int minSize, DelayedException<CommandSyntaxException> error) {
|
|
this.minSize = minSize;
|
|
this.error = error;
|
|
}
|
|
|
|
@Override
|
|
public @Nullable String parse(ParseState<StringReader> state) {
|
|
state.input().skipWhitespace();
|
|
int cursor = state.mark();
|
|
String value = state.input().readUnquotedString();
|
|
if (value.length() < this.minSize) {
|
|
state.errorCollector().store(cursor, this.error);
|
|
return null;
|
|
}
|
|
return value;
|
|
}
|
|
}
|
|
|