Rename GUI to Gui, Add static Gui factory functions
This commit is contained in:
parent
60ce81909f
commit
2eb20b9866
@ -10,7 +10,7 @@ import de.studiocode.invui.item.Item
|
|||||||
* @param slot The slot index
|
* @param slot The slot index
|
||||||
* @return The [SlotElement] placed on that slot or null if there is none
|
* @return The [SlotElement] placed on that slot or null if there is none
|
||||||
*/
|
*/
|
||||||
operator fun GUI.get(slot: Int): SlotElement? = getSlotElement(slot)
|
operator fun Gui.get(slot: Int): SlotElement? = getSlotElement(slot)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the [SlotElement] placed on these coordinates.
|
* Gets the [SlotElement] placed on these coordinates.
|
||||||
@ -19,7 +19,7 @@ operator fun GUI.get(slot: Int): SlotElement? = getSlotElement(slot)
|
|||||||
* @param y The y coordinate of the slot
|
* @param y The y coordinate of the slot
|
||||||
* @return The [SlotElement] placed on that slot or null if there is none
|
* @return The [SlotElement] placed on that slot or null if there is none
|
||||||
*/
|
*/
|
||||||
operator fun GUI.get(x: Int, y: Int): SlotElement? = getSlotElement(x, y)
|
operator fun Gui.get(x: Int, y: Int): SlotElement? = getSlotElement(x, y)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the [SlotElement] on that slot.
|
* Sets the [SlotElement] on that slot.
|
||||||
@ -27,7 +27,7 @@ operator fun GUI.get(x: Int, y: Int): SlotElement? = getSlotElement(x, y)
|
|||||||
* @param slot The slot index
|
* @param slot The slot index
|
||||||
* @param element The [SlotElement] to set or null to remove the current one
|
* @param element The [SlotElement] to set or null to remove the current one
|
||||||
*/
|
*/
|
||||||
operator fun GUI.set(slot: Int, element: SlotElement?) = setSlotElement(slot, element)
|
operator fun Gui.set(slot: Int, element: SlotElement?) = setSlotElement(slot, element)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the [SlotElement] on these coordinates.
|
* Sets the [SlotElement] on these coordinates.
|
||||||
@ -36,7 +36,7 @@ operator fun GUI.set(slot: Int, element: SlotElement?) = setSlotElement(slot, el
|
|||||||
* @param y The y coordinate of the slot
|
* @param y The y coordinate of the slot
|
||||||
* @param element The [SlotElement] to set or null to remove the current one
|
* @param element The [SlotElement] to set or null to remove the current one
|
||||||
*/
|
*/
|
||||||
operator fun GUI.set(x: Int, y: Int, element: SlotElement?) = setSlotElement(x, y, element)
|
operator fun Gui.set(x: Int, y: Int, element: SlotElement?) = setSlotElement(x, y, element)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the [Item] on that slot.
|
* Sets the [Item] on that slot.
|
||||||
@ -44,7 +44,7 @@ operator fun GUI.set(x: Int, y: Int, element: SlotElement?) = setSlotElement(x,
|
|||||||
* @param slot The slot index
|
* @param slot The slot index
|
||||||
* @param item The [Item] to set or null to remove the current one
|
* @param item The [Item] to set or null to remove the current one
|
||||||
*/
|
*/
|
||||||
operator fun GUI.set(slot: Int, item: Item?) = setItem(slot, item)
|
operator fun Gui.set(slot: Int, item: Item?) = setItem(slot, item)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the [Item] on these coordinates.
|
* Sets the [Item] on these coordinates.
|
||||||
@ -53,7 +53,7 @@ operator fun GUI.set(slot: Int, item: Item?) = setItem(slot, item)
|
|||||||
* @param y The y coordinate of the slot
|
* @param y The y coordinate of the slot
|
||||||
* @param item The [Item] to set or null to remove the current one
|
* @param item The [Item] to set or null to remove the current one
|
||||||
*/
|
*/
|
||||||
operator fun GUI.set(x: Int, y: Int, item: Item?) = setItem(x, y, item)
|
operator fun Gui.set(x: Int, y: Int, item: Item?) = setItem(x, y, item)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given [elements].
|
* Adds the given [elements].
|
||||||
@ -61,7 +61,7 @@ operator fun GUI.set(x: Int, y: Int, item: Item?) = setItem(x, y, item)
|
|||||||
* @param elements The [SlotElements][SlotElement] to add.
|
* @param elements The [SlotElements][SlotElement] to add.
|
||||||
*/
|
*/
|
||||||
@JvmName("plusAssignSlotElements")
|
@JvmName("plusAssignSlotElements")
|
||||||
operator fun GUI.plusAssign(elements: Iterable<SlotElement>) = elements.forEach { addSlotElements(it) }
|
operator fun Gui.plusAssign(elements: Iterable<SlotElement>) = elements.forEach { addSlotElements(it) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the given [items].
|
* Adds the given [items].
|
||||||
@ -69,4 +69,4 @@ operator fun GUI.plusAssign(elements: Iterable<SlotElement>) = elements.forEach
|
|||||||
* @param items The [Items][Item] to add.
|
* @param items The [Items][Item] to add.
|
||||||
*/
|
*/
|
||||||
@JvmName("plusAssignItems")
|
@JvmName("plusAssignItems")
|
||||||
operator fun GUI.plusAssign(items: Iterable<Item>) = items.forEach { addItems(it) }
|
operator fun Gui.plusAssign(items: Iterable<Item>) = items.forEach { addItems(it) }
|
16
invui-kotlin/src/main/kotlin/de/studiocode/invui/Windows.kt
Normal file
16
invui-kotlin/src/main/kotlin/de/studiocode/invui/Windows.kt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
@file:Suppress("PackageDirectoryMismatch")
|
||||||
|
|
||||||
|
package de.studiocode.invui.window.type
|
||||||
|
|
||||||
|
import de.studiocode.invui.window.Window
|
||||||
|
import de.studiocode.invui.window.type.context.WindowContext
|
||||||
|
|
||||||
|
fun <W: Window, C : WindowContext> WindowType<W, C>.create(contextConsumer: C.() -> Unit): W {
|
||||||
|
val ctx = createContext()
|
||||||
|
ctx.contextConsumer()
|
||||||
|
return createWindow(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
WindowType.NORMAL.create { }
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package de.studiocode.invui.animation;
|
package de.studiocode.invui.animation;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.window.Window;
|
import de.studiocode.invui.window.Window;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -10,11 +10,11 @@ import java.util.function.BiConsumer;
|
|||||||
public interface Animation {
|
public interface Animation {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link GUI} this {@link Animation} will take place in.
|
* Sets the {@link Gui} this {@link Animation} will take place in.
|
||||||
*
|
*
|
||||||
* @param gui The {@link GUI} this {@link Animation} will take place in
|
* @param gui The {@link Gui} this {@link Animation} will take place in
|
||||||
*/
|
*/
|
||||||
void setGUI(GUI gui);
|
void setGui(Gui gui);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link Window}s that will see this animation.
|
* Sets the {@link Window}s that will see this animation.
|
||||||
|
@ -2,7 +2,7 @@ package de.studiocode.invui.animation.impl;
|
|||||||
|
|
||||||
import de.studiocode.invui.InvUI;
|
import de.studiocode.invui.InvUI;
|
||||||
import de.studiocode.invui.animation.Animation;
|
import de.studiocode.invui.animation.Animation;
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.util.SlotUtils;
|
import de.studiocode.invui.util.SlotUtils;
|
||||||
import de.studiocode.invui.window.Window;
|
import de.studiocode.invui.window.Window;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -23,7 +23,7 @@ public abstract class BaseAnimation implements Animation {
|
|||||||
private final List<Runnable> finishHandlers = new ArrayList<>();
|
private final List<Runnable> finishHandlers = new ArrayList<>();
|
||||||
private final int tickDelay;
|
private final int tickDelay;
|
||||||
|
|
||||||
private GUI gui;
|
private Gui gui;
|
||||||
private int width;
|
private int width;
|
||||||
private int height;
|
private int height;
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ public abstract class BaseAnimation implements Animation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGUI(GUI gui) {
|
public void setGui(Gui gui) {
|
||||||
this.gui = gui;
|
this.gui = gui;
|
||||||
this.width = gui.getWidth();
|
this.width = gui.getWidth();
|
||||||
this.height = gui.getHeight();
|
this.height = gui.getHeight();
|
||||||
|
@ -30,20 +30,20 @@ import java.util.*;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public abstract class AbstractGUI implements GUI, GUIParent {
|
public abstract class AbstractGui implements Gui, GuiParent {
|
||||||
|
|
||||||
private final int width;
|
private final int width;
|
||||||
private final int height;
|
private final int height;
|
||||||
private final int size;
|
private final int size;
|
||||||
private final SlotElement[] slotElements;
|
private final SlotElement[] slotElements;
|
||||||
private final Set<GUIParent> parents = new HashSet<>();
|
private final Set<GuiParent> parents = new HashSet<>();
|
||||||
|
|
||||||
private SlotElement[] animationElements;
|
private SlotElement[] animationElements;
|
||||||
private Animation animation;
|
private Animation animation;
|
||||||
|
|
||||||
private ItemProvider background;
|
private ItemProvider background;
|
||||||
|
|
||||||
public AbstractGUI(int width, int height) {
|
public AbstractGui(int width, int height) {
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
this.size = width * height;
|
this.size = width * height;
|
||||||
@ -60,7 +60,7 @@ public abstract class AbstractGUI implements GUI, GUIParent {
|
|||||||
SlotElement slotElement = slotElements[slotNumber];
|
SlotElement slotElement = slotElements[slotNumber];
|
||||||
if (slotElement instanceof LinkedSlotElement) {
|
if (slotElement instanceof LinkedSlotElement) {
|
||||||
LinkedSlotElement linkedElement = (LinkedSlotElement) slotElement;
|
LinkedSlotElement linkedElement = (LinkedSlotElement) slotElement;
|
||||||
AbstractGUI gui = (AbstractGUI) linkedElement.getGUI();
|
AbstractGui gui = (AbstractGui) linkedElement.getGui();
|
||||||
gui.handleClick(linkedElement.getSlotIndex(), player, clickType, event);
|
gui.handleClick(linkedElement.getSlotIndex(), player, clickType, event);
|
||||||
} else if (slotElement instanceof ItemSlotElement) {
|
} else if (slotElement instanceof ItemSlotElement) {
|
||||||
event.setCancelled(true); // if it is an Item, don't let the player move it
|
event.setCancelled(true); // if it is an Item, don't let the player move it
|
||||||
@ -208,16 +208,16 @@ public abstract class AbstractGUI implements GUI, GUIParent {
|
|||||||
if (!updateEvent.isCancelled()) {
|
if (!updateEvent.isCancelled()) {
|
||||||
int leftOverAmount;
|
int leftOverAmount;
|
||||||
if (window instanceof AbstractDoubleWindow) {
|
if (window instanceof AbstractDoubleWindow) {
|
||||||
GUI otherGui;
|
Gui otherGui;
|
||||||
if (window instanceof AbstractSplitWindow) {
|
if (window instanceof AbstractSplitWindow) {
|
||||||
AbstractSplitWindow splitWindow = (AbstractSplitWindow) window;
|
AbstractSplitWindow splitWindow = (AbstractSplitWindow) window;
|
||||||
GUI[] guis = splitWindow.getGUIs();
|
Gui[] guis = splitWindow.getGuis();
|
||||||
otherGui = guis[0] == this ? guis[1] : guis[0];
|
otherGui = guis[0] == this ? guis[1] : guis[0];
|
||||||
} else {
|
} else {
|
||||||
otherGui = this;
|
otherGui = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
leftOverAmount = ((AbstractGUI) otherGui).putIntoFirstVirtualInventory(updateReason, clicked, inventory);
|
leftOverAmount = ((AbstractGui) otherGui).putIntoFirstVirtualInventory(updateReason, clicked, inventory);
|
||||||
} else {
|
} else {
|
||||||
leftOverAmount = InventoryUtils.addItemCorrectly(event.getWhoClicked().getInventory(), inventory.getItemStack(slot));
|
leftOverAmount = InventoryUtils.addItemCorrectly(event.getWhoClicked().getInventory(), inventory.getItemStack(slot));
|
||||||
}
|
}
|
||||||
@ -345,40 +345,40 @@ public abstract class AbstractGUI implements GUI, GUIParent {
|
|||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleSlotElementUpdate(GUI child, int slotIndex) {
|
public void handleSlotElementUpdate(Gui child, int slotIndex) {
|
||||||
// find all SlotElements that link to this slotIndex in this child GUI and notify all parents
|
// find all SlotElements that link to this slotIndex in this child Gui and notify all parents
|
||||||
for (int index = 0; index < size; index++) {
|
for (int index = 0; index < size; index++) {
|
||||||
SlotElement element = slotElements[index];
|
SlotElement element = slotElements[index];
|
||||||
if (element instanceof LinkedSlotElement) {
|
if (element instanceof LinkedSlotElement) {
|
||||||
LinkedSlotElement linkedSlotElement = (LinkedSlotElement) element;
|
LinkedSlotElement linkedSlotElement = (LinkedSlotElement) element;
|
||||||
if (linkedSlotElement.getGUI() == child && linkedSlotElement.getSlotIndex() == slotIndex)
|
if (linkedSlotElement.getGui() == child && linkedSlotElement.getSlotIndex() == slotIndex)
|
||||||
for (GUIParent parent : parents) parent.handleSlotElementUpdate(this, index);
|
for (GuiParent parent : parents) parent.handleSlotElementUpdate(this, index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addParent(@NotNull GUIParent parent) {
|
public void addParent(@NotNull GuiParent parent) {
|
||||||
parents.add(parent);
|
parents.add(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeParent(@NotNull GUIParent parent) {
|
public void removeParent(@NotNull GuiParent parent) {
|
||||||
parents.remove(parent);
|
parents.remove(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<GUIParent> getParents() {
|
public Set<GuiParent> getParents() {
|
||||||
return parents;
|
return parents;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Window> findAllWindows() {
|
public @NotNull List<@NotNull Window> findAllWindows() {
|
||||||
List<Window> windows = new ArrayList<>();
|
List<Window> windows = new ArrayList<>();
|
||||||
List<GUIParent> unexploredParents = new ArrayList<>(this.parents);
|
List<GuiParent> unexploredParents = new ArrayList<>(this.parents);
|
||||||
|
|
||||||
while (!unexploredParents.isEmpty()) {
|
while (!unexploredParents.isEmpty()) {
|
||||||
List<GUIParent> parents = new ArrayList<>(unexploredParents);
|
List<GuiParent> parents = new ArrayList<>(unexploredParents);
|
||||||
unexploredParents.clear();
|
unexploredParents.clear();
|
||||||
for (GUIParent parent : parents) {
|
for (GuiParent parent : parents) {
|
||||||
if (parent instanceof AbstractGUI) unexploredParents.addAll(((AbstractGUI) parent).getParents());
|
if (parent instanceof AbstractGui) unexploredParents.addAll(((AbstractGui) parent).getParents());
|
||||||
else if (parent instanceof Window) windows.add((Window) parent);
|
else if (parent instanceof Window) windows.add((Window) parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -387,7 +387,7 @@ public abstract class AbstractGUI implements GUI, GUIParent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Player> findAllCurrentViewers() {
|
public @NotNull Set<@NotNull Player> findAllCurrentViewers() {
|
||||||
return findAllWindows().stream()
|
return findAllWindows().stream()
|
||||||
.map(Window::getCurrentViewer)
|
.map(Window::getCurrentViewer)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
@ -400,7 +400,7 @@ public abstract class AbstractGUI implements GUI, GUIParent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playAnimation(@NotNull Animation animation, @Nullable Predicate<SlotElement> filter) {
|
public void playAnimation(@NotNull Animation animation, @Nullable Predicate<@NotNull SlotElement> filter) {
|
||||||
if (animation != null) cancelAnimation();
|
if (animation != null) cancelAnimation();
|
||||||
|
|
||||||
this.animation = animation;
|
this.animation = animation;
|
||||||
@ -416,7 +416,7 @@ public abstract class AbstractGUI implements GUI, GUIParent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
animation.setSlots(slots);
|
animation.setSlots(slots);
|
||||||
animation.setGUI(this);
|
animation.setGui(this);
|
||||||
animation.setWindows(findAllWindows());
|
animation.setWindows(findAllWindows());
|
||||||
animation.addShowHandler((frame, index) -> setSlotElement(index, animationElements[index]));
|
animation.addShowHandler((frame, index) -> setSlotElement(index, animationElements[index]));
|
||||||
animation.addFinishHandler(() -> {
|
animation.addFinishHandler(() -> {
|
||||||
@ -461,28 +461,28 @@ public abstract class AbstractGUI implements GUI, GUIParent {
|
|||||||
if (slotElement instanceof ItemSlotElement) {
|
if (slotElement instanceof ItemSlotElement) {
|
||||||
Item item = ((ItemSlotElement) slotElement).getItem();
|
Item item = ((ItemSlotElement) slotElement).getItem();
|
||||||
if (item instanceof ControlItem<?>)
|
if (item instanceof ControlItem<?>)
|
||||||
((ControlItem<?>) item).setGUI(this);
|
((ControlItem<?>) item).setGui(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify parents that a SlotElement has been changed
|
// notify parents that a SlotElement has been changed
|
||||||
parents.forEach(parent -> parent.handleSlotElementUpdate(this, index));
|
parents.forEach(parent -> parent.handleSlotElementUpdate(this, index));
|
||||||
|
|
||||||
AbstractGUI oldLink = oldElement instanceof LinkedSlotElement ? (AbstractGUI) ((LinkedSlotElement) oldElement).getGUI() : null;
|
AbstractGui oldLink = oldElement instanceof LinkedSlotElement ? (AbstractGui) ((LinkedSlotElement) oldElement).getGui() : null;
|
||||||
AbstractGUI newLink = slotElement instanceof LinkedSlotElement ? (AbstractGUI) ((LinkedSlotElement) slotElement).getGUI() : null;
|
AbstractGui newLink = slotElement instanceof LinkedSlotElement ? (AbstractGui) ((LinkedSlotElement) slotElement).getGui() : null;
|
||||||
|
|
||||||
// if newLink is the same as oldLink, there isn't anything to be done
|
// if newLink is the same as oldLink, there isn't anything to be done
|
||||||
if (newLink == oldLink) return;
|
if (newLink == oldLink) return;
|
||||||
|
|
||||||
// if the slot previously linked to GUI
|
// if the slot previously linked to Gui
|
||||||
if (oldLink != null) {
|
if (oldLink != null) {
|
||||||
// If no other slot still links to that GUI, remove this GUI from parents
|
// If no other slot still links to that Gui, remove this Gui from parents
|
||||||
if (Arrays.stream(slotElements)
|
if (Arrays.stream(slotElements)
|
||||||
.filter(element -> element instanceof LinkedSlotElement)
|
.filter(element -> element instanceof LinkedSlotElement)
|
||||||
.map(element -> ((LinkedSlotElement) element).getGUI())
|
.map(element -> ((LinkedSlotElement) element).getGui())
|
||||||
.noneMatch(gui -> gui == oldLink)) oldLink.removeParent(this);
|
.noneMatch(gui -> gui == oldLink)) oldLink.removeParent(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the slot now links to a GUI add this as parent
|
// if the slot now links to a Gui add this as parent
|
||||||
if (newLink != null) {
|
if (newLink != null) {
|
||||||
newLink.addParent(this);
|
newLink.addParent(this);
|
||||||
}
|
}
|
||||||
@ -498,7 +498,7 @@ public abstract class AbstractGUI implements GUI, GUIParent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SlotElement getSlotElement(int index) {
|
public @Nullable SlotElement getSlotElement(int index) {
|
||||||
return slotElements[index];
|
return slotElements[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -559,7 +559,7 @@ public abstract class AbstractGUI implements GUI, GUIParent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyStructure(@NotNull Structure structure) {
|
public void applyStructure(@NotNull Structure structure) {
|
||||||
structure.getIngredientList().insertIntoGUI(this);
|
structure.getIngredientList().insertIntoGui(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -574,7 +574,7 @@ public abstract class AbstractGUI implements GUI, GUIParent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SlotElement getSlotElement(int x, int y) {
|
public @Nullable SlotElement getSlotElement(int x, int y) {
|
||||||
return getSlotElement(convToIndex(x, y));
|
return getSlotElement(convToIndex(x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -656,7 +656,7 @@ public abstract class AbstractGUI implements GUI, GUIParent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fillRectangle(int x, int y, @NotNull GUI gui, boolean replaceExisting) {
|
public void fillRectangle(int x, int y, @NotNull Gui gui, boolean replaceExisting) {
|
||||||
int slotIndex = 0;
|
int slotIndex = 0;
|
||||||
for (int slot : SlotUtils.getSlotsRect(x, y, gui.getWidth(), gui.getHeight(), this.width)) {
|
for (int slot : SlotUtils.getSlotsRect(x, y, gui.getWidth(), gui.getHeight(), this.width)) {
|
||||||
if (hasSlotElement(slot) && !replaceExisting) continue;
|
if (hasSlotElement(slot) && !replaceExisting) continue;
|
@ -1,8 +1,8 @@
|
|||||||
package de.studiocode.invui.gui;
|
package de.studiocode.invui.gui;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.builder.GUIBuilder;
|
import de.studiocode.invui.gui.builder.GuiBuilder;
|
||||||
import de.studiocode.invui.gui.impl.PageNestedGUIImpl;
|
import de.studiocode.invui.gui.impl.PagedNestedGuiImpl;
|
||||||
import de.studiocode.invui.gui.impl.PagedItemsGUIImpl;
|
import de.studiocode.invui.gui.impl.PagedItemsGuiImpl;
|
||||||
import de.studiocode.invui.gui.structure.Structure;
|
import de.studiocode.invui.gui.structure.Structure;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -12,13 +12,13 @@ import java.util.List;
|
|||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link GUI} with pages.
|
* A {@link Gui} with pages.
|
||||||
*
|
*
|
||||||
* @see GUIBuilder
|
* @see GuiBuilder
|
||||||
* @see PagedItemsGUIImpl
|
* @see PagedItemsGuiImpl
|
||||||
* @see PageNestedGUIImpl
|
* @see PagedNestedGuiImpl
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractPagedGUI<C> extends AbstractGUI implements PagedGUI<C> {
|
public abstract class AbstractPagedGui<C> extends AbstractGui implements PagedGui<C> {
|
||||||
|
|
||||||
private final boolean infinitePages;
|
private final boolean infinitePages;
|
||||||
private final int[] contentListSlots;
|
private final int[] contentListSlots;
|
||||||
@ -26,13 +26,13 @@ public abstract class AbstractPagedGUI<C> extends AbstractGUI implements PagedGU
|
|||||||
|
|
||||||
private List<BiConsumer<Integer, Integer>> pageChangeHandlers;
|
private List<BiConsumer<Integer, Integer>> pageChangeHandlers;
|
||||||
|
|
||||||
public AbstractPagedGUI(int width, int height, boolean infinitePages, int... contentListSlots) {
|
public AbstractPagedGui(int width, int height, boolean infinitePages, int... contentListSlots) {
|
||||||
super(width, height);
|
super(width, height);
|
||||||
this.infinitePages = infinitePages;
|
this.infinitePages = infinitePages;
|
||||||
this.contentListSlots = contentListSlots;
|
this.contentListSlots = contentListSlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractPagedGUI(int width, int height, boolean infinitePages, Structure structure) {
|
public AbstractPagedGui(int width, int height, boolean infinitePages, Structure structure) {
|
||||||
this(width, height, infinitePages, structure.getIngredientList().findContentListSlots());
|
this(width, height, infinitePages, structure.getIngredientList().findContentListSlots());
|
||||||
applyStructure(structure);
|
applyStructure(structure);
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ public abstract class AbstractPagedGUI<C> extends AbstractGUI implements PagedGU
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPageChangeHandlers(@Nullable List<BiConsumer<Integer, Integer>> handlers) {
|
public void setPageChangeHandlers(@Nullable List<@NotNull BiConsumer<Integer, Integer>> handlers) {
|
||||||
this.pageChangeHandlers = handlers;
|
this.pageChangeHandlers = handlers;
|
||||||
}
|
}
|
||||||
|
|
@ -1,19 +1,19 @@
|
|||||||
package de.studiocode.invui.gui;
|
package de.studiocode.invui.gui;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.impl.ScrollItemsGUIImpl;
|
import de.studiocode.invui.gui.impl.ScrollItemsGuiImpl;
|
||||||
import de.studiocode.invui.gui.impl.ScrollNestedGUIImpl;
|
import de.studiocode.invui.gui.impl.ScrollNestedGuiImpl;
|
||||||
import de.studiocode.invui.gui.structure.Structure;
|
import de.studiocode.invui.gui.structure.Structure;
|
||||||
import de.studiocode.invui.util.SlotUtils;
|
import de.studiocode.invui.util.SlotUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A scrollable {@link GUI}
|
* A scrollable {@link Gui}
|
||||||
*
|
*
|
||||||
* @see ScrollItemsGUIImpl
|
* @see ScrollItemsGuiImpl
|
||||||
* @see ScrollNestedGUIImpl
|
* @see ScrollNestedGuiImpl
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractScrollGUI<C> extends AbstractGUI implements ScrollGUI<C> {
|
public abstract class AbstractScrollGui<C> extends AbstractGui implements ScrollGui<C> {
|
||||||
|
|
||||||
private final boolean infiniteLines;
|
private final boolean infiniteLines;
|
||||||
private final int lineLength;
|
private final int lineLength;
|
||||||
@ -22,7 +22,7 @@ public abstract class AbstractScrollGUI<C> extends AbstractGUI implements Scroll
|
|||||||
|
|
||||||
protected int offset;
|
protected int offset;
|
||||||
|
|
||||||
public AbstractScrollGUI(int width, int height, boolean infiniteLines, int... contentListSlots) {
|
public AbstractScrollGui(int width, int height, boolean infiniteLines, int... contentListSlots) {
|
||||||
super(width, height);
|
super(width, height);
|
||||||
this.infiniteLines = infiniteLines;
|
this.infiniteLines = infiniteLines;
|
||||||
this.contentListSlots = contentListSlots;
|
this.contentListSlots = contentListSlots;
|
||||||
@ -37,7 +37,7 @@ public abstract class AbstractScrollGUI<C> extends AbstractGUI implements Scroll
|
|||||||
throw new IllegalArgumentException("contentListSlots has to be a multiple of lineLength");
|
throw new IllegalArgumentException("contentListSlots has to be a multiple of lineLength");
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractScrollGUI(int width, int height, boolean infiniteLines, Structure structure) {
|
public AbstractScrollGui(int width, int height, boolean infiniteLines, Structure structure) {
|
||||||
this(width, height, infiniteLines, structure.getIngredientList().findContentListSlots());
|
this(width, height, infiniteLines, structure.getIngredientList().findContentListSlots());
|
||||||
applyStructure(structure);
|
applyStructure(structure);
|
||||||
}
|
}
|
@ -8,7 +8,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
public abstract class AbstractTabGUI extends AbstractGUI implements TabGUI {
|
public abstract class AbstractTabGui extends AbstractGui implements TabGui {
|
||||||
|
|
||||||
private final int tabAmount;
|
private final int tabAmount;
|
||||||
private final int[] listSlots;
|
private final int[] listSlots;
|
||||||
@ -17,13 +17,13 @@ public abstract class AbstractTabGUI extends AbstractGUI implements TabGUI {
|
|||||||
|
|
||||||
private List<BiConsumer<Integer, Integer>> tabChangeHandlers;
|
private List<BiConsumer<Integer, Integer>> tabChangeHandlers;
|
||||||
|
|
||||||
public AbstractTabGUI(int width, int height, int tabAmount, int... listSlots) {
|
public AbstractTabGui(int width, int height, int tabAmount, int... listSlots) {
|
||||||
super(width, height);
|
super(width, height);
|
||||||
this.tabAmount = tabAmount;
|
this.tabAmount = tabAmount;
|
||||||
this.listSlots = listSlots;
|
this.listSlots = listSlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractTabGUI(int width, int height, int tabAmount, Structure structure) {
|
public AbstractTabGui(int width, int height, int tabAmount, Structure structure) {
|
||||||
this(width, height, tabAmount, structure.getIngredientList().findContentListSlots());
|
this(width, height, tabAmount, structure.getIngredientList().findContentListSlots());
|
||||||
applyStructure(structure);
|
applyStructure(structure);
|
||||||
}
|
}
|
||||||
@ -73,13 +73,12 @@ public abstract class AbstractTabGUI extends AbstractGUI implements TabGUI {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
public @Nullable List<@NotNull BiConsumer<Integer, Integer>> getTabChangeHandlers() {
|
||||||
public List<BiConsumer<Integer, Integer>> getTabChangeHandlers() {
|
|
||||||
return tabChangeHandlers;
|
return tabChangeHandlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTabChangeHandlers(@Nullable List<BiConsumer<Integer, Integer>> tabChangeHandlers) {
|
public void setTabChangeHandlers(@Nullable List<@NotNull BiConsumer<Integer, Integer>> tabChangeHandlers) {
|
||||||
this.tabChangeHandlers = tabChangeHandlers;
|
this.tabChangeHandlers = tabChangeHandlers;
|
||||||
}
|
}
|
||||||
|
|
@ -1,13 +0,0 @@
|
|||||||
package de.studiocode.invui.gui;
|
|
||||||
|
|
||||||
public interface GUIParent {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by the child {@link GUI} to report an update of a {@link SlotElement}.
|
|
||||||
*
|
|
||||||
* @param child The child {@link GUI} whose {@link SlotElement} has changed
|
|
||||||
* @param slotIndex The slot index of the changed {@link SlotElement} in the child {@link GUI}
|
|
||||||
*/
|
|
||||||
void handleSlotElementUpdate(GUI child, int slotIndex);
|
|
||||||
|
|
||||||
}
|
|
@ -1,15 +1,15 @@
|
|||||||
package de.studiocode.invui.gui;
|
package de.studiocode.invui.gui;
|
||||||
|
|
||||||
import de.studiocode.invui.animation.Animation;
|
import de.studiocode.invui.animation.Animation;
|
||||||
import de.studiocode.invui.gui.builder.GUIBuilder;
|
import de.studiocode.invui.gui.builder.GuiBuilder;
|
||||||
import de.studiocode.invui.gui.impl.*;
|
import de.studiocode.invui.gui.impl.NormalGuiImpl;
|
||||||
import de.studiocode.invui.gui.structure.Structure;
|
import de.studiocode.invui.gui.structure.Structure;
|
||||||
import de.studiocode.invui.item.Item;
|
import de.studiocode.invui.item.Item;
|
||||||
import de.studiocode.invui.item.ItemProvider;
|
import de.studiocode.invui.item.ItemProvider;
|
||||||
import de.studiocode.invui.virtualinventory.VirtualInventory;
|
import de.studiocode.invui.virtualinventory.VirtualInventory;
|
||||||
import de.studiocode.invui.window.Window;
|
import de.studiocode.invui.window.Window;
|
||||||
|
import de.studiocode.invui.window.WindowManager;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -19,48 +19,63 @@ import java.util.Set;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A GUI is a container for width * height {@link SlotElement SlotElements}.<br>
|
* A Gui is a container for width * height {@link SlotElement SlotElements}.<br>
|
||||||
* Each {@link SlotElement} can either be an {@link Item},
|
* Each {@link SlotElement} can either be an {@link Item},
|
||||||
* a reference to a {@link VirtualInventory}'s or another {@link GUI}'s
|
* a reference to a {@link VirtualInventory}'s or another {@link Gui}'s
|
||||||
* slot index.<br>
|
* slot index.<br>
|
||||||
* A {@link GUI} is not an {@link Inventory}, nor does
|
* A {@link Gui} is not an {@link Inventory}, nor does
|
||||||
* it access one. It just contains {@link SlotElement SlotElements} and their positions.<br>
|
* it access one. It just contains {@link SlotElement SlotElements} and their positions.<br>
|
||||||
* In order to create an {@link Inventory} which is visible
|
* In order to create an {@link Inventory} which is visible
|
||||||
* to players, you will need to use a {@link Window}.
|
* to players, you will need to use a {@link Window}.
|
||||||
*
|
*
|
||||||
* @see GUIBuilder
|
* @see GuiBuilder
|
||||||
* @see AbstractGUI
|
* @see AbstractGui
|
||||||
* @see AbstractPagedGUI
|
* @see AbstractPagedGui
|
||||||
* @see AbstractScrollGUI
|
* @see AbstractScrollGui
|
||||||
* @see AbstractTabGUI
|
* @see AbstractTabGui
|
||||||
* @see NormalGUIImpl
|
|
||||||
* @see PagedItemsGUIImpl
|
|
||||||
* @see PageNestedGUIImpl
|
|
||||||
* @see ScrollItemsGUIImpl
|
|
||||||
* @see ScrollNestedGUIImpl
|
|
||||||
* @see ScrollVIGUIImpl
|
|
||||||
* @see TabGUIImpl
|
|
||||||
*/
|
*/
|
||||||
public interface GUI {
|
@SuppressWarnings("deprecation")
|
||||||
|
public interface Gui {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the size of the {@link GUI}.
|
* Creates a new empty {@link Gui}.
|
||||||
|
*
|
||||||
|
* @param width The width of the {@link Gui}.
|
||||||
|
* @param height The height of the {@link Gui}.
|
||||||
|
* @return The created {@link Gui}.
|
||||||
|
*/
|
||||||
|
static @NotNull Gui empty(int width, int height) {
|
||||||
|
return new NormalGuiImpl(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new empty {@link Gui}.
|
||||||
|
*
|
||||||
|
* @param structure The {@link Structure} of the {@link Gui}.
|
||||||
|
* @return The created {@link Gui}.
|
||||||
|
*/
|
||||||
|
static @NotNull Gui of(@NotNull Structure structure) {
|
||||||
|
return new NormalGuiImpl(structure);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the size of the {@link Gui}.
|
||||||
*
|
*
|
||||||
* @return The size of the gui.
|
* @return The size of the gui.
|
||||||
*/
|
*/
|
||||||
int getSize();
|
int getSize();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the width of the {@link GUI}
|
* Gets the width of the {@link Gui}
|
||||||
*
|
*
|
||||||
* @return The width of the {@link GUI}
|
* @return The width of the {@link Gui}
|
||||||
*/
|
*/
|
||||||
int getWidth();
|
int getWidth();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the height of the {@link GUI}
|
* Gets the height of the {@link Gui}
|
||||||
*
|
*
|
||||||
* @return The height of the {@link GUI}
|
* @return The height of the {@link Gui}
|
||||||
*/
|
*/
|
||||||
int getHeight();
|
int getHeight();
|
||||||
|
|
||||||
@ -84,7 +99,7 @@ public interface GUI {
|
|||||||
void setSlotElement(int index, @Nullable SlotElement slotElement);
|
void setSlotElement(int index, @Nullable SlotElement slotElement);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds {@link SlotElement SlotElements} to the {@link GUI}.
|
* Adds {@link SlotElement SlotElements} to the {@link Gui}.
|
||||||
*
|
*
|
||||||
* @param slotElements The {@link SlotElement SlotElements} to add.
|
* @param slotElements The {@link SlotElement SlotElements} to add.
|
||||||
*/
|
*/
|
||||||
@ -97,7 +112,7 @@ public interface GUI {
|
|||||||
* @param y The y coordinate
|
* @param y The y coordinate
|
||||||
* @return The {@link SlotElement} placed there
|
* @return The {@link SlotElement} placed there
|
||||||
*/
|
*/
|
||||||
SlotElement getSlotElement(int x, int y);
|
@Nullable SlotElement getSlotElement(int x, int y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link SlotElement} placed on that slot.
|
* Gets the {@link SlotElement} placed on that slot.
|
||||||
@ -105,7 +120,7 @@ public interface GUI {
|
|||||||
* @param index The slot index
|
* @param index The slot index
|
||||||
* @return The {@link SlotElement} placed on that slot
|
* @return The {@link SlotElement} placed on that slot
|
||||||
*/
|
*/
|
||||||
SlotElement getSlotElement(int index);
|
@Nullable SlotElement getSlotElement(int index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets if there is a {@link SlotElement} on these coordinates.
|
* Gets if there is a {@link SlotElement} on these coordinates.
|
||||||
@ -125,12 +140,11 @@ public interface GUI {
|
|||||||
boolean hasSlotElement(int index);
|
boolean hasSlotElement(int index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all {@link SlotElement SlotElements} of this {@link GUI} in an Array.
|
* Gets all {@link SlotElement SlotElements} of this {@link Gui} in an Array.
|
||||||
*
|
*
|
||||||
* @return All {@link SlotElement SlotElements} of this {@link GUI}
|
* @return All {@link SlotElement SlotElements} of this {@link Gui}
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable SlotElement @NotNull [] getSlotElements();
|
||||||
SlotElement @NotNull [] getSlotElements();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link Item} on these coordinates.
|
* Sets the {@link Item} on these coordinates.
|
||||||
@ -165,8 +179,7 @@ public interface GUI {
|
|||||||
* @param y The y coordinate
|
* @param y The y coordinate
|
||||||
* @return The {@link Item} which is placed on that slot or null if there isn't one
|
* @return The {@link Item} which is placed on that slot or null if there isn't one
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable Item getItem(int x, int y);
|
||||||
Item getItem(int x, int y);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link Item} placed on that slot.
|
* Gets the {@link Item} placed on that slot.
|
||||||
@ -174,8 +187,7 @@ public interface GUI {
|
|||||||
* @param index The slot index
|
* @param index The slot index
|
||||||
* @return The {@link Item} which is placed on that slot or null if there isn't one
|
* @return The {@link Item} which is placed on that slot or null if there isn't one
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable Item getItem(int index);
|
||||||
Item getItem(int index);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the {@link ItemProvider} that will be used if nothing else
|
* Gets the {@link ItemProvider} that will be used if nothing else
|
||||||
@ -183,8 +195,7 @@ public interface GUI {
|
|||||||
*
|
*
|
||||||
* @return The {@link ItemProvider}
|
* @return The {@link ItemProvider}
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable ItemProvider getBackground();
|
||||||
ItemProvider getBackground();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link ItemProvider} that will be used if nothing else
|
* Sets the {@link ItemProvider} that will be used if nothing else
|
||||||
@ -210,32 +221,32 @@ public interface GUI {
|
|||||||
void remove(int index);
|
void remove(int index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies the given {@link Structure} to the {@link GUI}.
|
* Applies the given {@link Structure} to the {@link Gui}.
|
||||||
*
|
*
|
||||||
* @param structure The structure
|
* @param structure The structure
|
||||||
*/
|
*/
|
||||||
void applyStructure(@NotNull Structure structure);
|
void applyStructure(@NotNull Structure structure);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all {@link Window Windows} that show this {@link GUI}.
|
* Finds all {@link Window Windows} that show this {@link Gui}.
|
||||||
*
|
*
|
||||||
* @return The list of {@link Window} that show this {@link GUI}
|
* @return The list of {@link Window} that show this {@link Gui}
|
||||||
*/
|
*/
|
||||||
List<Window> findAllWindows();
|
@NotNull List<@NotNull Window> findAllWindows();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds all {@link Player Players} that are currently seeing this {@link Window}.
|
* Finds all {@link Player Players} that are currently seeing this {@link Window}.
|
||||||
*
|
*
|
||||||
* @return The list of {@link Player Players} that are currently seeing this {@link Window}
|
* @return The list of {@link Player Players} that are currently seeing this {@link Window}
|
||||||
*/
|
*/
|
||||||
Set<Player> findAllCurrentViewers();
|
@NotNull Set<@NotNull Player> findAllCurrentViewers();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the open {@link Inventory} for all viewers of {@link Window Windows}
|
* Closes the open {@link Inventory} for all viewers of {@link Window Windows}
|
||||||
* where this {@link GUI} is displayed.
|
* where this {@link Gui} is displayed.
|
||||||
* Does not actually call the {@link Window#remove(boolean)} method, which will
|
* <p>
|
||||||
* be indirectly invoked by the {@link InventoryCloseEvent} if the {@link Window}
|
* If the {@link Window Windows} are not marked as "retain",
|
||||||
* is set to close on that event.
|
* they will be removed from the {@link WindowManager} automatically.
|
||||||
*/
|
*/
|
||||||
void closeForAllViewers();
|
void closeForAllViewers();
|
||||||
|
|
||||||
@ -245,7 +256,7 @@ public interface GUI {
|
|||||||
* @param animation The {@link Animation} to play.
|
* @param animation The {@link Animation} to play.
|
||||||
* @param filter The filter that selects which {@link SlotElement SlotElements} should be animated.
|
* @param filter The filter that selects which {@link SlotElement SlotElements} should be animated.
|
||||||
*/
|
*/
|
||||||
void playAnimation(@NotNull Animation animation, @Nullable Predicate<SlotElement> filter);
|
void playAnimation(@NotNull Animation animation, @Nullable Predicate<@NotNull SlotElement> filter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancels the running {@link Animation} if there is one.
|
* Cancels the running {@link Animation} if there is one.
|
||||||
@ -255,7 +266,7 @@ public interface GUI {
|
|||||||
//<editor-fold desc="fill methods">
|
//<editor-fold desc="fill methods">
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills the {@link GUI} with {@link Item Items}.
|
* Fills the {@link Gui} with {@link Item Items}.
|
||||||
*
|
*
|
||||||
* @param start The start index of the fill (inclusive)
|
* @param start The start index of the fill (inclusive)
|
||||||
* @param end The end index of the fill (exclusive)
|
* @param end The end index of the fill (exclusive)
|
||||||
@ -265,7 +276,7 @@ public interface GUI {
|
|||||||
void fill(int start, int end, @Nullable Item item, boolean replaceExisting);
|
void fill(int start, int end, @Nullable Item item, boolean replaceExisting);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills the entire {@link GUI} with {@link Item Items}.
|
* Fills the entire {@link Gui} with {@link Item Items}.
|
||||||
*
|
*
|
||||||
* @param item The {@link Item} that should be used or null to remove an existing item.
|
* @param item The {@link Item} that should be used or null to remove an existing item.
|
||||||
* @param replaceExisting If existing {@link Item Items} should be replaced.
|
* @param replaceExisting If existing {@link Item Items} should be replaced.
|
||||||
@ -291,7 +302,7 @@ public interface GUI {
|
|||||||
void fillColumn(int column, @Nullable Item item, boolean replaceExisting);
|
void fillColumn(int column, @Nullable Item item, boolean replaceExisting);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills the borders of this {@link GUI} with a specific {@link Item}
|
* Fills the borders of this {@link Gui} with a specific {@link Item}
|
||||||
*
|
*
|
||||||
* @param item The {@link Item} that should be used or null to remove an existing item.
|
* @param item The {@link Item} that should be used or null to remove an existing item.
|
||||||
* @param replaceExisting If existing {@link Item Items} should be replaced.
|
* @param replaceExisting If existing {@link Item Items} should be replaced.
|
||||||
@ -299,7 +310,7 @@ public interface GUI {
|
|||||||
void fillBorders(@Nullable Item item, boolean replaceExisting);
|
void fillBorders(@Nullable Item item, boolean replaceExisting);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills a rectangle in this {@link GUI} with a specific {@link Item}
|
* Fills a rectangle in this {@link Gui} with a specific {@link Item}
|
||||||
*
|
*
|
||||||
* @param x The x coordinate where the rectangle should start.
|
* @param x The x coordinate where the rectangle should start.
|
||||||
* @param y The y coordinate where the rectangle should start.
|
* @param y The y coordinate where the rectangle should start.
|
||||||
@ -311,33 +322,33 @@ public interface GUI {
|
|||||||
void fillRectangle(int x, int y, int width, int height, @Nullable Item item, boolean replaceExisting);
|
void fillRectangle(int x, int y, int width, int height, @Nullable Item item, boolean replaceExisting);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills a rectangle with another {@link GUI} in this {@link GUI}.
|
* Fills a rectangle with another {@link Gui} in this {@link Gui}.
|
||||||
*
|
*
|
||||||
* @param x The x coordinate where the rectangle should start
|
* @param x The x coordinate where the rectangle should start
|
||||||
* @param y The y coordinate where the rectangle should start
|
* @param y The y coordinate where the rectangle should start
|
||||||
* @param gui The {@link GUI} to be put into this {@link GUI}
|
* @param gui The {@link Gui} to be put into this {@link Gui}
|
||||||
* @param replaceExisting If existing {@link SlotElement SlotElements} should be replaced.
|
* @param replaceExisting If existing {@link SlotElement SlotElements} should be replaced.
|
||||||
*/
|
*/
|
||||||
void fillRectangle(int x, int y, @NotNull GUI gui, boolean replaceExisting);
|
void fillRectangle(int x, int y, @NotNull Gui gui, boolean replaceExisting);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills a rectangle with a {@link VirtualInventory} in this {@link GUI}.
|
* Fills a rectangle with a {@link VirtualInventory} in this {@link Gui}.
|
||||||
*
|
*
|
||||||
* @param x The x coordinate where the rectangle should start
|
* @param x The x coordinate where the rectangle should start
|
||||||
* @param y The y coordinate where the rectangle should start
|
* @param y The y coordinate where the rectangle should start
|
||||||
* @param width The line length of the rectangle. (VirtualInventory does not define a width)
|
* @param width The line length of the rectangle. (VirtualInventory does not define a width)
|
||||||
* @param virtualInventory The {@link VirtualInventory} to be put into this {@link GUI}.
|
* @param virtualInventory The {@link VirtualInventory} to be put into this {@link Gui}.
|
||||||
* @param replaceExisting If existing {@link SlotElement SlotElements} should be replaced.
|
* @param replaceExisting If existing {@link SlotElement SlotElements} should be replaced.
|
||||||
*/
|
*/
|
||||||
void fillRectangle(int x, int y, int width, @NotNull VirtualInventory virtualInventory, boolean replaceExisting);
|
void fillRectangle(int x, int y, int width, @NotNull VirtualInventory virtualInventory, boolean replaceExisting);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fills a rectangle with a {@link VirtualInventory} in this {@link GUI}.
|
* Fills a rectangle with a {@link VirtualInventory} in this {@link Gui}.
|
||||||
*
|
*
|
||||||
* @param x The x coordinate where the rectangle should start
|
* @param x The x coordinate where the rectangle should start
|
||||||
* @param y The y coordinate where the rectangle should start
|
* @param y The y coordinate where the rectangle should start
|
||||||
* @param width The line length of the rectangle. (VirtualInventory does not define a width)
|
* @param width The line length of the rectangle. (VirtualInventory does not define a width)
|
||||||
* @param virtualInventory The {@link VirtualInventory} to be put into this {@link GUI}.
|
* @param virtualInventory The {@link VirtualInventory} to be put into this {@link Gui}.
|
||||||
* @param background The {@link ItemProvider} for empty slots of the {@link VirtualInventory}
|
* @param background The {@link ItemProvider} for empty slots of the {@link VirtualInventory}
|
||||||
* @param replaceExisting If existing {@link SlotElement SlotElements} should be replaced.
|
* @param replaceExisting If existing {@link SlotElement SlotElements} should be replaced.
|
||||||
*/
|
*/
|
13
invui/src/main/java/de/studiocode/invui/gui/GuiParent.java
Normal file
13
invui/src/main/java/de/studiocode/invui/gui/GuiParent.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package de.studiocode.invui.gui;
|
||||||
|
|
||||||
|
public interface GuiParent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by the child {@link Gui} to report an update of a {@link SlotElement}.
|
||||||
|
*
|
||||||
|
* @param child The child {@link Gui} whose {@link SlotElement} has changed
|
||||||
|
* @param slotIndex The slot index of the changed {@link SlotElement} in the child {@link Gui}
|
||||||
|
*/
|
||||||
|
void handleSlotElementUpdate(Gui child, int slotIndex);
|
||||||
|
|
||||||
|
}
|
@ -1,106 +0,0 @@
|
|||||||
package de.studiocode.invui.gui;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.BiConsumer;
|
|
||||||
|
|
||||||
public interface PagedGUI<C> extends GUI {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the amount of pages this {@link PagedGUI} has.
|
|
||||||
*
|
|
||||||
* @return The amount of pages this {@link PagedGUI} has.
|
|
||||||
*/
|
|
||||||
int getPageAmount();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the current page of this {@link PagedGUI} as an index.
|
|
||||||
*
|
|
||||||
* @return Gets the current page of this {@link PagedGUI} as an index.
|
|
||||||
*/
|
|
||||||
int getCurrentPage();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the current page of this {@link PagedGUI}.
|
|
||||||
*
|
|
||||||
* @param page The page to set.
|
|
||||||
*/
|
|
||||||
void setPage(int page);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if there is a next page.
|
|
||||||
*
|
|
||||||
* @return Whether there is a next page.
|
|
||||||
*/
|
|
||||||
boolean hasNextPage();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if there is a previous page.
|
|
||||||
*
|
|
||||||
* @return Whether there is a previous page.
|
|
||||||
*/
|
|
||||||
boolean hasPreviousPage();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets if there are infinite pages in this {@link PagedGUI}.
|
|
||||||
*
|
|
||||||
* @return Whether there are infinite pages in this {@link PagedGUI}.
|
|
||||||
*/
|
|
||||||
boolean hasInfinitePages();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays the next page if there is one.
|
|
||||||
*/
|
|
||||||
void goForward();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays the previous page if there is one.
|
|
||||||
*/
|
|
||||||
void goBack();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the slot indices that are used to display content in this {@link PagedGUI}.
|
|
||||||
*
|
|
||||||
* @return The slot indices that are used to display content in this {@link PagedGUI}.
|
|
||||||
*/
|
|
||||||
int[] getContentListSlots();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the content of this {@link PagedGUI} for all pages.
|
|
||||||
*
|
|
||||||
* @param content The content to set.
|
|
||||||
*/
|
|
||||||
void setContent(List<@Nullable C> content);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the registered page change handlers.
|
|
||||||
*
|
|
||||||
* @return The registered page change handlers.
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
List<BiConsumer<Integer, Integer>> getPageChangeHandlers();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replaces the currently registered page change handlers with the given list.
|
|
||||||
*
|
|
||||||
* @param handlers The new page change handlers.
|
|
||||||
*/
|
|
||||||
void setPageChangeHandlers(@Nullable List<BiConsumer<Integer, Integer>> handlers);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a page change handler.
|
|
||||||
*
|
|
||||||
* @param handler The handler to register.
|
|
||||||
*/
|
|
||||||
void registerPageChangeHandler(@NotNull BiConsumer<Integer, Integer> handler);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregisters a page change handler.
|
|
||||||
*
|
|
||||||
* @param handler The handler to unregister.
|
|
||||||
*/
|
|
||||||
void unregisterPageChangeHandler(@NotNull BiConsumer<Integer, Integer> handler);
|
|
||||||
|
|
||||||
}
|
|
158
invui/src/main/java/de/studiocode/invui/gui/PagedGui.java
Normal file
158
invui/src/main/java/de/studiocode/invui/gui/PagedGui.java
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
package de.studiocode.invui.gui;
|
||||||
|
|
||||||
|
import de.studiocode.invui.gui.impl.PagedItemsGuiImpl;
|
||||||
|
import de.studiocode.invui.gui.impl.PagedNestedGuiImpl;
|
||||||
|
import de.studiocode.invui.gui.structure.Structure;
|
||||||
|
import de.studiocode.invui.item.Item;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public interface PagedGui<C> extends Gui {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link PagedGui}.
|
||||||
|
*
|
||||||
|
* @param width The width of the {@link PagedGui}.
|
||||||
|
* @param height The height of the {@link PagedGui}.
|
||||||
|
* @param items The {@link Item Items} to use as in pages.
|
||||||
|
* @param contentListSlots The slots where content should be displayed.
|
||||||
|
* @return The created {@link PagedGui}.
|
||||||
|
*/
|
||||||
|
static @NotNull PagedGui<Item> ofItems(int width, int height, @NotNull List<@NotNull Item> items, int... contentListSlots) {
|
||||||
|
return new PagedItemsGuiImpl(width, height, items, contentListSlots);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link PagedGui}.
|
||||||
|
*
|
||||||
|
* @param structure The {@link Structure} to use.
|
||||||
|
* @param items The {@link Item Items} to use as in pages.
|
||||||
|
* @return The created {@link PagedGui}.
|
||||||
|
*/
|
||||||
|
static @NotNull PagedGui<Item> ofItems(Structure structure, @NotNull List<@NotNull Item> items) {
|
||||||
|
return new PagedItemsGuiImpl(items, structure);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link PagedGui}.
|
||||||
|
*
|
||||||
|
* @param width The width of the {@link PagedGui}.
|
||||||
|
* @param height The height of the {@link PagedGui}.
|
||||||
|
* @param guis The {@link Gui Guis} to use as pages.
|
||||||
|
* @param contentListSlots The slots where content should be displayed.
|
||||||
|
* @return The created {@link PagedGui}.
|
||||||
|
*/
|
||||||
|
static @NotNull PagedGui<Gui> ofGuis(int width, int height, @NotNull List<@NotNull Gui> guis, int... contentListSlots) {
|
||||||
|
return new PagedNestedGuiImpl(width, height, guis, contentListSlots);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link PagedGui}.
|
||||||
|
*
|
||||||
|
* @param structure The {@link Structure} to use.
|
||||||
|
* @param guis The {@link Gui Guis} to use as pages.
|
||||||
|
* @return The created {@link PagedGui}.
|
||||||
|
*/
|
||||||
|
static @NotNull PagedGui<Gui> ofGuis(Structure structure, @NotNull List<@NotNull Gui> guis) {
|
||||||
|
return new PagedNestedGuiImpl(guis, structure);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the amount of pages this {@link PagedGui} has.
|
||||||
|
*
|
||||||
|
* @return The amount of pages this {@link PagedGui} has.
|
||||||
|
*/
|
||||||
|
int getPageAmount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current page of this {@link PagedGui} as an index.
|
||||||
|
*
|
||||||
|
* @return Gets the current page of this {@link PagedGui} as an index.
|
||||||
|
*/
|
||||||
|
int getCurrentPage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the current page of this {@link PagedGui}.
|
||||||
|
*
|
||||||
|
* @param page The page to set.
|
||||||
|
*/
|
||||||
|
void setPage(int page);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if there is a next page.
|
||||||
|
*
|
||||||
|
* @return Whether there is a next page.
|
||||||
|
*/
|
||||||
|
boolean hasNextPage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if there is a previous page.
|
||||||
|
*
|
||||||
|
* @return Whether there is a previous page.
|
||||||
|
*/
|
||||||
|
boolean hasPreviousPage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets if there are infinite pages in this {@link PagedGui}.
|
||||||
|
*
|
||||||
|
* @return Whether there are infinite pages in this {@link PagedGui}.
|
||||||
|
*/
|
||||||
|
boolean hasInfinitePages();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays the next page if there is one.
|
||||||
|
*/
|
||||||
|
void goForward();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays the previous page if there is one.
|
||||||
|
*/
|
||||||
|
void goBack();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the slot indices that are used to display content in this {@link PagedGui}.
|
||||||
|
*
|
||||||
|
* @return The slot indices that are used to display content in this {@link PagedGui}.
|
||||||
|
*/
|
||||||
|
int[] getContentListSlots();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the content of this {@link PagedGui} for all pages.
|
||||||
|
*
|
||||||
|
* @param content The content to set.
|
||||||
|
*/
|
||||||
|
void setContent(List<@Nullable C> content);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the registered page change handlers.
|
||||||
|
*
|
||||||
|
* @return The registered page change handlers.
|
||||||
|
*/
|
||||||
|
@Nullable List<@NotNull BiConsumer<Integer, Integer>> getPageChangeHandlers();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replaces the currently registered page change handlers with the given list.
|
||||||
|
*
|
||||||
|
* @param handlers The new page change handlers.
|
||||||
|
*/
|
||||||
|
void setPageChangeHandlers(@Nullable List<@NotNull BiConsumer<Integer, Integer>> handlers);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a page change handler.
|
||||||
|
*
|
||||||
|
* @param handler The handler to register.
|
||||||
|
*/
|
||||||
|
void registerPageChangeHandler(@NotNull BiConsumer<Integer, Integer> handler);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregisters a page change handler.
|
||||||
|
*
|
||||||
|
* @param handler The handler to unregister.
|
||||||
|
*/
|
||||||
|
void unregisterPageChangeHandler(@NotNull BiConsumer<Integer, Integer> handler);
|
||||||
|
|
||||||
|
}
|
@ -1,49 +0,0 @@
|
|||||||
package de.studiocode.invui.gui;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface ScrollGUI<C> extends GUI {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the current line of this {@link ScrollGUI}.
|
|
||||||
*
|
|
||||||
* @return The current line of this {@link ScrollGUI}.
|
|
||||||
*/
|
|
||||||
int getCurrentLine();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the max line index of this {@link ScrollGUI}.
|
|
||||||
*
|
|
||||||
* @return The max line index of this {@link ScrollGUI}.
|
|
||||||
*/
|
|
||||||
int getMaxLine();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the current line of this {@link ScrollGUI}.
|
|
||||||
*
|
|
||||||
* @param line The line to set.
|
|
||||||
*/
|
|
||||||
void setCurrentLine(int line);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if it is possible to scroll the specified amount of lines.
|
|
||||||
*
|
|
||||||
* @return Whether it is possible to scroll the specified amount of lines.
|
|
||||||
*/
|
|
||||||
boolean canScroll(int lines);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Scrolls the specified amount of lines.
|
|
||||||
*
|
|
||||||
* @param lines The amount of lines to scroll.
|
|
||||||
*/
|
|
||||||
void scroll(int lines);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the content of this {@link ScrollGUI} for all lines.
|
|
||||||
*
|
|
||||||
* @param content The content to set.
|
|
||||||
*/
|
|
||||||
void setContent(List<C> content);
|
|
||||||
|
|
||||||
}
|
|
130
invui/src/main/java/de/studiocode/invui/gui/ScrollGui.java
Normal file
130
invui/src/main/java/de/studiocode/invui/gui/ScrollGui.java
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
package de.studiocode.invui.gui;
|
||||||
|
|
||||||
|
import de.studiocode.invui.gui.impl.ScrollItemsGuiImpl;
|
||||||
|
import de.studiocode.invui.gui.impl.ScrollNestedGuiImpl;
|
||||||
|
import de.studiocode.invui.gui.impl.ScrollVIGuiImpl;
|
||||||
|
import de.studiocode.invui.gui.structure.Structure;
|
||||||
|
import de.studiocode.invui.item.Item;
|
||||||
|
import de.studiocode.invui.virtualinventory.VirtualInventory;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public interface ScrollGui<C> extends Gui {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link ScrollGui}.
|
||||||
|
*
|
||||||
|
* @param width The width of the {@link ScrollGui}.
|
||||||
|
* @param height The height of the {@link ScrollGui}.
|
||||||
|
* @param items The {@link Item Items} to use.
|
||||||
|
* @param contentListSlots The slots where content should be displayed.
|
||||||
|
* @return The created {@link ScrollGui}.
|
||||||
|
*/
|
||||||
|
static @NotNull ScrollGui<Item> ofItems(int width, int height, @NotNull List<@NotNull Item> items, int... contentListSlots) {
|
||||||
|
return new ScrollItemsGuiImpl(width, height, items, contentListSlots);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link ScrollGui}.
|
||||||
|
*
|
||||||
|
* @param structure The {@link Structure} to use.
|
||||||
|
* @param items The {@link Item Items} to use.
|
||||||
|
* @return The created {@link ScrollGui}.
|
||||||
|
*/
|
||||||
|
static @NotNull ScrollGui<Item> ofItems(@NotNull Structure structure, @NotNull List<@NotNull Item> items) {
|
||||||
|
return new ScrollItemsGuiImpl(items, structure);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link ScrollGui}.
|
||||||
|
*
|
||||||
|
* @param width The width of the {@link ScrollGui}.
|
||||||
|
* @param height The height of the {@link ScrollGui}.
|
||||||
|
* @param guis The {@link Gui Guis} to use.
|
||||||
|
* @param contentListSlots The slots where content should be displayed.
|
||||||
|
* @return The created {@link ScrollGui}.
|
||||||
|
*/
|
||||||
|
static @NotNull ScrollGui<Gui> ofGuis(int width, int height, @NotNull List<@NotNull Gui> guis, int... contentListSlots) {
|
||||||
|
return new ScrollNestedGuiImpl(width, height, guis, contentListSlots);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link ScrollGui}.
|
||||||
|
*
|
||||||
|
* @param structure The {@link Structure} to use.
|
||||||
|
* @param guis The {@link Gui Guis} to use.
|
||||||
|
* @return The created {@link ScrollGui}.
|
||||||
|
*/
|
||||||
|
static @NotNull ScrollGui<Gui> ofGuis(Structure structure, @NotNull List<@NotNull Gui> guis) {
|
||||||
|
return new ScrollNestedGuiImpl(guis, structure);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link ScrollGui}.
|
||||||
|
*
|
||||||
|
* @param width The width of the {@link ScrollGui}.
|
||||||
|
* @param height The height of the {@link ScrollGui}.
|
||||||
|
* @param inventories The {@link VirtualInventory VirtualInventories} to use.
|
||||||
|
* @param contentListSlots The slots where content should be displayed.
|
||||||
|
* @return The created {@link ScrollGui}.
|
||||||
|
*/
|
||||||
|
static @NotNull ScrollGui<VirtualInventory> ofInventories(int width, int height, @NotNull List<@NotNull VirtualInventory> inventories, int... contentListSlots) {
|
||||||
|
return new ScrollVIGuiImpl(width, height, inventories, contentListSlots);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link ScrollGui}.
|
||||||
|
*
|
||||||
|
* @param structure The {@link Structure} to use.
|
||||||
|
* @param inventories The {@link VirtualInventory VirtualInventories} to use.
|
||||||
|
* @return The created {@link ScrollGui}.
|
||||||
|
*/
|
||||||
|
static @NotNull ScrollGui<VirtualInventory> ofInventories(@NotNull Structure structure, @NotNull List<@NotNull VirtualInventory> inventories) {
|
||||||
|
return new ScrollVIGuiImpl(inventories, structure);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current line of this {@link ScrollGui}.
|
||||||
|
*
|
||||||
|
* @return The current line of this {@link ScrollGui}.
|
||||||
|
*/
|
||||||
|
int getCurrentLine();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the max line index of this {@link ScrollGui}.
|
||||||
|
*
|
||||||
|
* @return The max line index of this {@link ScrollGui}.
|
||||||
|
*/
|
||||||
|
int getMaxLine();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the current line of this {@link ScrollGui}.
|
||||||
|
*
|
||||||
|
* @param line The line to set.
|
||||||
|
*/
|
||||||
|
void setCurrentLine(int line);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if it is possible to scroll the specified amount of lines.
|
||||||
|
*
|
||||||
|
* @return Whether it is possible to scroll the specified amount of lines.
|
||||||
|
*/
|
||||||
|
boolean canScroll(int lines);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scrolls the specified amount of lines.
|
||||||
|
*
|
||||||
|
* @param lines The amount of lines to scroll.
|
||||||
|
*/
|
||||||
|
void scroll(int lines);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the content of this {@link ScrollGui} for all lines.
|
||||||
|
*
|
||||||
|
* @param content The content to set.
|
||||||
|
*/
|
||||||
|
void setContent(@NotNull List<@NotNull C> content);
|
||||||
|
|
||||||
|
}
|
@ -90,23 +90,23 @@ public interface SlotElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Links to a slot in another {@link GUI}
|
* Links to a slot in another {@link Gui}
|
||||||
*/
|
*/
|
||||||
class LinkedSlotElement implements SlotElement {
|
class LinkedSlotElement implements SlotElement {
|
||||||
|
|
||||||
private final GUI gui;
|
private final Gui gui;
|
||||||
|
|
||||||
private final int slot;
|
private final int slot;
|
||||||
|
|
||||||
public LinkedSlotElement(GUI gui, int slot) {
|
public LinkedSlotElement(Gui gui, int slot) {
|
||||||
if (!(gui instanceof AbstractGUI))
|
if (!(gui instanceof AbstractGui))
|
||||||
throw new IllegalArgumentException("Illegal GUI implementation");
|
throw new IllegalArgumentException("Illegal Gui implementation");
|
||||||
|
|
||||||
this.gui = gui;
|
this.gui = gui;
|
||||||
this.slot = slot;
|
this.slot = slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GUI getGUI() {
|
public Gui getGui() {
|
||||||
return gui;
|
return gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,18 +118,18 @@ public interface SlotElement {
|
|||||||
public SlotElement getHoldingElement() {
|
public SlotElement getHoldingElement() {
|
||||||
LinkedSlotElement element = this;
|
LinkedSlotElement element = this;
|
||||||
while (true) {
|
while (true) {
|
||||||
SlotElement below = element.getGUI().getSlotElement(element.getSlotIndex());
|
SlotElement below = element.getGui().getSlotElement(element.getSlotIndex());
|
||||||
if (below instanceof LinkedSlotElement) element = (LinkedSlotElement) below;
|
if (below instanceof LinkedSlotElement) element = (LinkedSlotElement) below;
|
||||||
else return below;
|
else return below;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<GUI> getGUIList() {
|
public List<Gui> getGuiList() {
|
||||||
ArrayList<GUI> guis = new ArrayList<>();
|
ArrayList<Gui> guis = new ArrayList<>();
|
||||||
LinkedSlotElement element = this;
|
LinkedSlotElement element = this;
|
||||||
while (true) {
|
while (true) {
|
||||||
guis.add(element.getGUI());
|
guis.add(element.getGui());
|
||||||
SlotElement below = element.getGUI().getSlotElement(element.getSlotIndex());
|
SlotElement below = element.getGui().getSlotElement(element.getSlotIndex());
|
||||||
if (below instanceof LinkedSlotElement)
|
if (below instanceof LinkedSlotElement)
|
||||||
element = (LinkedSlotElement) below;
|
element = (LinkedSlotElement) below;
|
||||||
else break;
|
else break;
|
||||||
|
@ -1,12 +1,39 @@
|
|||||||
package de.studiocode.invui.gui;
|
package de.studiocode.invui.gui;
|
||||||
|
|
||||||
|
import de.studiocode.invui.gui.impl.TabGuiImpl;
|
||||||
|
import de.studiocode.invui.gui.structure.Structure;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
public interface TabGUI extends GUI {
|
@SuppressWarnings("deprecation")
|
||||||
|
public interface TabGui extends Gui {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link TabGui}.
|
||||||
|
*
|
||||||
|
* @param width The width of the {@link TabGui}.
|
||||||
|
* @param height The height of the {@link TabGui}.
|
||||||
|
* @param tabs The {@link Gui Guis} to use as tabs.
|
||||||
|
* @param contentListSlots The slots where content should be displayed.
|
||||||
|
* @return The created {@link TabGui}.
|
||||||
|
*/
|
||||||
|
static @NotNull TabGui of(int width, int height, @NotNull List<@Nullable Gui> tabs, int... contentListSlots) {
|
||||||
|
return new TabGuiImpl(width, height, tabs, contentListSlots);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link TabGui}.
|
||||||
|
*
|
||||||
|
* @param structure The {@link Structure} to use.
|
||||||
|
* @param tabs The {@link Gui Guis} to use as tabs.
|
||||||
|
* @return The created {@link TabGui}.
|
||||||
|
*/
|
||||||
|
static @NotNull TabGui of(Structure structure, @NotNull List<@Nullable Gui> tabs) {
|
||||||
|
return new TabGuiImpl(tabs, structure);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the current tab index.
|
* Gets the current tab index.
|
||||||
@ -32,24 +59,24 @@ public interface TabGUI extends GUI {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the configured tabs.
|
* Gets the configured tabs.
|
||||||
|
*
|
||||||
* @return The configured tabs.
|
* @return The configured tabs.
|
||||||
*/
|
*/
|
||||||
List<GUI> getTabs();
|
@NotNull List<@Nullable Gui> getTabs();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the registered tab change handlers.
|
* Gets the registered tab change handlers.
|
||||||
*
|
*
|
||||||
* @return The registered tab change handlers.
|
* @return The registered tab change handlers.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable List<@NotNull BiConsumer<Integer, Integer>> getTabChangeHandlers();
|
||||||
List<BiConsumer<Integer, Integer>> getTabChangeHandlers();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces the currently registered tab change handlers with the given list.
|
* Replaces the currently registered tab change handlers with the given list.
|
||||||
*
|
*
|
||||||
* @param handlers The new page change handlers.
|
* @param handlers The new page change handlers.
|
||||||
*/
|
*/
|
||||||
void setTabChangeHandlers(@Nullable List<BiConsumer<Integer, Integer>> handlers);
|
void setTabChangeHandlers(@Nullable List<@NotNull BiConsumer<Integer, Integer>> handlers);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a page change handler.
|
* Registers a page change handler.
|
@ -1,8 +1,8 @@
|
|||||||
package de.studiocode.invui.gui.builder;
|
package de.studiocode.invui.gui.builder;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.gui.SlotElement;
|
import de.studiocode.invui.gui.SlotElement;
|
||||||
import de.studiocode.invui.gui.builder.guitype.GUIType;
|
import de.studiocode.invui.gui.builder.guitype.GuiType;
|
||||||
import de.studiocode.invui.gui.structure.Marker;
|
import de.studiocode.invui.gui.structure.Marker;
|
||||||
import de.studiocode.invui.gui.structure.Structure;
|
import de.studiocode.invui.gui.structure.Structure;
|
||||||
import de.studiocode.invui.item.Item;
|
import de.studiocode.invui.item.Item;
|
||||||
@ -19,85 +19,85 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A builder class to easily construct {@link GUI}s.<br>
|
* A builder class to easily construct {@link Gui}s.<br>
|
||||||
* It provides similar functionality to Bukkit's {@link ShapedRecipe}, as it
|
* It provides similar functionality to Bukkit's {@link ShapedRecipe}, as it
|
||||||
* allows for a structure String which defines the layout of the {@link GUI}.
|
* allows for a structure String which defines the layout of the {@link Gui}.
|
||||||
*/
|
*/
|
||||||
public class GUIBuilder<G extends GUI, C> {
|
public class GuiBuilder<G extends Gui, C> {
|
||||||
|
|
||||||
protected final GUIType<G, C> guiType;
|
protected final GuiType<G, C> guiType;
|
||||||
protected final GUIContext<C> context;
|
protected final GuiContext<C> context;
|
||||||
|
|
||||||
public GUIBuilder(@NotNull GUIType<G, C> guiType) {
|
public GuiBuilder(@NotNull GuiType<G, C> guiType) {
|
||||||
this.guiType = guiType;
|
this.guiType = guiType;
|
||||||
this.context = new GUIContext<>();
|
this.context = new GuiContext<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public GUIBuilder<G, C> setStructure(int width, int height, @NotNull String structureData) {
|
public GuiBuilder<G, C> setStructure(int width, int height, @NotNull String structureData) {
|
||||||
context.setStructure(new Structure(width, height, structureData));
|
context.setStructure(new Structure(width, height, structureData));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GUIBuilder<G, C> setStructure(@NotNull String... structureData) {
|
public GuiBuilder<G, C> setStructure(@NotNull String... structureData) {
|
||||||
return setStructure(new Structure(structureData));
|
return setStructure(new Structure(structureData));
|
||||||
}
|
}
|
||||||
|
|
||||||
public GUIBuilder<G, C> setStructure(@NotNull Structure structure) {
|
public GuiBuilder<G, C> setStructure(@NotNull Structure structure) {
|
||||||
context.setStructure(structure);
|
context.setStructure(structure);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GUIBuilder<G, C> addIngredient(char key, @NotNull ItemStack itemStack) {
|
public GuiBuilder<G, C> addIngredient(char key, @NotNull ItemStack itemStack) {
|
||||||
context.getStructure().addIngredient(key, itemStack);
|
context.getStructure().addIngredient(key, itemStack);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GUIBuilder<G, C> addIngredient(char key, @NotNull ItemProvider itemProvider) {
|
public GuiBuilder<G, C> addIngredient(char key, @NotNull ItemProvider itemProvider) {
|
||||||
context.getStructure().addIngredient(key, itemProvider);
|
context.getStructure().addIngredient(key, itemProvider);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GUIBuilder<G, C> addIngredient(char key, @NotNull Item item) {
|
public GuiBuilder<G, C> addIngredient(char key, @NotNull Item item) {
|
||||||
context.getStructure().addIngredient(key, item);
|
context.getStructure().addIngredient(key, item);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GUIBuilder<G, C> addIngredient(char key, @NotNull VirtualInventory inventory) {
|
public GuiBuilder<G, C> addIngredient(char key, @NotNull VirtualInventory inventory) {
|
||||||
context.getStructure().addIngredient(key, inventory);
|
context.getStructure().addIngredient(key, inventory);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GUIBuilder<G, C> addIngredient(char key, @NotNull VirtualInventory inventory, @Nullable ItemProvider background) {
|
public GuiBuilder<G, C> addIngredient(char key, @NotNull VirtualInventory inventory, @Nullable ItemProvider background) {
|
||||||
context.getStructure().addIngredient(key, inventory, background);
|
context.getStructure().addIngredient(key, inventory, background);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GUIBuilder<G, C> addIngredient(char key, @NotNull SlotElement element) {
|
public GuiBuilder<G, C> addIngredient(char key, @NotNull SlotElement element) {
|
||||||
context.getStructure().addIngredient(key, element);
|
context.getStructure().addIngredient(key, element);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GUIBuilder<G, C> addIngredient(char key, @NotNull Marker marker) {
|
public GuiBuilder<G, C> addIngredient(char key, @NotNull Marker marker) {
|
||||||
context.getStructure().addIngredient(key, marker);
|
context.getStructure().addIngredient(key, marker);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GUIBuilder<G, C> addIngredient(char key, @NotNull Supplier<? extends Item> itemSupplier) {
|
public GuiBuilder<G, C> addIngredient(char key, @NotNull Supplier<? extends Item> itemSupplier) {
|
||||||
context.getStructure().addIngredient(key, itemSupplier);
|
context.getStructure().addIngredient(key, itemSupplier);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GUIBuilder<G, C> addIngredientElementSupplier(char key, @NotNull Supplier<? extends SlotElement> elementSupplier) {
|
public GuiBuilder<G, C> addIngredientElementSupplier(char key, @NotNull Supplier<? extends SlotElement> elementSupplier) {
|
||||||
context.getStructure().addIngredientElementSupplier(key, elementSupplier);
|
context.getStructure().addIngredientElementSupplier(key, elementSupplier);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GUIBuilder<G, C> setContent(@NotNull List<C> content) {
|
public GuiBuilder<G, C> setContent(@NotNull List<C> content) {
|
||||||
context.setContent(content);
|
context.setContent(content);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GUIBuilder<G, C> addContent(@NotNull C content) {
|
public GuiBuilder<G, C> addContent(@NotNull C content) {
|
||||||
if (context.getContent() == null)
|
if (context.getContent() == null)
|
||||||
context.setContent(new ArrayList<>());
|
context.setContent(new ArrayList<>());
|
||||||
|
|
||||||
@ -107,9 +107,9 @@ public class GUIBuilder<G extends GUI, C> {
|
|||||||
|
|
||||||
public G build() {
|
public G build() {
|
||||||
if (context.getStructure() == null)
|
if (context.getStructure() == null)
|
||||||
throw new IllegalStateException("GUIContext has not been set yet.");
|
throw new IllegalStateException("GuiContext has not been set yet.");
|
||||||
|
|
||||||
return guiType.createGUI(context);
|
return guiType.createGui(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package de.studiocode.invui.gui.builder;
|
package de.studiocode.invui.gui.builder;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.gui.builder.guitype.GUIType;
|
import de.studiocode.invui.gui.builder.guitype.GuiType;
|
||||||
import de.studiocode.invui.gui.structure.Structure;
|
import de.studiocode.invui.gui.structure.Structure;
|
||||||
import de.studiocode.invui.item.ItemProvider;
|
import de.studiocode.invui.item.ItemProvider;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -9,10 +9,10 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link GUIContext} contains all information from the {@link GUIBuilder} to be passed to
|
* The {@link GuiContext} contains all information from the {@link GuiBuilder} to be passed to
|
||||||
* an instance of {@link GUIType} to create a new {@link GUI}.
|
* an instance of {@link GuiType} to create a new {@link Gui}.
|
||||||
*/
|
*/
|
||||||
public class GUIContext<C> {
|
public class GuiContext<C> {
|
||||||
|
|
||||||
private Structure structure;
|
private Structure structure;
|
||||||
private ItemProvider background;
|
private ItemProvider background;
|
@ -1,29 +0,0 @@
|
|||||||
package de.studiocode.invui.gui.builder.guitype;
|
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
|
||||||
import de.studiocode.invui.gui.PagedGUI;
|
|
||||||
import de.studiocode.invui.gui.ScrollGUI;
|
|
||||||
import de.studiocode.invui.gui.TabGUI;
|
|
||||||
import de.studiocode.invui.gui.builder.GUIContext;
|
|
||||||
import de.studiocode.invui.item.Item;
|
|
||||||
import de.studiocode.invui.virtualinventory.VirtualInventory;
|
|
||||||
|
|
||||||
public interface GUIType<G extends GUI, C> {
|
|
||||||
|
|
||||||
GUIType<GUI, Void> NORMAL = new NormalGUIType();
|
|
||||||
GUIType<PagedGUI<Item>, Item> PAGED_ITEMS = new PagedItemsGUIType();
|
|
||||||
GUIType<PagedGUI<GUI>, GUI> PAGED_GUIs = new PagedGUIsGUIType();
|
|
||||||
GUIType<TabGUI, GUI> TAB = new TabGUIType();
|
|
||||||
GUIType<ScrollGUI<Item>, Item> SCROLL_ITEMS = new ScrollItemsGUIType();
|
|
||||||
GUIType<ScrollGUI<GUI>, GUI> SCROLL_GUIS = new ScrollGUIsGUIType();
|
|
||||||
GUIType<ScrollGUI<VirtualInventory>, VirtualInventory> SCROLL_INVENTORY = new ScrollVIGUIType();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a {@link GUI} of type {@link G} with the given {@link GUIContext}
|
|
||||||
*
|
|
||||||
* @param context The {@link GUIContext} to create the {@link G} from.
|
|
||||||
* @return The created {@link G}
|
|
||||||
*/
|
|
||||||
G createGUI(GUIContext<C> context);
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,29 @@
|
|||||||
|
package de.studiocode.invui.gui.builder.guitype;
|
||||||
|
|
||||||
|
import de.studiocode.invui.gui.Gui;
|
||||||
|
import de.studiocode.invui.gui.PagedGui;
|
||||||
|
import de.studiocode.invui.gui.ScrollGui;
|
||||||
|
import de.studiocode.invui.gui.TabGui;
|
||||||
|
import de.studiocode.invui.gui.builder.GuiContext;
|
||||||
|
import de.studiocode.invui.item.Item;
|
||||||
|
import de.studiocode.invui.virtualinventory.VirtualInventory;
|
||||||
|
|
||||||
|
public interface GuiType<G extends Gui, C> {
|
||||||
|
|
||||||
|
GuiType<Gui, Void> NORMAL = new NormalGuiType();
|
||||||
|
GuiType<PagedGui<Item>, Item> PAGED_ITEMS = new PagedItemsGuiType();
|
||||||
|
GuiType<PagedGui<Gui>, Gui> PAGED_Guis = new PagedGuisGuiType();
|
||||||
|
GuiType<TabGui, Gui> TAB = new TabGuiType();
|
||||||
|
GuiType<ScrollGui<Item>, Item> SCROLL_ITEMS = new ScrollItemsGuiType();
|
||||||
|
GuiType<ScrollGui<Gui>, Gui> SCROLL_GuiS = new ScrollGuisGuiType();
|
||||||
|
GuiType<ScrollGui<VirtualInventory>, VirtualInventory> SCROLL_INVENTORY = new ScrollVIGuiType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a {@link Gui} of type {@link G} with the given {@link GuiContext}
|
||||||
|
*
|
||||||
|
* @param context The {@link GuiContext} to create the {@link G} from.
|
||||||
|
* @return The created {@link G}
|
||||||
|
*/
|
||||||
|
G createGui(GuiContext<C> context);
|
||||||
|
|
||||||
|
}
|
@ -1,14 +1,14 @@
|
|||||||
package de.studiocode.invui.gui.builder.guitype;
|
package de.studiocode.invui.gui.builder.guitype;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.gui.builder.GUIContext;
|
import de.studiocode.invui.gui.builder.GuiContext;
|
||||||
import de.studiocode.invui.gui.impl.NormalGUIImpl;
|
import de.studiocode.invui.gui.impl.NormalGuiImpl;
|
||||||
|
|
||||||
class NormalGUIType implements GUIType<GUI, Void> {
|
class NormalGuiType implements GuiType<Gui, Void> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NormalGUIImpl createGUI(GUIContext<Void> context) {
|
public NormalGuiImpl createGui(GuiContext<Void> context) {
|
||||||
NormalGUIImpl gui = new NormalGUIImpl(context.getStructure());
|
NormalGuiImpl gui = new NormalGuiImpl(context.getStructure());
|
||||||
gui.setBackground(context.getBackground());
|
gui.setBackground(context.getBackground());
|
||||||
return gui;
|
return gui;
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package de.studiocode.invui.gui.builder.guitype;
|
package de.studiocode.invui.gui.builder.guitype;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.gui.PagedGUI;
|
import de.studiocode.invui.gui.PagedGui;
|
||||||
import de.studiocode.invui.gui.builder.GUIContext;
|
import de.studiocode.invui.gui.builder.GuiContext;
|
||||||
import de.studiocode.invui.gui.impl.PageNestedGUIImpl;
|
import de.studiocode.invui.gui.impl.PagedNestedGuiImpl;
|
||||||
|
|
||||||
class PagedGUIsGUIType implements GUIType<PagedGUI<GUI>, GUI> {
|
class PagedGuisGuiType implements GuiType<PagedGui<Gui>, Gui> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageNestedGUIImpl createGUI(GUIContext<GUI> context) {
|
public PagedNestedGuiImpl createGui(GuiContext<Gui> context) {
|
||||||
PageNestedGUIImpl gui = new PageNestedGUIImpl(context.getContent(), context.getStructure());
|
PagedNestedGuiImpl gui = new PagedNestedGuiImpl(context.getContent(), context.getStructure());
|
||||||
gui.setBackground(context.getBackground());
|
gui.setBackground(context.getBackground());
|
||||||
return gui;
|
return gui;
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package de.studiocode.invui.gui.builder.guitype;
|
package de.studiocode.invui.gui.builder.guitype;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.PagedGUI;
|
import de.studiocode.invui.gui.PagedGui;
|
||||||
import de.studiocode.invui.gui.builder.GUIContext;
|
import de.studiocode.invui.gui.builder.GuiContext;
|
||||||
import de.studiocode.invui.gui.impl.PagedItemsGUIImpl;
|
import de.studiocode.invui.gui.impl.PagedItemsGuiImpl;
|
||||||
import de.studiocode.invui.item.Item;
|
import de.studiocode.invui.item.Item;
|
||||||
|
|
||||||
class PagedItemsGUIType implements GUIType<PagedGUI<Item>, Item> {
|
class PagedItemsGuiType implements GuiType<PagedGui<Item>, Item> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PagedItemsGUIImpl createGUI(GUIContext<Item> context) {
|
public PagedItemsGuiImpl createGui(GuiContext<Item> context) {
|
||||||
PagedItemsGUIImpl gui = new PagedItemsGUIImpl(context.getContent(), context.getStructure());
|
PagedItemsGuiImpl gui = new PagedItemsGuiImpl(context.getContent(), context.getStructure());
|
||||||
gui.setBackground(context.getBackground());
|
gui.setBackground(context.getBackground());
|
||||||
return gui;
|
return gui;
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package de.studiocode.invui.gui.builder.guitype;
|
package de.studiocode.invui.gui.builder.guitype;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.gui.ScrollGUI;
|
import de.studiocode.invui.gui.ScrollGui;
|
||||||
import de.studiocode.invui.gui.builder.GUIContext;
|
import de.studiocode.invui.gui.builder.GuiContext;
|
||||||
import de.studiocode.invui.gui.impl.ScrollNestedGUIImpl;
|
import de.studiocode.invui.gui.impl.ScrollNestedGuiImpl;
|
||||||
|
|
||||||
class ScrollGUIsGUIType implements GUIType<ScrollGUI<GUI>, GUI> {
|
class ScrollGuisGuiType implements GuiType<ScrollGui<Gui>, Gui> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ScrollNestedGUIImpl createGUI(GUIContext<GUI> context) {
|
public ScrollNestedGuiImpl createGui(GuiContext<Gui> context) {
|
||||||
ScrollNestedGUIImpl gui = new ScrollNestedGUIImpl(context.getContent(), context.getStructure());
|
ScrollNestedGuiImpl gui = new ScrollNestedGuiImpl(context.getContent(), context.getStructure());
|
||||||
gui.setBackground(gui.getBackground());
|
gui.setBackground(gui.getBackground());
|
||||||
return gui;
|
return gui;
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package de.studiocode.invui.gui.builder.guitype;
|
package de.studiocode.invui.gui.builder.guitype;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.ScrollGUI;
|
import de.studiocode.invui.gui.ScrollGui;
|
||||||
import de.studiocode.invui.gui.builder.GUIContext;
|
import de.studiocode.invui.gui.builder.GuiContext;
|
||||||
import de.studiocode.invui.gui.impl.ScrollItemsGUIImpl;
|
import de.studiocode.invui.gui.impl.ScrollItemsGuiImpl;
|
||||||
import de.studiocode.invui.item.Item;
|
import de.studiocode.invui.item.Item;
|
||||||
|
|
||||||
class ScrollItemsGUIType implements GUIType<ScrollGUI<Item>, Item> {
|
class ScrollItemsGuiType implements GuiType<ScrollGui<Item>, Item> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ScrollItemsGUIImpl createGUI(GUIContext<Item> context) {
|
public ScrollItemsGuiImpl createGui(GuiContext<Item> context) {
|
||||||
ScrollItemsGUIImpl gui = new ScrollItemsGUIImpl(context.getContent(), context.getStructure());
|
ScrollItemsGuiImpl gui = new ScrollItemsGuiImpl(context.getContent(), context.getStructure());
|
||||||
gui.setBackground(context.getBackground());
|
gui.setBackground(context.getBackground());
|
||||||
return gui;
|
return gui;
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package de.studiocode.invui.gui.builder.guitype;
|
package de.studiocode.invui.gui.builder.guitype;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.ScrollGUI;
|
import de.studiocode.invui.gui.ScrollGui;
|
||||||
import de.studiocode.invui.gui.builder.GUIContext;
|
import de.studiocode.invui.gui.builder.GuiContext;
|
||||||
import de.studiocode.invui.gui.impl.ScrollVIGUIImpl;
|
import de.studiocode.invui.gui.impl.ScrollVIGuiImpl;
|
||||||
import de.studiocode.invui.virtualinventory.VirtualInventory;
|
import de.studiocode.invui.virtualinventory.VirtualInventory;
|
||||||
|
|
||||||
class ScrollVIGUIType implements GUIType<ScrollGUI<VirtualInventory>, VirtualInventory> {
|
class ScrollVIGuiType implements GuiType<ScrollGui<VirtualInventory>, VirtualInventory> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ScrollVIGUIImpl createGUI(GUIContext<VirtualInventory> context) {
|
public ScrollVIGuiImpl createGui(GuiContext<VirtualInventory> context) {
|
||||||
ScrollVIGUIImpl gui = new ScrollVIGUIImpl(context.getContent(), context.getStructure());
|
ScrollVIGuiImpl gui = new ScrollVIGuiImpl(context.getContent(), context.getStructure());
|
||||||
gui.setBackground(context.getBackground());
|
gui.setBackground(context.getBackground());
|
||||||
return gui;
|
return gui;
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package de.studiocode.invui.gui.builder.guitype;
|
package de.studiocode.invui.gui.builder.guitype;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.gui.TabGUI;
|
import de.studiocode.invui.gui.TabGui;
|
||||||
import de.studiocode.invui.gui.builder.GUIContext;
|
import de.studiocode.invui.gui.builder.GuiContext;
|
||||||
import de.studiocode.invui.gui.impl.TabGUIImpl;
|
import de.studiocode.invui.gui.impl.TabGuiImpl;
|
||||||
|
|
||||||
class TabGUIType implements GUIType<TabGUI, GUI> {
|
class TabGuiType implements GuiType<TabGui, Gui> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TabGUIImpl createGUI(GUIContext<GUI> context) {
|
public TabGuiImpl createGui(GuiContext<Gui> context) {
|
||||||
TabGUIImpl gui = new TabGUIImpl(context.getContent(), context.getStructure());
|
TabGuiImpl gui = new TabGuiImpl(context.getContent(), context.getStructure());
|
||||||
gui.setBackground(context.getBackground());
|
gui.setBackground(context.getBackground());
|
||||||
return gui;
|
return gui;
|
||||||
}
|
}
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
package de.studiocode.invui.gui.impl;
|
|
||||||
|
|
||||||
import de.studiocode.invui.gui.AbstractGUI;
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
|
||||||
import de.studiocode.invui.gui.structure.Structure;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A normal {@link GUI} without any special features.
|
|
||||||
*/
|
|
||||||
public final class NormalGUIImpl extends AbstractGUI {
|
|
||||||
|
|
||||||
public NormalGUIImpl(int width, int height) {
|
|
||||||
super(width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NormalGUIImpl(@NotNull Structure structure) {
|
|
||||||
super(structure.getWidth(), structure.getHeight());
|
|
||||||
applyStructure(structure);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,38 @@
|
|||||||
|
package de.studiocode.invui.gui.impl;
|
||||||
|
|
||||||
|
import de.studiocode.invui.gui.AbstractGui;
|
||||||
|
import de.studiocode.invui.gui.Gui;
|
||||||
|
import de.studiocode.invui.gui.structure.Structure;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A normal {@link Gui} without any special features.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||||
|
public final class NormalGuiImpl extends AbstractGui {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link NormalGuiImpl}.
|
||||||
|
*
|
||||||
|
* @param width The width of this Gui.
|
||||||
|
* @param height The height of this Gui.
|
||||||
|
* @deprecated Use {@link Gui#empty(int, int)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public NormalGuiImpl(int width, int height) {
|
||||||
|
super(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link NormalGuiImpl}.
|
||||||
|
*
|
||||||
|
* @param structure The {@link Structure} to use.
|
||||||
|
* @deprecated Use {@link Gui#of(Structure)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public NormalGuiImpl(@NotNull Structure structure) {
|
||||||
|
super(structure.getWidth(), structure.getHeight());
|
||||||
|
applyStructure(structure);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,59 +0,0 @@
|
|||||||
package de.studiocode.invui.gui.impl;
|
|
||||||
|
|
||||||
import de.studiocode.invui.gui.AbstractPagedGUI;
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
|
||||||
import de.studiocode.invui.gui.SlotElement;
|
|
||||||
import de.studiocode.invui.gui.builder.GUIBuilder;
|
|
||||||
import de.studiocode.invui.gui.structure.Structure;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.IntStream;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A {@link AbstractPagedGUI} where every page is its own {@link GUI}.
|
|
||||||
*
|
|
||||||
* @see GUIBuilder
|
|
||||||
* @see PagedItemsGUIImpl
|
|
||||||
*/
|
|
||||||
public final class PageNestedGUIImpl extends AbstractPagedGUI<GUI> {
|
|
||||||
|
|
||||||
private List<GUI> guis;
|
|
||||||
|
|
||||||
public PageNestedGUIImpl(int width, int height, @Nullable List<GUI> guis, int... contentListSlots) {
|
|
||||||
super(width, height, false, contentListSlots);
|
|
||||||
setContent(guis);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PageNestedGUIImpl(@Nullable List<GUI> guis, @NotNull Structure structure) {
|
|
||||||
super(structure.getWidth(), structure.getHeight(), false, structure);
|
|
||||||
setContent(guis);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getPageAmount() {
|
|
||||||
return guis.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setContent(@Nullable List<GUI> guis) {
|
|
||||||
this.guis = guis == null ? new ArrayList<>() : guis;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<SlotElement> getPageElements(int page) {
|
|
||||||
if (guis.size() <= page) return new ArrayList<>();
|
|
||||||
|
|
||||||
GUI gui = guis.get(page);
|
|
||||||
int size = gui.getSize();
|
|
||||||
|
|
||||||
return IntStream.range(0, size)
|
|
||||||
.mapToObj(i -> new SlotElement.LinkedSlotElement(gui, i))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,9 +1,10 @@
|
|||||||
package de.studiocode.invui.gui.impl;
|
package de.studiocode.invui.gui.impl;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.AbstractPagedGUI;
|
import de.studiocode.invui.gui.AbstractPagedGui;
|
||||||
|
import de.studiocode.invui.gui.PagedGui;
|
||||||
import de.studiocode.invui.gui.SlotElement;
|
import de.studiocode.invui.gui.SlotElement;
|
||||||
import de.studiocode.invui.gui.SlotElement.ItemSlotElement;
|
import de.studiocode.invui.gui.SlotElement.ItemSlotElement;
|
||||||
import de.studiocode.invui.gui.builder.GUIBuilder;
|
import de.studiocode.invui.gui.builder.GuiBuilder;
|
||||||
import de.studiocode.invui.gui.structure.Structure;
|
import de.studiocode.invui.gui.structure.Structure;
|
||||||
import de.studiocode.invui.item.Item;
|
import de.studiocode.invui.item.Item;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -15,22 +16,41 @@ import java.util.function.BiConsumer;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link AbstractPagedGUI} that is filled with {@link Item}s.
|
* A {@link AbstractPagedGui} that is filled with {@link Item}s.
|
||||||
*
|
*
|
||||||
* @see GUIBuilder
|
* @see GuiBuilder
|
||||||
* @see PageNestedGUIImpl
|
* @see PagedNestedGuiImpl
|
||||||
*/
|
*/
|
||||||
public final class PagedItemsGUIImpl extends AbstractPagedGUI<Item> {
|
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||||
|
public final class PagedItemsGuiImpl extends AbstractPagedGui<Item> {
|
||||||
|
|
||||||
private List<Item> items;
|
private List<Item> items;
|
||||||
private List<BiConsumer<Integer, Integer>> pageChangeHandlers;
|
private List<BiConsumer<Integer, Integer>> pageChangeHandlers;
|
||||||
|
|
||||||
public PagedItemsGUIImpl(int width, int height, @Nullable List<Item> items, int... contentListSlots) {
|
/**
|
||||||
|
* Creates a new {@link PagedItemsGuiImpl}.
|
||||||
|
*
|
||||||
|
* @param width The width of this Gui.
|
||||||
|
* @param height The height of this Gui.
|
||||||
|
* @param items The {@link Item Items} to use as pages.
|
||||||
|
* @param contentListSlots The slots where content should be displayed.
|
||||||
|
* @deprecated Use {@link PagedGui#ofItems(int, int, List, int...)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public PagedItemsGuiImpl(int width, int height, @Nullable List<Item> items, int... contentListSlots) {
|
||||||
super(width, height, false, contentListSlots);
|
super(width, height, false, contentListSlots);
|
||||||
setContent(items);
|
setContent(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PagedItemsGUIImpl(@Nullable List<Item> items, @NotNull Structure structure) {
|
/**
|
||||||
|
* Creates a new {@link PagedItemsGuiImpl}.
|
||||||
|
*
|
||||||
|
* @param items The {@link Item Items} to use as pages.
|
||||||
|
* @param structure The {@link Structure} to use.
|
||||||
|
* @deprecated Use {@link PagedGui#ofItems(Structure, List)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public PagedItemsGuiImpl(@Nullable List<Item> items, @NotNull Structure structure) {
|
||||||
super(structure.getWidth(), structure.getHeight(), false, structure);
|
super(structure.getWidth(), structure.getHeight(), false, structure);
|
||||||
setContent(items);
|
setContent(items);
|
||||||
}
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
package de.studiocode.invui.gui.impl;
|
||||||
|
|
||||||
|
import de.studiocode.invui.gui.AbstractPagedGui;
|
||||||
|
import de.studiocode.invui.gui.Gui;
|
||||||
|
import de.studiocode.invui.gui.PagedGui;
|
||||||
|
import de.studiocode.invui.gui.SlotElement;
|
||||||
|
import de.studiocode.invui.gui.builder.GuiBuilder;
|
||||||
|
import de.studiocode.invui.gui.structure.Structure;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link AbstractPagedGui} where every page is its own {@link Gui}.
|
||||||
|
*
|
||||||
|
* @see GuiBuilder
|
||||||
|
* @see PagedItemsGuiImpl
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||||
|
public final class PagedNestedGuiImpl extends AbstractPagedGui<Gui> {
|
||||||
|
|
||||||
|
private List<Gui> guis;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link PagedNestedGuiImpl}.
|
||||||
|
*
|
||||||
|
* @param width The width of this Gui.
|
||||||
|
* @param height The height of this Gui.
|
||||||
|
* @param guis The {@link Gui Guis} to use as pages.
|
||||||
|
* @param contentListSlots The slots where content should be displayed.
|
||||||
|
* @deprecated Use {@link PagedGui#ofGuis(int, int, List, int...)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public PagedNestedGuiImpl(int width, int height, @Nullable List<Gui> guis, int... contentListSlots) {
|
||||||
|
super(width, height, false, contentListSlots);
|
||||||
|
setContent(guis);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link PagedNestedGuiImpl}.
|
||||||
|
*
|
||||||
|
* @param guis The {@link Gui Guis} to use as pages.
|
||||||
|
* @param structure The {@link Structure} to use.
|
||||||
|
* @deprecated Use {@link PagedGui#ofGuis(Structure, List)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public PagedNestedGuiImpl(@Nullable List<Gui> guis, @NotNull Structure structure) {
|
||||||
|
super(structure.getWidth(), structure.getHeight(), false, structure);
|
||||||
|
setContent(guis);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPageAmount() {
|
||||||
|
return guis.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setContent(@Nullable List<Gui> guis) {
|
||||||
|
this.guis = guis == null ? new ArrayList<>() : guis;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<SlotElement> getPageElements(int page) {
|
||||||
|
if (guis.size() <= page) return new ArrayList<>();
|
||||||
|
|
||||||
|
Gui gui = guis.get(page);
|
||||||
|
int size = gui.getSize();
|
||||||
|
|
||||||
|
return IntStream.range(0, size)
|
||||||
|
.mapToObj(i -> new SlotElement.LinkedSlotElement(gui, i))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package de.studiocode.invui.gui.impl;
|
package de.studiocode.invui.gui.impl;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.AbstractScrollGUI;
|
import de.studiocode.invui.gui.AbstractScrollGui;
|
||||||
|
import de.studiocode.invui.gui.ScrollGui;
|
||||||
import de.studiocode.invui.gui.SlotElement;
|
import de.studiocode.invui.gui.SlotElement;
|
||||||
import de.studiocode.invui.gui.structure.Structure;
|
import de.studiocode.invui.gui.structure.Structure;
|
||||||
import de.studiocode.invui.item.Item;
|
import de.studiocode.invui.item.Item;
|
||||||
@ -11,22 +12,41 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public final class ScrollItemsGUIImpl extends AbstractScrollGUI<Item> {
|
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||||
|
public final class ScrollItemsGuiImpl extends AbstractScrollGui<Item> {
|
||||||
|
|
||||||
private List<Item> items;
|
private List<Item> items;
|
||||||
|
|
||||||
public ScrollItemsGUIImpl(int width, int height, @Nullable List<Item> items, int... contentListSlots) {
|
/**
|
||||||
|
* Creates a new {@link ScrollItemsGuiImpl}.
|
||||||
|
*
|
||||||
|
* @param width The width of this Gui.
|
||||||
|
* @param height The height of this Gui.
|
||||||
|
* @param items The {@link Item Items} to use.
|
||||||
|
* @param contentListSlots The slots where content should be displayed.
|
||||||
|
* @deprecated Use {@link ScrollGui#ofItems(int, int, List, int...)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public ScrollItemsGuiImpl(int width, int height, @Nullable List<Item> items, int... contentListSlots) {
|
||||||
super(width, height, false, contentListSlots);
|
super(width, height, false, contentListSlots);
|
||||||
setContent(items);
|
setContent(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScrollItemsGUIImpl(@Nullable List<Item> items, @NotNull Structure structure) {
|
/**
|
||||||
|
* Creates a new {@link ScrollItemsGuiImpl}.
|
||||||
|
*
|
||||||
|
* @param items The {@link Item Items} to use.
|
||||||
|
* @param structure The {@link Structure} to use.
|
||||||
|
* @deprecated Use {@link ScrollGui#ofItems(Structure, List)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public ScrollItemsGuiImpl(@Nullable List<Item> items, @NotNull Structure structure) {
|
||||||
super(structure.getWidth(), structure.getHeight(), false, structure);
|
super(structure.getWidth(), structure.getHeight(), false, structure);
|
||||||
setContent(items);
|
setContent(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setContent(@Nullable List<Item> items) {
|
public void setContent(@NotNull List<Item> items) {
|
||||||
this.items = items != null ? items : new ArrayList<>();
|
this.items = items != null ? items : new ArrayList<>();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
@ -1,7 +1,8 @@
|
|||||||
package de.studiocode.invui.gui.impl;
|
package de.studiocode.invui.gui.impl;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.AbstractScrollGUI;
|
import de.studiocode.invui.gui.AbstractScrollGui;
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
|
import de.studiocode.invui.gui.ScrollGui;
|
||||||
import de.studiocode.invui.gui.SlotElement;
|
import de.studiocode.invui.gui.SlotElement;
|
||||||
import de.studiocode.invui.gui.structure.Structure;
|
import de.studiocode.invui.gui.structure.Structure;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -10,23 +11,42 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class ScrollNestedGUIImpl extends AbstractScrollGUI<GUI> {
|
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||||
|
public final class ScrollNestedGuiImpl extends AbstractScrollGui<Gui> {
|
||||||
|
|
||||||
private List<GUI> guis;
|
private List<Gui> guis;
|
||||||
private List<SlotElement.LinkedSlotElement> elements;
|
private List<SlotElement.LinkedSlotElement> elements;
|
||||||
|
|
||||||
public ScrollNestedGUIImpl(int width, int height, @Nullable List<GUI> guis, int... contentListSlots) {
|
/**
|
||||||
|
* Creates a new {@link ScrollNestedGuiImpl}.
|
||||||
|
*
|
||||||
|
* @param width The width of this Gui.
|
||||||
|
* @param height The height of this Gui.
|
||||||
|
* @param guis The {@link Gui Guis} to use.
|
||||||
|
* @param contentListSlots The slots where content should be displayed.
|
||||||
|
* @deprecated Use {@link ScrollGui#ofGuis(int, int, List, int...)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public ScrollNestedGuiImpl(int width, int height, @Nullable List<Gui> guis, int... contentListSlots) {
|
||||||
super(width, height, false, contentListSlots);
|
super(width, height, false, contentListSlots);
|
||||||
setContent(guis);
|
setContent(guis);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScrollNestedGUIImpl(@Nullable List<GUI> guis, @NotNull Structure structure) {
|
/**
|
||||||
|
* Creates a new {@link ScrollNestedGuiImpl}.
|
||||||
|
*
|
||||||
|
* @param guis The {@link Gui Guis} to use.
|
||||||
|
* @param structure The {@link Structure} to use.
|
||||||
|
* @deprecated Use {@link ScrollGui#ofGuis(Structure, List)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public ScrollNestedGuiImpl(@Nullable List<Gui> guis, @NotNull Structure structure) {
|
||||||
super(structure.getWidth(), structure.getHeight(), false, structure);
|
super(structure.getWidth(), structure.getHeight(), false, structure);
|
||||||
setContent(guis);
|
setContent(guis);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setContent(@Nullable List<GUI> guis) {
|
public void setContent(@NotNull List<Gui> guis) {
|
||||||
this.guis = guis != null ? guis : new ArrayList<>();
|
this.guis = guis != null ? guis : new ArrayList<>();
|
||||||
updateElements();
|
updateElements();
|
||||||
update();
|
update();
|
||||||
@ -34,7 +54,7 @@ public final class ScrollNestedGUIImpl extends AbstractScrollGUI<GUI> {
|
|||||||
|
|
||||||
private void updateElements() {
|
private void updateElements() {
|
||||||
elements = new ArrayList<>();
|
elements = new ArrayList<>();
|
||||||
for (GUI gui : guis) {
|
for (Gui gui : guis) {
|
||||||
for (int i = 0; i < gui.getSize(); i++) {
|
for (int i = 0; i < gui.getSize(); i++) {
|
||||||
elements.add(new SlotElement.LinkedSlotElement(gui, i));
|
elements.add(new SlotElement.LinkedSlotElement(gui, i));
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package de.studiocode.invui.gui.impl;
|
package de.studiocode.invui.gui.impl;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.AbstractScrollGUI;
|
import de.studiocode.invui.gui.AbstractScrollGui;
|
||||||
|
import de.studiocode.invui.gui.ScrollGui;
|
||||||
import de.studiocode.invui.gui.SlotElement;
|
import de.studiocode.invui.gui.SlotElement;
|
||||||
import de.studiocode.invui.gui.structure.Structure;
|
import de.studiocode.invui.gui.structure.Structure;
|
||||||
import de.studiocode.invui.virtualinventory.VirtualInventory;
|
import de.studiocode.invui.virtualinventory.VirtualInventory;
|
||||||
@ -9,23 +10,42 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class ScrollVIGUIImpl extends AbstractScrollGUI<VirtualInventory> {
|
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||||
|
public final class ScrollVIGuiImpl extends AbstractScrollGui<VirtualInventory> {
|
||||||
|
|
||||||
private List<VirtualInventory> inventories;
|
private List<VirtualInventory> inventories;
|
||||||
private List<SlotElement.VISlotElement> elements;
|
private List<SlotElement.VISlotElement> elements;
|
||||||
|
|
||||||
public ScrollVIGUIImpl(int width, int height, @NotNull List<VirtualInventory> inventories, int... contentListSlots) {
|
/**
|
||||||
|
* Creates a new {@link ScrollVIGuiImpl}.
|
||||||
|
*
|
||||||
|
* @param width The width of this Gui.
|
||||||
|
* @param height The width of this Gui.
|
||||||
|
* @param inventories The {@link VirtualInventory VirtualInventories} to use.
|
||||||
|
* @param contentListSlots The slots where content should be displayed.
|
||||||
|
* @deprecated Use {@link ScrollGui#ofInventories(int, int, List, int...)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public ScrollVIGuiImpl(int width, int height, @NotNull List<VirtualInventory> inventories, int... contentListSlots) {
|
||||||
super(width, height, false, contentListSlots);
|
super(width, height, false, contentListSlots);
|
||||||
setContent(inventories);
|
setContent(inventories);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScrollVIGUIImpl(@NotNull List<VirtualInventory> inventories, @NotNull Structure structure) {
|
/**
|
||||||
|
* Creates a new {@link ScrollVIGuiImpl}.
|
||||||
|
*
|
||||||
|
* @param inventories The {@link VirtualInventory VirtualInventories} to use.
|
||||||
|
* @param structure The {@link Structure} to use.
|
||||||
|
* @deprecated Use {@link ScrollGui#ofInventories(Structure, List)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public ScrollVIGuiImpl(@NotNull List<VirtualInventory> inventories, @NotNull Structure structure) {
|
||||||
super(structure.getWidth(), structure.getHeight(), false, structure);
|
super(structure.getWidth(), structure.getHeight(), false, structure);
|
||||||
setContent(inventories);
|
setContent(inventories);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setContent(List<VirtualInventory> inventory) {
|
public void setContent(@NotNull List<VirtualInventory> inventory) {
|
||||||
this.inventories = inventory;
|
this.inventories = inventory;
|
||||||
updateElements();
|
updateElements();
|
||||||
update();
|
update();
|
@ -1,68 +0,0 @@
|
|||||||
package de.studiocode.invui.gui.impl;
|
|
||||||
|
|
||||||
import de.studiocode.invui.gui.AbstractTabGUI;
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
|
||||||
import de.studiocode.invui.gui.SlotElement;
|
|
||||||
import de.studiocode.invui.gui.SlotElement.LinkedSlotElement;
|
|
||||||
import de.studiocode.invui.gui.builder.GUIBuilder;
|
|
||||||
import de.studiocode.invui.gui.structure.Structure;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A {@link GUI} that has multiple tabs with which users can switch between {@link GUI}s.
|
|
||||||
*
|
|
||||||
* @see GUIBuilder
|
|
||||||
*/
|
|
||||||
public final class TabGUIImpl extends AbstractTabGUI {
|
|
||||||
|
|
||||||
private final List<GUI> tabs;
|
|
||||||
private final List<List<SlotElement>> linkingElements;
|
|
||||||
|
|
||||||
public TabGUIImpl(int width, int height, @NotNull List<GUI> tabs, int[] listSlots) {
|
|
||||||
super(width, height, tabs.size(), listSlots);
|
|
||||||
this.linkingElements = tabs.stream().map(this::getLinkingElements).collect(Collectors.toList());
|
|
||||||
this.tabs = tabs;
|
|
||||||
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TabGUIImpl(@NotNull List<GUI> tabs, @NotNull Structure structure) {
|
|
||||||
super(structure.getWidth(), structure.getHeight(), tabs.size(), structure);
|
|
||||||
this.linkingElements = tabs.stream().map(this::getLinkingElements).collect(Collectors.toList());
|
|
||||||
this.tabs = tabs;
|
|
||||||
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<SlotElement> getLinkingElements(GUI gui) {
|
|
||||||
if (gui == null) return null;
|
|
||||||
|
|
||||||
List<SlotElement> elements = new ArrayList<>();
|
|
||||||
for (int slot = 0; slot < gui.getSize(); slot++) {
|
|
||||||
SlotElement link = new LinkedSlotElement(gui, slot);
|
|
||||||
elements.add(link);
|
|
||||||
}
|
|
||||||
|
|
||||||
return elements;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<GUI> getTabs() {
|
|
||||||
return Collections.unmodifiableList(tabs);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isTabAvailable(int tab) {
|
|
||||||
return tabs.get(tab) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected List<SlotElement> getSlotElements(int tab) {
|
|
||||||
return linkingElements.get(tab);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,89 @@
|
|||||||
|
package de.studiocode.invui.gui.impl;
|
||||||
|
|
||||||
|
import de.studiocode.invui.gui.AbstractTabGui;
|
||||||
|
import de.studiocode.invui.gui.Gui;
|
||||||
|
import de.studiocode.invui.gui.SlotElement;
|
||||||
|
import de.studiocode.invui.gui.SlotElement.LinkedSlotElement;
|
||||||
|
import de.studiocode.invui.gui.TabGui;
|
||||||
|
import de.studiocode.invui.gui.builder.GuiBuilder;
|
||||||
|
import de.studiocode.invui.gui.structure.Structure;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link Gui} that has multiple tabs with which users can switch between {@link Gui}s.
|
||||||
|
*
|
||||||
|
* @see GuiBuilder
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("DeprecatedIsStillUsed")
|
||||||
|
public final class TabGuiImpl extends AbstractTabGui {
|
||||||
|
|
||||||
|
private final List<Gui> tabs;
|
||||||
|
private final List<List<SlotElement>> linkingElements;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link TabGuiImpl}.
|
||||||
|
*
|
||||||
|
* @param width The width of this Gui.
|
||||||
|
* @param height The height of this Gui.
|
||||||
|
* @param tabs The {@link Gui Guis} to use as tabs.
|
||||||
|
* @param contentListSlots The slots where content should be displayed.
|
||||||
|
* @deprecated Use {@link TabGui#of(int, int, List, int...)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public TabGuiImpl(int width, int height, @NotNull List<@Nullable Gui> tabs, int[] contentListSlots) {
|
||||||
|
super(width, height, tabs.size(), contentListSlots);
|
||||||
|
this.linkingElements = tabs.stream().map(this::getLinkingElements).collect(Collectors.toList());
|
||||||
|
this.tabs = tabs;
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link TabGuiImpl}.
|
||||||
|
*
|
||||||
|
* @param tabs The {@link Gui Guis} to use as tabs.
|
||||||
|
* @param structure The {@link Structure} to use.
|
||||||
|
* @deprecated Use {@link TabGui#of(Structure, List)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public TabGuiImpl(@NotNull List<@Nullable Gui> tabs, @NotNull Structure structure) {
|
||||||
|
super(structure.getWidth(), structure.getHeight(), tabs.size(), structure);
|
||||||
|
this.linkingElements = tabs.stream().map(this::getLinkingElements).collect(Collectors.toList());
|
||||||
|
this.tabs = tabs;
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<SlotElement> getLinkingElements(Gui gui) {
|
||||||
|
if (gui == null) return null;
|
||||||
|
|
||||||
|
List<SlotElement> elements = new ArrayList<>();
|
||||||
|
for (int slot = 0; slot < gui.getSize(); slot++) {
|
||||||
|
SlotElement link = new LinkedSlotElement(gui, slot);
|
||||||
|
elements.add(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
return elements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public @NotNull List<@Nullable Gui> getTabs() {
|
||||||
|
return Collections.unmodifiableList(tabs);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTabAvailable(int tab) {
|
||||||
|
return tabs.get(tab) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<SlotElement> getSlotElements(int tab) {
|
||||||
|
return linkingElements.get(tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package de.studiocode.invui.gui.structure;
|
package de.studiocode.invui.gui.structure;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.util.SlotUtils;
|
import de.studiocode.invui.util.SlotUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -24,9 +24,9 @@ public class IngredientList extends ArrayList<Ingredient> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertIntoGUI(GUI gui) {
|
public void insertIntoGui(Gui gui) {
|
||||||
if (size() != gui.getSize())
|
if (size() != gui.getSize())
|
||||||
throw new IllegalArgumentException("Structure size does not match GUI size");
|
throw new IllegalArgumentException("Structure size does not match Gui size");
|
||||||
|
|
||||||
for (int i = 0; i < size(); i++) {
|
for (int i = 0; i < size(); i++) {
|
||||||
Ingredient ingredient = get(i);
|
Ingredient ingredient = get(i);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package de.studiocode.invui.gui.structure;
|
package de.studiocode.invui.gui.structure;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.AbstractPagedGUI;
|
import de.studiocode.invui.gui.AbstractPagedGui;
|
||||||
import de.studiocode.invui.gui.AbstractScrollGUI;
|
import de.studiocode.invui.gui.AbstractScrollGui;
|
||||||
import de.studiocode.invui.gui.AbstractTabGUI;
|
import de.studiocode.invui.gui.AbstractTabGui;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registry class for default markers
|
* Registry class for default markers
|
||||||
@ -10,14 +10,14 @@ import de.studiocode.invui.gui.AbstractTabGUI;
|
|||||||
public class Markers {
|
public class Markers {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The marker for horizontal content list slots in {@link AbstractPagedGUI PagedGUIs},
|
* The marker for horizontal content list slots in {@link AbstractPagedGui PagedGuis},
|
||||||
* {@link AbstractScrollGUI ScrollGUIs} and {@link AbstractTabGUI TabGUIs}
|
* {@link AbstractScrollGui ScrollGuis} and {@link AbstractTabGui TabGuis}
|
||||||
*/
|
*/
|
||||||
public static final Marker CONTENT_LIST_SLOT_HORIZONTAL = new Marker(true);
|
public static final Marker CONTENT_LIST_SLOT_HORIZONTAL = new Marker(true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The marker for vertical content list slots in {@link AbstractPagedGUI PagedGUIs},
|
* The marker for vertical content list slots in {@link AbstractPagedGui PagedGuis},
|
||||||
* {@link AbstractScrollGUI ScrollGUIs} and {@link AbstractTabGUI TabGUIs}
|
* {@link AbstractScrollGui ScrollGuis} and {@link AbstractTabGui TabGuis}
|
||||||
*/
|
*/
|
||||||
public static final Marker CONTENT_LIST_SLOT_VERTICAL = new Marker(false);
|
public static final Marker CONTENT_LIST_SLOT_VERTICAL = new Marker(false);
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package de.studiocode.invui.gui.structure;
|
package de.studiocode.invui.gui.structure;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.gui.SlotElement;
|
import de.studiocode.invui.gui.SlotElement;
|
||||||
import de.studiocode.invui.gui.SlotElement.ItemSlotElement;
|
import de.studiocode.invui.gui.SlotElement.ItemSlotElement;
|
||||||
import de.studiocode.invui.item.Item;
|
import de.studiocode.invui.item.Item;
|
||||||
@ -17,9 +17,9 @@ import java.util.HashMap;
|
|||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides an easy way to design {@link GUI}s.
|
* Provides an easy way to design {@link Gui}s.
|
||||||
* Inspired by Bukkit's {@link ShapedRecipe}, {@link Structure Structures} will let you
|
* Inspired by Bukkit's {@link ShapedRecipe}, {@link Structure Structures} will let you
|
||||||
* design a {@link GUI} in a similar way.
|
* design a {@link Gui} in a similar way.
|
||||||
*/
|
*/
|
||||||
public class Structure implements Cloneable {
|
public class Structure implements Cloneable {
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package de.studiocode.invui.item.impl.controlitem;
|
package de.studiocode.invui.item.impl.controlitem;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.item.Item;
|
import de.studiocode.invui.item.Item;
|
||||||
import de.studiocode.invui.item.ItemProvider;
|
import de.studiocode.invui.item.ItemProvider;
|
||||||
import de.studiocode.invui.item.impl.BaseItem;
|
import de.studiocode.invui.item.impl.BaseItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A special type of {@link Item} that stores the {@link GUI} in which it is displayed.
|
* A special type of {@link Item} that stores the {@link Gui} in which it is displayed.
|
||||||
*
|
*
|
||||||
* @param <G> The GUI Type this {@link ControlItem} will control. Not checked when adding it to a GUI.
|
* @param <G> The Gui Type this {@link ControlItem} will control. Not checked when adding it to a Gui.
|
||||||
*/
|
*/
|
||||||
public abstract class ControlItem<G extends GUI> extends BaseItem {
|
public abstract class ControlItem<G extends Gui> extends BaseItem {
|
||||||
|
|
||||||
private G gui;
|
private G gui;
|
||||||
|
|
||||||
@ -21,12 +21,12 @@ public abstract class ControlItem<G extends GUI> extends BaseItem {
|
|||||||
return getItemProvider(gui);
|
return getItemProvider(gui);
|
||||||
}
|
}
|
||||||
|
|
||||||
public G getGUI() {
|
public G getGui() {
|
||||||
return gui;
|
return gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void setGUI(Object gui) {
|
public void setGui(Object gui) {
|
||||||
if (this.gui == null) this.gui = (G) gui;
|
if (this.gui == null) this.gui = (G) gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package de.studiocode.invui.item.impl.controlitem;
|
package de.studiocode.invui.item.impl.controlitem;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.AbstractPagedGUI;
|
import de.studiocode.invui.gui.AbstractPagedGui;
|
||||||
import de.studiocode.invui.gui.PagedGUI;
|
import de.studiocode.invui.gui.PagedGui;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switches between pages in a {@link AbstractPagedGUI}
|
* Switches between pages in a {@link AbstractPagedGui}
|
||||||
*/
|
*/
|
||||||
public abstract class PageItem extends ControlItem<PagedGUI<?>> {
|
public abstract class PageItem extends ControlItem<PagedGui<?>> {
|
||||||
|
|
||||||
private final boolean forward;
|
private final boolean forward;
|
||||||
|
|
||||||
@ -21,8 +21,8 @@ public abstract class PageItem extends ControlItem<PagedGUI<?>> {
|
|||||||
@Override
|
@Override
|
||||||
public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
|
public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
|
||||||
if (clickType == ClickType.LEFT) {
|
if (clickType == ClickType.LEFT) {
|
||||||
if (forward) getGUI().goForward();
|
if (forward) getGui().goForward();
|
||||||
else getGUI().goBack();
|
else getGui().goBack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package de.studiocode.invui.item.impl.controlitem;
|
package de.studiocode.invui.item.impl.controlitem;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.AbstractScrollGUI;
|
import de.studiocode.invui.gui.AbstractScrollGui;
|
||||||
import de.studiocode.invui.gui.ScrollGUI;
|
import de.studiocode.invui.gui.ScrollGui;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
@ -10,9 +10,9 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scrolls in a {@link AbstractScrollGUI}
|
* Scrolls in a {@link AbstractScrollGui}
|
||||||
*/
|
*/
|
||||||
public abstract class ScrollItem extends ControlItem<ScrollGUI<?>> {
|
public abstract class ScrollItem extends ControlItem<ScrollGui<?>> {
|
||||||
|
|
||||||
private final HashMap<ClickType, Integer> scroll;
|
private final HashMap<ClickType, Integer> scroll;
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ public abstract class ScrollItem extends ControlItem<ScrollGUI<?>> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
|
public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
|
||||||
if (scroll.containsKey(clickType)) getGUI().scroll(scroll.get(clickType));
|
if (scroll.containsKey(clickType)) getGui().scroll(scroll.get(clickType));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package de.studiocode.invui.item.impl.controlitem;
|
package de.studiocode.invui.item.impl.controlitem;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.AbstractTabGUI;
|
import de.studiocode.invui.gui.AbstractTabGui;
|
||||||
import de.studiocode.invui.gui.TabGUI;
|
import de.studiocode.invui.gui.TabGui;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switches between tabs in a {@link AbstractTabGUI}
|
* Switches between tabs in a {@link AbstractTabGui}
|
||||||
*/
|
*/
|
||||||
public abstract class TabItem extends ControlItem<TabGUI> {
|
public abstract class TabItem extends ControlItem<TabGui> {
|
||||||
|
|
||||||
private final int tab;
|
private final int tab;
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ public abstract class TabItem extends ControlItem<TabGUI> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
|
public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
|
||||||
if (clickType == ClickType.LEFT) getGUI().showTab(tab);
|
if (clickType == ClickType.LEFT) getGui().showTab(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package de.studiocode.invui.util;
|
package de.studiocode.invui.util;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.virtualinventory.StackSizeProvider;
|
import de.studiocode.invui.virtualinventory.StackSizeProvider;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -107,13 +107,13 @@ public class InventoryUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Inventory createMatchingInventory(@NotNull GUI gui, @NotNull String title) {
|
public static Inventory createMatchingInventory(@NotNull Gui gui, @NotNull String title) {
|
||||||
InventoryType type;
|
InventoryType type;
|
||||||
|
|
||||||
if (gui.getWidth() == 9) type = null;
|
if (gui.getWidth() == 9) type = null;
|
||||||
else if (gui.getWidth() == 3 && gui.getHeight() == 3) type = InventoryType.DROPPER;
|
else if (gui.getWidth() == 3 && gui.getHeight() == 3) type = InventoryType.DROPPER;
|
||||||
else if (gui.getWidth() == 5 && gui.getHeight() == 1) type = InventoryType.HOPPER;
|
else if (gui.getWidth() == 5 && gui.getHeight() == 1) type = InventoryType.HOPPER;
|
||||||
else throw new UnsupportedOperationException("Invalid bounds of GUI");
|
else throw new UnsupportedOperationException("Invalid bounds of Gui");
|
||||||
|
|
||||||
if (type == null) return Bukkit.createInventory(null, gui.getSize(), title);
|
if (type == null) return Bukkit.createInventory(null, gui.getSize(), title);
|
||||||
else return Bukkit.createInventory(null, type, title);
|
else return Bukkit.createInventory(null, type, title);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package de.studiocode.invui.virtualinventory;
|
package de.studiocode.invui.virtualinventory;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.util.InventoryUtils;
|
import de.studiocode.invui.util.InventoryUtils;
|
||||||
import de.studiocode.invui.util.ArrayUtils;
|
import de.studiocode.invui.util.ArrayUtils;
|
||||||
import de.studiocode.invui.virtualinventory.event.InventoryUpdatedEvent;
|
import de.studiocode.invui.virtualinventory.event.InventoryUpdatedEvent;
|
||||||
@ -144,7 +144,7 @@ public class VirtualInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the priority for shift-clicking {@link ItemStack ItemStacks} into a {@link GUI}
|
* Gets the priority for shift-clicking {@link ItemStack ItemStacks} into a {@link Gui}
|
||||||
*
|
*
|
||||||
* @return The priority for shift-clicking, {@link VirtualInventory VirtualInventories} with
|
* @return The priority for shift-clicking, {@link VirtualInventory VirtualInventories} with
|
||||||
* a higher priority get prioritized.
|
* a higher priority get prioritized.
|
||||||
@ -154,7 +154,7 @@ public class VirtualInventory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the priority for shift-clicking {@link ItemStack ItemStacks} into a {@link GUI}
|
* Sets the priority for shift-clicking {@link ItemStack ItemStacks} into a {@link Gui}
|
||||||
* with multiple {@link VirtualInventory}.
|
* with multiple {@link VirtualInventory}.
|
||||||
* Not serialized with {@link VirtualInventoryManager#serializeInventory(VirtualInventory, OutputStream)}.
|
* Not serialized with {@link VirtualInventoryManager#serializeInventory(VirtualInventory, OutputStream)}.
|
||||||
*
|
*
|
||||||
|
@ -2,7 +2,7 @@ package de.studiocode.invui.window;
|
|||||||
|
|
||||||
import de.studiocode.inventoryaccess.InventoryAccess;
|
import de.studiocode.inventoryaccess.InventoryAccess;
|
||||||
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
||||||
import de.studiocode.invui.gui.AbstractGUI;
|
import de.studiocode.invui.gui.AbstractGui;
|
||||||
import de.studiocode.invui.gui.SlotElement;
|
import de.studiocode.invui.gui.SlotElement;
|
||||||
import de.studiocode.invui.util.Pair;
|
import de.studiocode.invui.util.Pair;
|
||||||
import de.studiocode.invui.util.SlotUtils;
|
import de.studiocode.invui.util.SlotUtils;
|
||||||
@ -120,7 +120,7 @@ public abstract class AbstractDoubleWindow extends AbstractWindow {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleClick(InventoryClickEvent event) {
|
public void handleClick(InventoryClickEvent event) {
|
||||||
Pair<AbstractGUI, Integer> clicked = getWhereClicked(event);
|
Pair<AbstractGui, Integer> clicked = getWhereClicked(event);
|
||||||
clicked.getFirst().handleClick(clicked.getSecond(), (Player) event.getWhoClicked(), event.getClick(), event);
|
clicked.getFirst().handleClick(clicked.getSecond(), (Player) event.getWhoClicked(), event.getClick(), event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,6 +149,6 @@ public abstract class AbstractDoubleWindow extends AbstractWindow {
|
|||||||
|
|
||||||
protected abstract SlotElement getSlotElement(int index);
|
protected abstract SlotElement getSlotElement(int index);
|
||||||
|
|
||||||
protected abstract Pair<AbstractGUI, Integer> getWhereClicked(InventoryClickEvent event);
|
protected abstract Pair<AbstractGui, Integer> getWhereClicked(InventoryClickEvent event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package de.studiocode.invui.window;
|
package de.studiocode.invui.window;
|
||||||
|
|
||||||
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
||||||
import de.studiocode.invui.gui.AbstractGUI;
|
import de.studiocode.invui.gui.AbstractGui;
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.gui.SlotElement;
|
import de.studiocode.invui.gui.SlotElement;
|
||||||
import de.studiocode.invui.util.Pair;
|
import de.studiocode.invui.util.Pair;
|
||||||
import de.studiocode.invui.util.SlotUtils;
|
import de.studiocode.invui.util.SlotUtils;
|
||||||
@ -11,13 +11,13 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
|||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Window} where top and player {@link Inventory} are affected by the same {@link GUI}.
|
* A {@link Window} where top and player {@link Inventory} are affected by the same {@link Gui}.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractMergedWindow extends AbstractDoubleWindow {
|
public abstract class AbstractMergedWindow extends AbstractDoubleWindow {
|
||||||
|
|
||||||
private final AbstractGUI gui;
|
private final AbstractGui gui;
|
||||||
|
|
||||||
public AbstractMergedWindow(Player player, ComponentWrapper title, AbstractGUI gui, Inventory upperInventory, boolean closeable, boolean retain) {
|
public AbstractMergedWindow(Player player, ComponentWrapper title, AbstractGui gui, Inventory upperInventory, boolean closeable, boolean retain) {
|
||||||
super(player, title, gui.getSize(), upperInventory, closeable, retain);
|
super(player, title, gui.getSize(), upperInventory, closeable, retain);
|
||||||
this.gui = gui;
|
this.gui = gui;
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ public abstract class AbstractMergedWindow extends AbstractDoubleWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleSlotElementUpdate(GUI child, int slotIndex) {
|
public void handleSlotElementUpdate(Gui child, int slotIndex) {
|
||||||
redrawItem(slotIndex, gui.getSlotElement(slotIndex), true);
|
redrawItem(slotIndex, gui.getSlotElement(slotIndex), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ public abstract class AbstractMergedWindow extends AbstractDoubleWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pair<AbstractGUI, Integer> getWhereClicked(InventoryClickEvent event) {
|
protected Pair<AbstractGui, Integer> getWhereClicked(InventoryClickEvent event) {
|
||||||
Inventory clicked = event.getClickedInventory();
|
Inventory clicked = event.getClickedInventory();
|
||||||
int slot = event.getSlot();
|
int slot = event.getSlot();
|
||||||
int clickedIndex = clicked == getUpperInventory() ? slot
|
int clickedIndex = clicked == getUpperInventory() ? slot
|
||||||
@ -45,13 +45,13 @@ public abstract class AbstractMergedWindow extends AbstractDoubleWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pair<AbstractGUI, Integer> getGUIAt(int index) {
|
protected Pair<AbstractGui, Integer> getGuiAt(int index) {
|
||||||
return index < gui.getSize() ? new Pair<>(gui, index) : null;
|
return index < gui.getSize() ? new Pair<>(gui, index) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractGUI[] getGUIs() {
|
public AbstractGui[] getGuis() {
|
||||||
return new AbstractGUI[] {gui};
|
return new AbstractGui[] {gui};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package de.studiocode.invui.window;
|
package de.studiocode.invui.window;
|
||||||
|
|
||||||
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
||||||
import de.studiocode.invui.gui.AbstractGUI;
|
import de.studiocode.invui.gui.AbstractGui;
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.gui.SlotElement;
|
import de.studiocode.invui.gui.SlotElement;
|
||||||
import de.studiocode.invui.util.InventoryUtils;
|
import de.studiocode.invui.util.InventoryUtils;
|
||||||
import de.studiocode.invui.util.Pair;
|
import de.studiocode.invui.util.Pair;
|
||||||
@ -19,11 +19,11 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public abstract class AbstractSingleWindow extends AbstractWindow {
|
public abstract class AbstractSingleWindow extends AbstractWindow {
|
||||||
|
|
||||||
private final AbstractGUI gui;
|
private final AbstractGui gui;
|
||||||
private final int size;
|
private final int size;
|
||||||
protected Inventory inventory;
|
protected Inventory inventory;
|
||||||
|
|
||||||
public AbstractSingleWindow(UUID viewerUUID, ComponentWrapper title, AbstractGUI gui, Inventory inventory, boolean initItems, boolean closeable, boolean retain) {
|
public AbstractSingleWindow(UUID viewerUUID, ComponentWrapper title, AbstractGui gui, Inventory inventory, boolean initItems, boolean closeable, boolean retain) {
|
||||||
super(viewerUUID, title, gui.getSize(), closeable, retain);
|
super(viewerUUID, title, gui.getSize(), closeable, retain);
|
||||||
this.gui = gui;
|
this.gui = gui;
|
||||||
this.size = gui.getSize();
|
this.size = gui.getSize();
|
||||||
@ -56,7 +56,7 @@ public abstract class AbstractSingleWindow extends AbstractWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleSlotElementUpdate(GUI child, int slotIndex) {
|
public void handleSlotElementUpdate(Gui child, int slotIndex) {
|
||||||
redrawItem(slotIndex, gui.getSlotElement(slotIndex), true);
|
redrawItem(slotIndex, gui.getSlotElement(slotIndex), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ public abstract class AbstractSingleWindow extends AbstractWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pair<AbstractGUI, Integer> getGUIAt(int index) {
|
protected Pair<AbstractGui, Integer> getGuiAt(int index) {
|
||||||
return index < gui.getSize() ? new Pair<>(gui, index) : null;
|
return index < gui.getSize() ? new Pair<>(gui, index) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,11 +98,11 @@ public abstract class AbstractSingleWindow extends AbstractWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractGUI[] getGUIs() {
|
public AbstractGui[] getGuis() {
|
||||||
return new AbstractGUI[] {gui};
|
return new AbstractGui[] {gui};
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbstractGUI getGUI() {
|
public AbstractGui getGui() {
|
||||||
return gui;
|
return gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package de.studiocode.invui.window;
|
package de.studiocode.invui.window;
|
||||||
|
|
||||||
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
||||||
import de.studiocode.invui.gui.AbstractGUI;
|
import de.studiocode.invui.gui.AbstractGui;
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.gui.SlotElement;
|
import de.studiocode.invui.gui.SlotElement;
|
||||||
import de.studiocode.invui.util.Pair;
|
import de.studiocode.invui.util.Pair;
|
||||||
import de.studiocode.invui.util.SlotUtils;
|
import de.studiocode.invui.util.SlotUtils;
|
||||||
@ -11,14 +11,14 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
|||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Window} where top and player {@link Inventory} are affected by different {@link GUI}s.
|
* A {@link Window} where top and player {@link Inventory} are affected by different {@link Gui}s.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSplitWindow extends AbstractDoubleWindow {
|
public abstract class AbstractSplitWindow extends AbstractDoubleWindow {
|
||||||
|
|
||||||
private final AbstractGUI upperGui;
|
private final AbstractGui upperGui;
|
||||||
private final AbstractGUI lowerGui;
|
private final AbstractGui lowerGui;
|
||||||
|
|
||||||
public AbstractSplitWindow(Player player, ComponentWrapper title, AbstractGUI upperGui, AbstractGUI lowerGui, Inventory upperInventory, boolean initItems, boolean closeable, boolean retain) {
|
public AbstractSplitWindow(Player player, ComponentWrapper title, AbstractGui upperGui, AbstractGui lowerGui, Inventory upperInventory, boolean initItems, boolean closeable, boolean retain) {
|
||||||
super(player, title, upperGui.getSize() + lowerGui.getSize(), upperInventory, closeable, retain);
|
super(player, title, upperGui.getSize() + lowerGui.getSize(), upperInventory, closeable, retain);
|
||||||
this.upperGui = upperGui;
|
this.upperGui = upperGui;
|
||||||
this.lowerGui = lowerGui;
|
this.lowerGui = lowerGui;
|
||||||
@ -29,7 +29,7 @@ public abstract class AbstractSplitWindow extends AbstractDoubleWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleSlotElementUpdate(GUI child, int slotIndex) {
|
public void handleSlotElementUpdate(Gui child, int slotIndex) {
|
||||||
redrawItem(child == upperGui ? slotIndex : upperGui.getSize() + slotIndex,
|
redrawItem(child == upperGui ? slotIndex : upperGui.getSize() + slotIndex,
|
||||||
child.getSlotElement(slotIndex), true);
|
child.getSlotElement(slotIndex), true);
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ public abstract class AbstractSplitWindow extends AbstractDoubleWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pair<AbstractGUI, Integer> getWhereClicked(InventoryClickEvent event) {
|
protected Pair<AbstractGui, Integer> getWhereClicked(InventoryClickEvent event) {
|
||||||
Inventory clicked = event.getClickedInventory();
|
Inventory clicked = event.getClickedInventory();
|
||||||
if (clicked == getUpperInventory()) {
|
if (clicked == getUpperInventory()) {
|
||||||
return new Pair<>(upperGui, event.getSlot());
|
return new Pair<>(upperGui, event.getSlot());
|
||||||
@ -52,7 +52,7 @@ public abstract class AbstractSplitWindow extends AbstractDoubleWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Pair<AbstractGUI, Integer> getGUIAt(int index) {
|
protected Pair<AbstractGui, Integer> getGuiAt(int index) {
|
||||||
if (index < upperGui.getSize()) return new Pair<>(upperGui, index);
|
if (index < upperGui.getSize()) return new Pair<>(upperGui, index);
|
||||||
else if (index < (upperGui.getSize() + lowerGui.getSize()))
|
else if (index < (upperGui.getSize() + lowerGui.getSize()))
|
||||||
return new Pair<>(lowerGui, index - upperGui.getSize());
|
return new Pair<>(lowerGui, index - upperGui.getSize());
|
||||||
@ -60,8 +60,8 @@ public abstract class AbstractSplitWindow extends AbstractDoubleWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractGUI[] getGUIs() {
|
public AbstractGui[] getGuis() {
|
||||||
return new AbstractGUI[] {upperGui, lowerGui};
|
return new AbstractGui[] {upperGui, lowerGui};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,9 @@ import de.studiocode.inventoryaccess.InventoryAccess;
|
|||||||
import de.studiocode.inventoryaccess.component.BaseComponentWrapper;
|
import de.studiocode.inventoryaccess.component.BaseComponentWrapper;
|
||||||
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
||||||
import de.studiocode.invui.InvUI;
|
import de.studiocode.invui.InvUI;
|
||||||
import de.studiocode.invui.gui.AbstractGUI;
|
import de.studiocode.invui.gui.AbstractGui;
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.gui.GUIParent;
|
import de.studiocode.invui.gui.GuiParent;
|
||||||
import de.studiocode.invui.gui.SlotElement;
|
import de.studiocode.invui.gui.SlotElement;
|
||||||
import de.studiocode.invui.gui.SlotElement.ItemSlotElement;
|
import de.studiocode.invui.gui.SlotElement.ItemSlotElement;
|
||||||
import de.studiocode.invui.gui.SlotElement.LinkedSlotElement;
|
import de.studiocode.invui.gui.SlotElement.LinkedSlotElement;
|
||||||
@ -38,7 +38,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public abstract class AbstractWindow implements Window, GUIParent {
|
public abstract class AbstractWindow implements Window, GuiParent {
|
||||||
|
|
||||||
private static final NamespacedKey SLOT_KEY = new NamespacedKey(InvUI.getInstance().getPlugin(), "slot");
|
private static final NamespacedKey SLOT_KEY = new NamespacedKey(InvUI.getInstance().getPlugin(), "slot");
|
||||||
|
|
||||||
@ -70,13 +70,13 @@ public abstract class AbstractWindow implements Window, GUIParent {
|
|||||||
// put ItemStack in inventory
|
// put ItemStack in inventory
|
||||||
ItemStack itemStack;
|
ItemStack itemStack;
|
||||||
if (element == null || (element instanceof VISlotElement && element.getItemStack(viewerUUID) == null)) {
|
if (element == null || (element instanceof VISlotElement && element.getItemStack(viewerUUID) == null)) {
|
||||||
ItemProvider background = getGUIAt(index).getFirst().getBackground();
|
ItemProvider background = getGuiAt(index).getFirst().getBackground();
|
||||||
itemStack = background == null ? null : background.getFor(viewerUUID);
|
itemStack = background == null ? null : background.getFor(viewerUUID);
|
||||||
} else if (element instanceof LinkedSlotElement && element.getHoldingElement() == null) {
|
} else if (element instanceof LinkedSlotElement && element.getHoldingElement() == null) {
|
||||||
ItemProvider background = null;
|
ItemProvider background = null;
|
||||||
|
|
||||||
List<GUI> guis = ((LinkedSlotElement) element).getGUIList();
|
List<Gui> guis = ((LinkedSlotElement) element).getGuiList();
|
||||||
guis.add(0, getGUIAt(index).getFirst());
|
guis.add(0, getGuiAt(index).getFirst());
|
||||||
|
|
||||||
for (int i = guis.size() - 1; i >= 0; i--) {
|
for (int i = guis.size() - 1; i >= 0; i--) {
|
||||||
background = guis.get(i).getBackground();
|
background = guis.get(i).getBackground();
|
||||||
@ -146,8 +146,8 @@ public abstract class AbstractWindow implements Window, GUIParent {
|
|||||||
ItemStack currentStack = event.getView().getItem(rawSlot);
|
ItemStack currentStack = event.getView().getItem(rawSlot);
|
||||||
if (currentStack != null && currentStack.getType() == Material.AIR) currentStack = null;
|
if (currentStack != null && currentStack.getType() == Material.AIR) currentStack = null;
|
||||||
|
|
||||||
// get the GUI at that slot and ask for permission to drag an Item there
|
// get the Gui at that slot and ask for permission to drag an Item there
|
||||||
Pair<AbstractGUI, Integer> pair = getGUIAt(rawSlot);
|
Pair<AbstractGui, Integer> pair = getGuiAt(rawSlot);
|
||||||
if (pair != null && !pair.getFirst().handleItemDrag(updateReason, pair.getSecond(), currentStack, newItems.get(rawSlot))) {
|
if (pair != null && !pair.getFirst().handleItemDrag(updateReason, pair.getSecond(), currentStack, newItems.get(rawSlot))) {
|
||||||
// the drag was cancelled
|
// the drag was cancelled
|
||||||
int currentAmount = currentStack == null ? 0 : currentStack.getAmount();
|
int currentAmount = currentStack == null ? 0 : currentStack.getAmount();
|
||||||
@ -160,7 +160,7 @@ public abstract class AbstractWindow implements Window, GUIParent {
|
|||||||
// Redraw all items after the event so there won't be any Items that aren't actually there
|
// Redraw all items after the event so there won't be any Items that aren't actually there
|
||||||
Bukkit.getScheduler().runTask(InvUI.getInstance().getPlugin(),
|
Bukkit.getScheduler().runTask(InvUI.getInstance().getPlugin(),
|
||||||
() -> event.getRawSlots().forEach(rawSlot -> {
|
() -> event.getRawSlots().forEach(rawSlot -> {
|
||||||
if (getGUIAt(rawSlot) != null) redrawItem(rawSlot);
|
if (getGuiAt(rawSlot) != null) redrawItem(rawSlot);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ public abstract class AbstractWindow implements Window, GUIParent {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Arrays.stream(getGUIs())
|
Arrays.stream(getGuis())
|
||||||
.forEach(gui -> gui.removeParent(this));
|
.forEach(gui -> gui.removeParent(this));
|
||||||
|
|
||||||
if (closeForViewer) close();
|
if (closeForViewer) close();
|
||||||
@ -322,9 +322,9 @@ public abstract class AbstractWindow implements Window, GUIParent {
|
|||||||
|
|
||||||
protected abstract SlotElement getSlotElement(int index);
|
protected abstract SlotElement getSlotElement(int index);
|
||||||
|
|
||||||
protected abstract Pair<AbstractGUI, Integer> getGUIAt(int index);
|
protected abstract Pair<AbstractGui, Integer> getGuiAt(int index);
|
||||||
|
|
||||||
protected abstract AbstractGUI[] getGUIs();
|
protected abstract AbstractGui[] getGuis();
|
||||||
|
|
||||||
protected abstract Inventory[] getInventories();
|
protected abstract Inventory[] getInventories();
|
||||||
|
|
||||||
|
@ -1,13 +1,6 @@
|
|||||||
package de.studiocode.invui.window;
|
package de.studiocode.invui.window;
|
||||||
|
|
||||||
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
||||||
import de.studiocode.invui.window.impl.AnvilSingleWindowImpl;
|
|
||||||
import de.studiocode.invui.window.impl.AnvilSplitWindowImpl;
|
|
||||||
import de.studiocode.invui.window.impl.CartographySingleWindowImpl;
|
|
||||||
import de.studiocode.invui.window.impl.CartographySplitWindowImpl;
|
|
||||||
import de.studiocode.invui.window.impl.NormalMergedWindowImpl;
|
|
||||||
import de.studiocode.invui.window.impl.NormalSingleWindowImpl;
|
|
||||||
import de.studiocode.invui.window.impl.NormalSplitWindowImpl;
|
|
||||||
import de.studiocode.invui.window.type.WindowType;
|
import de.studiocode.invui.window.type.WindowType;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -18,7 +11,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Window is the way to show a player a GUI. Windows can only have one viewer.
|
* A Window is the way to show a player a Gui. Windows can only have one viewer.
|
||||||
* The default Window implementations can be instantiated using {@link WindowType}.
|
* The default Window implementations can be instantiated using {@link WindowType}.
|
||||||
*
|
*
|
||||||
* @see WindowType
|
* @see WindowType
|
||||||
@ -27,13 +20,6 @@ import java.util.UUID;
|
|||||||
* @see AbstractDoubleWindow
|
* @see AbstractDoubleWindow
|
||||||
* @see AbstractSplitWindow
|
* @see AbstractSplitWindow
|
||||||
* @see AbstractMergedWindow
|
* @see AbstractMergedWindow
|
||||||
* @see NormalSingleWindowImpl
|
|
||||||
* @see NormalSplitWindowImpl
|
|
||||||
* @see NormalMergedWindowImpl
|
|
||||||
* @see AnvilSingleWindowImpl
|
|
||||||
* @see AnvilSplitWindowImpl
|
|
||||||
* @see CartographySingleWindowImpl
|
|
||||||
* @see CartographySplitWindowImpl
|
|
||||||
*/
|
*/
|
||||||
public interface Window {
|
public interface Window {
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package de.studiocode.invui.window.impl;
|
|||||||
import de.studiocode.inventoryaccess.InventoryAccess;
|
import de.studiocode.inventoryaccess.InventoryAccess;
|
||||||
import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory;
|
import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory;
|
||||||
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
||||||
import de.studiocode.invui.gui.AbstractGUI;
|
import de.studiocode.invui.gui.AbstractGui;
|
||||||
import de.studiocode.invui.window.AbstractSingleWindow;
|
import de.studiocode.invui.window.AbstractSingleWindow;
|
||||||
import de.studiocode.invui.window.AnvilWindow;
|
import de.studiocode.invui.window.AnvilWindow;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -15,7 +15,7 @@ public final class AnvilSingleWindowImpl extends AbstractSingleWindow implements
|
|||||||
|
|
||||||
private final AnvilInventory anvilInventory;
|
private final AnvilInventory anvilInventory;
|
||||||
|
|
||||||
public AnvilSingleWindowImpl(Player player, ComponentWrapper title, AbstractGUI gui, Consumer<String> renameHandler, boolean closable, boolean retain) {
|
public AnvilSingleWindowImpl(Player player, ComponentWrapper title, AbstractGui gui, Consumer<String> renameHandler, boolean closable, boolean retain) {
|
||||||
super(player.getUniqueId(), title, gui, null, false, closable, retain);
|
super(player.getUniqueId(), title, gui, null, false, closable, retain);
|
||||||
anvilInventory = InventoryAccess.createAnvilInventory(player, title, renameHandler);
|
anvilInventory = InventoryAccess.createAnvilInventory(player, title, renameHandler);
|
||||||
inventory = anvilInventory.getBukkitInventory();
|
inventory = anvilInventory.getBukkitInventory();
|
||||||
|
@ -3,7 +3,7 @@ package de.studiocode.invui.window.impl;
|
|||||||
import de.studiocode.inventoryaccess.InventoryAccess;
|
import de.studiocode.inventoryaccess.InventoryAccess;
|
||||||
import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory;
|
import de.studiocode.inventoryaccess.abstraction.inventory.AnvilInventory;
|
||||||
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
||||||
import de.studiocode.invui.gui.AbstractGUI;
|
import de.studiocode.invui.gui.AbstractGui;
|
||||||
import de.studiocode.invui.window.AbstractSplitWindow;
|
import de.studiocode.invui.window.AbstractSplitWindow;
|
||||||
import de.studiocode.invui.window.AnvilWindow;
|
import de.studiocode.invui.window.AnvilWindow;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -15,7 +15,7 @@ public final class AnvilSplitWindowImpl extends AbstractSplitWindow implements A
|
|||||||
|
|
||||||
private final AnvilInventory anvilInventory;
|
private final AnvilInventory anvilInventory;
|
||||||
|
|
||||||
public AnvilSplitWindowImpl(Player player, ComponentWrapper title, AbstractGUI upperGui, AbstractGUI lowerGui, Consumer<String> renameHandler, boolean closeable, boolean retain) {
|
public AnvilSplitWindowImpl(Player player, ComponentWrapper title, AbstractGui upperGui, AbstractGui lowerGui, Consumer<String> renameHandler, boolean closeable, boolean retain) {
|
||||||
super(player, title, upperGui, lowerGui, null, false, closeable, retain);
|
super(player, title, upperGui, lowerGui, null, false, closeable, retain);
|
||||||
|
|
||||||
anvilInventory = InventoryAccess.createAnvilInventory(player, title, renameHandler);
|
anvilInventory = InventoryAccess.createAnvilInventory(player, title, renameHandler);
|
||||||
|
@ -5,7 +5,7 @@ import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory;
|
|||||||
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
||||||
import de.studiocode.inventoryaccess.map.MapIcon;
|
import de.studiocode.inventoryaccess.map.MapIcon;
|
||||||
import de.studiocode.inventoryaccess.map.MapPatch;
|
import de.studiocode.inventoryaccess.map.MapPatch;
|
||||||
import de.studiocode.invui.gui.AbstractGUI;
|
import de.studiocode.invui.gui.AbstractGui;
|
||||||
import de.studiocode.invui.util.MathUtils;
|
import de.studiocode.invui.util.MathUtils;
|
||||||
import de.studiocode.invui.window.AbstractSingleWindow;
|
import de.studiocode.invui.window.AbstractSingleWindow;
|
||||||
import de.studiocode.invui.window.CartographyWindow;
|
import de.studiocode.invui.window.CartographyWindow;
|
||||||
@ -24,9 +24,9 @@ public final class CartographySingleWindowImpl extends AbstractSingleWindow impl
|
|||||||
private final CartographyInventory cartographyInventory;
|
private final CartographyInventory cartographyInventory;
|
||||||
private int mapId;
|
private int mapId;
|
||||||
|
|
||||||
public CartographySingleWindowImpl(Player player, ComponentWrapper title, AbstractGUI gui, boolean closeable, boolean retain) {
|
public CartographySingleWindowImpl(Player player, ComponentWrapper title, AbstractGui gui, boolean closeable, boolean retain) {
|
||||||
super(player.getUniqueId(), title, gui, null, false, closeable, retain);
|
super(player.getUniqueId(), title, gui, null, false, closeable, retain);
|
||||||
if (gui.getWidth() != 2 || gui.getHeight() != 1) throw new IllegalArgumentException("GUI has to be 2x1");
|
if (gui.getWidth() != 2 || gui.getHeight() != 1) throw new IllegalArgumentException("Gui has to be 2x1");
|
||||||
|
|
||||||
cartographyInventory = InventoryAccess.createCartographyInventory(player, title);
|
cartographyInventory = InventoryAccess.createCartographyInventory(player, title);
|
||||||
inventory = cartographyInventory.getBukkitInventory();
|
inventory = cartographyInventory.getBukkitInventory();
|
||||||
@ -60,7 +60,7 @@ public final class CartographySingleWindowImpl extends AbstractSingleWindow impl
|
|||||||
@Override
|
@Override
|
||||||
public void handleClick(InventoryClickEvent event) {
|
public void handleClick(InventoryClickEvent event) {
|
||||||
if (event.getSlot() != 0) {
|
if (event.getSlot() != 0) {
|
||||||
getGUI().handleClick(event.getSlot() - 1, (Player) event.getWhoClicked(), event.getClick(), event);
|
getGui().handleClick(event.getSlot() - 1, (Player) event.getWhoClicked(), event.getClick(), event);
|
||||||
} else {
|
} else {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
@ -5,9 +5,9 @@ import de.studiocode.inventoryaccess.abstraction.inventory.CartographyInventory;
|
|||||||
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
||||||
import de.studiocode.inventoryaccess.map.MapIcon;
|
import de.studiocode.inventoryaccess.map.MapIcon;
|
||||||
import de.studiocode.inventoryaccess.map.MapPatch;
|
import de.studiocode.inventoryaccess.map.MapPatch;
|
||||||
import de.studiocode.invui.gui.AbstractGUI;
|
import de.studiocode.invui.gui.AbstractGui;
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.gui.impl.NormalGUIImpl;
|
import de.studiocode.invui.gui.impl.NormalGuiImpl;
|
||||||
import de.studiocode.invui.util.MathUtils;
|
import de.studiocode.invui.util.MathUtils;
|
||||||
import de.studiocode.invui.window.AbstractSplitWindow;
|
import de.studiocode.invui.window.AbstractSplitWindow;
|
||||||
import de.studiocode.invui.window.CartographyWindow;
|
import de.studiocode.invui.window.CartographyWindow;
|
||||||
@ -24,8 +24,8 @@ public final class CartographySplitWindowImpl extends AbstractSplitWindow implem
|
|||||||
private final CartographyInventory cartographyInventory;
|
private final CartographyInventory cartographyInventory;
|
||||||
private int mapId;
|
private int mapId;
|
||||||
|
|
||||||
public CartographySplitWindowImpl(Player player, ComponentWrapper title, AbstractGUI upperGui, AbstractGUI lowerGui, boolean closeable, boolean retain) {
|
public CartographySplitWindowImpl(Player player, ComponentWrapper title, AbstractGui upperGui, AbstractGui lowerGui, boolean closeable, boolean retain) {
|
||||||
super(player, title, createWrappingGUI(upperGui), lowerGui, null, false, closeable, retain);
|
super(player, title, createWrappingGui(upperGui), lowerGui, null, false, closeable, retain);
|
||||||
|
|
||||||
cartographyInventory = InventoryAccess.createCartographyInventory(player, title);
|
cartographyInventory = InventoryAccess.createCartographyInventory(player, title);
|
||||||
upperInventory = cartographyInventory.getBukkitInventory();
|
upperInventory = cartographyInventory.getBukkitInventory();
|
||||||
@ -35,13 +35,13 @@ public final class CartographySplitWindowImpl extends AbstractSplitWindow implem
|
|||||||
register();
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AbstractGUI createWrappingGUI(GUI upperGui) {
|
private static AbstractGui createWrappingGui(Gui upperGui) {
|
||||||
if (upperGui.getWidth() != 2 || upperGui.getHeight() != 1)
|
if (upperGui.getWidth() != 2 || upperGui.getHeight() != 1)
|
||||||
throw new IllegalArgumentException("GUI has to be 2x1");
|
throw new IllegalArgumentException("Gui has to be 2x1");
|
||||||
|
|
||||||
NormalGUIImpl wrapperGUI = new NormalGUIImpl(3, 1);
|
NormalGuiImpl wrapperGui = new NormalGuiImpl(3, 1);
|
||||||
wrapperGUI.fillRectangle(1, 0, upperGui, true);
|
wrapperGui.fillRectangle(1, 0, upperGui, true);
|
||||||
return wrapperGUI;
|
return wrapperGui;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package de.studiocode.invui.window.impl;
|
package de.studiocode.invui.window.impl;
|
||||||
|
|
||||||
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
||||||
import de.studiocode.invui.gui.AbstractGUI;
|
import de.studiocode.invui.gui.AbstractGui;
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.window.AbstractMergedWindow;
|
import de.studiocode.invui.window.AbstractMergedWindow;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -10,16 +10,16 @@ import org.bukkit.inventory.Inventory;
|
|||||||
|
|
||||||
public final class NormalMergedWindowImpl extends AbstractMergedWindow {
|
public final class NormalMergedWindowImpl extends AbstractMergedWindow {
|
||||||
|
|
||||||
public NormalMergedWindowImpl(Player player, ComponentWrapper title, AbstractGUI gui, boolean closeable, boolean retain) {
|
public NormalMergedWindowImpl(Player player, ComponentWrapper title, AbstractGui gui, boolean closeable, boolean retain) {
|
||||||
super(player, title, gui, createInventory(gui), closeable, retain);
|
super(player, title, gui, createInventory(gui), closeable, retain);
|
||||||
register();
|
register();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Inventory createInventory(GUI gui) {
|
private static Inventory createInventory(Gui gui) {
|
||||||
if (gui.getWidth() != 9)
|
if (gui.getWidth() != 9)
|
||||||
throw new IllegalArgumentException("GUI width has to be 9");
|
throw new IllegalArgumentException("Gui width has to be 9");
|
||||||
if (gui.getHeight() <= 4)
|
if (gui.getHeight() <= 4)
|
||||||
throw new IllegalArgumentException("GUI height has to be bigger than 4");
|
throw new IllegalArgumentException("Gui height has to be bigger than 4");
|
||||||
|
|
||||||
return Bukkit.createInventory(null, gui.getSize() - 36);
|
return Bukkit.createInventory(null, gui.getSize() - 36);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package de.studiocode.invui.window.impl;
|
package de.studiocode.invui.window.impl;
|
||||||
|
|
||||||
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
||||||
import de.studiocode.invui.gui.AbstractGUI;
|
import de.studiocode.invui.gui.AbstractGui;
|
||||||
import de.studiocode.invui.util.InventoryUtils;
|
import de.studiocode.invui.util.InventoryUtils;
|
||||||
import de.studiocode.invui.window.AbstractSingleWindow;
|
import de.studiocode.invui.window.AbstractSingleWindow;
|
||||||
|
|
||||||
@ -9,7 +9,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public final class NormalSingleWindowImpl extends AbstractSingleWindow {
|
public final class NormalSingleWindowImpl extends AbstractSingleWindow {
|
||||||
|
|
||||||
public NormalSingleWindowImpl(UUID viewerUUID, ComponentWrapper title, AbstractGUI gui, boolean closeable, boolean retain) {
|
public NormalSingleWindowImpl(UUID viewerUUID, ComponentWrapper title, AbstractGui gui, boolean closeable, boolean retain) {
|
||||||
super(viewerUUID, title, gui, InventoryUtils.createMatchingInventory(gui, ""), true, closeable, retain);
|
super(viewerUUID, title, gui, InventoryUtils.createMatchingInventory(gui, ""), true, closeable, retain);
|
||||||
register();
|
register();
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package de.studiocode.invui.window.impl;
|
package de.studiocode.invui.window.impl;
|
||||||
|
|
||||||
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
import de.studiocode.inventoryaccess.component.ComponentWrapper;
|
||||||
import de.studiocode.invui.gui.AbstractGUI;
|
import de.studiocode.invui.gui.AbstractGui;
|
||||||
import de.studiocode.invui.util.InventoryUtils;
|
import de.studiocode.invui.util.InventoryUtils;
|
||||||
import de.studiocode.invui.window.AbstractSplitWindow;
|
import de.studiocode.invui.window.AbstractSplitWindow;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public final class NormalSplitWindowImpl extends AbstractSplitWindow {
|
public final class NormalSplitWindowImpl extends AbstractSplitWindow {
|
||||||
|
|
||||||
public NormalSplitWindowImpl(Player player, ComponentWrapper title, AbstractGUI upperGui, AbstractGUI lowerGui, boolean closeable, boolean retain) {
|
public NormalSplitWindowImpl(Player player, ComponentWrapper title, AbstractGui upperGui, AbstractGui lowerGui, boolean closeable, boolean retain) {
|
||||||
super(player, title, upperGui, lowerGui, InventoryUtils.createMatchingInventory(upperGui, ""), true, closeable, retain);
|
super(player, title, upperGui, lowerGui, InventoryUtils.createMatchingInventory(upperGui, ""), true, closeable, retain);
|
||||||
register();
|
register();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package de.studiocode.invui.window.type;
|
package de.studiocode.invui.window.type;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.AbstractGUI;
|
import de.studiocode.invui.gui.AbstractGui;
|
||||||
import de.studiocode.invui.window.AnvilWindow;
|
import de.studiocode.invui.window.AnvilWindow;
|
||||||
import de.studiocode.invui.window.CartographyWindow;
|
import de.studiocode.invui.window.CartographyWindow;
|
||||||
import de.studiocode.invui.window.Window;
|
import de.studiocode.invui.window.Window;
|
||||||
@ -24,7 +24,7 @@ public interface WindowType<W extends Window, C extends WindowContext> {
|
|||||||
return new NormalSingleWindowImpl(
|
return new NormalSingleWindowImpl(
|
||||||
context.getViewer(),
|
context.getViewer(),
|
||||||
context.getTitle(),
|
context.getTitle(),
|
||||||
(AbstractGUI) context.getGUI(),
|
(AbstractGui) context.getGui(),
|
||||||
context.isCloseable(),
|
context.isCloseable(),
|
||||||
context.isRetain()
|
context.isRetain()
|
||||||
);
|
);
|
||||||
@ -44,7 +44,7 @@ public interface WindowType<W extends Window, C extends WindowContext> {
|
|||||||
return new NormalMergedWindowImpl(
|
return new NormalMergedWindowImpl(
|
||||||
context.getViewer(),
|
context.getViewer(),
|
||||||
context.getTitle(),
|
context.getTitle(),
|
||||||
(AbstractGUI) context.getGUI(),
|
(AbstractGui) context.getGui(),
|
||||||
context.isCloseable(),
|
context.isCloseable(),
|
||||||
context.isRetain()
|
context.isRetain()
|
||||||
);
|
);
|
||||||
@ -64,8 +64,8 @@ public interface WindowType<W extends Window, C extends WindowContext> {
|
|||||||
return new NormalSplitWindowImpl(
|
return new NormalSplitWindowImpl(
|
||||||
context.getViewer(),
|
context.getViewer(),
|
||||||
context.getTitle(),
|
context.getTitle(),
|
||||||
(AbstractGUI) context.getUpperGUI(),
|
(AbstractGui) context.getUpperGui(),
|
||||||
(AbstractGUI) context.getLowerGUI(),
|
(AbstractGui) context.getLowerGui(),
|
||||||
context.isCloseable(),
|
context.isCloseable(),
|
||||||
context.isRetain()
|
context.isRetain()
|
||||||
);
|
);
|
||||||
@ -85,7 +85,7 @@ public interface WindowType<W extends Window, C extends WindowContext> {
|
|||||||
return new AnvilSingleWindowImpl(
|
return new AnvilSingleWindowImpl(
|
||||||
context.getViewer(),
|
context.getViewer(),
|
||||||
context.getTitle(),
|
context.getTitle(),
|
||||||
(AbstractGUI) context.getGUI(),
|
(AbstractGui) context.getGui(),
|
||||||
context.getRenameHandler(),
|
context.getRenameHandler(),
|
||||||
context.isCloseable(),
|
context.isCloseable(),
|
||||||
context.isRetain()
|
context.isRetain()
|
||||||
@ -106,8 +106,8 @@ public interface WindowType<W extends Window, C extends WindowContext> {
|
|||||||
return new AnvilSplitWindowImpl(
|
return new AnvilSplitWindowImpl(
|
||||||
context.getViewer(),
|
context.getViewer(),
|
||||||
context.getTitle(),
|
context.getTitle(),
|
||||||
(AbstractGUI) context.getUpperGUI(),
|
(AbstractGui) context.getUpperGui(),
|
||||||
(AbstractGUI) context.getLowerGUI(),
|
(AbstractGui) context.getLowerGui(),
|
||||||
context.getRenameHandler(),
|
context.getRenameHandler(),
|
||||||
context.isCloseable(),
|
context.isCloseable(),
|
||||||
context.isRetain()
|
context.isRetain()
|
||||||
@ -128,7 +128,7 @@ public interface WindowType<W extends Window, C extends WindowContext> {
|
|||||||
return new CartographySingleWindowImpl(
|
return new CartographySingleWindowImpl(
|
||||||
context.getViewer(),
|
context.getViewer(),
|
||||||
context.getTitle(),
|
context.getTitle(),
|
||||||
(AbstractGUI) context.getGUI(),
|
(AbstractGui) context.getGui(),
|
||||||
context.isCloseable(),
|
context.isCloseable(),
|
||||||
context.isRetain()
|
context.isRetain()
|
||||||
);
|
);
|
||||||
@ -148,8 +148,8 @@ public interface WindowType<W extends Window, C extends WindowContext> {
|
|||||||
return new CartographySplitWindowImpl(
|
return new CartographySplitWindowImpl(
|
||||||
context.getViewer(),
|
context.getViewer(),
|
||||||
context.getTitle(),
|
context.getTitle(),
|
||||||
(AbstractGUI) context.getUpperGUI(),
|
(AbstractGui) context.getUpperGui(),
|
||||||
(AbstractGUI) context.getLowerGUI(),
|
(AbstractGui) context.getLowerGui(),
|
||||||
context.isCloseable(),
|
context.isCloseable(),
|
||||||
context.isRetain()
|
context.isRetain()
|
||||||
);
|
);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package de.studiocode.invui.window.type.context;
|
package de.studiocode.invui.window.type.context;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.gui.builder.GUIBuilder;
|
import de.studiocode.invui.gui.builder.GuiBuilder;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -11,22 +11,22 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
public final class AnvilSingleWindowContext extends AbstractWindowContext<Player> {
|
public final class AnvilSingleWindowContext extends AbstractWindowContext<Player> {
|
||||||
|
|
||||||
private Supplier<GUI> guiSupplier;
|
private Supplier<Gui> guiSupplier;
|
||||||
private Consumer<String> renameHandler;
|
private Consumer<String> renameHandler;
|
||||||
|
|
||||||
public @Nullable GUI getGUI() {
|
public @Nullable Gui getGui() {
|
||||||
return guiSupplier.get();
|
return guiSupplier.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGUI(@NotNull Supplier<GUI> guiSupplier) {
|
public void setGui(@NotNull Supplier<Gui> guiSupplier) {
|
||||||
this.guiSupplier = guiSupplier;
|
this.guiSupplier = guiSupplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGUI(@NotNull GUI gui) {
|
public void setGui(@NotNull Gui gui) {
|
||||||
this.guiSupplier = () -> gui;
|
this.guiSupplier = () -> gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGUI(@NotNull GUIBuilder<?, ?> builder) {
|
public void setGui(@NotNull GuiBuilder<?, ?> builder) {
|
||||||
this.guiSupplier = builder::build;
|
this.guiSupplier = builder::build;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package de.studiocode.invui.window.type.context;
|
package de.studiocode.invui.window.type.context;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.gui.builder.GUIBuilder;
|
import de.studiocode.invui.gui.builder.GuiBuilder;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -11,39 +11,39 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
public final class AnvilSplitWindowContext extends AbstractWindowContext<Player> {
|
public final class AnvilSplitWindowContext extends AbstractWindowContext<Player> {
|
||||||
|
|
||||||
private Supplier<GUI> upperGuiSupplier;
|
private Supplier<Gui> upperGuiSupplier;
|
||||||
private Supplier<GUI> lowerGuiSupplier;
|
private Supplier<Gui> lowerGuiSupplier;
|
||||||
private Consumer<String> renameHandler;
|
private Consumer<String> renameHandler;
|
||||||
|
|
||||||
public @Nullable GUI getUpperGUI() {
|
public @Nullable Gui getUpperGui() {
|
||||||
return upperGuiSupplier.get();
|
return upperGuiSupplier.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpperGUI(@NotNull Supplier<GUI> guiSupplier) {
|
public void setUpperGui(@NotNull Supplier<Gui> guiSupplier) {
|
||||||
this.upperGuiSupplier = guiSupplier;
|
this.upperGuiSupplier = guiSupplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpperGUI(@NotNull GUI gui) {
|
public void setUpperGui(@NotNull Gui gui) {
|
||||||
this.upperGuiSupplier = () -> gui;
|
this.upperGuiSupplier = () -> gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpperGUI(@NotNull GUIBuilder<?, ?> builder) {
|
public void setUpperGui(@NotNull GuiBuilder<?, ?> builder) {
|
||||||
this.upperGuiSupplier = builder::build;
|
this.upperGuiSupplier = builder::build;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable GUI getLowerGUI() {
|
public @Nullable Gui getLowerGui() {
|
||||||
return lowerGuiSupplier.get();
|
return lowerGuiSupplier.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLowerGUI(@NotNull Supplier<GUI> guiSupplier) {
|
public void setLowerGui(@NotNull Supplier<Gui> guiSupplier) {
|
||||||
this.lowerGuiSupplier = guiSupplier;
|
this.lowerGuiSupplier = guiSupplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLowerGUI(@NotNull GUI gui) {
|
public void setLowerGui(@NotNull Gui gui) {
|
||||||
this.lowerGuiSupplier = () -> gui;
|
this.lowerGuiSupplier = () -> gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLowerGUI(@NotNull GUIBuilder<?, ?> builder) {
|
public void setLowerGui(@NotNull GuiBuilder<?, ?> builder) {
|
||||||
this.lowerGuiSupplier = builder::build;
|
this.lowerGuiSupplier = builder::build;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package de.studiocode.invui.window.type.context;
|
package de.studiocode.invui.window.type.context;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.gui.builder.GUIBuilder;
|
import de.studiocode.invui.gui.builder.GuiBuilder;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -10,21 +10,21 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
public final class CartographySingleWindowContext extends AbstractWindowContext<Player> {
|
public final class CartographySingleWindowContext extends AbstractWindowContext<Player> {
|
||||||
|
|
||||||
private Supplier<GUI> guiSupplier;
|
private Supplier<Gui> guiSupplier;
|
||||||
|
|
||||||
public @Nullable GUI getGUI() {
|
public @Nullable Gui getGui() {
|
||||||
return guiSupplier.get();
|
return guiSupplier.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGUI(@NotNull Supplier<GUI> guiSupplier) {
|
public void setGui(@NotNull Supplier<Gui> guiSupplier) {
|
||||||
this.guiSupplier = guiSupplier;
|
this.guiSupplier = guiSupplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGUI(@NotNull GUI gui) {
|
public void setGui(@NotNull Gui gui) {
|
||||||
this.guiSupplier = () -> gui;
|
this.guiSupplier = () -> gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGUI(@NotNull GUIBuilder<?, ?> builder) {
|
public void setGui(@NotNull GuiBuilder<?, ?> builder) {
|
||||||
this.guiSupplier = builder::build;
|
this.guiSupplier = builder::build;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package de.studiocode.invui.window.type.context;
|
package de.studiocode.invui.window.type.context;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.gui.builder.GUIBuilder;
|
import de.studiocode.invui.gui.builder.GuiBuilder;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -10,38 +10,38 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
public final class CartographySplitWindowContext extends AbstractWindowContext<Player> {
|
public final class CartographySplitWindowContext extends AbstractWindowContext<Player> {
|
||||||
|
|
||||||
private Supplier<GUI> upperGuiSupplier;
|
private Supplier<Gui> upperGuiSupplier;
|
||||||
private Supplier<GUI> lowerGuiSupplier;
|
private Supplier<Gui> lowerGuiSupplier;
|
||||||
|
|
||||||
public @Nullable GUI getUpperGUI() {
|
public @Nullable Gui getUpperGui() {
|
||||||
return upperGuiSupplier.get();
|
return upperGuiSupplier.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpperGUI(@NotNull Supplier<GUI> guiSupplier) {
|
public void setUpperGui(@NotNull Supplier<Gui> guiSupplier) {
|
||||||
this.upperGuiSupplier = guiSupplier;
|
this.upperGuiSupplier = guiSupplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpperGUI(@NotNull GUI gui) {
|
public void setUpperGui(@NotNull Gui gui) {
|
||||||
this.upperGuiSupplier = () -> gui;
|
this.upperGuiSupplier = () -> gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpperGUI(@NotNull GUIBuilder<?, ?> builder) {
|
public void setUpperGui(@NotNull GuiBuilder<?, ?> builder) {
|
||||||
this.upperGuiSupplier = builder::build;
|
this.upperGuiSupplier = builder::build;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable GUI getLowerGUI() {
|
public @Nullable Gui getLowerGui() {
|
||||||
return lowerGuiSupplier.get();
|
return lowerGuiSupplier.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLowerGUI(@NotNull Supplier<GUI> guiSupplier) {
|
public void setLowerGui(@NotNull Supplier<Gui> guiSupplier) {
|
||||||
this.lowerGuiSupplier = guiSupplier;
|
this.lowerGuiSupplier = guiSupplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLowerGUI(@NotNull GUI gui) {
|
public void setLowerGui(@NotNull Gui gui) {
|
||||||
this.lowerGuiSupplier = () -> gui;
|
this.lowerGuiSupplier = () -> gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLowerGUI(@NotNull GUIBuilder<?, ?> builder) {
|
public void setLowerGui(@NotNull GuiBuilder<?, ?> builder) {
|
||||||
this.lowerGuiSupplier = builder::build;
|
this.lowerGuiSupplier = builder::build;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package de.studiocode.invui.window.type.context;
|
package de.studiocode.invui.window.type.context;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.gui.builder.GUIBuilder;
|
import de.studiocode.invui.gui.builder.GuiBuilder;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -10,21 +10,21 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
public final class NormalCombinedWindowContext extends AbstractWindowContext<Player> {
|
public final class NormalCombinedWindowContext extends AbstractWindowContext<Player> {
|
||||||
|
|
||||||
private Supplier<GUI> guiSupplier;
|
private Supplier<Gui> guiSupplier;
|
||||||
|
|
||||||
public @Nullable GUI getGUI() {
|
public @Nullable Gui getGui() {
|
||||||
return guiSupplier.get();
|
return guiSupplier.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGUI(@NotNull Supplier<GUI> guiSupplier) {
|
public void setGui(@NotNull Supplier<Gui> guiSupplier) {
|
||||||
this.guiSupplier = guiSupplier;
|
this.guiSupplier = guiSupplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGUI(@NotNull GUI gui) {
|
public void setGui(@NotNull Gui gui) {
|
||||||
this.guiSupplier = () -> gui;
|
this.guiSupplier = () -> gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGUI(@NotNull GUIBuilder<?, ?> builder) {
|
public void setGui(@NotNull GuiBuilder<?, ?> builder) {
|
||||||
this.guiSupplier = builder::build;
|
this.guiSupplier = builder::build;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package de.studiocode.invui.window.type.context;
|
package de.studiocode.invui.window.type.context;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.gui.builder.GUIBuilder;
|
import de.studiocode.invui.gui.builder.GuiBuilder;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -11,21 +11,21 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
public final class NormalSingleWindowContext extends AbstractWindowContext<UUID> {
|
public final class NormalSingleWindowContext extends AbstractWindowContext<UUID> {
|
||||||
|
|
||||||
private Supplier<GUI> guiSupplier;
|
private Supplier<Gui> guiSupplier;
|
||||||
|
|
||||||
public @Nullable GUI getGUI() {
|
public @Nullable Gui getGui() {
|
||||||
return guiSupplier.get();
|
return guiSupplier.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGUI(@NotNull Supplier<GUI> guiSupplier) {
|
public void setGui(@NotNull Supplier<Gui> guiSupplier) {
|
||||||
this.guiSupplier = guiSupplier;
|
this.guiSupplier = guiSupplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGUI(@NotNull GUI gui) {
|
public void setGui(@NotNull Gui gui) {
|
||||||
this.guiSupplier = () -> gui;
|
this.guiSupplier = () -> gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGUI(@NotNull GUIBuilder<?, ?> builder) {
|
public void setGui(@NotNull GuiBuilder<?, ?> builder) {
|
||||||
this.guiSupplier = builder::build;
|
this.guiSupplier = builder::build;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package de.studiocode.invui.window.type.context;
|
package de.studiocode.invui.window.type.context;
|
||||||
|
|
||||||
import de.studiocode.invui.gui.GUI;
|
import de.studiocode.invui.gui.Gui;
|
||||||
import de.studiocode.invui.gui.builder.GUIBuilder;
|
import de.studiocode.invui.gui.builder.GuiBuilder;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -10,38 +10,38 @@ import java.util.function.Supplier;
|
|||||||
|
|
||||||
public final class NormalSplitWindowContext extends AbstractWindowContext<Player> {
|
public final class NormalSplitWindowContext extends AbstractWindowContext<Player> {
|
||||||
|
|
||||||
private Supplier<GUI> upperGuiSupplier;
|
private Supplier<Gui> upperGuiSupplier;
|
||||||
private Supplier<GUI> lowerGuiSupplier;
|
private Supplier<Gui> lowerGuiSupplier;
|
||||||
|
|
||||||
public @Nullable GUI getUpperGUI() {
|
public @Nullable Gui getUpperGui() {
|
||||||
return upperGuiSupplier.get();
|
return upperGuiSupplier.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpperGUI(@NotNull Supplier<GUI> guiSupplier) {
|
public void setUpperGui(@NotNull Supplier<Gui> guiSupplier) {
|
||||||
this.upperGuiSupplier = guiSupplier;
|
this.upperGuiSupplier = guiSupplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpperGUI(@NotNull GUI gui) {
|
public void setUpperGui(@NotNull Gui gui) {
|
||||||
this.upperGuiSupplier = () -> gui;
|
this.upperGuiSupplier = () -> gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpperGUI(@NotNull GUIBuilder<?, ?> builder) {
|
public void setUpperGui(@NotNull GuiBuilder<?, ?> builder) {
|
||||||
this.upperGuiSupplier = builder::build;
|
this.upperGuiSupplier = builder::build;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable GUI getLowerGUI() {
|
public @Nullable Gui getLowerGui() {
|
||||||
return lowerGuiSupplier.get();
|
return lowerGuiSupplier.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLowerGUI(@NotNull Supplier<GUI> guiSupplier) {
|
public void setLowerGui(@NotNull Supplier<Gui> guiSupplier) {
|
||||||
this.lowerGuiSupplier = guiSupplier;
|
this.lowerGuiSupplier = guiSupplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLowerGUI(@NotNull GUI gui) {
|
public void setLowerGui(@NotNull Gui gui) {
|
||||||
this.lowerGuiSupplier = () -> gui;
|
this.lowerGuiSupplier = () -> gui;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLowerGUI(@NotNull GUIBuilder<?, ?> builder) {
|
public void setLowerGui(@NotNull GuiBuilder<?, ?> builder) {
|
||||||
this.lowerGuiSupplier = builder::build;
|
this.lowerGuiSupplier = builder::build;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user