Reformat code

This commit is contained in:
NichtStudioCode 2023-09-04 19:02:19 +02:00
parent de30faabd7
commit 66b9c33a42
21 changed files with 74 additions and 60 deletions

@ -8,9 +8,9 @@ import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.invui.animation.Animation; import xyz.xenondevs.invui.animation.Animation;
import xyz.xenondevs.invui.gui.structure.Marker; import xyz.xenondevs.invui.gui.structure.Marker;
import xyz.xenondevs.invui.gui.structure.Structure; import xyz.xenondevs.invui.gui.structure.Structure;
import xyz.xenondevs.invui.inventory.Inventory;
import xyz.xenondevs.invui.item.Item; import xyz.xenondevs.invui.item.Item;
import xyz.xenondevs.invui.item.ItemProvider; import xyz.xenondevs.invui.item.ItemProvider;
import xyz.xenondevs.invui.inventory.Inventory;
import xyz.xenondevs.invui.window.Window; import xyz.xenondevs.invui.window.Window;
import xyz.xenondevs.invui.window.WindowManager; import xyz.xenondevs.invui.window.WindowManager;
@ -369,23 +369,23 @@ public interface Gui {
/** /**
* Fills a rectangle with a {@link Inventory} in this {@link Gui}. * Fills a rectangle with a {@link Inventory} 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. * @param width The line length of the rectangle.
* @param inventory The {@link Inventory} to be put into this {@link Gui}. * @param inventory The {@link Inventory} 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 Inventory inventory, boolean replaceExisting); void fillRectangle(int x, int y, int width, @NotNull Inventory inventory, boolean replaceExisting);
/** /**
* Fills a rectangle with a {@link Inventory} in this {@link Gui}. * Fills a rectangle with a {@link Inventory} 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. * @param width The line length of the rectangle.
* @param inventory The {@link Inventory} to be put into this {@link Gui}. * @param inventory The {@link Inventory} to be put into this {@link Gui}.
* @param background The {@link ItemProvider} for empty slots of the {@link Inventory} * @param background The {@link ItemProvider} for empty slots of the {@link Inventory}
* @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 Inventory inventory, @Nullable ItemProvider background, boolean replaceExisting); void fillRectangle(int x, int y, int width, @NotNull Inventory inventory, @Nullable ItemProvider background, boolean replaceExisting);

@ -34,12 +34,12 @@ final class NormalGuiImpl extends AbstractGui {
public @NotNull Gui build() { public @NotNull Gui build() {
if (structure == null) if (structure == null)
throw new IllegalStateException("Structure is not defined."); throw new IllegalStateException("Structure is not defined.");
var gui = new NormalGuiImpl(structure); var gui = new NormalGuiImpl(structure);
applyModifiers(gui); applyModifiers(gui);
return gui; return gui;
} }
} }
} }

@ -134,7 +134,7 @@ public interface PagedGui<C> extends Gui {
* *
* @param width The width of the {@link PagedGui}. * @param width The width of the {@link PagedGui}.
* @param height The height of the {@link PagedGui}. * @param height The height of the {@link PagedGui}.
* @param inventories The {@link Inventory Inventories} to use as pages. * @param inventories The {@link Inventory Inventories} to use as pages.
* @param contentListSlots The slots where content should be displayed. * @param contentListSlots The slots where content should be displayed.
* @return The created {@link PagedGui}. * @return The created {@link PagedGui}.
*/ */
@ -145,8 +145,8 @@ public interface PagedGui<C> extends Gui {
/** /**
* Creates a new {@link PagedGui}. * Creates a new {@link PagedGui}.
* *
* @param structure The {@link Structure} to use. * @param structure The {@link Structure} to use.
* @param inventories The {@link Inventory Inventories} to use as pages. * @param inventories The {@link Inventory Inventories} to use as pages.
* @return The created {@link PagedGui}. * @return The created {@link PagedGui}.
*/ */
static @NotNull PagedGui<@NotNull Inventory> ofInventories(@NotNull Structure structure, @NotNull List<@NotNull Inventory> inventories) { static @NotNull PagedGui<@NotNull Inventory> ofInventories(@NotNull Structure structure, @NotNull List<@NotNull Inventory> inventories) {

@ -25,7 +25,7 @@ final class PagedInventoriesGuiImpl extends AbstractPagedGui<Inventory> {
* *
* @param width The width of this Gui. * @param width The width of this Gui.
* @param height The height of this Gui. * @param height The height of this Gui.
* @param inventories The {@link Inventory Inventories} to use as pages. * @param inventories The {@link Inventory Inventories} to use as pages.
* @param contentListSlots The slots where content should be displayed. * @param contentListSlots The slots where content should be displayed.
*/ */
public PagedInventoriesGuiImpl(int width, int height, @Nullable List<@NotNull Inventory> inventories, int... contentListSlots) { public PagedInventoriesGuiImpl(int width, int height, @Nullable List<@NotNull Inventory> inventories, int... contentListSlots) {
@ -36,8 +36,8 @@ final class PagedInventoriesGuiImpl extends AbstractPagedGui<Inventory> {
/** /**
* Creates a new {@link PagedInventoriesGuiImpl}. * Creates a new {@link PagedInventoriesGuiImpl}.
* *
* @param inventories The {@link Inventory Inventories} to use as pages. * @param inventories The {@link Inventory Inventories} to use as pages.
* @param structure The {@link Structure} to use. * @param structure The {@link Structure} to use.
*/ */
public PagedInventoriesGuiImpl(@Nullable List<@NotNull Inventory> inventories, @NotNull Structure structure) { public PagedInventoriesGuiImpl(@Nullable List<@NotNull Inventory> inventories, @NotNull Structure structure) {
super(structure.getWidth(), structure.getHeight(), false, structure); super(structure.getWidth(), structure.getHeight(), false, structure);

@ -4,8 +4,8 @@ import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.invui.gui.structure.Structure; import xyz.xenondevs.invui.gui.structure.Structure;
import xyz.xenondevs.invui.item.Item;
import xyz.xenondevs.invui.inventory.Inventory; import xyz.xenondevs.invui.inventory.Inventory;
import xyz.xenondevs.invui.item.Item;
import java.util.List; import java.util.List;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;

@ -10,7 +10,7 @@ import java.util.List;
/** /**
* A {@link AbstractScrollGui} that uses {@link Inventory VirtualInventories} as content. * A {@link AbstractScrollGui} that uses {@link Inventory VirtualInventories} as content.
* *
* @see ScrollItemsGuiImpl * @see ScrollItemsGuiImpl
* @see ScrollNestedGuiImpl * @see ScrollNestedGuiImpl
*/ */

@ -1,9 +1,9 @@
package xyz.xenondevs.invui.gui; package xyz.xenondevs.invui.gui;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import xyz.xenondevs.invui.inventory.Inventory;
import xyz.xenondevs.invui.item.Item; import xyz.xenondevs.invui.item.Item;
import xyz.xenondevs.invui.item.ItemProvider; import xyz.xenondevs.invui.item.ItemProvider;
import xyz.xenondevs.invui.inventory.Inventory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

@ -4,8 +4,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.invui.gui.SlotElement; import xyz.xenondevs.invui.gui.SlotElement;
import xyz.xenondevs.invui.gui.SlotElement.InventorySlotElement; import xyz.xenondevs.invui.gui.SlotElement.InventorySlotElement;
import xyz.xenondevs.invui.item.ItemProvider;
import xyz.xenondevs.invui.inventory.Inventory; import xyz.xenondevs.invui.inventory.Inventory;
import xyz.xenondevs.invui.item.ItemProvider;
import java.util.function.Supplier; import java.util.function.Supplier;

@ -2,7 +2,7 @@ package xyz.xenondevs.invui.gui.structure;
/** /**
* Used to mark slots in a {@link Structure} as special slots. * Used to mark slots in a {@link Structure} as special slots.
* *
* @see Markers * @see Markers
*/ */
public class Marker { public class Marker {

@ -8,11 +8,11 @@ import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.invui.gui.Gui; import xyz.xenondevs.invui.gui.Gui;
import xyz.xenondevs.invui.gui.SlotElement; import xyz.xenondevs.invui.gui.SlotElement;
import xyz.xenondevs.invui.gui.SlotElement.ItemSlotElement; import xyz.xenondevs.invui.gui.SlotElement.ItemSlotElement;
import xyz.xenondevs.invui.inventory.Inventory;
import xyz.xenondevs.invui.item.Item; import xyz.xenondevs.invui.item.Item;
import xyz.xenondevs.invui.item.ItemProvider; import xyz.xenondevs.invui.item.ItemProvider;
import xyz.xenondevs.invui.item.ItemWrapper; import xyz.xenondevs.invui.item.ItemWrapper;
import xyz.xenondevs.invui.item.impl.SimpleItem; import xyz.xenondevs.invui.item.impl.SimpleItem;
import xyz.xenondevs.invui.inventory.Inventory;
import java.util.HashMap; import java.util.HashMap;
import java.util.function.Supplier; import java.util.function.Supplier;

@ -14,12 +14,12 @@ public class ItemPostUpdateEvent extends ItemUpdateEvent {
/** /**
* Creates a new {@link ItemPreUpdateEvent}. * Creates a new {@link ItemPreUpdateEvent}.
* *
* @param inventory The {@link Inventory} where this action takes place. * @param inventory The {@link Inventory} where this action takes place.
* @param updateReason The {@link UpdateReason} for the calling of this event. * @param updateReason The {@link UpdateReason} for the calling of this event.
* This will probably be a {@link PlayerUpdateReason} in most cases but can be a custom one * This will probably be a {@link PlayerUpdateReason} in most cases but can be a custom one
* if you called the methods in the {@link Inventory} yourself. * if you called the methods in the {@link Inventory} yourself.
* if it wasn't a {@link Player} * if it wasn't a {@link Player}
* @param slot The slot that is affected * @param slot The slot that is affected
* @param previousItem The {@link ItemStack} that was on that slot previously * @param previousItem The {@link ItemStack} that was on that slot previously
* @param newItem The {@link ItemStack} that is on that slot now * @param newItem The {@link ItemStack} that is on that slot now
*/ */

@ -16,12 +16,12 @@ public class ItemPreUpdateEvent extends ItemUpdateEvent {
/** /**
* Creates a new {@link ItemPreUpdateEvent}. * Creates a new {@link ItemPreUpdateEvent}.
* *
* @param inventory The {@link Inventory} where this action takes place. * @param inventory The {@link Inventory} where this action takes place.
* @param updateReason The {@link UpdateReason} for the calling of this event. * @param updateReason The {@link UpdateReason} for the calling of this event.
* This will probably be a {@link PlayerUpdateReason} in most cases but can be a custom one * This will probably be a {@link PlayerUpdateReason} in most cases but can be a custom one
* if you called the methods in the {@link Inventory} yourself. * if you called the methods in the {@link Inventory} yourself.
* if it wasn't a {@link Player} * if it wasn't a {@link Player}
* @param slot The slot that is affected * @param slot The slot that is affected
* @param previousItem The {@link ItemStack} that was there previously * @param previousItem The {@link ItemStack} that was there previously
* @param newItem The {@link ItemStack} that will be there if the event isn't cancelled * @param newItem The {@link ItemStack} that will be there if the event isn't cancelled
*/ */
@ -36,7 +36,7 @@ public class ItemPreUpdateEvent extends ItemUpdateEvent {
* to a different one. * to a different one.
* *
* @param newItem The {@link ItemStack} to appear in the {@link Inventory} * @param newItem The {@link ItemStack} to appear in the {@link Inventory}
* if the {@link ItemPreUpdateEvent} is not cancelled. * if the {@link ItemPreUpdateEvent} is not cancelled.
*/ */
public void setNewItem(@Nullable ItemStack newItem) { public void setNewItem(@Nullable ItemStack newItem) {
this.newItemStack = newItem; this.newItemStack = newItem;

@ -17,12 +17,12 @@ abstract class ItemUpdateEvent {
/** /**
* Creates a new {@link ItemPreUpdateEvent}. * Creates a new {@link ItemPreUpdateEvent}.
* *
* @param inventory The {@link Inventory} where this action takes place. * @param inventory The {@link Inventory} where this action takes place.
* @param updateReason The {@link UpdateReason} for the calling of this event. * @param updateReason The {@link UpdateReason} for the calling of this event.
* This will probably be a {@link PlayerUpdateReason} in most cases but can be a custom one * This will probably be a {@link PlayerUpdateReason} in most cases but can be a custom one
* if you called the methods in the {@link Inventory} yourself. * if you called the methods in the {@link Inventory} yourself.
* if it wasn't a {@link Player} * if it wasn't a {@link Player}
* @param slot The slot that is affected * @param slot The slot that is affected
* @param previousItem The {@link ItemStack} that was there previously * @param previousItem The {@link ItemStack} that was there previously
* @param newItem The {@link ItemStack} that will be there if the event isn't cancelled * @param newItem The {@link ItemStack} that will be there if the event isn't cancelled
*/ */

@ -3,7 +3,10 @@ package xyz.xenondevs.invui.util;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate; import java.util.function.Predicate;
public class ArrayUtils { public class ArrayUtils {

@ -20,6 +20,7 @@ public class ItemUtils {
/** /**
* Checks whether the given {@link ItemStack} is empty and returns null if it is. * Checks whether the given {@link ItemStack} is empty and returns null if it is.
*
* @param itemStack The {@link ItemStack} to check. * @param itemStack The {@link ItemStack} to check.
* @return The {@link ItemStack} if it is not empty or null otherwise. * @return The {@link ItemStack} if it is not empty or null otherwise.
*/ */

@ -19,7 +19,6 @@ import xyz.xenondevs.invui.util.InventoryUtils;
import xyz.xenondevs.invui.util.Pair; import xyz.xenondevs.invui.util.Pair;
import java.util.Set; import java.util.Set;
import java.util.UUID;
import java.util.function.Supplier; import java.util.function.Supplier;
/** /**

@ -16,6 +16,7 @@ public interface AnvilWindow extends Window {
/** /**
* Creates a new {@link Builder.Single Window Builder} for a single {@link AnvilWindow}. * Creates a new {@link Builder.Single Window Builder} for a single {@link AnvilWindow}.
*
* @return The new {@link Builder.Single Window Builder}. * @return The new {@link Builder.Single Window Builder}.
*/ */
static @NotNull Builder.Single single() { static @NotNull Builder.Single single() {
@ -24,6 +25,7 @@ public interface AnvilWindow extends Window {
/** /**
* Creates a new single {@link AnvilWindow} after configuring a {@link Builder.Single Window Builder} using the given {@link Consumer}. * Creates a new single {@link AnvilWindow} after configuring a {@link Builder.Single Window Builder} using the given {@link Consumer}.
*
* @param consumer The {@link Consumer} to configure the {@link Builder.Single Window Builder}. * @param consumer The {@link Consumer} to configure the {@link Builder.Single Window Builder}.
* @return The created {@link AnvilWindow}. * @return The created {@link AnvilWindow}.
*/ */
@ -35,6 +37,7 @@ public interface AnvilWindow extends Window {
/** /**
* Creates a new {@link Builder.Split Window Builder} for a split {@link AnvilWindow}. * Creates a new {@link Builder.Split Window Builder} for a split {@link AnvilWindow}.
*
* @return The new {@link Builder.Split Window Builder}. * @return The new {@link Builder.Split Window Builder}.
*/ */
static @NotNull Builder.Split split() { static @NotNull Builder.Split split() {
@ -43,6 +46,7 @@ public interface AnvilWindow extends Window {
/** /**
* Creates a new split {@link AnvilWindow} after configuring a {@link Builder.Split Window Builder} using the given {@link Consumer}. * Creates a new split {@link AnvilWindow} after configuring a {@link Builder.Split Window Builder} using the given {@link Consumer}.
*
* @param consumer The {@link Consumer} to configure the {@link Builder.Split Window Builder}. * @param consumer The {@link Consumer} to configure the {@link Builder.Split Window Builder}.
* @return The created {@link AnvilWindow}. * @return The created {@link AnvilWindow}.
*/ */
@ -54,49 +58,52 @@ public interface AnvilWindow extends Window {
/** /**
* Gets the current rename text. * Gets the current rename text.
*
* @return The current rename text. * @return The current rename text.
*/ */
@Nullable String getRenameText(); @Nullable String getRenameText();
/** /**
* An {@link AnvilWindow} builder. * An {@link AnvilWindow} builder.
*
* @param <S> The builder type. * @param <S> The builder type.
*
* @see Window.Builder.Normal * @see Window.Builder.Normal
* @see CartographyWindow.Builder * @see CartographyWindow.Builder
*/ */
interface Builder<S extends Builder<S>> extends Window.Builder<AnvilWindow, S> { interface Builder<S extends Builder<S>> extends Window.Builder<AnvilWindow, S> {
/** /**
* Sets the rename handlers of the {@link AnvilWindow}. * Sets the rename handlers of the {@link AnvilWindow}.
*
* @param renameHandlers The new rename handlers. * @param renameHandlers The new rename handlers.
* @return The current builder. * @return The current builder.
*/ */
@Contract("_ -> this") @Contract("_ -> this")
@NotNull S setRenameHandlers(@NotNull List<@NotNull Consumer<String>> renameHandlers); @NotNull S setRenameHandlers(@NotNull List<@NotNull Consumer<String>> renameHandlers);
/** /**
* Adds a rename handler to the {@link AnvilWindow}. * Adds a rename handler to the {@link AnvilWindow}.
*
* @param renameHandler The rename handler to add. * @param renameHandler The rename handler to add.
* @return The current builder. * @return The current builder.
*/ */
@Contract("_ -> this") @Contract("_ -> this")
@NotNull S addRenameHandler(@NotNull Consumer<String> renameHandler); @NotNull S addRenameHandler(@NotNull Consumer<String> renameHandler);
/** /**
* A single {@link AnvilWindow} builder. Combines both {@link AnvilWindow.Builder} and {@link Window.Builder.Single} * A single {@link AnvilWindow} builder. Combines both {@link AnvilWindow.Builder} and {@link Window.Builder.Single}
* for an {@link AnvilWindow} with only one {@link Gui} that does not access the {@link Player Player's} inventory. * for an {@link AnvilWindow} with only one {@link Gui} that does not access the {@link Player Player's} inventory.
* *
* @see Window.Builder.Normal.Single * @see Window.Builder.Normal.Single
* @see CartographyWindow.Builder.Single * @see CartographyWindow.Builder.Single
*/ */
interface Single extends Builder<Single>, Window.Builder.Single<AnvilWindow, Single> {} interface Single extends Builder<Single>, Window.Builder.Single<AnvilWindow, Single> {}
/** /**
* A split {@link AnvilWindow} builder. Combines both {@link AnvilWindow.Builder} and {@link Window.Builder.Double} * A split {@link AnvilWindow} builder. Combines both {@link AnvilWindow.Builder} and {@link Window.Builder.Double}
* for an {@link AnvilWindow} with two {@link Gui Guis}, where the lower {@link Gui} is used to fill the * for an {@link AnvilWindow} with two {@link Gui Guis}, where the lower {@link Gui} is used to fill the
* {@link Player Player's} inventory. * {@link Player Player's} inventory.
* *
* @see Window.Builder.Normal.Split * @see Window.Builder.Normal.Split
* @see CartographyWindow.Builder.Split * @see CartographyWindow.Builder.Split
*/ */

@ -69,7 +69,7 @@ final class CartographySingleWindowImpl extends AbstractSingleWindow implements
cartographyInventory.open(); cartographyInventory.open();
} }
public static final class BuilderImpl public static final class BuilderImpl
extends AbstractSingleWindow.AbstractBuilder<CartographyWindow, CartographyWindow.Builder.Single> extends AbstractSingleWindow.AbstractBuilder<CartographyWindow, CartographyWindow.Builder.Single>
implements CartographyWindow.Builder.Single implements CartographyWindow.Builder.Single
{ {

@ -18,8 +18,8 @@ final class NormalSingleWindowImpl extends AbstractSingleWindow {
super(player, title, gui, InventoryUtils.createMatchingInventory(gui, ""), closeable); super(player, title, gui, InventoryUtils.createMatchingInventory(gui, ""), closeable);
} }
public static final class BuilderImpl public static final class BuilderImpl
extends AbstractSingleWindow.AbstractBuilder<Window, Window.Builder.Normal.Single> extends AbstractSingleWindow.AbstractBuilder<Window, Window.Builder.Normal.Single>
implements Window.Builder.Normal.Single implements Window.Builder.Normal.Single
{ {

@ -167,11 +167,11 @@ public interface Window {
* Gets the contents of the {@link Window#getCurrentViewer() viewer's} inventory. * Gets the contents of the {@link Window#getCurrentViewer() viewer's} inventory.
* This method will always return the actual inventory contents and will not be affected by double windows placing * This method will always return the actual inventory contents and will not be affected by double windows placing
* gui items in the {@link Player's} inventory. * gui items in the {@link Player's} inventory.
* *
* @return The contents of the {@link Window#getCurrentViewer() viewer's} inventory, * @return The contents of the {@link Window#getCurrentViewer() viewer's} inventory,
* or null if the {@link Window} {@link Window#isOpen() isn't open}. * or null if the {@link Window} {@link Window#isOpen() isn't open}.
*/ */
@Nullable ItemStack @Nullable[] getPlayerItems(); @Nullable ItemStack @Nullable [] getPlayerItems();
/** /**
* Replaces the currently registered open handlers with the given list. * Replaces the currently registered open handlers with the given list.

@ -17,7 +17,10 @@ import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import xyz.xenondevs.invui.InvUI; import xyz.xenondevs.invui.InvUI;
import java.util.*; import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/** /**
* Manages all {@link Window Windows} and provides methods for searching them. * Manages all {@link Window Windows} and provides methods for searching them.
@ -98,6 +101,7 @@ public class WindowManager implements Listener {
/** /**
* Gets a set of all open {@link Window Windows}. * Gets a set of all open {@link Window Windows}.
*
* @deprecated Use {@link #getWindows()} instead * @deprecated Use {@link #getWindows()} instead
*/ */
@Deprecated @Deprecated