-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
479 additions
and
96 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
src/client/java/works/nuty/calcite/parser/BlockPosParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package works.nuty.calcite.parser; | ||
|
||
import net.minecraft.predicate.NumberRange; | ||
import works.nuty.calcite.parser.array.IntArrayParser; | ||
import works.nuty.calcite.parser.common.DefaultParser; | ||
import works.nuty.calcite.parser.primitive.IntParser; | ||
|
||
public class BlockPosParser extends IntArrayParser { | ||
public BlockPosParser(DefaultParser parent) { | ||
super(parent, new IntParser(parent), NumberRange.IntRange.exactly(3)); | ||
} | ||
} |
260 changes: 226 additions & 34 deletions
260
src/client/java/works/nuty/calcite/parser/EntityParser.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/client/java/works/nuty/calcite/parser/array/ByteArrayParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/client/java/works/nuty/calcite/parser/array/IntArrayParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/client/java/works/nuty/calcite/parser/array/LongArrayParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../works/nuty/calcite/parser/AnyParser.java → ...nuty/calcite/parser/common/AnyParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ks/nuty/calcite/parser/DefaultParser.java → .../calcite/parser/common/DefaultParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/client/java/works/nuty/calcite/parser/common/EnumParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package works.nuty.calcite.parser.common; | ||
|
||
import com.mojang.brigadier.exceptions.CommandSyntaxException; | ||
|
||
import java.util.Set; | ||
|
||
public class EnumParser extends DefaultParser { | ||
|
||
private final Set<String> values; | ||
|
||
public EnumParser(DefaultParser parent, Set<String> values) { | ||
super(parent); | ||
this.values = values; | ||
} | ||
|
||
@Override | ||
public void parse() throws CommandSyntaxException { | ||
int cursor = reader().getCursor(); | ||
boolean quoted = reader().canRead() && (reader().peek() == '\'' || reader().peek() == '"'); | ||
boolean closed = false; | ||
|
||
try { | ||
reader().readString(); | ||
closed = true; | ||
} catch (CommandSyntaxException ignored) { | ||
} | ||
|
||
final String id = reader().getString().substring(cursor + (quoted ? 1 : 0), reader().getCursor() - (quoted && closed ? 1 : 0)); | ||
|
||
suggest(builder -> { | ||
values.stream() | ||
.filter(registryId -> registryId.startsWith(id)) | ||
.forEach(i -> builder.suggest("\"" + i + "\"")); | ||
|
||
return builder.buildFuture(); | ||
}); | ||
|
||
if (values.stream().anyMatch(registryId -> registryId.equals(id))) { | ||
return; | ||
} | ||
|
||
reader().setCursor(cursor); | ||
throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.readerExpectedStartOfQuote().createWithContext(reader()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ava/works/nuty/calcite/parser/Parser.java → ...ks/nuty/calcite/parser/common/Parser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.