From c83d02c30cd17be0132dfa508cfd3e069039d978 Mon Sep 17 00:00:00 2001 From: s809 <11816467-s809@users.noreply.gitlab.com> Date: Sun, 25 Feb 2024 13:11:37 +0500 Subject: [PATCH] Always print git info --- .../common/AbstractModInitializer.java | 42 +++++++++++-------- .../distanthorizons/common/IEventProxy.java | 6 --- 2 files changed, 25 insertions(+), 23 deletions(-) delete mode 100644 common/src/main/java/com/seibel/distanthorizons/common/IEventProxy.java diff --git a/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java b/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java index 8c42b6a82..033415940 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/AbstractModInitializer.java @@ -92,7 +92,7 @@ public abstract class AbstractModInitializer ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeDhInitEvent.class, null); this.startup(); - this.printModInfo(true); + this.printModInfo(); this.createClientProxy().registerEvents(); this.createServerProxy(false).registerEvents(); @@ -116,7 +116,7 @@ public abstract class AbstractModInitializer ApiEventInjector.INSTANCE.fireAllEvents(DhApiBeforeDhInitEvent.class, null); this.startup(); - this.printModInfo(false); + this.printModInfo(); // This prevents returning uninitialized Config values, // resulting from a circular reference mid-initialization in a static class @@ -155,17 +155,14 @@ public abstract class AbstractModInitializer this.createInitialBindings(); } - private void printModInfo(boolean printGitInfo) + private void printModInfo() { LOGGER.info(ModInfo.READABLE_NAME + ", Version: " + ModInfo.VERSION); - if (printGitInfo) - { - // Useful for dev builds - LOGGER.info("DH Branch: " + ModJarInfo.Git_Branch); - LOGGER.info("DH Commit: " + ModJarInfo.Git_Commit); - LOGGER.info("DH Jar Build Source: " + ModJarInfo.Build_Source); - } + // Useful for dev builds + LOGGER.info("DH Branch: " + ModJarInfo.Git_Branch); + LOGGER.info("DH Commit: " + ModJarInfo.Git_Commit); + LOGGER.info("DH Jar Build Source: " + ModJarInfo.Build_Source); } protected void tryCreateModCompatAccessor(String modId, Class accessorClass, Supplier accessorConstructor) @@ -199,10 +196,16 @@ public abstract class AbstractModInitializer for (AbstractConfigType type : ConfigBase.INSTANCE.entries) { - if (!(type instanceof ConfigEntry)) continue; + if (!(type instanceof ConfigEntry)) + { + continue; + } //noinspection PatternVariableCanBeUsed ConfigEntry configEntry = (ConfigEntry) type; - if (configEntry.getServersideShortName() == null) continue; + if (configEntry.getServersideShortName() == null) + { + continue; + } Function< Function, Object>, @@ -255,12 +258,15 @@ public abstract class AbstractModInitializer Supplier>, BiFunction, String, ?>> >() {{ - put(Integer.class, new Pair<>(() -> integer((int) configEntry.getMin(), (int) configEntry.getMax()), IntegerArgumentType::getInteger)); - put(Double.class, new Pair<>(() -> doubleArg((double) configEntry.getMin(), (double) configEntry.getMax()), DoubleArgumentType::getDouble)); - put(Boolean.class, new Pair<>(BoolArgumentType::bool, BoolArgumentType::getBool)); + this.put(Integer.class, new Pair<>(() -> integer((int) configEntry.getMin(), (int) configEntry.getMax()), IntegerArgumentType::getInteger)); + this.put(Double.class, new Pair<>(() -> doubleArg((double) configEntry.getMin(), (double) configEntry.getMax()), DoubleArgumentType::getDouble)); + this.put(Boolean.class, new Pair<>(BoolArgumentType::bool, BoolArgumentType::getBool)); }}.entrySet()) { - if (!pair.getKey().isAssignableFrom(configEntry.getType())) continue; + if (!pair.getKey().isAssignableFrom(configEntry.getType())) + { + continue; + } subcommand.then(argument("value", pair.getValue().first.get()) .executes(makeConfigUpdater.apply(c -> pair.getValue().second.apply(c, "value")))); @@ -270,13 +276,15 @@ public abstract class AbstractModInitializer } if (!setterAdded) + { throw new RuntimeException("Config type of "+type.getName()+" is not supported: "+configEntry.getType().getSimpleName()); + } } builder.then(subcommand); } - commandDispatcher.register(builder); + this.commandDispatcher.register(builder); } diff --git a/common/src/main/java/com/seibel/distanthorizons/common/IEventProxy.java b/common/src/main/java/com/seibel/distanthorizons/common/IEventProxy.java deleted file mode 100644 index 0f2e6b896..000000000 --- a/common/src/main/java/com/seibel/distanthorizons/common/IEventProxy.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.seibel.distanthorizons.common; - -public interface IEventProxy -{ - void registerEvents(); -}