diff --git a/libjf-base/src/main/java/io/gitlab/jfronny/libjf/HttpUtils.java b/libjf-base/src/main/java/io/gitlab/jfronny/libjf/HttpUtils.java deleted file mode 100644 index edd417d..0000000 --- a/libjf-base/src/main/java/io/gitlab/jfronny/libjf/HttpUtils.java +++ /dev/null @@ -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 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 _send(String accept, HttpResponse.BodyHandler 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 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 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 sendLines() throws IOException { - return _send("*/*", HttpResponse.BodyHandlers.ofLines()); - } - - public 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)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); - } -} diff --git a/libjf-config-legacy-shim/build.gradle.kts b/libjf-config-legacy-shim/build.gradle.kts deleted file mode 100644 index 1f18088..0000000 --- a/libjf-config-legacy-shim/build.gradle.kts +++ /dev/null @@ -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")) -} diff --git a/libjf-config-legacy-shim/src/client/java/io/gitlab/jfronny/libjf/config/api/WidgetFactory.java b/libjf-config-legacy-shim/src/client/java/io/gitlab/jfronny/libjf/config/api/WidgetFactory.java deleted file mode 100644 index c982e86..0000000 --- a/libjf-config-legacy-shim/src/client/java/io/gitlab/jfronny/libjf/config/api/WidgetFactory.java +++ /dev/null @@ -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) { - } -} diff --git a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/Category.java b/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/Category.java deleted file mode 100644 index 7e1c52f..0000000 --- a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/Category.java +++ /dev/null @@ -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 { -} diff --git a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/ConfigHolder.java b/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/ConfigHolder.java deleted file mode 100644 index 389089c..0000000 --- a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/ConfigHolder.java +++ /dev/null @@ -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 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); -} diff --git a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/ConfigInstance.java b/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/ConfigInstance.java deleted file mode 100644 index 6509f20..0000000 --- a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/ConfigInstance.java +++ /dev/null @@ -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> getEntries(); - Map getPresets(); - default List getReferencedConfigs() { - return List.of(); - } - Map getCategories(); - default void fix() { - for (EntryInfo entry : getEntries()) { - entry.fix(); - } - } - -} diff --git a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/Entry.java b/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/Entry.java deleted file mode 100644 index c248bba..0000000 --- a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/Entry.java +++ /dev/null @@ -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; -} diff --git a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/EntryInfo.java b/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/EntryInfo.java deleted file mode 100644 index 6153287..0000000 --- a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/EntryInfo.java +++ /dev/null @@ -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 { - /** - * @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 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(); -} diff --git a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/JfConfig.java b/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/JfConfig.java deleted file mode 100644 index fd95039..0000000 --- a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/JfConfig.java +++ /dev/null @@ -1,5 +0,0 @@ -package io.gitlab.jfronny.libjf.config.api; - -@Deprecated -public interface JfConfig { -} diff --git a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/Preset.java b/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/Preset.java deleted file mode 100644 index 79df120..0000000 --- a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/Preset.java +++ /dev/null @@ -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 { -} diff --git a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/Verifier.java b/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/Verifier.java deleted file mode 100644 index 9c34822..0000000 --- a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/api/Verifier.java +++ /dev/null @@ -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 { -} diff --git a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/impl/legacy/ConfigHolderImpl.java b/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/impl/legacy/ConfigHolderImpl.java deleted file mode 100644 index 2da0693..0000000 --- a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/impl/legacy/ConfigHolderImpl.java +++ /dev/null @@ -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, io.gitlab.jfronny.libjf.config.api.v1.ConfigInstance> klazzToInstance = new HashMap<>(); - @Override - public void register(String modId, Class config) { - AtomicReference 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 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( - 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.staticToConsumer(klazz, method).addHandler(e -> LibJf.LOGGER.error("Could not apply preset", e))); - } else if (method.isAnnotationPresent(Verifier.class)) { - builder.addVerifier(ReflectiveConfigBuilderImpl.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 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); - } -} diff --git a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/impl/legacy/ConfigInstanceImpl.java b/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/impl/legacy/ConfigInstanceImpl.java deleted file mode 100644 index 2c7dc4f..0000000 --- a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/impl/legacy/ConfigInstanceImpl.java +++ /dev/null @@ -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> getEntries() { - return category.getEntries().stream().>map(EntryInfoImpl::new).toList(); - } - - @Override - public Map getPresets() { - return category.getPresets(); - } - - @Override - public List getReferencedConfigs() { - return category.getReferencedConfigs().stream().map(r -> new ConfigInstanceImpl(root, r)).toList(); - } - - @Override - public Map getCategories() { - return category.getCategories().entrySet().stream().collect(Collectors.toMap( - Map.Entry::getKey, - s -> new ConfigInstanceImpl(root, s.getValue()) - )); - } - - @Override - public void fix() { - category.fix(); - } -} diff --git a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/impl/legacy/EntryInfoImpl.java b/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/impl/legacy/EntryInfoImpl.java deleted file mode 100644 index 108a8d7..0000000 --- a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/impl/legacy/EntryInfoImpl.java +++ /dev/null @@ -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(io.gitlab.jfronny.libjf.config.api.v1.EntryInfo 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(); - } -} diff --git a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/impl/legacy/LegacyRegistrationHook.java b/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/impl/legacy/LegacyRegistrationHook.java deleted file mode 100644 index 882725e..0000000 --- a/libjf-config-legacy-shim/src/main/java/io/gitlab/jfronny/libjf/config/impl/legacy/LegacyRegistrationHook.java +++ /dev/null @@ -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()); - }); - } -} diff --git a/libjf-config-legacy-shim/src/main/resources/fabric.mod.json b/libjf-config-legacy-shim/src/main/resources/fabric.mod.json deleted file mode 100644 index f85773c..0000000 --- a/libjf-config-legacy-shim/src/main/resources/fabric.mod.json +++ /dev/null @@ -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" - } - } -} diff --git a/libjf-config-legacy-shim/src/testmod/java/io/gitlab/jfronny/libjf/config/test/legacy/TestConfig.java b/libjf-config-legacy-shim/src/testmod/java/io/gitlab/jfronny/libjf/config/test/legacy/TestConfig.java deleted file mode 100644 index 73d4a81..0000000 --- a/libjf-config-legacy-shim/src/testmod/java/io/gitlab/jfronny/libjf/config/test/legacy/TestConfig.java +++ /dev/null @@ -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 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; - } - } -} diff --git a/libjf-config-legacy-shim/src/testmod/resources/assets/libjf-config-legacy-shim-testmod/lang/en_us.json b/libjf-config-legacy-shim/src/testmod/resources/assets/libjf-config-legacy-shim-testmod/lang/en_us.json deleted file mode 100644 index 3002237..0000000 --- a/libjf-config-legacy-shim/src/testmod/resources/assets/libjf-config-legacy-shim-testmod/lang/en_us.json +++ /dev/null @@ -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" -} diff --git a/libjf-config-legacy-shim/src/testmod/resources/fabric.mod.json b/libjf-config-legacy-shim/src/testmod/resources/fabric.mod.json deleted file mode 100644 index 4938e1b..0000000 --- a/libjf-config-legacy-shim/src/testmod/resources/fabric.mod.json +++ /dev/null @@ -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"] - } - } - } -} diff --git a/settings.gradle.kts b/settings.gradle.kts index 6687b76..877bd40 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -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")