Skip to content

Commit

Permalink
Kinda big feature update!
Browse files Browse the repository at this point in the history
  • Loading branch information
XyperCode committed Feb 7, 2024
1 parent fa078e3 commit 9ec6d0f
Show file tree
Hide file tree
Showing 37 changed files with 1,391 additions and 71 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@ bin/
.DS_Store
/map-compressed.ubo
/map-normal.ubo
/map.uso
/list-compressed.ubo
/list-normal.ubo
/list.uso
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ repositories {
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'

compileOnly(group: 'org.jetbrains', name: 'annotations', version: '23.0.0')
}

compileJava {
Expand Down Expand Up @@ -65,8 +67,8 @@ tasks.withType(GenerateModuleMetadata) {
afterEvaluate {
javadoc {
source(sourceSets.main.allJava.sourceDirectories)
title = "CoreLibs"
description = "CoreLibs is the core library collection for Ultreon Team projects."
title = "Ultreon Data API (UBO/USO)"
description = "Extensible NBT-like data API."
setDestinationDir(file("$rootProject.projectDir/build/docs/javadoc"))
// Configure the classpath
classpath = files(sourceSets.main.compileClasspath)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
project_version=1.2.2
project_version=1.3.0
30 changes: 28 additions & 2 deletions src/main/java/com/ultreon/data/DataIo.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
package com.ultreon.data;

import com.ultreon.data.types.IType;
import com.ultreon.data.types.*;
import com.ultreon.data.util.DataTypeVisitor;

import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URL;
import java.util.BitSet;
import java.util.UUID;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;

public class DataIo {
private static final short VERSION = 2;
private static final short VERSION = 3;
private static final int HEADER = 0xff804269;

@SafeVarargs
Expand Down Expand Up @@ -125,4 +130,25 @@ public static void writeCompressed(IType<?> type, OutputStream stream) throws IO
gzipStream.finish();
gzipStream.flush();
}

public static String toUso(IType<?> type) {
return type.writeUso();
}

public static <T> T visit(DataTypeVisitor<T> visitor, IType<?> type) {
return type.accept(visitor);
}

@SuppressWarnings("unchecked")
@SafeVarargs
public static <T extends IType<?>> T fromUso(String value, T... type) throws IOException {
try (BufferedReader reader = new BufferedReader(new StringReader(value))) {
IType<?> iType = readUso(reader.readLine());
return (T) iType;
}
}

private static IType<?> readUso(String value) throws IOException {
return new UsoParser(value).parse();
}
}
1 change: 1 addition & 0 deletions src/main/java/com/ultreon/data/TypeRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class TypeRegistry {
register(Types.LONG_ARRAY, LongArrayType::read);
register(Types.FLOAT_ARRAY, FloatArrayType::read);
register(Types.DOUBLE_ARRAY, DoubleArrayType::read);
register(Types.CHAR_ARRAY, CharArrayType::read);
register(Types.UUID, UUIDType::read);
register(Types.BIT_SET, BitSetType::read);
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/ultreon/data/Types.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class Types {
public static int LONG_ARRAY = 0x54;
public static int FLOAT_ARRAY = 0x56;
public static int DOUBLE_ARRAY = 0x57;
public static int CHAR_ARRAY = 0x58;
public static int UUID = 0x70;
public static int BIT_SET = 0x80;
}
Loading

0 comments on commit 9ec6d0f

Please sign in to comment.