https://github.com/meteordevelopment/starscript
Fast text formatting language for Java.
https://github.com/meteordevelopment/starscript
Last synced: 5 months ago
JSON representation
Fast text formatting language for Java.
- Host: GitHub
- URL: https://github.com/meteordevelopment/starscript
- Owner: MeteorDevelopment
- License: mit
- Created: 2021-05-23T13:15:11.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-06-21T17:57:48.000Z (7 months ago)
- Last Synced: 2025-06-21T18:38:05.539Z (7 months ago)
- Language: Java
- Homepage:
- Size: 116 KB
- Stars: 49
- Watchers: 1
- Forks: 9
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Starscript
Fast text formatting language for Java.
- Lightweight with no dependencies
- Faster than `String.format` (See [Benchmark](https://github.com/MeteorDevelopment/starscript/blob/master/src/test/java/org/meteordev/starscript/Benchmark.java))
- Standard operators + - * / % ^
- Ability to call functions defined in java
- Variables can be different each time they are used
- Conditional output (ternary operator)
- Variables can be maps
## Examples
- `Hello {name}!`
- `Number: {someNumber * 100}`
- `FPS: {round(fps)}`
- `Today is a {good ? 'good' : 'bad'} day`
- `Name: {player.name}`
## Usage
Gradle:
```groovy
repositories {
maven {
name = "meteor-maven"
url = "https://maven.meteordev.org/releases"
}
}
dependencies {
implementation "org.meteordev:starscript:0.2.3"
}
```
Java:
```java
// Parse
Parser.Result result = Parser.parse("Hello {name}!");
// Check for errors
if (result.hasErrors()) {
for (Error error : result.errors) System.out.println(error);
return;
}
// Compile
Script script = Compiler.compile(result);
// Create starscript instance
Starscript ss = new Starscript();
StandardLib.init(ss); // Adds a few default functions, not required
ss.set("name", "MineGame159");
// ss.set("name", () -> Value.string("MineGame159"));
// Run
System.out.println(ss.run(script)); // Hello MineGame159!
```
## Documentation
Full syntax and features can be found on [wiki](https://github.com/MeteorDevelopment/starscript/wiki).
Javadocs can be found [here](https://javadoc.jitpack.io/com/github/MeteorDevelopment/starscript).