From c965923c632ba8bb8f00e162e6358424827fc351 Mon Sep 17 00:00:00 2001 From: TexTrue <3140846162@qq.com> Date: Sun, 18 Aug 2024 13:51:07 +0800 Subject: [PATCH] clean --- .../api/{config/v2 => }/AzusaConfig.java | 4 +- .../azusaconfig/api/config/AzusaConfig.java | 295 ------------------ .../impl/{config => }/AzusaConfigImpl.java | 2 +- .../fabric/AzusaConfigModFabric.java | 2 +- .../neoforge/AzusaConfigModNeoForge.java | 6 +- 5 files changed, 5 insertions(+), 304 deletions(-) rename common/src/main/java/ho/artisan/azusaconfig/api/{config/v2 => }/AzusaConfig.java (98%) delete mode 100644 common/src/main/java/ho/artisan/azusaconfig/api/config/AzusaConfig.java rename common/src/main/java/ho/artisan/azusaconfig/impl/{config => }/AzusaConfigImpl.java (98%) diff --git a/common/src/main/java/ho/artisan/azusaconfig/api/config/v2/AzusaConfig.java b/common/src/main/java/ho/artisan/azusaconfig/api/AzusaConfig.java similarity index 98% rename from common/src/main/java/ho/artisan/azusaconfig/api/config/v2/AzusaConfig.java rename to common/src/main/java/ho/artisan/azusaconfig/api/AzusaConfig.java index c40f6aa..1fd4a60 100644 --- a/common/src/main/java/ho/artisan/azusaconfig/api/config/v2/AzusaConfig.java +++ b/common/src/main/java/ho/artisan/azusaconfig/api/AzusaConfig.java @@ -15,9 +15,9 @@ * limitations under the License. */ -package ho.artisan.azusaconfig.api.config.v2; +package ho.artisan.azusaconfig.api; -import ho.artisan.azusaconfig.impl.config.AzusaConfigImpl; +import ho.artisan.azusaconfig.impl.AzusaConfigImpl; import org.quiltmc.config.api.Config; import org.quiltmc.config.api.ReflectiveConfig; import org.quiltmc.config.impl.ConfigImpl; diff --git a/common/src/main/java/ho/artisan/azusaconfig/api/config/AzusaConfig.java b/common/src/main/java/ho/artisan/azusaconfig/api/config/AzusaConfig.java deleted file mode 100644 index 635a3db..0000000 --- a/common/src/main/java/ho/artisan/azusaconfig/api/config/AzusaConfig.java +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright 2022, 2023 QuiltMC - * Copyright 2024 HO-Artisan - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package ho.artisan.azusaconfig.api.config; - -import java.nio.file.Path; -import java.nio.file.Paths; - -import ho.artisan.azusaconfig.impl.config.AzusaConfigImpl; -import org.quiltmc.config.api.Config; -import org.quiltmc.config.api.WrappedConfig; -import org.quiltmc.config.api.annotations.ConfigFieldAnnotationProcessor; -import org.quiltmc.config.api.values.ValueList; -import org.quiltmc.config.api.values.ValueMap; -import org.quiltmc.config.impl.ConfigImpl; - -/** - * Class containing helper methods that mods should use to create config files as part of Quilt's config system. - */ -@Deprecated -public final class AzusaConfig { - /** - * Creates and registers a config file - * - * @param family the mod owning the resulting config file - * @param id the configs id - * @param path additional path elements to include as part of this configs file, e.g. - * if the path is empty, the config file might be ".minecraft/config/example_mod/id.toml" - * if the path is "client/gui", the config file might be ".minecraft/config/example_mod/client/gui/id.toml" - * @param creators any number of {@link Config.Creator}s that can be used to configure the resulting config - */ - public static Config create(String family, String id, Path path, Config.Creator... creators) { - return ConfigImpl.create(AzusaConfigImpl.getConfigEnvironment(), family, id, path, creators); - } - - /** - * Creates and registers a config file - * - * @param family the mod owning the resulting config file - * @param id the configs id - * @param creators any number of {@link Config.Creator}s that can be used to configure the resulting config - */ - public static Config create(String family, String id, Config.Creator... creators) { - return create(family, id, Paths.get(""), creators); - } - - /** - * Creates and registers a config with fields derived from the fields of the passed class - * - *

The passed class should have the following characteristics: - *

- * - *

Certain annotations can also be used on fields of this class to attach metadata to them. The {@link org.quiltmc.config.api.annotations.Comment} - * annotation is one such annotation that is provided by default, but additional {@link ConfigFieldAnnotationProcessor}s - * can be registered with {@link ConfigFieldAnnotationProcessor#register(Class, ConfigFieldAnnotationProcessor)}. - * - * @param family the mod owning the resulting config file - * @param id the config's id - * @param path additional path elements to include as part of this configs file, e.g. - * if the path is empty, the config file might be ".minecraft/config/example_mod/id.toml" - * if the path is "client/gui", the config file might be ".minecraft/config/example_mod/client/gui/id.toml" - * @param before a {@link Config.Creator} that can be used to configure the resulting config further - * @param configCreatorClass a class as described above - * @param after a {@link Config.Creator} that can be used to configure the resulting config further - * @return a {@link WrappedConfig } - */ - public static C create(String family, String id, Path path, Config.Creator before, Class configCreatorClass, Config.Creator after) { - return Config.create(AzusaConfigImpl.getConfigEnvironment(), family, id, path, before, configCreatorClass, after); - } - - /** - * Creates and registers a config with fields derived from the fields of the passed class - * - *

The passed class should have the following characteristics: - *

- * - *

Certain annotations can also be used on fields of this class to attach metadata to them. The {@link org.quiltmc.config.api.annotations.Comment} - * annotation is one such annotation that is provided by default, but additional {@link ConfigFieldAnnotationProcessor}s - * can be registered with {@link ConfigFieldAnnotationProcessor#register(Class, ConfigFieldAnnotationProcessor)}. - * - * @param family the mod owning the resulting config file - * @param id the config's id - * @param path additional path elements to include as part of this configs file, e.g. - * if the path is empty, the config file might be ".minecraft/config/example_mod/id.toml" - * if the path is "client/gui", the config file might be ".minecraft/config/example_mod/client/gui/id.toml" - * @param before a {@link Config.Creator} that can be used to configure the resulting config further - * @param configCreatorClass a class as described above - * @return a {@link WrappedConfig } - */ - public static C create(String family, String id, Path path, Config.Creator before, Class configCreatorClass) { - return create(family, id, path, before, configCreatorClass, builder -> {}); - } - - /** - * Creates and registers a config with fields derived from the fields of the passed class - * - *

The passed class should have the following characteristics: - *

- * - *

Certain annotations can also be used on fields of this class to attach metadata to them. The {@link org.quiltmc.config.api.annotations.Comment} - * annotation is one such annotation that is provided by default, but additional {@link ConfigFieldAnnotationProcessor}s - * can be registered with {@link ConfigFieldAnnotationProcessor#register(Class, ConfigFieldAnnotationProcessor)}. - * - * @param family the mod owning the resulting config file - * @param id the configs id - * @param path additional path elements to include as part of this configs file, e.g. - * if the path is empty, the config file might be ".minecraft/config/example_mod/id.toml" - * if the path is "client/gui", the config file might be ".minecraft/config/example_mod/client/gui/id.toml" - * @param configCreatorClass a class as described above - * @param after a {@link Config.Creator} that can be used to configure the resulting config further - * @return a {@link WrappedConfig } - */ - public static C create(String family, String id, Path path, Class configCreatorClass, Config.Creator after) { - return create(family, id, path, builder -> {}, configCreatorClass, after); - } - - /** - * Creates and registers a config with fields derived from the fields of the passed class - * - *

The passed class should have the following characteristics: - *

- * - *

Certain annotations can also be used on fields of this class to attach metadata to them. The {@link org.quiltmc.config.api.annotations.Comment} - * annotation is one such annotation that is provided by default, but additional {@link ConfigFieldAnnotationProcessor}s - * can be registered with {@link ConfigFieldAnnotationProcessor#register(Class, ConfigFieldAnnotationProcessor)}. - * - * @param family the mod owning the resulting config file - * @param id the config's id - * @param path additional path elements to include as part of this configs file, e.g. - * if the path is empty, the config file might be ".minecraft/config/example_mod/id.toml" - * if the path is "client/gui", the config file might be ".minecraft/config/example_mod/client/gui/id.toml" - * @param configCreatorClass a class as described above - * @return a {@link WrappedConfig } - */ - public static C create(String family, String id, Path path, Class configCreatorClass) { - return create(family, id, path, builder -> {}, configCreatorClass, builder -> {}); - } - - /** - * Creates and registers a config with fields derived from the fields of the passed class - * - *

The passed class should have the following characteristics: - *

- * - *

Certain annotations can also be used on fields of this class to attach metadata to them. The {@link org.quiltmc.config.api.annotations.Comment} - * annotation is one such annotation that is provided by default, but additional {@link ConfigFieldAnnotationProcessor}s - * can be registered with {@link ConfigFieldAnnotationProcessor#register(Class, ConfigFieldAnnotationProcessor)}. - * - * @param family the mod owning the resulting config file - * @param id the config's id - * @param before a {@link Config.Creator} that can be used to configure the resulting config further - * @param configCreatorClass a class as described above - * @param after a {@link Config.Creator} that can be used to configure the resulting config further - * @return a {@link WrappedConfig } - */ - public static C create(String family, String id, Config.Creator before, Class configCreatorClass, Config.Creator after) { - return create(family, id, Paths.get(""), before, configCreatorClass, after); - } - - /** - * Creates and registers a config with fields derived from the fields of the passed class - * - *

The passed class should have the following characteristics: - *

- * - *

Certain annotations can also be used on fields of this class to attach metadata to them. The {@link org.quiltmc.config.api.annotations.Comment} - * annotation is one such annotation that is provided by default, but additional {@link ConfigFieldAnnotationProcessor}s - * can be registered with {@link ConfigFieldAnnotationProcessor#register(Class, ConfigFieldAnnotationProcessor)}. - * - * @param family the mod owning the resulting config file - * @param id the config's id - * @param before a {@link Config.Creator} that can be used to configure the resulting config further - * @param configCreatorClass a class as described above - * @return a {@link WrappedConfig } - */ - public static C create(String family, String id, Config.Creator before, Class configCreatorClass) { - return create(family, id, Paths.get(""), before, configCreatorClass, builder -> {}); - } - - /** - * Creates and registers a config with fields derived from the fields of the passed class - * - *

The passed class should have the following characteristics: - *

- * - *

Certain annotations can also be used on fields of this class to attach metadata to them. The {@link org.quiltmc.config.api.annotations.Comment} - * annotation is one such annotation that is provided by default, but additional {@link ConfigFieldAnnotationProcessor}s - * can be registered with {@link ConfigFieldAnnotationProcessor#register(Class, ConfigFieldAnnotationProcessor)}. - * - * @param family the mod owning the resulting config file - * @param id the config's id - * @param configCreatorClass a class as described above - * @param after a {@link Config.Creator} that can be used to configure the resulting config further - * @return a {@link WrappedConfig } - */ - public static C create(String family, String id, Class configCreatorClass, Config.Creator after) { - return create(family, id, Paths.get(""), builder -> {}, configCreatorClass, after); - } - - /** - * Creates and registers a config with fields derived from the fields of the passed class - * - *

The passed class should have the following characteristics: - *

- * - * @param family the mod owning the resulting config file - * @param id the config's id - * @param configCreatorClass a class as described above - * @return a {@link WrappedConfig } - */ - public static C create(String family, String id, Class configCreatorClass) { - return create(family, id, Paths.get(""), builder -> {}, configCreatorClass, builder -> {}); - } - - private AzusaConfig() { - } -} diff --git a/common/src/main/java/ho/artisan/azusaconfig/impl/config/AzusaConfigImpl.java b/common/src/main/java/ho/artisan/azusaconfig/impl/AzusaConfigImpl.java similarity index 98% rename from common/src/main/java/ho/artisan/azusaconfig/impl/config/AzusaConfigImpl.java rename to common/src/main/java/ho/artisan/azusaconfig/impl/AzusaConfigImpl.java index 8f0c498..ba9e7eb 100644 --- a/common/src/main/java/ho/artisan/azusaconfig/impl/config/AzusaConfigImpl.java +++ b/common/src/main/java/ho/artisan/azusaconfig/impl/AzusaConfigImpl.java @@ -15,7 +15,7 @@ * limitations under the License. */ -package ho.artisan.azusaconfig.impl.config; +package ho.artisan.azusaconfig.impl; import java.nio.file.Path; import java.util.LinkedHashMap; diff --git a/fabric/src/main/java/ho/artisan/azusaconfig/fabric/AzusaConfigModFabric.java b/fabric/src/main/java/ho/artisan/azusaconfig/fabric/AzusaConfigModFabric.java index 05378a8..75b229b 100644 --- a/fabric/src/main/java/ho/artisan/azusaconfig/fabric/AzusaConfigModFabric.java +++ b/fabric/src/main/java/ho/artisan/azusaconfig/fabric/AzusaConfigModFabric.java @@ -1,6 +1,6 @@ package ho.artisan.azusaconfig.fabric; -import ho.artisan.azusaconfig.impl.config.AzusaConfigImpl; +import ho.artisan.azusaconfig.impl.AzusaConfigImpl; import net.fabricmc.api.ModInitializer; public class AzusaConfigModFabric implements ModInitializer { diff --git a/neoforge/src/main/java/ho/artisan/azusaconfig/neoforge/AzusaConfigModNeoForge.java b/neoforge/src/main/java/ho/artisan/azusaconfig/neoforge/AzusaConfigModNeoForge.java index dd732ed..ad43bb6 100644 --- a/neoforge/src/main/java/ho/artisan/azusaconfig/neoforge/AzusaConfigModNeoForge.java +++ b/neoforge/src/main/java/ho/artisan/azusaconfig/neoforge/AzusaConfigModNeoForge.java @@ -1,16 +1,12 @@ package ho.artisan.azusaconfig.neoforge; import ho.artisan.azusaconfig.AzusaConfigMod; -import ho.artisan.azusaconfig.impl.config.AzusaConfigImpl; -import net.neoforged.fml.IExtensionPoint; -import net.neoforged.fml.ModLoadingContext; +import ho.artisan.azusaconfig.impl.AzusaConfigImpl; import net.neoforged.fml.common.Mod; @Mod(AzusaConfigMod.MOD_ID) public class AzusaConfigModNeoForge { - public AzusaConfigModNeoForge() { - ModLoadingContext.get().registerExtensionPoint(IExtensionPoint.DisplayTest.class, () -> new IExtensionPoint.DisplayTest(() -> IExtensionPoint.DisplayTest.IGNORESERVERONLY, (a, b) -> true)); AzusaConfigImpl.init(); } }