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 169 additions and 116 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}}"
+58 -44
View File
@@ -1,57 +1,25 @@
plugins { plugins {
id "fabric-loom" version "1.6-SNAPSHOT" id 'fabric-loom' version '1.8-SNAPSHOT'
id "maven-publish" id 'maven-publish'
id "java-library"
} }
if (System.getenv("VERSION")) {
project.mod_version = System.getenv("VERSION")
}
version = "${project.mod_version}"
group = "dev.draylar" group = "dev.draylar"
archivesBaseName = "omega-config"
subprojects { base {
apply plugin: 'fabric-loom' archivesName = "omega-config"
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()
}
} }
allprojects { allprojects {
apply plugin: "fabric-loom" apply plugin: "fabric-loom"
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17 sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17
version = project.mod_version + "+" + project.minecraft_version version = project.mod_version
repositories { repositories {}
maven {
name = "FabricMC"
url = "https://maven.fabricmc.net"
}
}
dependencies { dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}" 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') 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 // Main project depends on the base & gui module for testing
dependencies { dependencies {
implementation project(path: ":omega-config-base", configuration: "namedElements") implementation project(path: ":omega-config-base", configuration: "namedElements")
+11 -9
View File
@@ -1,17 +1,19 @@
# Done to increase the memory available to gradle. # Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx2G org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true
# Fabric Properties # Fabric Properties
# check these on https://fabricmc.net/versions.html # check these on https://fabricmc.net/versions.html
minecraft_version=1.20.6 minecraft_version=1.20.1
yarn_mappings=1.20.6+build.3 yarn_mappings=1.20.1+build.10
loader_version=0.15.11 loader_version=0.16.7
# Fabric API
fabric_version=0.100.2+1.20.6
# Mod Properties # Mod Properties
mod_version=1.4.3 mod_version=1.4.1
maven_group=dev.draylar maven_group=dev.bigduckie
archives_base_name=omega-config archives_base_name=omega-config
# Dependencies
fabric_version=0.92.2+1.20.1
modmenu_version=7.1.0 modmenu_version=7.1.0
+3 -1
View File
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists 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 zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists 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.Comment;
import draylar.omegaconfig.api.Config; import draylar.omegaconfig.api.Config;
import draylar.omegaconfig.gson.SyncableExclusionStrategy; import draylar.omegaconfig.gson.SyncableExclusionStrategy;
import io.netty.buffer.Unpooled;
import net.fabricmc.api.ModInitializer; 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.ServerPlayConnectionEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList; import net.minecraft.nbt.NbtList;
import net.minecraft.network.PacketByteBuf; 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 net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@@ -26,15 +24,45 @@ import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; 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 class OmegaConfig implements ModInitializer {
public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create(); 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 Gson SYNC_ONLY_GSON = new GsonBuilder().addSerializationExclusionStrategy(new SyncableExclusionStrategy()).setPrettyPrinting().create();
public static final Logger LOGGER = LogManager.getLogger(); public static final Logger LOGGER = LogManager.getLogger();
private static final List<Config> REGISTERED_CONFIGURATIONS = new ArrayList<>(); 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) { public static <T extends Config> T register(Class<T> configClass) {
try { try {
// Attempt to instantiate a new instance of this class. // Attempt to instantiate a new instance of this class.
@@ -69,8 +97,8 @@ public class OmegaConfig implements ModInitializer {
return config; return config;
} catch (NoSuchMethodException | InstantiationException | IllegalAccessException | } catch (NoSuchMethodException | InstantiationException | IllegalAccessException |
InvocationTargetException exception) { InvocationTargetException e) {
exception.printStackTrace(); e.printStackTrace();
throw new RuntimeException("No valid constructor found for: " + configClass.getName()); throw new RuntimeException("No valid constructor found for: " + configClass.getName());
} }
} }
@@ -212,38 +240,4 @@ public class OmegaConfig implements ModInitializer {
public static List<Config> getRegisteredConfigurations() { public static List<Config> getRegisteredConfigurations() {
return REGISTERED_CONFIGURATIONS; 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 = new Identifier("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.MinecraftClient;
import net.minecraft.client.RunArgs; import net.minecraft.client.RunArgs;
import net.minecraft.nbt.NbtCompound; import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtList; import net.minecraft.nbt.NbtList;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.Unique;
@@ -30,14 +31,13 @@ public class ClientMixin {
method = "<init>", method = "<init>",
at = @At("RETURN")) at = @At("RETURN"))
private void onReturn(RunArgs args, CallbackInfo ci) { private void onReturn(RunArgs args, CallbackInfo ci) {
ClientPlayNetworking.registerGlobalReceiver(OmegaConfig.SyncConfigPayload.ID, (payload, context) -> { ClientPlayNetworking.registerGlobalReceiver(OmegaConfig.CONFIG_SYNC_PACKET, (client, handler, buf, responseSender) -> {
NbtCompound tag = buf.readNbt();
NbtCompound tag = payload.nbtCompound();
savedClientConfig.clear(); savedClientConfig.clear();
context.client().execute(() -> { client.execute(() -> {
if (tag != null && tag.contains("Configurations")) { if (tag != null && tag.contains("Configurations")) {
NbtList list = tag.getList("Configurations", NbtType.COMPOUND); NbtList list = tag.getList("Configurations", NbtElement.COMPOUND_TYPE);
list.forEach(compound -> { list.forEach(compound -> {
NbtCompound syncedConfiguration = (NbtCompound) compound; NbtCompound syncedConfiguration = (NbtCompound) compound;
String name = syncedConfiguration.getString("ConfigName"); String name = syncedConfiguration.getString("ConfigName");
@@ -6,7 +6,8 @@
"description": "The last config solution you will ever use.", "description": "The last config solution you will ever use.",
"authors": [ "authors": [
"Draylar", "Draylar",
"Frqnny" "Frqnny",
"Big Duckie"
], ],
"entrypoints": { "entrypoints": {
"main": [ "main": [
@@ -30,7 +31,9 @@
}, },
"custom": { "custom": {
"modmenu": { "modmenu": {
"badges": [ "library" ] "badges": [
"library"
]
} }
} }
} }
+1 -1
View File
@@ -1,10 +1,10 @@
pluginManagement { pluginManagement {
repositories { repositories {
jcenter()
maven { maven {
name = 'Fabric' name = 'Fabric'
url = 'https://maven.fabricmc.net/' url = 'https://maven.fabricmc.net/'
} }
mavenCentral()
gradlePluginPortal() gradlePluginPortal()
} }
} }
@@ -8,7 +8,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
//taken straight out of Mo' Structures //taken straight out of Mo Structures
public class StructuresConfigTest implements Config { public class StructuresConfigTest implements Config {
@Comment(""" @Comment("""