Reformated

This commit is contained in:
Frank 2022-06-08 20:57:21 +02:00
parent 079b51e3f6
commit 852e5a6abc
385 changed files with 6924 additions and 5656 deletions

View file

@ -4,51 +4,67 @@ import org.betterx.bclib.BCLib;
import org.betterx.bclib.api.v2.dataexchange.handler.autosync.AutoSync;
public class ClientConfig extends NamedPathConfig {
public static final ConfigToken<Boolean> SUPPRESS_EXPERIMENTAL_DIALOG = ConfigToken.Boolean(false,
"suppressExperimentalDialogOnLoad",
"ui");
public static final ConfigToken<Boolean> SUPPRESS_EXPERIMENTAL_DIALOG = ConfigToken.Boolean(
false,
"suppressExperimentalDialogOnLoad",
"ui"
);
@ConfigUI(topPadding = 12)
public static final ConfigToken<Boolean> ENABLED = ConfigToken.Boolean(true, "enabled", AutoSync.SYNC_CATEGORY);
@ConfigUI(leftPadding = 8)
public static final DependendConfigToken<Boolean> ACCEPT_CONFIGS = DependendConfigToken.Boolean(true,
"acceptConfigs",
AutoSync.SYNC_CATEGORY,
(config) -> config.get(
ENABLED));
public static final DependendConfigToken<Boolean> ACCEPT_CONFIGS = DependendConfigToken.Boolean(
true,
"acceptConfigs",
AutoSync.SYNC_CATEGORY,
(config) -> config.get(
ENABLED)
);
@ConfigUI(leftPadding = 8)
public static final DependendConfigToken<Boolean> ACCEPT_FILES = DependendConfigToken.Boolean(true,
"acceptFiles",
AutoSync.SYNC_CATEGORY,
(config) -> config.get(
ENABLED));
public static final DependendConfigToken<Boolean> ACCEPT_FILES = DependendConfigToken.Boolean(
true,
"acceptFiles",
AutoSync.SYNC_CATEGORY,
(config) -> config.get(
ENABLED)
);
@ConfigUI(leftPadding = 8)
public static final DependendConfigToken<Boolean> ACCEPT_MODS = DependendConfigToken.Boolean(false,
"acceptMods",
AutoSync.SYNC_CATEGORY,
(config) -> config.get(
ENABLED));
public static final DependendConfigToken<Boolean> ACCEPT_MODS = DependendConfigToken.Boolean(
false,
"acceptMods",
AutoSync.SYNC_CATEGORY,
(config) -> config.get(
ENABLED)
);
@ConfigUI(leftPadding = 8)
public static final DependendConfigToken<Boolean> DISPLAY_MOD_INFO = DependendConfigToken.Boolean(true,
"displayModInfo",
AutoSync.SYNC_CATEGORY,
(config) -> config.get(
ENABLED));
public static final DependendConfigToken<Boolean> DISPLAY_MOD_INFO = DependendConfigToken.Boolean(
true,
"displayModInfo",
AutoSync.SYNC_CATEGORY,
(config) -> config.get(
ENABLED)
);
@ConfigUI(topPadding = 12)
public static final ConfigToken<Boolean> DEBUG_HASHES = ConfigToken.Boolean(false,
"debugHashes",
AutoSync.SYNC_CATEGORY);
public static final ConfigToken<Boolean> DEBUG_HASHES = ConfigToken.Boolean(
false,
"debugHashes",
AutoSync.SYNC_CATEGORY
);
@ConfigUI(leftPadding = 8)
public static final ConfigToken<Boolean> CUSTOM_FOG_RENDERING = ConfigToken.Boolean(true,
"customFogRendering",
"rendering");
public static final ConfigToken<Boolean> CUSTOM_FOG_RENDERING = ConfigToken.Boolean(
true,
"customFogRendering",
"rendering"
);
@ConfigUI(leftPadding = 8)
public static final ConfigToken<Boolean> NETHER_THICK_FOG = ConfigToken.Boolean(true,
"netherThickFog",
"rendering");
public static final ConfigToken<Boolean> NETHER_THICK_FOG = ConfigToken.Boolean(
true,
"netherThickFog",
"rendering"
);
public ClientConfig() {
super(BCLib.MOD_ID, "client", false);

View file

@ -139,9 +139,11 @@ public abstract class Config {
return false;
}
protected <T extends Comparable<T>, RE extends ConfigKeeper.RangeEntry<T>> boolean setRanged(ConfigKey key,
T value,
Class<RE> type) {
protected <T extends Comparable<T>, RE extends ConfigKeeper.RangeEntry<T>> boolean setRanged(
ConfigKey key,
T value,
Class<RE> type
) {
try {
ConfigKeeper.RangeEntry<T> entry = keeper.getEntry(key, type);
if (entry == null) return false;
@ -208,8 +210,10 @@ public abstract class Config {
protected List<String> getStringArray(ConfigKey key, List<String> defaultValue) {
List<String> str = keeper.getValue(key, ConfigKeeper.StringArrayEntry.class);
if (str == null) {
ConfigKeeper.StringArrayEntry entry = keeper.registerEntry(key,
new ConfigKeeper.StringArrayEntry(defaultValue));
ConfigKeeper.StringArrayEntry entry = keeper.registerEntry(
key,
new ConfigKeeper.StringArrayEntry(defaultValue)
);
return entry.getValue();
}
return str != null ? str : defaultValue;

View file

@ -1,5 +1,9 @@
package org.betterx.bclib.config;
import org.betterx.bclib.api.v2.dataexchange.handler.autosync.FileContentWrapper;
import org.betterx.bclib.util.JsonFactory;
import org.betterx.bclib.util.Pair;
import net.minecraft.util.GsonHelper;
import com.google.common.collect.Maps;
@ -7,9 +11,6 @@ import com.google.common.reflect.TypeToken;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import org.betterx.bclib.api.v2.dataexchange.handler.autosync.FileContentWrapper;
import org.betterx.bclib.util.JsonFactory;
import org.betterx.bclib.util.Pair;
import java.io.ByteArrayInputStream;
import java.io.File;

View file

@ -1,9 +1,9 @@
package org.betterx.bclib.config;
import net.minecraft.resources.ResourceLocation;
import org.betterx.bclib.util.Pair;
import net.minecraft.resources.ResourceLocation;
import java.util.Arrays;
import org.jetbrains.annotations.NotNull;

View file

@ -1,10 +1,11 @@
package org.betterx.bclib.config;
import org.betterx.bclib.util.JsonFactory;
import net.fabricmc.loader.api.FabricLoader;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import org.betterx.bclib.util.JsonFactory;
import java.io.File;
import java.nio.file.Path;

View file

@ -1,10 +1,10 @@
package org.betterx.bclib.config;
import org.betterx.bclib.BCLib;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import org.betterx.bclib.BCLib;
import java.util.Collections;
public class Configs {
@ -30,13 +30,21 @@ public class Configs {
}
static {
BIOMES_CONFIG.keeper.registerEntry(new ConfigKey("end_land_biomes", "force_include"),
new ConfigKeeper.StringArrayEntry(Collections.EMPTY_LIST));
BIOMES_CONFIG.keeper.registerEntry(new ConfigKey("end_void_biomes", "force_include"),
new ConfigKeeper.StringArrayEntry(Collections.EMPTY_LIST));
BIOMES_CONFIG.keeper.registerEntry(new ConfigKey("nether_biomes", "force_include"),
new ConfigKeeper.StringArrayEntry(Collections.EMPTY_LIST));
BIOMES_CONFIG.keeper.registerEntry(new ConfigKey("nether_biomes", "force_exclude"),
new ConfigKeeper.StringArrayEntry(Collections.EMPTY_LIST));
BIOMES_CONFIG.keeper.registerEntry(
new ConfigKey("end_land_biomes", "force_include"),
new ConfigKeeper.StringArrayEntry(Collections.EMPTY_LIST)
);
BIOMES_CONFIG.keeper.registerEntry(
new ConfigKey("end_void_biomes", "force_include"),
new ConfigKeeper.StringArrayEntry(Collections.EMPTY_LIST)
);
BIOMES_CONFIG.keeper.registerEntry(
new ConfigKey("nether_biomes", "force_include"),
new ConfigKeeper.StringArrayEntry(Collections.EMPTY_LIST)
);
BIOMES_CONFIG.keeper.registerEntry(
new ConfigKey("nether_biomes", "force_exclude"),
new ConfigKeeper.StringArrayEntry(Collections.EMPTY_LIST)
);
}
}

View file

@ -3,16 +3,20 @@ package org.betterx.bclib.config;
import org.betterx.bclib.BCLib;
public class MainConfig extends NamedPathConfig {
public static final ConfigToken<Boolean> APPLY_PATCHES = ConfigToken.Boolean(true,
"applyPatches",
Configs.MAIN_PATCH_CATEGORY);
public static final ConfigToken<Boolean> APPLY_PATCHES = ConfigToken.Boolean(
true,
"applyPatches",
Configs.MAIN_PATCH_CATEGORY
);
@ConfigUI(leftPadding = 8)
public static final ConfigToken<Boolean> REPAIR_BIOMES = DependendConfigToken.Boolean(true,
"repairBiomesOnLoad",
Configs.MAIN_PATCH_CATEGORY,
(config) -> config.get(
APPLY_PATCHES));
public static final ConfigToken<Boolean> REPAIR_BIOMES = DependendConfigToken.Boolean(
true,
"repairBiomesOnLoad",
Configs.MAIN_PATCH_CATEGORY,
(config) -> config.get(
APPLY_PATCHES)
);
public MainConfig() {
super(BCLib.MOD_ID, "main", true, true);

View file

@ -1,9 +1,9 @@
package org.betterx.bclib.config;
import net.minecraft.resources.ResourceLocation;
import org.betterx.bclib.BCLib;
import net.minecraft.resources.ResourceLocation;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.LinkedList;
@ -51,28 +51,34 @@ public class NamedPathConfig extends PathConfig {
public static class DependendConfigToken<T> extends ConfigToken<T> {
protected final Predicate<NamedPathConfig> dependenciesTrue;
protected DependendConfigToken(Class<?> type,
T defaultValue,
String entry,
ResourceLocation path,
Predicate<NamedPathConfig> dependenciesTrue) {
protected DependendConfigToken(
Class<?> type,
T defaultValue,
String entry,
ResourceLocation path,
Predicate<NamedPathConfig> dependenciesTrue
) {
this(type, defaultValue, entry, new String[]{path.getNamespace(), path.getPath()}, dependenciesTrue);
}
protected DependendConfigToken(Class<?> type,
T defaultValue,
String entry,
String path,
Predicate<NamedPathConfig> dependenciesTrue) {
protected DependendConfigToken(
Class<?> type,
T defaultValue,
String entry,
String path,
Predicate<NamedPathConfig> dependenciesTrue
) {
super(type, defaultValue, entry, path);
this.dependenciesTrue = dependenciesTrue;
}
protected DependendConfigToken(Class<?> type,
T defaultValue,
String entry,
String[] path,
Predicate<NamedPathConfig> dependenciesTrue) {
protected DependendConfigToken(
Class<?> type,
T defaultValue,
String entry,
String[] path,
Predicate<NamedPathConfig> dependenciesTrue
) {
super(type, defaultValue, entry, path);
this.dependenciesTrue = dependenciesTrue;
}
@ -81,15 +87,19 @@ public class NamedPathConfig extends PathConfig {
return dependenciesTrue.test(config);
}
public static DependendConfigToken<Boolean> Boolean(boolean defaultValue,
String entry,
String path,
Predicate<NamedPathConfig> dependenciesTrue) {
return new DependendConfigToken<Boolean>(ConfigKeeper.BooleanEntry.class,
defaultValue,
entry,
path,
dependenciesTrue);
public static DependendConfigToken<Boolean> Boolean(
boolean defaultValue,
String entry,
String path,
Predicate<NamedPathConfig> dependenciesTrue
) {
return new DependendConfigToken<Boolean>(
ConfigKeeper.BooleanEntry.class,
defaultValue,
entry,
path,
dependenciesTrue
);
}
}

View file

@ -8,39 +8,53 @@ import java.util.List;
public class ServerConfig extends NamedPathConfig {
public static final ConfigToken<Boolean> ENABLED = ConfigToken.Boolean(true, "enabled", AutoSync.SYNC_CATEGORY);
public static final DependendConfigToken<Boolean> OFFER_CONFIGS = DependendConfigToken.Boolean(true,
"offerConfigs",
AutoSync.SYNC_CATEGORY,
(config) -> config.get(
ENABLED));
public static final DependendConfigToken<Boolean> OFFER_FILES = DependendConfigToken.Boolean(true,
"offerFiles",
AutoSync.SYNC_CATEGORY,
(config) -> config.get(
ENABLED));
public static final DependendConfigToken<Boolean> OFFER_MODS = DependendConfigToken.Boolean(true,
"offerMods",
AutoSync.SYNC_CATEGORY,
(config) -> config.get(
ENABLED));
public static final DependendConfigToken<Boolean> OFFER_ALL_MODS = DependendConfigToken.Boolean(false,
"offerAllMods",
AutoSync.SYNC_CATEGORY,
(config) -> config.get(
OFFER_MODS));
public static final DependendConfigToken<Boolean> SEND_ALL_MOD_INFO = DependendConfigToken.Boolean(false,
"sendAllModInfo",
AutoSync.SYNC_CATEGORY,
(config) -> config.get(
ENABLED));
public static final DependendConfigToken<Boolean> OFFER_CONFIGS = DependendConfigToken.Boolean(
true,
"offerConfigs",
AutoSync.SYNC_CATEGORY,
(config) -> config.get(
ENABLED)
);
public static final DependendConfigToken<Boolean> OFFER_FILES = DependendConfigToken.Boolean(
true,
"offerFiles",
AutoSync.SYNC_CATEGORY,
(config) -> config.get(
ENABLED)
);
public static final DependendConfigToken<Boolean> OFFER_MODS = DependendConfigToken.Boolean(
true,
"offerMods",
AutoSync.SYNC_CATEGORY,
(config) -> config.get(
ENABLED)
);
public static final DependendConfigToken<Boolean> OFFER_ALL_MODS = DependendConfigToken.Boolean(
false,
"offerAllMods",
AutoSync.SYNC_CATEGORY,
(config) -> config.get(
OFFER_MODS)
);
public static final DependendConfigToken<Boolean> SEND_ALL_MOD_INFO = DependendConfigToken.Boolean(
false,
"sendAllModInfo",
AutoSync.SYNC_CATEGORY,
(config) -> config.get(
ENABLED)
);
public static final ConfigToken<List<String>> ADDITIONAL_MODS = ConfigToken.StringArray(new ArrayList<>(0),
"additionalMods",
AutoSync.SYNC_CATEGORY);
public static final ConfigToken<List<String>> EXCLUDED_MODS = ConfigToken.StringArray(new ArrayList<>(0),
"excludeMods",
AutoSync.SYNC_CATEGORY);
public static final ConfigToken<List<String>> ADDITIONAL_MODS = ConfigToken.StringArray(
new ArrayList<>(0),
"additionalMods",
AutoSync.SYNC_CATEGORY
);
public static final ConfigToken<List<String>> EXCLUDED_MODS = ConfigToken.StringArray(
new ArrayList<>(0),
"excludeMods",
AutoSync.SYNC_CATEGORY
);
public ServerConfig() {