Attempt to use gradle with JDK 16 and fix server
This commit is contained in:
parent
632f5a85b8
commit
40ecca4904
@ -1,4 +1,4 @@
|
||||
image: gradle:alpine
|
||||
image: gradle:jdk16
|
||||
|
||||
variables:
|
||||
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
|
||||
|
70
build.gradle
70
build.gradle
@ -1,19 +1,6 @@
|
||||
import groovy.json.JsonOutput
|
||||
import groovy.json.JsonSlurper
|
||||
import proguard.gradle.ProGuardTask
|
||||
import net.fabricmc.loom.task.RunClientTask
|
||||
import net.fabricmc.loom.task.RunServerTask
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
google()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.guardsquare:proguard-gradle:7.0.1'
|
||||
}
|
||||
}
|
||||
import net.fabricmc.loom.configuration.ide.RunConfigSettings
|
||||
import net.fabricmc.loom.task.RunGameTask
|
||||
import net.fabricmc.loom.LoomGradleExtension
|
||||
|
||||
plugins {
|
||||
id 'fabric-loom' version '0.7-SNAPSHOT'
|
||||
@ -29,7 +16,6 @@ group = project.maven_group
|
||||
|
||||
repositories {
|
||||
maven { url = 'https://maven.terraformersmc.com/'; name = "ModMenu" }
|
||||
maven { url "https://maven.shedaniel.me/" }
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
@ -39,14 +25,6 @@ sourceSets {
|
||||
}
|
||||
}
|
||||
|
||||
task runTestmodClient(type: RunClientTask) {
|
||||
classpath sourceSets.testmod.runtimeClasspath
|
||||
}
|
||||
|
||||
task runTestmodServer(type: RunServerTask) {
|
||||
classpath sourceSets.testmod.runtimeClasspath
|
||||
}
|
||||
|
||||
dependencies {
|
||||
//to change the versions see the gradle.properties file
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
@ -56,40 +34,20 @@ dependencies {
|
||||
modImplementation "com.terraformersmc:modmenu:1.16.9"
|
||||
}
|
||||
|
||||
task runTestmodClient(type: RunGameTask, constructorArgs: [getExtensions().getByType(LoomGradleExtension.class).getRunConfigs().getByName("client")]) {
|
||||
classpath sourceSets.testmod.runtimeClasspath
|
||||
}
|
||||
|
||||
task runTestmodServer(type: RunGameTask, constructorArgs: [getExtensions().getByType(LoomGradleExtension.class).getRunConfigs().getByName("server")]) {
|
||||
classpath sourceSets.testmod.runtimeClasspath
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include "fabric.mod.json"
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version
|
||||
}
|
||||
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude "fabric.mod.json"
|
||||
}
|
||||
|
||||
doLast {
|
||||
fileTree(dir: outputs.files.asPath, include: "**/*.json").each {
|
||||
File file -> file.text = JsonOutput.toJson(new JsonSlurper().parse(file))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def proguardJarOut = file(jar.archiveFile.get().getAsFile().absolutePath.replace(".jar", "-min.jar"))
|
||||
|
||||
task proguardJar(type: ProGuardTask, dependsOn: jar) {
|
||||
configuration './proguard.conf'
|
||||
verbose
|
||||
injars jar.archiveFile.get().getAsFile()
|
||||
outjars proguardJarOut
|
||||
libraryjars files(configurations.compileClasspath)
|
||||
printmapping 'out.map'
|
||||
}
|
||||
|
||||
tasks.remapJar {
|
||||
input.set proguardJarOut
|
||||
archiveClassifier.set null
|
||||
dependsOn proguardJar
|
||||
}
|
||||
|
||||
// ensure that the encoding is set to UTF-8, no matter what the system default is
|
||||
@ -97,6 +55,10 @@ tasks.remapJar {
|
||||
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
def targetVersion = 8
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
it.options.release = targetVersion
|
||||
}
|
||||
}
|
||||
|
||||
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
||||
|
@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G
|
||||
# Fabric Properties
|
||||
# check these on https://modmuss50.me/fabric.html
|
||||
minecraft_version=1.16.5
|
||||
yarn_mappings=1.16.5+build.6
|
||||
yarn_mappings=1.16.5+build.9
|
||||
loader_version=0.11.3
|
||||
# Mod Properties
|
||||
mod_version=1.0.0
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -1,11 +0,0 @@
|
||||
-libraryjars <java.home>/jmods/java.base.jmod(!**.jar;!module-info.class)
|
||||
-keep public class io.gitlab.jfronny.libjf.config.JfConfig {
|
||||
public protected *;
|
||||
}
|
||||
-keep public class io.gitlab.jfronny.libjf.Libjf
|
||||
-keep public class io.gitlab.jfronny.libjf.config.ModMenu
|
||||
-repackageclasses 'jf.lib'
|
||||
-allowaccessmodification
|
||||
-overloadaggressively
|
||||
-optimizationpasses 5
|
||||
-optimizations '*'
|
23
src/main/java/io/gitlab/jfronny/libjf/LibjfClient.java
Normal file
23
src/main/java/io/gitlab/jfronny/libjf/LibjfClient.java
Normal file
@ -0,0 +1,23 @@
|
||||
package io.gitlab.jfronny.libjf;
|
||||
|
||||
import io.gitlab.jfronny.libjf.config.Config;
|
||||
import io.gitlab.jfronny.libjf.config.Entry;
|
||||
import io.gitlab.jfronny.libjf.config.EntryInfo;
|
||||
import io.gitlab.jfronny.libjf.gson.GsonHidden;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
|
||||
public class LibjfClient implements ClientModInitializer {
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
for (Config config : Libjf.getConfigs().values()) {
|
||||
Libjf.LOGGER.info("Registring config UI for " + config.modid);
|
||||
for (EntryInfo info : config.entries) {
|
||||
if (info.field.isAnnotationPresent(Entry.class) || info.field.isAnnotationPresent(GsonHidden.class))
|
||||
try {
|
||||
config.initClient(info);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -38,55 +38,51 @@ public class Config {
|
||||
|
||||
for (Field field : config.getFields()) {
|
||||
EntryInfo info = new EntryInfo();
|
||||
if (field.isAnnotationPresent(Entry.class) || field.isAnnotationPresent(GsonHidden.class))
|
||||
try {
|
||||
initClient(field, info);
|
||||
} catch (Exception e) {continue;}
|
||||
info.field = field;
|
||||
if (field.isAnnotationPresent(Entry.class))
|
||||
try {
|
||||
info.defaultValue = field.get(null);
|
||||
} catch (IllegalAccessException ignored) {}
|
||||
entries.add(info);
|
||||
}
|
||||
try {
|
||||
Libjf.GSON.fromJson(Files.newBufferedReader(path), config); }
|
||||
catch (Exception e) { write(); }
|
||||
|
||||
for (EntryInfo info : entries) {
|
||||
if (info.field.isAnnotationPresent(Entry.class))
|
||||
try {
|
||||
info.value = info.field.get(null);
|
||||
info.tempValue = info.value.toString();
|
||||
} catch (IllegalAccessException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void initClient(Field field, EntryInfo info) {
|
||||
Class<?> type = field.getType();
|
||||
Entry e = field.getAnnotation(Entry.class);
|
||||
info.width = e != null ? e.width() : 0;
|
||||
info.field = field;
|
||||
|
||||
if (e != null)
|
||||
if (type == int.class) textField(info, Integer::parseInt, INTEGER_ONLY, e.min(), e.max(), true);
|
||||
else if (type == double.class) textField(info, Double::parseDouble, DECIMAL_ONLY, e.min(), e.max(),false);
|
||||
else if (type == String.class) textField(info, String::length, null, Math.min(e.min(),0), Math.max(e.max(),1),true);
|
||||
else if (type == boolean.class) {
|
||||
Function<Object,Text> func = value -> new LiteralText((Boolean) value ? "True" : "False").formatted((Boolean) value ? Formatting.GREEN : Formatting.RED);
|
||||
info.widget = new AbstractMap.SimpleEntry<ButtonWidget.PressAction, Function<Object, Text>>(button -> {
|
||||
info.value = !(Boolean) info.value;
|
||||
button.setMessage(func.apply(info.value));
|
||||
}, func);
|
||||
} else if (type.isEnum()) {
|
||||
List<?> values = Arrays.asList(field.getType().getEnumConstants());
|
||||
Function<Object,Text> func = value -> new TranslatableText(modid + ".jfconfig." + "enum." + type.getSimpleName() + "." + info.value.toString());
|
||||
info.widget = new AbstractMap.SimpleEntry<ButtonWidget.PressAction, Function<Object,Text>>( button -> {
|
||||
int index = values.indexOf(info.value) + 1;
|
||||
info.value = values.get(index >= values.size()? 0 : index);
|
||||
button.setMessage(func.apply(info.value));
|
||||
}, func);
|
||||
}
|
||||
entries.add(info);
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void initClient(EntryInfo info) {
|
||||
if (!(info.field.isAnnotationPresent(Entry.class) || info.field.isAnnotationPresent(GsonHidden.class))) return;
|
||||
Class<?> type = info.field.getType();
|
||||
Entry e = info.field.getAnnotation(Entry.class);
|
||||
info.width = e != null ? e.width() : 0;
|
||||
|
||||
if (e == null) return;
|
||||
|
||||
if (type == int.class) textField(info, Integer::parseInt, INTEGER_ONLY, e.min(), e.max(), true);
|
||||
else if (type == double.class) textField(info, Double::parseDouble, DECIMAL_ONLY, e.min(), e.max(),false);
|
||||
else if (type == String.class) textField(info, String::length, null, Math.min(e.min(),0), Math.max(e.max(),1),true);
|
||||
else if (type == boolean.class) {
|
||||
Function<Object,Text> func = value -> new LiteralText((Boolean) value ? "True" : "False").formatted((Boolean) value ? Formatting.GREEN : Formatting.RED);
|
||||
info.widget = new AbstractMap.SimpleEntry<ButtonWidget.PressAction, Function<Object, Text>>(button -> {
|
||||
info.value = !(Boolean) info.value;
|
||||
button.setMessage(func.apply(info.value));
|
||||
}, func);
|
||||
} else if (type.isEnum()) {
|
||||
List<?> values = Arrays.asList(info.field.getType().getEnumConstants());
|
||||
Function<Object,Text> func = value -> new TranslatableText(modid + ".jfconfig." + "enum." + type.getSimpleName() + "." + info.value.toString());
|
||||
info.widget = new AbstractMap.SimpleEntry<ButtonWidget.PressAction, Function<Object,Text>>( button -> {
|
||||
int index = values.indexOf(info.value) + 1;
|
||||
info.value = values.get(index >= values.size()? 0 : index);
|
||||
button.setMessage(func.apply(info.value));
|
||||
}, func);
|
||||
}
|
||||
|
||||
try {
|
||||
info.value = info.field.get(null);
|
||||
info.tempValue = info.value.toString();
|
||||
} catch (IllegalAccessException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
private void textField(EntryInfo info, Function<String,Number> f, Pattern pattern, double min, double max, boolean cast) {
|
||||
|
@ -18,13 +18,13 @@
|
||||
"preLaunch": [
|
||||
"io.gitlab.jfronny.libjf.Libjf"
|
||||
],
|
||||
"client": [
|
||||
"io.gitlab.jfronny.libjf.LibjfClient"
|
||||
],
|
||||
"modmenu": [
|
||||
"io.gitlab.jfronny.libjf.config.ModMenu"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"libjf.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.11.3",
|
||||
"minecraft": "1.16.5"
|
||||
|
@ -1,13 +0,0 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "io.gitlab.jfronny.libjf.mixin",
|
||||
"compatibilityLevel": "JAVA_8",
|
||||
"mixins": [
|
||||
],
|
||||
"client": [
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user