From 367fa7c68da50f73978d3ea7b375729dda8773c0 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Mon, 20 Jun 2022 22:19:06 +0800 Subject: Add a bit JDocs for config --- .../rei/api/client/config/ConfigManager.java | 14 +- .../rei/api/client/config/ConfigObject.java | 141 ++++++++++++++++++++- .../client/config/entry/EntryStackProvider.java | 43 +++++++ 3 files changed, 193 insertions(+), 5 deletions(-) (limited to 'api/src/main/java/me/shedaniel') diff --git a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigManager.java b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigManager.java index b65b54f54..2d898d524 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigManager.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigManager.java @@ -46,19 +46,19 @@ public interface ConfigManager extends Reloadable { void saveConfig(); /** - * Gets if craftable only filter is enabled + * Returns whether the craftable only filter is enabled. * * @return whether craftable only filter is enabled */ boolean isCraftableOnlyEnabled(); /** - * Toggles the craftable only filter + * Toggles the craftable only filter. */ void toggleCraftableOnly(); /** - * Opens the config screen + * Opens the config screen. * * @param parent the screen shown before */ @@ -67,12 +67,18 @@ public interface ConfigManager extends Reloadable { } /** - * Gets the config screen + * Returns the config screen. * * @param parent the screen shown before * @return the config screen */ Screen getConfigScreen(Screen parent); + /** + * Returns the config object. + * + * @return the config object + * @see ConfigObject#getInstance() + */ ConfigObject getConfig(); } diff --git a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java index 100a57583..b8ce1656c 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java @@ -24,6 +24,7 @@ package me.shedaniel.rei.api.client.config; import me.shedaniel.clothconfig2.api.ModifierKeyCode; +import me.shedaniel.rei.api.client.REIRuntime; import me.shedaniel.rei.api.client.config.entry.EntryStackProvider; import me.shedaniel.rei.api.client.favorites.FavoriteEntry; import me.shedaniel.rei.api.client.gui.config.*; @@ -42,57 +43,196 @@ public interface ConfigObject { return ConfigManager.getInstance().getConfig(); } + /** + * Returns whether the overlay is visible. + * + * @return whether the overlay is visible + */ boolean isOverlayVisible(); + /** + * Sets whether the overlay is visible. + * + * @param overlayVisible whether the overlay should be visible + */ void setOverlayVisible(boolean overlayVisible); + /** + * Returns whether cheating is enabled. This method may return + * the contextual cheating state if cheat mode is set to Creative Only. + * + * @return whether cheating is enabled + * @see #getCheatingMode() + */ boolean isCheating(); + /** + * Sets whether cheating is enabled. + * + * @param cheating whether cheating should be enabled + */ void setCheating(boolean cheating); + /** + * Returns the cheating mode. + * + * @return the cheating mode + * @see #isCheating() + */ @ApiStatus.Experimental CheatingMode getCheatingMode(); + /** + * Returns the entry panel sorting method. + * + * @return the entry panel sorting method + */ EntryPanelOrdering getItemListOrdering(); + /** + * Returns whether the entry panel is in ascending order. + * + * @return whether the entry panel is in ascending order + */ boolean isItemListAscending(); + /** + * Returns whether REI is in dark mode. + * + * @return whether REI is in dark mode + */ boolean isUsingDarkTheme(); + /** + * Returns whether grabbing items is used to cheat items. + * + * @return whether grabbing items is used to cheat items + */ boolean isGrabbingItems(); + /** + * Returns whether favorites motions are animated. + * + * @return whether favorites motions are animated + */ boolean isFavoritesAnimated(); + /** + * Returns whether a toast is shown on screen when a display identifier is copied. + * + * @return whether a toast is shown on screen when a display identifier is copied + */ boolean isToastDisplayedOnCopyIdentifier(); + /** + * Returns whether the entry list is scrolled, rather than paginated. + * + * @return whether the entry list is scrolled, rather than paginated + */ boolean isEntryListWidgetScrolled(); + /** + * Returns whether REI should append mod names to tooltips. + * + * @return whether REI should append mod names to tooltips + */ boolean shouldAppendModNames(); + /** + * Returns the display type of the display screen. + * + * @return the display type of the display screen + */ DisplayScreenType getRecipeScreenType(); + /** + * Sets the display type of the display screen. + * + * @param displayScreenType the display type of the display screen + */ void setRecipeScreenType(DisplayScreenType displayScreenType); + /** + * Returns the location of the search field. This method is not contextual, + * you might instead want to use {@link REIRuntime#getContextualSearchFieldLocation()}. + * + * @return the location of the search field + */ SearchFieldLocation getSearchFieldLocation(); + /** + * Returns whether the entry list is displayed on the left side of the screen. + * + * @return whether the entry list is displayed on the left side of the screen + */ default boolean isLeftHandSidePanel() { return getDisplayPanelLocation() == DisplayPanelLocation.LEFT; } + /** + * Returns the location of the entry list, favorites list will go to the opposite side. + * + * @return the location of the entry list + */ DisplayPanelLocation getDisplayPanelLocation(); + /** + * Returns whether the craftable filter button is visible. + * For checking whether the filter is active, use {@link ConfigManager#isCraftableOnlyEnabled()}. + * + * @return whether the craftable filter button is visible + */ boolean isCraftableFilterEnabled(); + /** + * Returns the game mode command used to change the game mode. + *

+ * {@code {gamemode}} is a placeholder for the game mode. + * + * @return the game mode command used to change the game mode + */ String getGamemodeCommand(); + /** + * Returns the give command used to cheat items on servers + *

+ * {@code {item_name}} is the item path, {@code {item_identifier}} is the item identifier, + * {@code {count}} is the item count, {@code {player_name}} is the recipient player name. + * + * @return the give command used to cheat items on servers + */ String getGiveCommand(); + /** + * Returns the weather command used to change the weather. + *

+ * {@code {weather}} is a placeholder for the weather. + * + * @return the weather command used to change the weather + */ String getWeatherCommand(); + /** + * Returns the time command used to change the time. + *

+ * {@code {time}} is a placeholder for the time. + * + * @return the time command used to change the time + */ String getTimeCommand(); + /** + * Returns the maximum number of displays that can be displayed per page. + * + * @return the maximum number of displays that can be displayed per page + */ int getMaxRecipePerPage(); + /** + * Returns the maximum page height for displays. + * + * @return the maximum page height for displays + */ int getMaxRecipesPageHeight(); boolean doesDisableRecipeBook(); @@ -111,7 +251,6 @@ public interface ConfigObject { boolean doesRegisterRecipesInAnotherThread(); @Deprecated(forRemoval = true) - @ApiStatus.ScheduledForRemoval boolean doesSnapToRows(); boolean isFavoritesEnabled(); diff --git a/api/src/main/java/me/shedaniel/rei/api/client/config/entry/EntryStackProvider.java b/api/src/main/java/me/shedaniel/rei/api/client/config/entry/EntryStackProvider.java index 1a72ee953..caafc9fbf 100644 --- a/api/src/main/java/me/shedaniel/rei/api/client/config/entry/EntryStackProvider.java +++ b/api/src/main/java/me/shedaniel/rei/api/client/config/entry/EntryStackProvider.java @@ -23,22 +23,57 @@ package me.shedaniel.rei.api.client.config.entry; +import me.shedaniel.rei.api.common.entry.EntrySerializer; import me.shedaniel.rei.api.common.entry.EntryStack; +import me.shedaniel.rei.api.common.entry.type.EntryDefinition; import me.shedaniel.rei.api.common.util.EntryStacks; import net.minecraft.nbt.CompoundTag; import org.jetbrains.annotations.ApiStatus; import java.util.Objects; +/** + * A deferred {@link EntryStack} provider. + * Allows easier serialization of {@link EntryStack}s. + * + * @param the type of {@link EntryStack} + */ @ApiStatus.Experimental @ApiStatus.NonExtendable public interface EntryStackProvider { + /** + * Resolves and returns the {@link EntryStack}. + * + * @return the {@link EntryStack}, or {@link EntryStack#empty()} if failed to resolve + */ EntryStack provide(); + /** + * Serializes the {@link EntryStack} to a {@link CompoundTag}. + * + * @return the saved tag + * @throws UnsupportedOperationException if the {@link EntryDefinition} does not support saving to a tag + * @see EntrySerializer#supportSaving() + * @see EntryStack#saveStack() + * @since 8.3 + */ CompoundTag save(); + /** + * Returns whether the {@link EntryStack} is valid. + * + * @return whether the {@link EntryStack} is valid + */ boolean isValid(); + /** + * Creates a new {@link EntryStackProvider} from the given {@link CompoundTag}, + * the stack is not resolved immediately, but rather deferred until {@link #provide()} is called. + * + * @param tag the tag to load from + * @param the type of {@link EntryStack} + * @return the {@link EntryStackProvider} + */ static EntryStackProvider defer(CompoundTag tag) { return new EntryStackProvider() { private EntryStack stack; @@ -84,6 +119,14 @@ public interface EntryStackProvider { }; } + /** + * Creates a new {@link EntryStackProvider} from the given {@link EntryStack}. + * This provider is not deferred, and will resolve the stack immediately. + * + * @param stack the stack to use + * @param the type of {@link EntryStack} + * @return the {@link EntryStackProvider} + */ static EntryStackProvider ofStack(EntryStack stack) { stack = stack.normalize(); EntryStack finalStack = stack; -- cgit