aboutsummaryrefslogtreecommitdiff
path: root/api/src/main/java/me
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-06-20 22:19:06 +0800
committershedaniel <daniel@shedaniel.me>2022-06-28 03:21:12 +0800
commit367fa7c68da50f73978d3ea7b375729dda8773c0 (patch)
tree7fc66d36f30f418dd8654ffa50043d9828945449 /api/src/main/java/me
parentea6b9e340700865ef46be1e7e14a9e221208ec2e (diff)
downloadRoughlyEnoughItems-367fa7c68da50f73978d3ea7b375729dda8773c0.tar.gz
RoughlyEnoughItems-367fa7c68da50f73978d3ea7b375729dda8773c0.tar.bz2
RoughlyEnoughItems-367fa7c68da50f73978d3ea7b375729dda8773c0.zip
Add a bit JDocs for config
Diffstat (limited to 'api/src/main/java/me')
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/config/ConfigManager.java14
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/config/ConfigObject.java141
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/client/config/entry/EntryStackProvider.java43
3 files changed, 193 insertions, 5 deletions
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<REIClientPlugin> {
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<REIClientPlugin> {
}
/**
- * 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.
+ * <p>
+ * {@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
+ * <p>
+ * {@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.
+ * <p>
+ * {@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.
+ * <p>
+ * {@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 <T> the type of {@link EntryStack}
+ */
@ApiStatus.Experimental
@ApiStatus.NonExtendable
public interface EntryStackProvider<T> {
+ /**
+ * Resolves and returns the {@link EntryStack}.
+ *
+ * @return the {@link EntryStack}, or {@link EntryStack#empty()} if failed to resolve
+ */
EntryStack<T> 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 <T> the type of {@link EntryStack}
+ * @return the {@link EntryStackProvider}
+ */
static <T> EntryStackProvider<T> defer(CompoundTag tag) {
return new EntryStackProvider<T>() {
private EntryStack<T> stack;
@@ -84,6 +119,14 @@ public interface EntryStackProvider<T> {
};
}
+ /**
+ * 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 <T> the type of {@link EntryStack}
+ * @return the {@link EntryStackProvider}
+ */
static <T> EntryStackProvider<T> ofStack(EntryStack<T> stack) {
stack = stack.normalize();
EntryStack<T> finalStack = stack;