From 91f4717647cebc98dc9c64e5c6e5f4f8b1822602 Mon Sep 17 00:00:00 2001 From: MrBunnyDc Date: Fri, 27 Sep 2024 12:23:23 -0400 Subject: [PATCH] Set spotless --- .../wuidebook/impl/FabricPlatformImpl.java | 5 + .../wonejo/wuidebook/WuidebookCommonMod.java | 21 ++- .../de/wonejo/wuidebook/api/book/Book.java | 7 + .../wonejo/wuidebook/api/book/BookInfo.java | 44 +++++ .../wuidebook/api/book/BookRegistry.java | 63 +++++++ .../api/compat/WuidebookImplementation.java | 15 +- .../wuidebook/api/config/ConfigManager.java | 3 +- .../serialization/ConfigValueSerializer.java | 9 +- .../api/service/XPlatAbstraction.java | 2 + .../api/util/ResourceLocationUtils.java | 9 +- .../api/util/WuidebookRegistryException.java | 12 ++ .../de/wonejo/wuidebook/api/wgc/WgcTag.java | 9 +- .../wuidebook/impl/book/BookInfoImpl.java | 158 ++++++++++++++++++ .../wuidebook/impl/config/ConfigSpecImpl.java | 6 +- .../impl/config/DeserializeResultImpl.java | 12 +- .../serializer/color/HexColorSerializer.java | 3 +- .../serializer/color/RgbColorSerializer.java | 3 +- .../wonejo/wuidebook/impl/wgc/WgcTagImpl.java | 9 +- .../wuidebook/mixin/MinecraftClientMixin.java | 1 - .../assets/wuidebook/lang/en_us.json | 6 +- 20 files changed, 343 insertions(+), 54 deletions(-) create mode 100644 XPlat/src/main/java/de/wonejo/wuidebook/api/book/Book.java create mode 100644 XPlat/src/main/java/de/wonejo/wuidebook/api/book/BookInfo.java create mode 100644 XPlat/src/main/java/de/wonejo/wuidebook/api/book/BookRegistry.java create mode 100644 XPlat/src/main/java/de/wonejo/wuidebook/api/util/WuidebookRegistryException.java create mode 100644 XPlat/src/main/java/de/wonejo/wuidebook/impl/book/BookInfoImpl.java diff --git a/Fabric/src/main/java/de/wonejo/wuidebook/impl/FabricPlatformImpl.java b/Fabric/src/main/java/de/wonejo/wuidebook/impl/FabricPlatformImpl.java index 333d080..e831969 100644 --- a/Fabric/src/main/java/de/wonejo/wuidebook/impl/FabricPlatformImpl.java +++ b/Fabric/src/main/java/de/wonejo/wuidebook/impl/FabricPlatformImpl.java @@ -13,6 +13,11 @@ public List gatherImplementations() { return List.of(); } + @Override + public String getCurrentLoadedModId() { + return FabricLoader.getInstance().getMappingResolver().getCurrentRuntimeNamespace(); + } + public Path getConfigPath() { return FabricLoader.getInstance().getConfigDir(); } diff --git a/XPlat/src/main/java/de/wonejo/wuidebook/WuidebookCommonMod.java b/XPlat/src/main/java/de/wonejo/wuidebook/WuidebookCommonMod.java index f7f5421..e0a358e 100644 --- a/XPlat/src/main/java/de/wonejo/wuidebook/WuidebookCommonMod.java +++ b/XPlat/src/main/java/de/wonejo/wuidebook/WuidebookCommonMod.java @@ -5,6 +5,9 @@ import de.wonejo.wuidebook.api.config.ConfigManager; import de.wonejo.wuidebook.api.util.Constants; import de.wonejo.wuidebook.api.util.McEnvironment; +import de.wonejo.wuidebook.api.util.TriState; +import de.wonejo.wuidebook.api.wgc.WgcValueTypeRegistry; +import de.wonejo.wuidebook.api.wgc.value.*; import de.wonejo.wuidebook.impl.config.serializer.*; import de.wonejo.wuidebook.impl.config.serializer.color.ColorConfigSerializer; import de.wonejo.wuidebook.impl.service.ModServices; @@ -22,6 +25,7 @@ public class WuidebookCommonMod { private static final WuidebookCommonMod INSTANCE = new WuidebookCommonMod(); private static Path CONFIG_DIRECTORY = ModServices.ABSTRACTION.getConfigPath(); private final ConfigManager configManager = ConfigManager.get(); + private final WgcValueTypeRegistry wgcValueTypeRegistry = WgcValueTypeRegistry.get(); private WuidebookCommonMod () {} @@ -37,9 +41,23 @@ public void setup () { } this.setupConfigAPI (implementations); + this.setupWgcFiles(implementations); } - private void setupConfigAPI (@NotNull List pImplementation) { + private void setupWgcFiles ( @NotNull List pImplementation ) { + this.wgcValueTypeRegistry.registerType(ByteWgcValue.TYPE.id(), (value) -> new ByteWgcValue (Byte.parseByte(value))); + this.wgcValueTypeRegistry.registerType(ShortWgcValue.TYPE.id(), (value) -> new ShortWgcValue (Short.parseShort(value))); + this.wgcValueTypeRegistry.registerType(IntWgcValue.TYPE.id(), (value) -> new IntWgcValue (Integer.parseInt(value))); + this.wgcValueTypeRegistry.registerType(FloatWgcValue.TYPE.id(), (value) -> new FloatWgcValue (Float.parseFloat(value))); + this.wgcValueTypeRegistry.registerType(DoubleWgcValue.TYPE.id(), (value) -> new DoubleWgcValue (Double.parseDouble(value))); + this.wgcValueTypeRegistry.registerType(BooleanWgcValue.TYPE.id(), (value) -> new BooleanWgcValue (TriState.fromBooleanText(value))); + this.wgcValueTypeRegistry.registerType(StringWgcValue.TYPE.id(), StringWgcValue::new); + this.wgcValueTypeRegistry.registerType(NullWgcValue.TYPE.id(), (value) -> new NullWgcValue()); + + for ( WuidebookImplementation impl : pImplementation ) impl.onRegisterCustomWGCValueType(this.wgcValueTypeRegistry); + } + + private void setupConfigAPI ( @NotNull List pImplementation ) { this.configManager.registerSerializer(Constants.CFG_STR_SERIALIZER, new StringCfgSerializer()); this.configManager.registerSerializer(Constants.CFG_INT_SERIALIZER, new IntCfgSerializer()); this.configManager.registerSerializer(Constants.CFG_FLOAT_SERIALIZER, new FloatCfgSerializer()); @@ -50,7 +68,6 @@ private void setupConfigAPI (@NotNull List pImplementat for ( WuidebookImplementation impl : pImplementation ) { impl.onRegisterConfigSerializer(this.configManager); - impl.onRegisterConfigFiles(this.configManager); } this.configManager.getFileList(McEnvironment.COMMON).forEach(ConfigFile::loadFile); diff --git a/XPlat/src/main/java/de/wonejo/wuidebook/api/book/Book.java b/XPlat/src/main/java/de/wonejo/wuidebook/api/book/Book.java new file mode 100644 index 0000000..51be0d8 --- /dev/null +++ b/XPlat/src/main/java/de/wonejo/wuidebook/api/book/Book.java @@ -0,0 +1,7 @@ +package de.wonejo.wuidebook.api.book; + +public interface Book { + + BookInfo getInformation (); + +} diff --git a/XPlat/src/main/java/de/wonejo/wuidebook/api/book/BookInfo.java b/XPlat/src/main/java/de/wonejo/wuidebook/api/book/BookInfo.java new file mode 100644 index 0000000..0fffa17 --- /dev/null +++ b/XPlat/src/main/java/de/wonejo/wuidebook/api/book/BookInfo.java @@ -0,0 +1,44 @@ +package de.wonejo.wuidebook.api.book; + +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; + +import java.awt.*; + +public interface BookInfo { + + static Builder builder () { + return de.wonejo.wuidebook.impl.book.BookInfoImpl.builderImpl(); + } + + ResourceLocation bookId (); + + ResourceLocation modelLocation (); + ResourceLocation mainBookGUITexture (); + ResourceLocation pageBookGUITexture (); + + Component title (); + Component header (); + Component itemName (); + Component author (); + + Color bookColor (); + + boolean shouldSpawnWithBook (); + + interface Builder { + Builder withId ( ResourceLocation pBookId ); + Builder withModelLocation ( ResourceLocation pLocation ); + Builder withMainBookTexture ( ResourceLocation pLocation ); + Builder withPageBookTexture ( ResourceLocation pLocation ); + Builder setTitle ( Component pTitle ); + Builder setHeader ( Component pHeader ); + Builder setItemName ( Component pItemName ); + Builder setAuthor ( Component pAuthor ); + Builder withBookColor ( Color pColor ); + Builder shouldSpawnWithBook (); + + BookInfo build (); + } + +} diff --git a/XPlat/src/main/java/de/wonejo/wuidebook/api/book/BookRegistry.java b/XPlat/src/main/java/de/wonejo/wuidebook/api/book/BookRegistry.java new file mode 100644 index 0000000..868efa6 --- /dev/null +++ b/XPlat/src/main/java/de/wonejo/wuidebook/api/book/BookRegistry.java @@ -0,0 +1,63 @@ +package de.wonejo.wuidebook.api.book; + +import com.google.common.collect.Maps; +import com.mojang.datafixers.util.Pair; +import de.wonejo.wuidebook.api.util.Constants; +import de.wonejo.wuidebook.api.util.WuidebookRegistryException; +import de.wonejo.wuidebook.impl.service.ModServices; +import net.minecraft.resources.ResourceLocation; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; + +import java.util.Map; +import java.util.Optional; + +public final class BookRegistry { + private static final Logger LOGGER = LogManager.getLogger(); + private final Map> bookInformation = Maps.newHashMap(); + private final Map books = Maps.newHashMap(); + private boolean areBooksBuilt; + + private BookRegistry () {} + + @ApiStatus.Internal + public void buildBooks () { + if (this.areBooksBuilt) return; + if (!ModServices.ABSTRACTION.getCurrentLoadedModId().equals(Constants.MOD_ID)) throw new RuntimeException("Can not use Wuidebook buildBooks on other mods code!"); + + this.areBooksBuilt = true; + } + + public void registerBook ( @NotNull BookInfo pInfo, ResourceLocation pBaseFileLocation ) { + if ( this.bookInformation.putIfAbsent(pInfo.bookId(), Pair.of(pInfo, pBaseFileLocation)) != null ) + throw new WuidebookRegistryException("Can not register two ( or more ) book information with id: " + pInfo.bookId() + ", it wouldn't be registered!"); + } + + public @NotNull Book getBook (ResourceLocation pBookId ) { + Book book = this.books.get(pBookId); + if (!areBooksBuilt) throw new RuntimeException("Can not get wuidebook guide, books aren't build."); + if ( book == null ) throw new RuntimeException("Can not get book with id: " + pBookId + " because it isn't present."); + return book; + } + + public Optional getOptBook ( ResourceLocation pBookId ) { + Book book = this.books.get(pBookId); + if (!areBooksBuilt) throw new RuntimeException("Can not get wuidebook guide, books aren't build."); + return Optional.ofNullable(book); + } + + public BookInfo getInfo ( ResourceLocation pBookId ) { + Pair pair = this.bookInformation.get(pBookId); + if ( pair == null ) throw new NullPointerException("Can not get book information, there isn't a book ith id: " + pBookId); + return pair.getFirst(); + } + + public ResourceLocation getBaseFileLocation ( ResourceLocation pBookId ) { + Pair pair = this.bookInformation.get(pBookId); + if ( pair == null ) throw new NullPointerException("Can not get base file location, there isn't a book with id: " + pBookId); + return pair.getSecond(); + } + +} diff --git a/XPlat/src/main/java/de/wonejo/wuidebook/api/compat/WuidebookImplementation.java b/XPlat/src/main/java/de/wonejo/wuidebook/api/compat/WuidebookImplementation.java index 5538ed7..accaea5 100644 --- a/XPlat/src/main/java/de/wonejo/wuidebook/api/compat/WuidebookImplementation.java +++ b/XPlat/src/main/java/de/wonejo/wuidebook/api/compat/WuidebookImplementation.java @@ -2,6 +2,7 @@ import de.wonejo.wuidebook.api.config.ConfigManager; import de.wonejo.wuidebook.api.config.ConfigProviderBuilder; +import de.wonejo.wuidebook.api.wgc.WgcValueTypeRegistry; public interface WuidebookImplementation { @@ -13,14 +14,6 @@ public interface WuidebookImplementation { */ default void onRegisterConfigSerializer ( ConfigManager pManager ) {} - /** - * Register custom config files for configs. - *

- * Note: Do not use this method to register serializers, only config files. - * @since 4.0.0-dev2 - */ - default void onRegisterConfigFiles ( ConfigManager pManager ) {} - /** * PLEASE, if you use any of these three methods, specify in your config the modId, sommething like: 'exampleModId.exampleConfig' PLEASE. *

@@ -31,4 +24,10 @@ default void onRegisterCustomClientConfig ( ConfigProviderBuilder pBuilder ) {} default void onRegisterCustomServerConfig ( ConfigProviderBuilder pBuilder ) {} default void onRegisterCustomCommonConfig ( ConfigProviderBuilder pBuilder ) {} + /** + * If add custom WGC content templates and need to add other value type use this, might help. + * @since 4.0.0-dev2 + */ + default void onRegisterCustomWGCValueType ( WgcValueTypeRegistry pRegistry ) {} + } diff --git a/XPlat/src/main/java/de/wonejo/wuidebook/api/config/ConfigManager.java b/XPlat/src/main/java/de/wonejo/wuidebook/api/config/ConfigManager.java index 476b90b..770bfab 100644 --- a/XPlat/src/main/java/de/wonejo/wuidebook/api/config/ConfigManager.java +++ b/XPlat/src/main/java/de/wonejo/wuidebook/api/config/ConfigManager.java @@ -3,6 +3,7 @@ import com.google.common.collect.Maps; import de.wonejo.wuidebook.api.config.serialization.ConfigValueSerializer; import de.wonejo.wuidebook.api.util.McEnvironment; +import de.wonejo.wuidebook.api.util.WuidebookRegistryException; import net.minecraft.resources.ResourceLocation; import org.apache.commons.compress.utils.Lists; import org.apache.logging.log4j.LogManager; @@ -21,7 +22,7 @@ private ConfigManager () {} public void registerSerializer ( ResourceLocation pSerializerId, ConfigValueSerializer pSerializer ) { if ( this.serializers.putIfAbsent(pSerializerId, pSerializer) != null ) - LOGGER.warn("Can not register serializer with id: {}, there is already a serializer with that id.", pSerializer); + throw new WuidebookRegistryException("Can not register serializer with id: '%s', there is already a serializer with that id.".formatted(pSerializer)); } public void registerFile ( ConfigFile pFile ) { diff --git a/XPlat/src/main/java/de/wonejo/wuidebook/api/config/serialization/ConfigValueSerializer.java b/XPlat/src/main/java/de/wonejo/wuidebook/api/config/serialization/ConfigValueSerializer.java index 34068d2..df45751 100644 --- a/XPlat/src/main/java/de/wonejo/wuidebook/api/config/serialization/ConfigValueSerializer.java +++ b/XPlat/src/main/java/de/wonejo/wuidebook/api/config/serialization/ConfigValueSerializer.java @@ -57,8 +57,7 @@ interface DeserializeResult { * Create a success deserialization result. * @since 4.0.0-dev2 */ - @NotNull - static DeserializeResult success ( B pResult ) { + @NotNull static DeserializeResult success ( B pResult ) { return DeserializeResultImpl.success(pResult); } @@ -66,8 +65,7 @@ static DeserializeResult success ( B pResult ) { * Create a deserialization result that can have the result and errors. * @since 4.0.0-dev2 */ - @NotNull - static DeserializeResult haveBoth ( B pResult, List pErrors ) { + @NotNull static DeserializeResult haveBoth ( B pResult, List pErrors ) { return DeserializeResultImpl.haveBoth(pResult, pErrors); } @@ -75,8 +73,7 @@ static DeserializeResult haveBoth ( B pResult, List pErrors ) { * Create a success deserialization result. * @since 4.0.0-dev2 */ - @NotNull - static DeserializeResult fail ( List pErrors ) { + @NotNull static DeserializeResult fail ( List pErrors ) { return DeserializeResultImpl.fail(pErrors); } diff --git a/XPlat/src/main/java/de/wonejo/wuidebook/api/service/XPlatAbstraction.java b/XPlat/src/main/java/de/wonejo/wuidebook/api/service/XPlatAbstraction.java index da277f0..ee29642 100644 --- a/XPlat/src/main/java/de/wonejo/wuidebook/api/service/XPlatAbstraction.java +++ b/XPlat/src/main/java/de/wonejo/wuidebook/api/service/XPlatAbstraction.java @@ -9,6 +9,8 @@ public interface XPlatAbstraction { List gatherImplementations (); + String getCurrentLoadedModId (); + Path getConfigPath (); boolean isDevWorkspace (); diff --git a/XPlat/src/main/java/de/wonejo/wuidebook/api/util/ResourceLocationUtils.java b/XPlat/src/main/java/de/wonejo/wuidebook/api/util/ResourceLocationUtils.java index c98fa1b..5b3ee4a 100644 --- a/XPlat/src/main/java/de/wonejo/wuidebook/api/util/ResourceLocationUtils.java +++ b/XPlat/src/main/java/de/wonejo/wuidebook/api/util/ResourceLocationUtils.java @@ -5,18 +5,15 @@ public class ResourceLocationUtils { - @NotNull - public static ResourceLocation minecraft (String pPath) { + @NotNull public static ResourceLocation minecraft (String pPath) { return ResourceLocation.withDefaultNamespace(pPath); } - @NotNull - public static ResourceLocation wuidebook ( String pPath ) { + @NotNull public static ResourceLocation wuidebook ( String pPath ) { return ResourceLocation.fromNamespaceAndPath(Constants.MOD_ID, pPath); } - @NotNull - public static ResourceLocation common ( String pPath ) { + @NotNull public static ResourceLocation common ( String pPath ) { return ResourceLocation.fromNamespaceAndPath("c", pPath); } diff --git a/XPlat/src/main/java/de/wonejo/wuidebook/api/util/WuidebookRegistryException.java b/XPlat/src/main/java/de/wonejo/wuidebook/api/util/WuidebookRegistryException.java new file mode 100644 index 0000000..8d99f52 --- /dev/null +++ b/XPlat/src/main/java/de/wonejo/wuidebook/api/util/WuidebookRegistryException.java @@ -0,0 +1,12 @@ +package de.wonejo.wuidebook.api.util; + +public class WuidebookRegistryException extends RuntimeException { + + public WuidebookRegistryException ( String pMessage ) { + super(pMessage); + } + + public WuidebookRegistryException ( String pMessage, Throwable pThrowable ) { + super(pMessage, pThrowable); + } +} diff --git a/XPlat/src/main/java/de/wonejo/wuidebook/api/wgc/WgcTag.java b/XPlat/src/main/java/de/wonejo/wuidebook/api/wgc/WgcTag.java index 3504fd5..231d68b 100644 --- a/XPlat/src/main/java/de/wonejo/wuidebook/api/wgc/WgcTag.java +++ b/XPlat/src/main/java/de/wonejo/wuidebook/api/wgc/WgcTag.java @@ -11,8 +11,7 @@ public interface WgcTag { - @NotNull - static WgcTag createTag (String pKey, Map> pProperties) { + @NotNull static WgcTag createTag (String pKey, Map> pProperties) { return WgcTagImpl.createTag(pKey, pProperties); } @@ -25,13 +24,11 @@ static WgcTag createTag (String pKey, Map> pProper interface Property { - @NotNull - static WgcTag.Property createProperty ( ResourceLocation pKey, ResourceLocation pValueType, String pValue ) { + @NotNull static WgcTag.Property createProperty ( ResourceLocation pKey, ResourceLocation pValueType, String pValue ) { return WgcTagImpl.PropertyImpl.createProperty(pKey, pValueType, pValue); } - @NotNull - static WgcTag.Property createProperty ( ResourceLocation pKey, WgcTagValue pValue ) { + @NotNull static WgcTag.Property createProperty ( ResourceLocation pKey, WgcTagValue pValue ) { return WgcTagImpl.PropertyImpl.createProperty(pKey, pValue); } diff --git a/XPlat/src/main/java/de/wonejo/wuidebook/impl/book/BookInfoImpl.java b/XPlat/src/main/java/de/wonejo/wuidebook/impl/book/BookInfoImpl.java new file mode 100644 index 0000000..783b666 --- /dev/null +++ b/XPlat/src/main/java/de/wonejo/wuidebook/impl/book/BookInfoImpl.java @@ -0,0 +1,158 @@ +package de.wonejo.wuidebook.impl.book; + +import de.wonejo.wuidebook.api.book.BookInfo; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; + +import java.awt.*; + +public class BookInfoImpl implements BookInfo { + + @NotNull public static Builder builderImpl () { + return BuilderImpl.builderImpl(); + } + + private final ResourceLocation bookId; + private final ResourceLocation modelLocation; + private final ResourceLocation mainBookTexture; + private final ResourceLocation pageBookTexture; + private final Component title; + private final Component header; + private final Component itemName; + private final Component author; + private final Color bookColor; + private final boolean shouldSpawnWithBook; + + private BookInfoImpl ( ResourceLocation pBookId, ResourceLocation pModelLocation, ResourceLocation pMainBookTexture, ResourceLocation pPageBookTexture, Component pTitle, Component pHeader, Component pItemName, Component pAuthor, Color pColor, boolean pShouldSpawnWithBook ) { + this.bookId = pBookId; + this.modelLocation = pModelLocation; + this.mainBookTexture = pMainBookTexture; + this.pageBookTexture = pPageBookTexture; + this.title = pTitle; + this.header = pHeader; + this.itemName = pItemName; + this.bookColor = pColor; + this.author = pAuthor; + this.shouldSpawnWithBook = pShouldSpawnWithBook; + } + + public ResourceLocation bookId() { + return this.bookId; + } + + public ResourceLocation modelLocation() { + return this.modelLocation; + } + + public ResourceLocation mainBookGUITexture() { + return this.mainBookTexture; + } + + public ResourceLocation pageBookGUITexture() { + return this.pageBookTexture; + } + + public Component title() { + return this.title; + } + + public Component header() { + return this.header; + } + + public Component itemName() { + return this.itemName; + } + + public Component author() { + return this.author; + } + + public Color bookColor() { + return this.bookColor; + } + + public boolean shouldSpawnWithBook() { + return this.shouldSpawnWithBook; + } + + private static class BuilderImpl implements BookInfo.Builder { + + @NotNull static BuilderImpl builderImpl () { + return new BuilderImpl(); + } + + private ResourceLocation bookId; + private ResourceLocation modelLocation; + private ResourceLocation mainBookTexture; + private ResourceLocation pageBookTexture; + private Component title = Component.translatable("wuidebook.book.info.title.undefined"); + private Component header; + private Component itemName; + private Component author = Component.translatable("wuidebook.book.info.author.unknown"); + private Color bookColor = new Color(154, 21, 63); + private boolean shouldSpawnWithBook = false; + + private BuilderImpl () {} + + public BookInfo.Builder withId(ResourceLocation pBookId) { + this.bookId = pBookId; + return this; + } + + public BookInfo.Builder withModelLocation(ResourceLocation pLocation) { + this.modelLocation = pLocation; + return this; + } + + public BookInfo.Builder withMainBookTexture(ResourceLocation pLocation) { + this.mainBookTexture = pageBookTexture; + return this; + } + + public BookInfo.Builder withPageBookTexture(ResourceLocation pLocation) { + this.pageBookTexture = pLocation; + return this; + } + + public BookInfo.Builder setTitle(Component pTitle) { + this.title = pTitle; + return this; + } + + public BookInfo.Builder setHeader(Component pHeader) { + this.header = pHeader; + return this; + } + + public BookInfo.Builder setItemName(Component pItemName) { + this.itemName = pItemName; + return this; + } + + public Builder setAuthor(Component pAuthor) { + this.author = pAuthor; + return this; + } + + public BookInfo.Builder withBookColor(Color pColor) { + this.bookColor = pColor; + return this; + } + + public BookInfo.Builder shouldSpawnWithBook() { + this.shouldSpawnWithBook = true; + return this; + } + + @NotNull public BookInfo build() { + if ( this.bookId == null ) throw new IllegalArgumentException("Can not build book info with null id."); + if ( this.header == null ) this.header = this.title; + if ( this.itemName == null ) this.itemName = this.title; + + return new BookInfoImpl(this.bookId, this.modelLocation, this.mainBookTexture, this.pageBookTexture, this.title, this.header, this.itemName, this.author, this.bookColor, this.shouldSpawnWithBook); + } + + } +} diff --git a/XPlat/src/main/java/de/wonejo/wuidebook/impl/config/ConfigSpecImpl.java b/XPlat/src/main/java/de/wonejo/wuidebook/impl/config/ConfigSpecImpl.java index 833fe5f..2e32d27 100644 --- a/XPlat/src/main/java/de/wonejo/wuidebook/impl/config/ConfigSpecImpl.java +++ b/XPlat/src/main/java/de/wonejo/wuidebook/impl/config/ConfigSpecImpl.java @@ -12,14 +12,12 @@ public class ConfigSpecImpl implements ConfigSpec { @ApiStatus.Internal - @NotNull - public static ConfigSpecImpl createSpec ( ConfigValueSerializer pSerializer, String pKey, String pDescription, T pDefaultValue ) { + @NotNull public static ConfigSpecImpl createSpec ( ConfigValueSerializer pSerializer, String pKey, String pDescription, T pDefaultValue ) { return new ConfigSpecImpl<>(pKey, pDescription, pSerializer, pDefaultValue); } private final String key; - @Nullable - private final String description; + @Nullable private final String description; private final T defaultValue; private final ConfigValueSerializer serializer; private volatile T currentValue; diff --git a/XPlat/src/main/java/de/wonejo/wuidebook/impl/config/DeserializeResultImpl.java b/XPlat/src/main/java/de/wonejo/wuidebook/impl/config/DeserializeResultImpl.java index ae4990d..deeef07 100644 --- a/XPlat/src/main/java/de/wonejo/wuidebook/impl/config/DeserializeResultImpl.java +++ b/XPlat/src/main/java/de/wonejo/wuidebook/impl/config/DeserializeResultImpl.java @@ -9,23 +9,19 @@ public class DeserializeResultImpl implements ConfigValueSerializer.DeserializeResult { - @NotNull - public static ConfigValueSerializer.DeserializeResult success ( B pResult ) { + @NotNull public static ConfigValueSerializer.DeserializeResult success ( B pResult ) { return new DeserializeResultImpl<>(pResult); } - @NotNull - public static ConfigValueSerializer.DeserializeResult haveBoth ( B pResult, List pErrors ) { + @NotNull public static ConfigValueSerializer.DeserializeResult haveBoth ( B pResult, List pErrors ) { return new DeserializeResultImpl<>(pResult, pErrors); } - @NotNull - public static ConfigValueSerializer.DeserializeResult fail ( List pErrors ) { + @NotNull public static ConfigValueSerializer.DeserializeResult fail ( List pErrors ) { return new DeserializeResultImpl<>(pErrors); } - @Nullable - private final T result; + @Nullable private final T result; private final List errors; private DeserializeResultImpl ( T pResult ) { diff --git a/XPlat/src/main/java/de/wonejo/wuidebook/impl/config/serializer/color/HexColorSerializer.java b/XPlat/src/main/java/de/wonejo/wuidebook/impl/config/serializer/color/HexColorSerializer.java index aa1c3f9..225335f 100644 --- a/XPlat/src/main/java/de/wonejo/wuidebook/impl/config/serializer/color/HexColorSerializer.java +++ b/XPlat/src/main/java/de/wonejo/wuidebook/impl/config/serializer/color/HexColorSerializer.java @@ -9,8 +9,7 @@ class HexColorSerializer implements ConfigValueSerializer { - @NotNull - @ApiStatus.Internal + @NotNull @ApiStatus.Internal static HexColorSerializer getHex () { return new HexColorSerializer(); } diff --git a/XPlat/src/main/java/de/wonejo/wuidebook/impl/config/serializer/color/RgbColorSerializer.java b/XPlat/src/main/java/de/wonejo/wuidebook/impl/config/serializer/color/RgbColorSerializer.java index 6fff440..b29b3fd 100644 --- a/XPlat/src/main/java/de/wonejo/wuidebook/impl/config/serializer/color/RgbColorSerializer.java +++ b/XPlat/src/main/java/de/wonejo/wuidebook/impl/config/serializer/color/RgbColorSerializer.java @@ -9,8 +9,7 @@ class RgbColorSerializer implements ConfigValueSerializer { - @NotNull - @ApiStatus.Internal + @NotNull @ApiStatus.Internal static RgbColorSerializer getRgb () { return new RgbColorSerializer(); } diff --git a/XPlat/src/main/java/de/wonejo/wuidebook/impl/wgc/WgcTagImpl.java b/XPlat/src/main/java/de/wonejo/wuidebook/impl/wgc/WgcTagImpl.java index ea7b69e..1e8006c 100644 --- a/XPlat/src/main/java/de/wonejo/wuidebook/impl/wgc/WgcTagImpl.java +++ b/XPlat/src/main/java/de/wonejo/wuidebook/impl/wgc/WgcTagImpl.java @@ -12,8 +12,7 @@ public class WgcTagImpl implements WgcTag { - @NotNull - public static WgcTag createTag ( String pKey, Map> pProperties ) { + @NotNull public static WgcTag createTag ( String pKey, Map> pProperties ) { return new WgcTagImpl(pKey, pProperties); } @@ -51,13 +50,11 @@ public Set propertiesKeySet() { public static class PropertyImpl implements WgcTag.Property { - @NotNull - public static WgcTag.Property createProperty ( ResourceLocation pKey, ResourceLocation pValueType, String pValue ) { + @NotNull public static WgcTag.Property createProperty ( ResourceLocation pKey, ResourceLocation pValueType, String pValue ) { return new PropertyImpl<>(pKey, pValueType, pValue); } - @NotNull - public static WgcTag.Property createProperty ( ResourceLocation pKey, WgcTagValue pValue ) { + @NotNull public static WgcTag.Property createProperty ( ResourceLocation pKey, WgcTagValue pValue ) { return new PropertyImpl<>(pKey, pValue); } diff --git a/XPlat/src/main/java/de/wonejo/wuidebook/mixin/MinecraftClientMixin.java b/XPlat/src/main/java/de/wonejo/wuidebook/mixin/MinecraftClientMixin.java index 39aa436..6bbd638 100644 --- a/XPlat/src/main/java/de/wonejo/wuidebook/mixin/MinecraftClientMixin.java +++ b/XPlat/src/main/java/de/wonejo/wuidebook/mixin/MinecraftClientMixin.java @@ -4,7 +4,6 @@ import de.wonejo.wuidebook.api.config.ConfigManager; import de.wonejo.wuidebook.api.util.McEnvironment; import net.minecraft.client.Minecraft; -import org.apache.commons.compress.archivers.sevenz.CLI; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; diff --git a/XPlat/src/main/resources/assets/wuidebook/lang/en_us.json b/XPlat/src/main/resources/assets/wuidebook/lang/en_us.json index 609af91..e08e620 100644 --- a/XPlat/src/main/resources/assets/wuidebook/lang/en_us.json +++ b/XPlat/src/main/resources/assets/wuidebook/lang/en_us.json @@ -14,6 +14,8 @@ "__comment": "Config Specs", "wuidebook.config.spec.debuglogging": "Debug Logging", "wuidebook.config.spec.sendwarnwhenconfigisnottranslated": "Send warning when config is not translated", - "wuidebook.config.spec.globalBookSpawn": true - + "wuidebook.config.spec.globalBookSpawn": "Global Book Spawn", + "__section": "book", + "wuidebook.book.info.title.undefined": "Title is undefined", + "wuidebook.book.info.author.unknown": "Unknown Author" } \ No newline at end of file