Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
412ab2c1d0 |
+58
-44
@@ -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_17
|
||||
version = project.mod_version + "+" + project.minecraft_version
|
||||
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
-9
@@ -1,17 +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.20.6
|
||||
yarn_mappings=1.20.6+build.3
|
||||
loader_version=0.15.11
|
||||
|
||||
# Fabric API
|
||||
fabric_version=0.100.2+1.20.6
|
||||
minecraft_version=1.20.1
|
||||
yarn_mappings=1.20.1+build.10
|
||||
loader_version=0.16.7
|
||||
|
||||
# Mod Properties
|
||||
mod_version=1.4.2
|
||||
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
@@ -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
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
jdk:
|
||||
- openjdk17
|
||||
before_install:
|
||||
- sdk install java 17.0.1-open
|
||||
- sdk use java 17.0.1-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 = 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.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": [
|
||||
@@ -14,10 +15,10 @@
|
||||
]
|
||||
},
|
||||
"contact": {
|
||||
"homepage": "https://github.com/Draylar/omega-config",
|
||||
"sources": "https://github.com/Draylar/omega-config",
|
||||
"issues": "https://github.com/Draylar/omega-config/issues"
|
||||
},
|
||||
"homepage": "https://github.com/Draylar/omega-config",
|
||||
"sources": "https://github.com/Draylar/omega-config",
|
||||
"issues": "https://github.com/Draylar/omega-config/issues"
|
||||
},
|
||||
"license": "MIT",
|
||||
"environment": "*",
|
||||
"mixins": [
|
||||
@@ -28,9 +29,11 @@
|
||||
"fabric": "*",
|
||||
"minecraft": "*"
|
||||
},
|
||||
"custom": {
|
||||
"modmenu": {
|
||||
"badges": [ "library" ]
|
||||
}
|
||||
"custom": {
|
||||
"modmenu": {
|
||||
"badges": [
|
||||
"library"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -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("""
|
||||
|
||||
Reference in New Issue
Block a user