2021-09-27 20:55:48 +02:00
|
|
|
package io.gitlab.jfronny.libjf;
|
|
|
|
|
2022-11-25 14:57:40 +01:00
|
|
|
import io.gitlab.jfronny.commons.log.Level;
|
|
|
|
import io.gitlab.jfronny.commons.log.Logger;
|
|
|
|
import io.gitlab.jfronny.commons.log.slf4j.SLF4JLogger;
|
2022-09-25 12:33:51 +02:00
|
|
|
import io.gitlab.jfronny.commons.serialize.gson.api.v1.GsonHolders;
|
2022-08-28 13:55:15 +02:00
|
|
|
import io.gitlab.jfronny.libjf.gson.GsonAdapter;
|
2022-06-23 17:50:30 +02:00
|
|
|
import io.gitlab.jfronny.libjf.gson.HiddenAnnotationExclusionStrategy;
|
2022-08-21 22:34:55 +02:00
|
|
|
import net.fabricmc.api.ModInitializer;
|
2022-06-23 17:50:30 +02:00
|
|
|
import net.fabricmc.loader.api.FabricLoader;
|
2022-09-25 12:33:51 +02:00
|
|
|
import net.fabricmc.loader.api.entrypoint.EntrypointContainer;
|
|
|
|
import net.fabricmc.loader.api.metadata.ModMetadata;
|
2021-09-27 20:55:48 +02:00
|
|
|
|
2022-08-21 22:34:55 +02:00
|
|
|
public class LibJf implements ModInitializer {
|
2021-09-27 20:55:48 +02:00
|
|
|
public static final String MOD_ID = "libjf";
|
2022-06-03 22:45:14 +02:00
|
|
|
public static final Logger LOGGER = Logger.forName(MOD_ID);
|
2022-04-29 15:48:27 +02:00
|
|
|
|
|
|
|
static {
|
2022-09-25 12:33:51 +02:00
|
|
|
//TODO remove all uses of this from dependents, then remove this
|
|
|
|
GsonHolders.modifyBuilder(builder -> {
|
|
|
|
for (EntrypointContainer<GsonAdapter> container : FabricLoader.getInstance().getEntrypointContainers(MOD_ID + ":gson_adapter", GsonAdapter.class)) {
|
|
|
|
ModMetadata meta = container.getProvider().getMetadata();
|
|
|
|
LOGGER.warn("Mod " + meta.getName() + " (" + meta.getId() + ") uses the now deprecated libjf:gson_adapter. Please update!");
|
|
|
|
container.getEntrypoint().apply(builder);
|
2022-04-29 15:48:27 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
HiddenAnnotationExclusionStrategy.register();
|
2022-09-25 12:33:51 +02:00
|
|
|
GsonHolders.registerSerializer();
|
2022-04-29 15:48:27 +02:00
|
|
|
}
|
2022-08-21 22:34:55 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onInitialize() {
|
2022-09-15 14:57:26 +02:00
|
|
|
Logger.registerFactory(SLF4JLogger::new);
|
|
|
|
Logger.setMinimumLevel(FabricLoader.getInstance().isDevelopmentEnvironment() ? Level.TRACE : Level.INFO);
|
2022-08-21 22:34:55 +02:00
|
|
|
}
|
2021-09-27 20:55:48 +02:00
|
|
|
}
|