Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lucko/commodore-file
The commodore file format
https://github.com/lucko/commodore-file
Last synced: 7 days ago
JSON representation
The commodore file format
- Host: GitHub
- URL: https://github.com/lucko/commodore-file
- Owner: lucko
- License: mit
- Created: 2020-07-25T18:01:07.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-18T11:53:39.000Z (almost 4 years ago)
- Last Synced: 2024-05-01T21:21:28.841Z (7 months ago)
- Language: Java
- Size: 13.7 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# commodore-file [![Javadocs](https://javadoc.io/badge/me.lucko/commodore-file.svg)](https://javadoc.io/doc/me.lucko/commodore-file) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/me.lucko/commodore-file/badge.svg)](https://maven-badges.herokuapp.com/maven-central/me.lucko/commodore-file)
The commodore file format is a simplified way of representing Brigadier command node trees in a string form.
This repository is a Java parser for the format.
## Example
Below is an example commodore file for [Minecraft's `/time` command](https://minecraft.gamepedia.com/Commands/time):```
time {
set {
day;
noon;
night;
midnight;
time brigadier:integer;
}
add {
time brigadier:integer;
}
query {
daytime;
gametime;
day;
}
}
```To parse to a brigadier `CommandNode`:
```java
LiteralCommandNode timeCommand = CommodoreFileReader.INSTANCE.parse(new File("time.commodore"));
```This will return a command node equivalent to the following node as build with brigadier's API.
```java
LiteralCommandNode timeCommand = LiteralArgumentBuilder.literal("time")
.then(LiteralArgumentBuilder.literal("set")
.then(LiteralArgumentBuilder.literal("day"))
.then(LiteralArgumentBuilder.literal("noon"))
.then(LiteralArgumentBuilder.literal("night"))
.then(LiteralArgumentBuilder.literal("midnight"))
.then(RequiredArgumentBuilder.argument("time", IntegerArgumentType.integer())))
.then(LiteralArgumentBuilder.literal("add")
.then(RequiredArgumentBuilder.argument("time", IntegerArgumentType.integer())))
.then(LiteralArgumentBuilder.literal("query")
.then(LiteralArgumentBuilder.literal("daytime"))
.then(LiteralArgumentBuilder.literal("gametime"))
.then(LiteralArgumentBuilder.literal("day"))
).build();
```