mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-11 10:16:15 +00:00
Added biome-key-format configuration option to config.yml
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
package com.dfsek.terra.api.config;
|
||||
|
||||
import com.dfsek.terra.api.Platform;
|
||||
import com.dfsek.terra.api.registry.key.RegistryKey;
|
||||
|
||||
|
||||
public interface PluginConfig {
|
||||
@@ -23,6 +24,20 @@ public interface PluginConfig {
|
||||
|
||||
boolean isDebugLog();
|
||||
|
||||
String getBiomeKeyFormat();
|
||||
|
||||
default RegistryKey getBiomeKey(ConfigPack pack, RegistryKey biomeKey) {
|
||||
String format = this.getBiomeKeyFormat()
|
||||
.replace("%pack_id%", pack.getID().toLowerCase())
|
||||
.replace("%biome_namespace%", biomeKey.getNamespace().toLowerCase())
|
||||
.replace("%biome_id%", biomeKey.getID().toLowerCase());
|
||||
if (format.contains(":")) {
|
||||
return RegistryKey.parse(format);
|
||||
} else {
|
||||
return RegistryKey.of("terra", format);
|
||||
}
|
||||
}
|
||||
|
||||
int getBiomeSearchResolution();
|
||||
|
||||
int getStructureCache();
|
||||
|
||||
@@ -5,20 +5,20 @@ import java.util.regex.Pattern;
|
||||
|
||||
|
||||
public final class RegistryKey implements StringIdentifiable, Namespaced {
|
||||
private static final Pattern ID_PATTERN = Pattern.compile("^[a-zA-Z0-9_-]*$");
|
||||
private static final Pattern ID_PATTERN = Pattern.compile("^[a-zA-Z0-9/_-]*$");
|
||||
private final String namespace;
|
||||
private final String id;
|
||||
|
||||
private RegistryKey(String namespace, String id) {
|
||||
if(!ID_PATTERN.matcher(namespace).matches()) {
|
||||
throw new IllegalArgumentException(
|
||||
"Namespace must only contain alphanumeric characters, hyphens, and underscores. \"" + namespace +
|
||||
"Namespace must only contain alphanumeric characters, hyphens, underscores and forward slashes. \"" + namespace +
|
||||
"\" is not a valid namespace.");
|
||||
}
|
||||
|
||||
if(!ID_PATTERN.matcher(id).matches()) {
|
||||
throw new IllegalArgumentException(
|
||||
"ID must only contain alphanumeric characters, hyphens, and underscores. \"" + id +
|
||||
"ID must only contain alphanumeric characters, hyphens, underscores and forward slashes. \"" + id +
|
||||
"\" is not a valid ID.");
|
||||
}
|
||||
|
||||
|
||||
@@ -55,6 +55,10 @@ public class PluginConfigImpl implements ConfigTemplate, PluginConfig {
|
||||
@Default
|
||||
private boolean debugLog = false;
|
||||
|
||||
@Value("biome-key-format")
|
||||
@Default
|
||||
private String biomeKeyFormat = "%pack_id%/%biome_namespace%/%biome_id%";
|
||||
|
||||
@Value("biome-search-resolution")
|
||||
@Default
|
||||
private int biomeSearch = 4;
|
||||
@@ -124,6 +128,11 @@ public class PluginConfigImpl implements ConfigTemplate, PluginConfig {
|
||||
return debugLog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBiomeKeyFormat() {
|
||||
return biomeKeyFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBiomeSearchResolution() {
|
||||
return biomeSearch;
|
||||
|
||||
@@ -11,6 +11,7 @@ debug:
|
||||
profiler: false
|
||||
script: false
|
||||
dump-default: true
|
||||
biome-key-format: "%pack_id%/%biome_namespace%/%biome_id%"
|
||||
biome-search-resolution: 4
|
||||
cache:
|
||||
structure: 32
|
||||
|
||||
Reference in New Issue
Block a user