Skip to content

LevelZ-File/java-bindings

Repository files navigation

levelz-java

Java & Kotlin Parser & API For LevelZ File Format

JitPack GitHub Release

Overview

Provides Java & Kotlin Parsing/Support for the LevelZ File Format.

Download

Maven

<!-- Add Calculus Games Repository -->

<repositories>
    <repository>
        <id>calculus-games</id>
        <url>https://repo.calcugames.xyz/repository/maven-releases/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>xyz.calcugames</groupId>
        <artifactId>levelz-java</artifactId>
        <version>[VERSION]</version>
    </dependency>
</dependencies>

Gradle (Groovy)

// Add Calculus Games Repository
repositories {
    maven { url 'https://repo.calcugames.xyz/repository/maven-releases/' }
}

dependencies {
    implementation 'xyz.calcugames:levelz-java:[VERSION]'
}

Gradle (Kotlin DSL)

// Add Calculus Games Repository
repositories {
    maven("https://repo.calcugames.xyz/repository/maven-releases/")
}

dependencies {
    implementation("xyz.calcugames:levelz-java:[VERSION]")
}

Usage

Java

Coordinate2D coordinate2D = new Coordinate2D(1, 2);
Coordinate3D coordinate3D = new Coordinate3D(1, 2, 3);
public class Main {
    public static void main(String[] args) {
        // Resource from JAR
        InputStream is = Main.class.getResourceAsStream("/example_2d.lvlz");
        Level2D level = (Level2D) LevelParser.builder()
                .input(is)
                .build()
                .parse();
        
        // Resource from File
        File file = new File("example_2d.lvlz");
        Level2D level = (Level2D) LevelParser.builder()
                .input(file)
                .build()
                .parse();
    }
}

Kotlin

val (x, y) = Coordinate2D(1, 2)
val (x, y, z) = Coordinate3D(1, 2, 3)
fun main() {
    // Resource from JAR
    val input = Main::class.java.getResourceAsStream("/example_3d.lvlz")
    val level = LevelParser.builder()
        .input(input)
        .build()
        .parse().as3D

    // Resource from File
    val file = File("example_3d.lvlz")
    val level = LevelParser.builder()
        .input(file)
        .build()
        .parse().as3D
}