Compare commits

..
Author SHA1 Message Date
big-duckie da2ffa19ff Add actions support.
release / build (21) (push) Successful in 12m1s
2025-01-01 14:27:06 -07:00
big-duckie 412ab2c1d0 Fix up some issues. 2025-01-01 14:25:39 -07:00
10 changed files with 170 additions and 118 deletions
+43
View File
@@ -0,0 +1,43 @@
name: release
on:
push:
tags:
- "*"
env:
VERSION: "${{github.ref_name}}"
jobs:
build:
strategy:
matrix:
java: [
21, # Current Java LTS
]
runs-on: ubuntu-22.04
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: setup jdk ${{ matrix.java }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}
distribution: "temurin"
- name: make gradle wrapper executable
run: chmod +x ./gradlew
- name: build
run: ./gradlew build
- name: publish maven
continue-on-error: true
env:
MAVEN_TOKEN: "${{secrets.MAVEN_TOKEN}}"
run: ./gradlew publish
- name: publish release
uses: akkuman/gitea-release-action@v1
with:
files: |-
build/libs/**
token: "${{secrets.GITHUB_TOKEN}}"
+59 -45
View File
@@ -1,57 +1,25 @@
plugins {
id "fabric-loom" version "1.6-SNAPSHOT"
id "maven-publish"
id "java-library"
id 'fabric-loom' version '1.8-SNAPSHOT'
id 'maven-publish'
}
if (System.getenv("VERSION")) {
project.mod_version = System.getenv("VERSION")
}
version = "${project.mod_version}"
group = "dev.draylar"
archivesBaseName = "omega-config"
subprojects {
apply plugin: 'fabric-loom'
apply plugin: 'maven-publish'
archivesBaseName = project.name
group = "dev.draylar.${project.group}"
// Only publish for submodules (not the root project) - add standard jar, + sources & development jar
publishing {
repositories {
maven {
name = "draylarRepository"
url = "https://maven.draylar.dev/releases"
credentials(PasswordCredentials)
authentication {
basic(BasicAuthentication)
}
}
}
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
// Add sources & javadoc artifacts
java {
withSourcesJar()
withJavadocJar()
}
base {
archivesName = "omega-config"
}
allprojects {
apply plugin: "fabric-loom"
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_21
version = project.mod_version + "-" + project.minecraft_version
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
version = project.mod_version
repositories {
maven {
name = "FabricMC"
url = "https://maven.fabricmc.net"
}
}
repositories {}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
@@ -68,7 +36,8 @@ allprojects {
}
}
tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
it.options.release = 17
javadoc.options.addStringOption('Xdoclint:none', '-quiet')
}
@@ -79,6 +48,51 @@ allprojects {
}
}
subprojects {
apply plugin: 'fabric-loom'
apply plugin: 'maven-publish'
archivesBaseName = project.name
group = "dev.draylar.${project.group}"
// Only publish for submodules (not the root project) - add standard jar, + sources & development jar
publishing {
publications {
create("mavenJava", MavenPublication) {
artifactId = project.archives_base_name
version = "${project.mod_version}+${project.minecraft_version}"
from components.java
}
}
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
maven {
name = "Gitea"
url = uri("https://git.bigduckie.dev/api/packages/big-duckie/maven")
credentials(HttpHeaderCredentials) {
name = "Authorization"
value = "token ${System.getenv("MAVEN_TOKEN")}"
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
}
// Add sources & javadoc artifacts
java {
withSourcesJar()
withJavadocJar()
}
}
// Main project depends on the base & gui module for testing
dependencies {
implementation project(path: ":omega-config-base", configuration: "namedElements")
+11 -10
View File
@@ -1,18 +1,19 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx2G
org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true
# Fabric Properties
# check these on https://fabricmc.net/versions.html
minecraft_version=1.21
yarn_mappings=1.21+build.2
loader_version=0.15.11
# Fabric API
fabric_version=0.100.2+1.21
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.16.7
# Mod Properties
mod_version=1.4.4
maven_group=dev.draylar
mod_version=1.4.1
maven_group=dev.bigduckie
archives_base_name=omega-config
# Dependencies
fabric_version=0.92.2+1.20.1
modmenu_version=7.1.0
+3 -1
View File
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-5
View File
@@ -1,5 +0,0 @@
jdk:
- openjdk21
before_install:
- sdk install java 21.0.3-open
- sdk use java 21.0.3-open
@@ -5,16 +5,14 @@ import com.google.gson.GsonBuilder;
import draylar.omegaconfig.api.Comment;
import draylar.omegaconfig.api.Config;
import draylar.omegaconfig.gson.SyncableExclusionStrategy;
import io.netty.buffer.Unpooled;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.codec.PacketCodec;
import net.minecraft.network.codec.PacketCodecs;
import net.minecraft.network.packet.CustomPayload;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -26,15 +24,45 @@ import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
public class OmegaConfig implements ModInitializer {
public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
public static final Identifier CONFIG_SYNC_PACKET = new Identifier("omegaconfig", "sync");
public static final Gson SYNC_ONLY_GSON = new GsonBuilder().addSerializationExclusionStrategy(new SyncableExclusionStrategy()).setPrettyPrinting().create();
public static final Logger LOGGER = LogManager.getLogger();
private static final List<Config> REGISTERED_CONFIGURATIONS = new ArrayList<>();
@Override
public void onInitialize() {
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> server.execute(() -> {
PacketByteBuf packet = new PacketByteBuf(Unpooled.buffer());
// list of configurations that are synced
NbtCompound root = new NbtCompound();
NbtList configurations = new NbtList();
// Iterate over each configuration.
// Find values that should be synced and send the value over.
OmegaConfig.getRegisteredConfigurations().forEach(config -> {
if (config.hasAnySyncable()) {
configurations.add(config.writeSyncingTag());
}
});
// save to packet and send to user
root.put("Configurations", configurations);
packet.writeNbt(root);
handler.sendPacket(ServerPlayNetworking.createS2CPacket(CONFIG_SYNC_PACKET, packet));
}));
}
public static <T extends Config> T register(Class<T> configClass) {
try {
// Attempt to instantiate a new instance of this class.
@@ -69,8 +97,8 @@ public class OmegaConfig implements ModInitializer {
return config;
} catch (NoSuchMethodException | InstantiationException | IllegalAccessException |
InvocationTargetException exception) {
exception.printStackTrace();
InvocationTargetException e) {
e.printStackTrace();
throw new RuntimeException("No valid constructor found for: " + configClass.getName());
}
}
@@ -212,38 +240,4 @@ public class OmegaConfig implements ModInitializer {
public static List<Config> getRegisteredConfigurations() {
return REGISTERED_CONFIGURATIONS;
}
@Override
public void onInitialize() {
PayloadTypeRegistry.playS2C().register(OmegaConfig.SyncConfigPayload.ID, OmegaConfig.SyncConfigPayload.CODEC);
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> server.execute(() -> {
// list of configurations that are synced
NbtCompound root = new NbtCompound();
NbtList configurations = new NbtList();
// Iterate over each configuration.
// Find values that should be synced and send the value over.
OmegaConfig.getRegisteredConfigurations().forEach(config -> {
if (config.hasAnySyncable()) {
configurations.add(config.writeSyncingTag());
}
});
// save to packet and send to user
root.put("Configurations", configurations);
sender.sendPacket(new SyncConfigPayload(root));
}));
}
public record SyncConfigPayload(NbtCompound nbtCompound) implements CustomPayload {
public static final Identifier CONFIG_SYNC_PACKET = Identifier.of("omegaconfig", "sync");
public static final CustomPayload.Id<SyncConfigPayload> ID = new Id<>(CONFIG_SYNC_PACKET);
public static final PacketCodec<PacketByteBuf, SyncConfigPayload> CODEC = PacketCodecs.NBT_COMPOUND.xmap(SyncConfigPayload::new, SyncConfigPayload::nbtCompound).cast();
@Override
public Id<? extends CustomPayload> getId() {
return ID;
}
}
}
@@ -8,6 +8,7 @@ import net.fabricmc.fabric.api.util.NbtType;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.RunArgs;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtList;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
@@ -30,14 +31,13 @@ public class ClientMixin {
method = "<init>",
at = @At("RETURN"))
private void onReturn(RunArgs args, CallbackInfo ci) {
ClientPlayNetworking.registerGlobalReceiver(OmegaConfig.SyncConfigPayload.ID, (payload, context) -> {
NbtCompound tag = payload.nbtCompound();
ClientPlayNetworking.registerGlobalReceiver(OmegaConfig.CONFIG_SYNC_PACKET, (client, handler, buf, responseSender) -> {
NbtCompound tag = buf.readNbt();
savedClientConfig.clear();
context.client().execute(() -> {
client.execute(() -> {
if (tag != null && tag.contains("Configurations")) {
NbtList list = tag.getList("Configurations", NbtType.COMPOUND);
NbtList list = tag.getList("Configurations", NbtElement.COMPOUND_TYPE);
list.forEach(compound -> {
NbtCompound syncedConfiguration = (NbtCompound) compound;
String name = syncedConfiguration.getString("ConfigName");
@@ -6,7 +6,8 @@
"description": "The last config solution you will ever use.",
"authors": [
"Draylar",
"Frqnny"
"Frqnny",
"Big Duckie"
],
"entrypoints": {
"main": [
@@ -30,7 +31,9 @@
},
"custom": {
"modmenu": {
"badges": [ "library" ]
"badges": [
"library"
]
}
}
}
+1 -1
View File
@@ -1,10 +1,10 @@
pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
gradlePluginPortal()
}
}
@@ -8,7 +8,7 @@ import java.util.HashMap;
import java.util.Map;
//taken straight out of Mo' Structures
//taken straight out of Mo Structures
public class StructuresConfigTest implements Config {
@Comment("""