Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.devnatan.inventoryframework;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
Expand All @@ -10,9 +9,8 @@
import me.devnatan.inventoryframework.pipeline.Pipeline;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.UnmodifiableView;

public interface RootView extends VirtualView, Iterable<IFContext> {
public interface RootView extends VirtualView {

/**
* The unique identifier of this view.
Expand All @@ -24,72 +22,14 @@ public interface RootView extends VirtualView, Iterable<IFContext> {

/**
* All contexts linked to this view.
*
* @return An unmodifiable set of all currently active contexts in this view.
*/
@NotNull
@UnmodifiableView
Set<IFContext> getContexts();

/**
* Returns the context that is linked to the specified viewer in this view.
* <p>
* <b><i> This is an internal inventory-framework API that should not be used from outside of
* this library. No compatibility guarantees are provided. </i></b>
*
* @param viewer The viewer.
* @return The context of the viewer in this context.
* @throws IllegalArgumentException If there's no context linked to the given viewer.
*/
@ApiStatus.Internal
@NotNull
IFContext getContext(@NotNull Viewer viewer);

/**
* Returns the context that is linked to the specified viewer in this view.
* <p>
* <b><i> This is an internal inventory-framework API that should not be used from outside of
* this library. No compatibility guarantees are provided. </i></b>
*
* @param viewerId The id of the viewer.
* @return The context of the viewer in this context.
* @throws IllegalArgumentException If there's no context linked to the given viewer.
*/
@NotNull
IFContext getContext(@NotNull String viewerId);

/**
* Adds a context to this view.
* <p>
* <b><i> This is an internal inventory-framework API that should not be used from outside of
* this library. No compatibility guarantees are provided. </i></b>
*
* @param context The context to add.
*/
@ApiStatus.Internal
void addContext(@NotNull IFContext context);

/**
* Removes a given context from this view if that context is linked to this view.
* <p>
* <b><i> This is an internal inventory-framework API that should not be used from outside of
* this library. No compatibility guarantees are provided. </i></b>
*
* @param context The context to remove.
*/
@ApiStatus.Internal
void removeContext(@NotNull IFContext context);

/**
* Renders a given context in this view.
* <p>
* <b><i> This is an internal inventory-framework API that should not be used from outside of
* this library. No compatibility guarantees are provided. </i></b>
*
* @param context The context to render.
* @return An unmodifiable set of all currently active contexts in this view.
*/
@ApiStatus.Internal
void renderContext(@NotNull IFContext context);
Set<IFContext> getInternalContexts();

/**
* Called when the view is about to be configured, the returned object will be the view's
Expand Down Expand Up @@ -127,23 +67,6 @@ public interface RootView extends VirtualView, Iterable<IFContext> {
@NotNull
Pipeline<VirtualView> getPipeline();

/**
* Opens this view to more than one viewer.
* <p>
* <b><i> This is an internal inventory-framework API that should not be used from outside of
* this library. No compatibility guarantees are provided. </i></b>
*
* @param viewers The viewers that'll see this view.
* @param initialData The initial data.
*/
@ApiStatus.Internal
void open(@NotNull List<Viewer> viewers, Object initialData);

/**
* Closes all contexts that are currently active in this view.
*/
void closeForEveryone();

/**
* The ElementFactory for this view.
* <p>
Expand All @@ -158,25 +81,26 @@ public interface RootView extends VirtualView, Iterable<IFContext> {

/**
* Runs a task in the next tick.
* <p>
* <b><i> This is an internal inventory-framework API that should not be used from outside of
* this library. No compatibility guarantees are provided. </i></b>
*
* @param task The task to run.
*/
@ApiStatus.Internal
void nextTick(Runnable task);

/**
* The IFViewFrame for this view.
* <p>
* <b><i> This is an internal inventory-framework API that should not be used from outside of
* this library. No compatibility guarantees are provided. </i></b>
*
* @return The current framework that holds this view.
* @throws UnsupportedOperationException If this view doesn't support a framework.
*/
@ApiStatus.Internal
IFViewFrame<?> getFramework();

Job getScheduledUpdateJob();

/**
* <b><i> This is an internal inventory-framework API that should not be used from outside of
* this library. No compatibility guarantees are provided. </i></b>
*/
@ApiStatus.Internal
void setScheduledUpdateJob(@NotNull Job job);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package me.devnatan.inventoryframework;

/**
* Thrown when an operation is called in a shared context, but it's not supported for some reason.
*
* @see <a href="https://github.com/DevNatan/inventory-framework/wiki/Shared-Contexts">Shared Contexts on Wiki</a>
*/
public final class UnsupportedOperationInSharedContextException extends InventoryFrameworkException {

public UnsupportedOperationInSharedContextException() {
super("This operation is not supported in shared contexts.");
}

public UnsupportedOperationInSharedContextException(String replacement) {
super(String.format("This operation is not supported in shared contexts. Use #%s instead.", replacement));
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package me.devnatan.inventoryframework;

import java.util.List;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Unmodifiable;

public interface ViewContainer {

Expand Down Expand Up @@ -77,18 +75,12 @@ public interface ViewContainer {
*/
int getColumnsCount();

@NotNull
@Unmodifiable
List<Viewer> getViewers();

void open(@NotNull Viewer viewer);

void close();

void close(@NotNull Viewer viewer);

void changeTitle(@Nullable String title);

void changeTitle(@Nullable String title, @NotNull Viewer target);

boolean isEntityContainer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public final class ViewType {
public static final ViewType SHULKER_BOX = new ViewType("shulker-box", 27, 3, 9);
public static final ViewType SMOKER = new ViewType("smoker", 3, 2, 2, false, new int[] {2});
public static final ViewType VILLAGER_TRADING = new ViewType("villager-trading", 3, 1, 3, false, new int[] {2});
public static final ViewType PLAYER = new ViewType("player", 54, 3, 9, false);

private static final int[] EMPTY_RESULT_SLOTS = new int[0];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package me.devnatan.inventoryframework;

import me.devnatan.inventoryframework.context.IFRenderContext;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

@ApiStatus.Internal
public interface Viewer {

/**
Expand Down Expand Up @@ -31,4 +35,12 @@ public interface Viewer {
*/
@NotNull
ViewContainer getSelfContainer();

@NotNull
IFRenderContext getContext();

void setContext(IFRenderContext context);

@Contract("_ -> this")
Viewer withContext(IFRenderContext context);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
import me.devnatan.inventoryframework.context.IFContext;
import org.jetbrains.annotations.ApiStatus;

public interface ItemComponentBuilder<S extends ItemComponentBuilder<S, C>, C extends IFContext>
extends ComponentBuilder<S, C> {
public interface ItemComponentBuilder<Self extends ItemComponentBuilder<Self, Context>, Context extends IFContext>
extends ComponentBuilder<Self, Context> {

/**
* Sets the slot that the item will be positioned.
*
* @param slot The item slot.
* @return This item builder.
*/
S withSlot(int slot);
Self withSlot(int slot);

// TODO needs documentation
@ApiStatus.Experimental
S withSlot(int row, int column);
Self withSlot(int row, int column);

@ApiStatus.Internal
boolean isContainedWithin(int position);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package me.devnatan.inventoryframework.component;

@FunctionalInterface
public interface PaginationElementFactory<T, V> {
public interface PaginationElementFactory<Context, V> {

ComponentFactory create(T context, int index, int slot, V value);
ComponentFactory create(Context context, int index, int slot, V value);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
package me.devnatan.inventoryframework.context;

import org.jetbrains.annotations.ApiStatus;

public interface IFCloseContext extends IFConfinedContext {

IFContext getParent();
/**
* <b><i> This is an internal inventory-framework API that should not be used from outside of
* this library. No compatibility guarantees are provided. </i></b>
*/
@ApiStatus.Internal
IFRenderContext getParent();

/**
* Cancellation state of that context.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public interface IFConfinedContext extends IFContext {
*
* @return The {@link Viewer} in the current scope of execution.
*/
@NotNull
Viewer getViewer();

/**
Expand Down
Loading