Remove deprecated stuff
This commit is contained in:
parent
f9e31f36ef
commit
2be11e2f9f
@ -1,162 +0,0 @@
|
||||
package io.gitlab.jfronny.libjf;
|
||||
|
||||
import io.gitlab.jfronny.commons.serialize.gson.api.v1.GsonHolders;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.*;
|
||||
import java.net.http.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @deprecated User the commons HttpUtils instead
|
||||
*/
|
||||
@Deprecated
|
||||
public class HttpUtils {
|
||||
private static final HttpClient CLIENT = HttpClient.newBuilder().followRedirects(HttpClient.Redirect.ALWAYS).build();
|
||||
|
||||
private enum Method {
|
||||
GET, POST
|
||||
}
|
||||
|
||||
public static class Request {
|
||||
private static final Pattern CURSEFORGE_API = Pattern.compile("(?:http(s)?://)?addons-ecs\\.forgesvc\\.net/api/+");
|
||||
private final String url;
|
||||
private final HttpRequest.Builder builder;
|
||||
private Method method;
|
||||
private int sent = 0;
|
||||
|
||||
public Request(Method method, String url) throws URISyntaxException {
|
||||
this.url = url.replace(" ", "%20");
|
||||
this.builder = HttpRequest.newBuilder()
|
||||
.uri(new URI(this.url))
|
||||
.header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public Request bearer(String token) {
|
||||
builder.header("Authorization", "Bearer " + token);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Request header(String name, String value) {
|
||||
builder.header(name, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Request bodyString(String string) {
|
||||
builder.header("Content-Type", "text/plain");
|
||||
builder.method(method.name(), HttpRequest.BodyPublishers.ofString(string));
|
||||
method = null;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Request bodyForm(String string) {
|
||||
builder.header("Content-Type", "application/x-www-form-urlencoded");
|
||||
builder.method(method.name(), HttpRequest.BodyPublishers.ofString(string));
|
||||
method = null;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Request bodyForm(Map<String, String> entries) {
|
||||
return bodyForm(entries.entrySet()
|
||||
.stream()
|
||||
.map(entry -> URLEncoder.encode(entry.getKey(), StandardCharsets.UTF_8) + '=' + URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8))
|
||||
.collect(Collectors.joining("&")));
|
||||
}
|
||||
|
||||
public Request bodyJson(String string) {
|
||||
builder.header("Content-Type", "application/json");
|
||||
builder.method(method.name(), HttpRequest.BodyPublishers.ofString(string));
|
||||
method = null;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Request bodyJson(Object object) {
|
||||
builder.header("Content-Type", "application/json");
|
||||
builder.method(method.name(), HttpRequest.BodyPublishers.ofString(GsonHolders.API.getGson().toJson(object)));
|
||||
method = null;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private <T> T _send(String accept, HttpResponse.BodyHandler<T> responseBodyHandler) throws IOException {
|
||||
sent++;
|
||||
if (sent > 3) throw new IOException("Attempted third redirect, stopping");
|
||||
builder.header("Accept", accept);
|
||||
if (method != null) builder.method(method.name(), HttpRequest.BodyPublishers.noBody());
|
||||
|
||||
HttpResponse<T> res;
|
||||
try {
|
||||
res = CLIENT.send(builder.build(), responseBodyHandler);
|
||||
} catch (InterruptedException e) {
|
||||
throw new IOException("Could not send request", e);
|
||||
}
|
||||
if (res.statusCode() == 200) return res.body();
|
||||
Optional<String> location = res.headers().firstValue("location");
|
||||
// Redirect
|
||||
if (location.isPresent() && (res.statusCode() == 302 || res.statusCode() == 307) && method == Method.GET) {
|
||||
try {
|
||||
return HttpUtils.get(location.get())._send(accept, responseBodyHandler);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new IOException("Could not follow redirect", e);
|
||||
}
|
||||
}
|
||||
// CurseForge serverside error
|
||||
if (CURSEFORGE_API.matcher(url).matches() && res.statusCode() >= 500 && res.statusCode() < 600) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
throw new IOException("Could not sleep before resending request" + e);
|
||||
}
|
||||
return _send(accept, responseBodyHandler);
|
||||
}
|
||||
throw new IOException("Unexpected return method: " + res.statusCode() + " (URL=" + url + ")");
|
||||
}
|
||||
|
||||
public void send() throws IOException {
|
||||
_send("*/*", HttpResponse.BodyHandlers.discarding());
|
||||
}
|
||||
|
||||
public InputStream sendInputStream() throws IOException {
|
||||
return _send("*/*", HttpResponse.BodyHandlers.ofInputStream());
|
||||
}
|
||||
|
||||
public String sendString() throws IOException {
|
||||
return _send("*/*", HttpResponse.BodyHandlers.ofString());
|
||||
}
|
||||
|
||||
public Stream<String> sendLines() throws IOException {
|
||||
return _send("*/*", HttpResponse.BodyHandlers.ofLines());
|
||||
}
|
||||
|
||||
public <T> T sendJson(Type type) throws IOException {
|
||||
InputStream in = _send("application/json", HttpResponse.BodyHandlers.ofInputStream());
|
||||
return in == null ? null : GsonHolders.API.getGson().fromJson(new InputStreamReader(in), type);
|
||||
}
|
||||
|
||||
private String getString(Object a) throws IOException {
|
||||
if (a instanceof InputStream s) return new String(s.readAllBytes());
|
||||
if (a instanceof String s) return s;
|
||||
if (a instanceof Stream s) return ((Stream<String>)s).collect(Collectors.joining());
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static Request get(String url) throws URISyntaxException {
|
||||
return new Request(Method.GET, url);
|
||||
}
|
||||
|
||||
public static Request post(String url) throws URISyntaxException {
|
||||
return new Request(Method.POST, url);
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
import io.gitlab.jfronny.scripts.*
|
||||
|
||||
base {
|
||||
archivesName.set("libjf-config-legacy-shim")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(devProject(":libjf-base"))
|
||||
api(devProject(":libjf-config-core-v1"))
|
||||
api(devProject(":libjf-config-commands-v1"))
|
||||
api(devProject(":libjf-config-reflect-v1"))
|
||||
api(devProject(":libjf-config-ui-tiny-v1"))
|
||||
api(devProject(":libjf-unsafe-v0"))
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package io.gitlab.jfronny.libjf.config.api;
|
||||
|
||||
import net.minecraft.client.font.TextRenderer;
|
||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||
import net.minecraft.client.gui.widget.ClickableWidget;
|
||||
|
||||
@Deprecated
|
||||
public interface WidgetFactory {
|
||||
Widget build(int screenWidth, TextRenderer textRenderer, ButtonWidget done);
|
||||
|
||||
record Widget(Runnable updateControls, ClickableWidget control) {
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package io.gitlab.jfronny.libjf.config.api;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Deprecated
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface Category {
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package io.gitlab.jfronny.libjf.config.api;
|
||||
|
||||
import io.gitlab.jfronny.libjf.config.impl.legacy.ConfigHolderImpl;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
|
||||
@Deprecated
|
||||
public interface ConfigHolder {
|
||||
static ConfigHolder getInstance() {
|
||||
return new ConfigHolderImpl(io.gitlab.jfronny.libjf.config.api.v1.ConfigHolder.getInstance());
|
||||
}
|
||||
void register(String modId, Class<?> config);
|
||||
Map<String, ConfigInstance> getRegistered();
|
||||
ConfigInstance get(Class<?> configClass);
|
||||
ConfigInstance get(String modId);
|
||||
ConfigInstance get(Path configPath);
|
||||
boolean isRegistered(Class<?> configClass);
|
||||
boolean isRegistered(String modId);
|
||||
boolean isRegistered(Path configPath);
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package io.gitlab.jfronny.libjf.config.api;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Deprecated
|
||||
public interface ConfigInstance {
|
||||
static ConfigInstance get(Class<?> configClass) {
|
||||
return ConfigHolder.getInstance().get(configClass);
|
||||
}
|
||||
static ConfigInstance get(String modId) {
|
||||
return ConfigHolder.getInstance().get(modId);
|
||||
}
|
||||
void load();
|
||||
void write();
|
||||
String getId();
|
||||
String getCategoryPath();
|
||||
default String getTranslationPrefix() {
|
||||
return getId() + ".jfconfig." + getCategoryPath();
|
||||
}
|
||||
List<EntryInfo<?>> getEntries();
|
||||
Map<String, Runnable> getPresets();
|
||||
default List<ConfigInstance> getReferencedConfigs() {
|
||||
return List.of();
|
||||
}
|
||||
Map<String, ConfigInstance> getCategories();
|
||||
default void fix() {
|
||||
for (EntryInfo<?> entry : getEntries()) {
|
||||
entry.fix();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package io.gitlab.jfronny.libjf.config.api;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Deprecated
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Entry {
|
||||
int width() default 100;
|
||||
double min() default Double.NEGATIVE_INFINITY;
|
||||
double max() default Double.POSITIVE_INFINITY;
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
package io.gitlab.jfronny.libjf.config.api;
|
||||
|
||||
import io.gitlab.jfronny.gson.JsonElement;
|
||||
import io.gitlab.jfronny.gson.stream.JsonWriter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Deprecated
|
||||
public interface EntryInfo<T> {
|
||||
/**
|
||||
* @return Get the default value of this entry
|
||||
*/
|
||||
T getDefault();
|
||||
|
||||
/**
|
||||
* Gets the current value
|
||||
* @return The current value
|
||||
*/
|
||||
T getValue() throws IllegalAccessException;
|
||||
|
||||
/**
|
||||
* Set the current value to the parameter
|
||||
* @param value The value to use
|
||||
*/
|
||||
void setValue(T value) throws IllegalAccessException;
|
||||
|
||||
/**
|
||||
* Get the value type of this entry. Will use the class definition, not the current value
|
||||
* @return The type of this entry
|
||||
*/
|
||||
Class<T> getValueType();
|
||||
|
||||
/**
|
||||
* Ensure the current value is within expected bounds.
|
||||
*/
|
||||
void fix();
|
||||
|
||||
/**
|
||||
* Get the name of this entry
|
||||
* @return This entry's name
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Set this entry's value to that of the element
|
||||
* @param element The element to read from
|
||||
*/
|
||||
void loadFromJson(JsonElement element) throws IllegalAccessException;
|
||||
|
||||
/**
|
||||
* Write the currently cached value to the writer
|
||||
* @param writer The writer to write to
|
||||
*/
|
||||
void writeTo(JsonWriter writer, String translationPrefix) throws IOException, IllegalAccessException;
|
||||
|
||||
/**
|
||||
* @return Get the width for this entry
|
||||
*/
|
||||
int getWidth();
|
||||
|
||||
/**
|
||||
* @return Get the minimum value of this entry
|
||||
*/
|
||||
double getMinValue();
|
||||
|
||||
/**
|
||||
* @return Get the maximum value for this entry
|
||||
*/
|
||||
double getMaxValue();
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package io.gitlab.jfronny.libjf.config.api;
|
||||
|
||||
@Deprecated
|
||||
public interface JfConfig {
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package io.gitlab.jfronny.libjf.config.api;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Deprecated
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface Preset {
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package io.gitlab.jfronny.libjf.config.api;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
@Deprecated
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
public @interface Verifier {
|
||||
}
|
@ -1,111 +0,0 @@
|
||||
package io.gitlab.jfronny.libjf.config.impl.legacy;
|
||||
|
||||
import io.gitlab.jfronny.libjf.LibJf;
|
||||
import io.gitlab.jfronny.libjf.config.api.*;
|
||||
import io.gitlab.jfronny.libjf.config.api.v1.ConfigCategory;
|
||||
import io.gitlab.jfronny.libjf.config.api.v1.dsl.CategoryBuilder;
|
||||
import io.gitlab.jfronny.libjf.config.api.v1.dsl.DSL;
|
||||
import io.gitlab.jfronny.libjf.config.api.v1.type.Type;
|
||||
import io.gitlab.jfronny.libjf.config.impl.AuxiliaryMetadata;
|
||||
import io.gitlab.jfronny.libjf.config.impl.dsl.DslEntryInfo;
|
||||
import io.gitlab.jfronny.libjf.config.impl.reflect.ReflectiveConfigBuilderImpl;
|
||||
import net.fabricmc.loader.api.ModContainer;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Deprecated
|
||||
public record ConfigHolderImpl(io.gitlab.jfronny.libjf.config.api.v1.ConfigHolder base) implements ConfigHolder {
|
||||
private static final Map<Class<?>, io.gitlab.jfronny.libjf.config.api.v1.ConfigInstance> klazzToInstance = new HashMap<>();
|
||||
@Override
|
||||
public void register(String modId, Class<?> config) {
|
||||
AtomicReference<ModContainer> mc = new AtomicReference<>();
|
||||
base.migrateFiles(modId);
|
||||
klazzToInstance.put(config, DSL.create(modId).register(builder -> {
|
||||
Optional.ofNullable(AuxiliaryMetadata.forMod(modId)).ifPresent(meta -> meta.applyTo(builder));
|
||||
return applyCategory(builder, config);
|
||||
}));
|
||||
}
|
||||
|
||||
private <T extends CategoryBuilder<?>> T applyCategory(T builder, Class<?> klazz) {
|
||||
for (Field field : klazz.getFields()) {
|
||||
if (field.isAnnotationPresent(Entry.class)) {
|
||||
Entry entry = field.getAnnotation(Entry.class);
|
||||
Object defaultValue = null;
|
||||
try {
|
||||
defaultValue = field.get(null);
|
||||
} catch (IllegalAccessException ignored) {
|
||||
}
|
||||
//noinspection unchecked,rawtypes
|
||||
builder.value(new DslEntryInfo<Object>(
|
||||
field.getName(),
|
||||
defaultValue,
|
||||
() -> field.get(null),
|
||||
v -> field.set(null, v),
|
||||
(Type) Type.ofClass(field.getGenericType()),
|
||||
entry.width(),
|
||||
entry.min(),
|
||||
entry.max()
|
||||
));
|
||||
}
|
||||
}
|
||||
builder.addPreset(ReflectiveConfigBuilderImpl.CONFIG_PRESET_DEFAULT, ConfigCategory::reset);
|
||||
for (Method method : klazz.getMethods()) {
|
||||
try {
|
||||
if (method.isAnnotationPresent(Preset.class)) {
|
||||
builder.addPreset(builder.getTranslationPrefix() + method.getName(), ReflectiveConfigBuilderImpl.<ConfigCategory>staticToConsumer(klazz, method).addHandler(e -> LibJf.LOGGER.error("Could not apply preset", e)));
|
||||
} else if (method.isAnnotationPresent(Verifier.class)) {
|
||||
builder.addVerifier(ReflectiveConfigBuilderImpl.<ConfigCategory>staticToConsumer(klazz, method).addHandler(e -> LibJf.LOGGER.error("Could not run verifier", e)));
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
LibJf.LOGGER.error("Could not process method " + method.getName() + " of config class " + klazz.getName());
|
||||
}
|
||||
}
|
||||
for (Class<?> category : klazz.getClasses()) {
|
||||
if (category.isAnnotationPresent(Category.class)) {
|
||||
String name = category.getSimpleName();
|
||||
name = Character.toLowerCase(name.charAt(0)) + name.substring(1); // camelCase
|
||||
builder.category(name, categoryBuilder -> applyCategory(categoryBuilder, category));
|
||||
}
|
||||
}
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ConfigInstance> getRegistered() {
|
||||
return base.getRegistered().entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, s -> ConfigInstanceImpl.of(s.getValue())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigInstance get(Class<?> configClass) {
|
||||
return ConfigInstanceImpl.of(klazzToInstance.get(configClass));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigInstance get(String modId) {
|
||||
return ConfigInstanceImpl.of(base.get(modId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigInstance get(Path configPath) {
|
||||
return ConfigInstanceImpl.of(base.get(configPath));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegistered(Class<?> configClass) {
|
||||
return klazzToInstance.containsKey(configClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegistered(String modId) {
|
||||
return base.isRegistered(modId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRegistered(Path configPath) {
|
||||
return base.isRegistered(configPath);
|
||||
}
|
||||
}
|
@ -1,72 +0,0 @@
|
||||
package io.gitlab.jfronny.libjf.config.impl.legacy;
|
||||
|
||||
import io.gitlab.jfronny.libjf.config.api.ConfigInstance;
|
||||
import io.gitlab.jfronny.libjf.config.api.EntryInfo;
|
||||
import io.gitlab.jfronny.libjf.config.api.v1.ConfigCategory;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Deprecated
|
||||
public record ConfigInstanceImpl(io.gitlab.jfronny.libjf.config.api.v1.ConfigInstance root, ConfigCategory category) implements ConfigInstance {
|
||||
public ConfigInstanceImpl(io.gitlab.jfronny.libjf.config.api.v1.ConfigInstance instance) {
|
||||
this(Objects.requireNonNull(instance), instance);
|
||||
}
|
||||
|
||||
public static ConfigInstanceImpl of(io.gitlab.jfronny.libjf.config.api.v1.ConfigInstance instance) {
|
||||
return instance == null ? null : new ConfigInstanceImpl(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
root.load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write() {
|
||||
root.write();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return category.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCategoryPath() {
|
||||
return category.getCategoryPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTranslationPrefix() {
|
||||
return category.getTranslationPrefix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EntryInfo<?>> getEntries() {
|
||||
return category.getEntries().stream().<EntryInfo<?>>map(EntryInfoImpl::new).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Runnable> getPresets() {
|
||||
return category.getPresets();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ConfigInstance> getReferencedConfigs() {
|
||||
return category.getReferencedConfigs().stream().<ConfigInstance>map(r -> new ConfigInstanceImpl(root, r)).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ConfigInstance> getCategories() {
|
||||
return category.getCategories().entrySet().stream().collect(Collectors.toMap(
|
||||
Map.Entry::getKey,
|
||||
s -> new ConfigInstanceImpl(root, s.getValue())
|
||||
));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fix() {
|
||||
category.fix();
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
package io.gitlab.jfronny.libjf.config.impl.legacy;
|
||||
|
||||
import io.gitlab.jfronny.gson.JsonElement;
|
||||
import io.gitlab.jfronny.gson.stream.JsonWriter;
|
||||
import io.gitlab.jfronny.libjf.config.api.EntryInfo;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Deprecated
|
||||
public record EntryInfoImpl<T>(io.gitlab.jfronny.libjf.config.api.v1.EntryInfo<T> base) implements EntryInfo {
|
||||
@Override
|
||||
public Object getDefault() {
|
||||
return base.getDefault();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue() throws IllegalAccessException {
|
||||
return base.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setValue(Object value) throws IllegalAccessException {
|
||||
base.setValue((T) value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getValueType() {
|
||||
return base.getValueType().asClass() instanceof Class<?> k ? k : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fix() {
|
||||
base.fix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return base.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadFromJson(JsonElement element) throws IllegalAccessException {
|
||||
base.loadFromJson(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(JsonWriter writer, String translationPrefix) throws IOException, IllegalAccessException {
|
||||
base.writeTo(writer, translationPrefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return base.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMinValue() {
|
||||
return base.getMinValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxValue() {
|
||||
return base.getMaxValue();
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package io.gitlab.jfronny.libjf.config.impl.legacy;
|
||||
|
||||
import io.gitlab.jfronny.libjf.config.api.ConfigHolder;
|
||||
import io.gitlab.jfronny.libjf.config.api.JfConfig;
|
||||
import io.gitlab.jfronny.libjf.config.api.v1.JfCustomConfig;
|
||||
import io.gitlab.jfronny.libjf.config.api.v1.dsl.DSL;
|
||||
import io.gitlab.jfronny.libjf.unsafe.DynamicEntry;
|
||||
|
||||
@Deprecated
|
||||
public class LegacyRegistrationHook implements JfCustomConfig {
|
||||
@Override
|
||||
public void register(DSL.Defaulted dsl) {
|
||||
DynamicEntry.execute("libjf:config", Object.class, s -> {
|
||||
if (s.instance().getClass().isAnnotationPresent(io.gitlab.jfronny.libjf.config.api.v1.JfConfig.class)) return;
|
||||
if (s.instance() instanceof JfCustomConfig) return;
|
||||
if (!(s.instance() instanceof JfConfig)) return;
|
||||
ConfigHolder.getInstance().register(s.modId(), s.instance().getClass());
|
||||
});
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "libjf-config-legacy-shim",
|
||||
"name": "LibJF Config Legacy Shim",
|
||||
"version": "${version}",
|
||||
"provides": ["libjf-config-v0"],
|
||||
"authors": ["JFronny"],
|
||||
"contact": {
|
||||
"email": "projects.contact@frohnmeyer-wds.de",
|
||||
"homepage": "https://jfronny.gitlab.io",
|
||||
"issues": "https://git.frohnmeyer-wds.de/JfMods/LibJF/issues",
|
||||
"sources": "https://git.frohnmeyer-wds.de/JfMods/LibJF"
|
||||
},
|
||||
"license": "MIT",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"libjf:config": [
|
||||
"io.gitlab.jfronny.libjf.config.impl.legacy.LegacyRegistrationHook"
|
||||
]
|
||||
},
|
||||
"depends": {
|
||||
"fabricloader": ">=0.12.0",
|
||||
"minecraft": "*",
|
||||
"libjf-config-core-v1": ">=${version}",
|
||||
"libjf-config-reflect-v1": ">=${version}",
|
||||
"libjf-unsafe-v0": ">=${version}"
|
||||
},
|
||||
"custom": {
|
||||
"modmenu": {
|
||||
"badges": ["library"],
|
||||
"parent": "libjf"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
package io.gitlab.jfronny.libjf.config.test.legacy;
|
||||
|
||||
import io.gitlab.jfronny.commons.serialize.gson.api.Ignore;
|
||||
import io.gitlab.jfronny.libjf.config.api.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TestConfig implements JfConfig {
|
||||
@Entry public static boolean disablePacks = false;
|
||||
@Entry public static Boolean disablePacks2 = false;
|
||||
@Entry public static int intTest = 20;
|
||||
@Entry(min = -6) public static float floatTest = -5;
|
||||
@Entry(max = 21) public static double doubleTest = 20;
|
||||
@Entry public static String dieStr = "lolz";
|
||||
@Entry @Ignore
|
||||
public static String guiOnlyStr = "lolz";
|
||||
public static String gsonOnlyStr = "lolz";
|
||||
@Entry public static Test enumTest = Test.Test;
|
||||
@Entry public static List<String> stringList;
|
||||
|
||||
@Preset
|
||||
public static void moskau() {
|
||||
disablePacks = true;
|
||||
disablePacks2 = true;
|
||||
intTest = -5;
|
||||
floatTest = -6;
|
||||
doubleTest = 4;
|
||||
dieStr = "Moskau";
|
||||
}
|
||||
|
||||
@Verifier
|
||||
public static void setIntTestIfDisable() {
|
||||
if (disablePacks) intTest = 0;
|
||||
}
|
||||
|
||||
@Verifier
|
||||
public static void stringListVerifier() {
|
||||
if (stringList == null) stringList = new ArrayList<>(List.of("Obama"));
|
||||
}
|
||||
|
||||
public enum Test {
|
||||
Test, ER
|
||||
}
|
||||
|
||||
@Category
|
||||
public static class Subcategory {
|
||||
@Entry public static boolean boolInSub = false;
|
||||
@Entry public static int intIbSub = 15;
|
||||
|
||||
@Category
|
||||
public static class Inception {
|
||||
@Entry public static Test yesEnum = Test.ER;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
{
|
||||
"libjf-config-legacy-shim-testmod.jfconfig.title": "JfConfig example",
|
||||
"libjf-config-legacy-shim-testmod.jfconfig.disablePacks": "Disable resource packs",
|
||||
"libjf-config-legacy-shim-testmod.jfconfig.intTest": "Int Test",
|
||||
"libjf-config-legacy-shim-testmod.jfconfig.decimalTest": "Decimal Test",
|
||||
"libjf-config-legacy-shim-testmod.jfconfig.dieStr": "String Test",
|
||||
"libjf-config-legacy-shim-testmod.jfconfig.gsonOnlyStr.tooltip": "George",
|
||||
"libjf-config-legacy-shim-testmod.jfconfig.enumTest": "Enum Test",
|
||||
"libjf-config-legacy-shim-testmod.jfconfig.enumTest.tooltip": "Enum Test Tooltip",
|
||||
"libjf-config-legacy-shim-testmod.jfconfig.enum.Test.Test": "Test",
|
||||
"libjf-config-legacy-shim-testmod.jfconfig.enum.Test.ER": "ER",
|
||||
"libjf-config-legacy-shim-testmod.jfconfig.moskau": "Moskau"
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "libjf-config-legacy-shim-testmod",
|
||||
"version": "1.0",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"libjf:config": [
|
||||
"io.gitlab.jfronny.libjf.config.test.legacy.TestConfig"
|
||||
]
|
||||
},
|
||||
"depends": {
|
||||
"libjf-config-v0": "*"
|
||||
},
|
||||
"custom": {
|
||||
"libjf": {
|
||||
"config": {
|
||||
"referencedConfigs": ["libjf-web-v0"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -14,7 +14,6 @@ include("libjf-config-core-v1")
|
||||
include("libjf-config-reflect-v1")
|
||||
include("libjf-config-commands-v1")
|
||||
include("libjf-config-ui-tiny-v1")
|
||||
include("libjf-config-legacy-shim")
|
||||
include("libjf-data-v0")
|
||||
include("libjf-data-manipulation-v0")
|
||||
include("libjf-devutil")
|
||||
|
Loading…
Reference in New Issue
Block a user