diff --git a/examples/paper/src/main/java/me/devnatan/inventoryframework/runtime/view/RowColumnSample.java b/examples/paper/src/main/java/me/devnatan/inventoryframework/runtime/view/RowColumnSample.java index 5701c8db..35978438 100644 --- a/examples/paper/src/main/java/me/devnatan/inventoryframework/runtime/view/RowColumnSample.java +++ b/examples/paper/src/main/java/me/devnatan/inventoryframework/runtime/view/RowColumnSample.java @@ -4,14 +4,13 @@ import me.devnatan.inventoryframework.ViewConfigBuilder; import me.devnatan.inventoryframework.context.RenderContext; import me.devnatan.inventoryframework.state.MutableIntState; -import me.devnatan.inventoryframework.state.MutableState; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; public class RowColumnSample extends View { - private final MutableIntState intState = mutableState(0); + private final MutableIntState intState = mutableState(0); @Override public void onInit(@NotNull ViewConfigBuilder config) { @@ -20,16 +19,15 @@ public void onInit(@NotNull ViewConfigBuilder config) { @Override public void onFirstRender(@NotNull RenderContext render) { - render.slot(13) - .withItem(intState.get(render) == 3 ? new ItemStack(Material.GOLD_INGOT) : new ItemStack(Material.IRON_INGOT)); + render.slot(13) + .withItem( + intState.get(render) == 3 + ? new ItemStack(Material.GOLD_INGOT) + : new ItemStack(Material.IRON_INGOT)); - render.firstRow((pos, slot) -> - slot.withItem(new ItemStack(Material.BLUE_STAINED_GLASS_PANE)) - .onClick(click -> intState.increment(click)) - ); + render.firstRow((pos, slot) -> slot.withItem(new ItemStack(Material.BLUE_STAINED_GLASS_PANE)) + .onClick(click -> intState.increment(click))); - render.lastColumn((pos, slot) -> - slot.withItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE)) - ); + render.lastColumn((pos, slot) -> slot.withItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE))); } } diff --git a/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/ViewConfig.java b/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/ViewConfig.java index 2fed7881..6d010e68 100644 --- a/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/ViewConfig.java +++ b/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/ViewConfig.java @@ -118,7 +118,6 @@ public boolean isOptionSet(@NotNull Option option) { return false; } - // TODO docs @SuppressWarnings("unused") @VisibleForTesting public boolean isOptionSet(@NotNull Option option, T value) { @@ -145,7 +144,6 @@ public static Option createOption(@NotNull String name, @NotNull T defaul public ViewConfig merge(ViewConfig other) { if (other == null) return this; - // TODO merge "options" and "modifiers" from both, distinctly return new ViewConfig( merge(other, ViewConfig::getTitle, Objects::nonNull), merge(other, ViewConfig::getSize, value -> value != 0), @@ -169,7 +167,6 @@ private T merge(ViewConfig other, Function retriever, Functio return value; } - // TODO docs @SuppressWarnings("unused") @FunctionalInterface public interface Modifier { diff --git a/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/ViewConfigBuilder.java b/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/ViewConfigBuilder.java index 94175577..addca176 100644 --- a/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/ViewConfigBuilder.java +++ b/inventory-framework-api/src/main/java/me/devnatan/inventoryframework/ViewConfigBuilder.java @@ -98,9 +98,14 @@ public ViewConfigBuilder size(int size) { return this; } - // TODO needs documentation + /** + * Expands the size of the inventory to the max permitted by {@link #getType() its type}. + * + * @return This configuration builder. + * @see ViewType#getMaxSize() + */ public ViewConfigBuilder maxSize() { - throw new UnsupportedOperationException("TODO"); + return size(Integer.MAX_VALUE); } /** @@ -278,9 +283,11 @@ public ViewConfig build() { option, option.defaultValue())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + final int size = getSize() == Integer.MAX_VALUE ? getType().getMaxSize() : getSize(); + return new ViewConfig( getTitle(), - getSize(), + size, getType(), optionsMap, getLayout(),