Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build_1605.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ jobs:
with:
fetch-depth: 30

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
cache: gradle

- name: Grant execute permission for gradlew
Expand Down
29 changes: 19 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.7-SNAPSHOT" apply false
id('xyz.wagyourtail.jvmdowngrader').version("${jvmdowngrader_version}").apply(false)
}

architectury {
minecraft = rootProject.minecraft_version
minecraft = minecraft_version
}

subprojects {
Expand All @@ -14,14 +15,21 @@ subprojects {
silentMojangMappingsLicense()
}

repositories {
maven {
name = 'ParchmentMC'
url = 'https://maven.parchmentmc.org'
}
}

dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
mappings loom.officialMojangMappings()
//jabel, for modern Java syntax
//https://central.sonatype.com/artifact/com.pkware.jabel/jabel-javac-plugin
annotationProcessor 'com.pkware.jabel:jabel-javac-plugin:1.0.1-1'
compileOnly 'com.pkware.jabel:jabel-javac-plugin:1.0.1-1'
//lambok: https://projectlombok.org/setup/gradle
minecraft("com.mojang:minecraft:${rootProject.minecraft_version}")
mappings(loom.layered {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${rootProject.parchment_version}@zip")
})

//lombok: https://projectlombok.org/setup/gradle
compileOnly 'org.projectlombok:lombok:1.18.34'
annotationProcessor 'org.projectlombok:lombok:1.18.34'
}
Expand All @@ -31,6 +39,7 @@ allprojects {
apply plugin: "java"
apply plugin: "architectury-plugin"
apply plugin: "maven-publish"
apply plugin: 'xyz.wagyourtail.jvmdowngrader'

//not accessible from time to time
// apply from: "https://files.latmod.com/public/markdown-git-changelog.gradle"
Expand All @@ -40,14 +49,14 @@ allprojects {
group = project.maven_group
archivesBaseName = project.archives_base_name

tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
options.encoding = "UTF-8"
sourceCompatibility = 21

// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
options.release = 8
// options.release = 8
}

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import dev.latvian.kubejs.block.*;
import dev.latvian.kubejs.block.custom.*;
import dev.latvian.kubejs.block.custom.builder.*;
import dev.latvian.kubejs.block.predicate.BlockStatePredicate;
import dev.latvian.kubejs.block.BlockStatePredicate;
import dev.latvian.kubejs.client.painter.Painter;
import dev.latvian.kubejs.client.painter.screen.*;
import dev.latvian.kubejs.entity.EntityJS;
Expand Down Expand Up @@ -566,12 +566,12 @@ public void generateAssetJsons(AssetJsonGenerator generator) {
}

@Override
public void generateLang(Map<String, String> lang) {
lang.put("itemGroup.kubejs.kubejs", "KubeJS");
public void generateLang(Map<String, String> enusLang) {
enusLang.put("itemGroup.kubejs.kubejs", KubeJS.MOD_NAME);

for (val builder : RegistryInfos.ALL_BUILDERS) {
if (builder.overrideLangJson && builder.display != null) {
lang.put(builder.getTranslationKey(), builder.display.getString());
enusLang.put(builder.getTranslationKey(), builder.display.getString());
}
}
}
Expand Down
189 changes: 108 additions & 81 deletions common/src/main/java/dev/latvian/kubejs/CommonProperties.java
Original file line number Diff line number Diff line change
@@ -1,91 +1,118 @@
package dev.latvian.kubejs;

import java.io.Reader;
import java.io.Writer;
import dev.latvian.kubejs.util.KubeJSPlugins;
import lombok.val;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Properties;

/**
* @author LatvianModder
*/
public class CommonProperties {
private static CommonProperties instance;

public static CommonProperties get() {
if (instance == null) {
instance = new CommonProperties();
}

return instance;
}

private final Properties properties;
private boolean writeProperties;

public boolean hideServerScriptErrors;
public boolean serverOnly;
public boolean announceReload;
public boolean invertClassLoader;
public String packMode;
public boolean debugInfo;

private CommonProperties() {
properties = new Properties();

try {
Path propertiesFile = KubeJSPaths.CONFIG.resolve("common.properties");
writeProperties = false;

if (Files.exists(propertiesFile)) {
try (Reader reader = Files.newBufferedReader(propertiesFile)) {
properties.load(reader);
}
} else {
writeProperties = true;
}

hideServerScriptErrors = get("hideServerScriptErrors", false);
serverOnly = get("serverOnly", false);
announceReload = get("announceReload", true);
invertClassLoader = "true".equals(properties.getProperty("invertClassLoader")); // Advanced option, not recommended to be set to true
packMode = get("packmode", "default");
debugInfo = get("debugInfo", false);

if (writeProperties) {
try (Writer writer = Files.newBufferedWriter(propertiesFile)) {
properties.store(writer, "KubeJS Common Properties");
}
}
} catch (Exception ex) {
ex.printStackTrace();
}

KubeJS.LOGGER.info("Loaded common.properties");
}

private void remove(String key) {
String s = properties.getProperty(key);

if (s != null) {
properties.remove(key);
writeProperties = true;
}
}

private String get(String key, String def) {
String s = properties.getProperty(key);

if (s == null) {
properties.setProperty(key, def);
writeProperties = true;
return def;
}

return s;
}

private boolean get(String key, boolean def) {
return get(key, def ? "true" : "false").equals("true");
}
private static CommonProperties INSTANCE;

public static CommonProperties get() {
if (INSTANCE == null) {
INSTANCE = new CommonProperties();
}

return INSTANCE;
}

public static void reload() {
INSTANCE = new CommonProperties();
}

private final Properties properties;
private boolean writeProperties;

public boolean hideServerScriptErrors;
public boolean serverOnly;
public boolean announceReload;
public boolean invertClassLoader;
public String packMode;
public boolean debugInfo;
public boolean saveDevPropertiesInConfig;
public boolean allowAsyncStreams;
public boolean matchJsonRecipes;
public boolean ignoreCustomUniqueRecipeIds;
public boolean startupErrorGUI;
public String startupErrorReportUrl;

private CommonProperties() {
properties = new Properties();

try {
writeProperties = false;

if (Files.exists(KubeJSPaths.COMMON_PROPERTIES)) {
try (val reader = Files.newBufferedReader(KubeJSPaths.COMMON_PROPERTIES)) {
properties.load(reader);
}
} else {
writeProperties = true;
}

hideServerScriptErrors = get("hideServerScriptErrors", false);
serverOnly = get("serverOnly", false);
announceReload = get("announceReload", true);
packMode = get("packmode", "");
saveDevPropertiesInConfig = get("saveDevPropertiesInConfig", false);
allowAsyncStreams = get("allowAsyncStreams", true);
matchJsonRecipes = get("matchJsonRecipes", true);
ignoreCustomUniqueRecipeIds = get("ignoreCustomUniqueRecipeIds", false);
startupErrorGUI = get("startupErrorGUI", false);
startupErrorReportUrl = get("startupErrorReportUrl", "");

KubeJSPlugins.forEachPlugin(p -> p.loadCommonProperties(this));

if (writeProperties) {
save();
}
} catch (Exception ex) {
ex.printStackTrace();
}

KubeJS.LOGGER.info("Loaded common.properties");
}

public void remove(String key) {
val s = properties.getProperty(key);

if (s != null) {
properties.remove(key);
writeProperties = true;
}
}

public String get(String key, String def) {
val s = properties.getProperty(key);

if (s == null) {
properties.setProperty(key, def);
writeProperties = true;
return def;
}

return s;
}

public boolean get(String key, boolean def) {
return get(key, def ? "true" : "false").equals("true");
}

public void save() {
try (val writer = Files.newBufferedWriter(KubeJSPaths.COMMON_PROPERTIES)) {
properties.store(writer, "KubeJS Common Properties");
} catch (Exception ex) {
ex.printStackTrace();
}
}

public void setPackMode(String s) {
packMode = s;
properties.setProperty("packmode", s);
save();
}
}
Loading
Loading