From 8aed1dbe545dde97b1f4184f9a36f8f068eff848 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 23 Jun 2021 01:54:58 +0100 Subject: [PATCH] No longer depends on Paper, serializes components instead, temporarily. --- build.gradle.kts | 2 +- .../gui/builder/gui/PaginatedBuilder.java | 3 +- .../gui/builder/gui/ScrollingBuilder.java | 3 +- .../gui/builder/gui/SimpleBuilder.java | 14 ++- .../gui/builder/gui/StorageBuilder.java | 11 +- .../dev/triumphteam/gui/guis/BaseGui.java | 115 ++++++------------ .../java/dev/triumphteam/gui/guis/Gui.java | 62 +++------- .../triumphteam/gui/guis/PaginatedGui.java | 74 +++-------- .../triumphteam/gui/guis/ScrollingGui.java | 91 ++------------ .../dev/triumphteam/gui/guis/StorageGui.java | 54 +------- 10 files changed, 98 insertions(+), 331 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index afea5ce0..db1c86d4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -11,7 +11,7 @@ subprojects { } group = "dev.triumphteam" - version = "3.0.2" + version = "3.0.3" repositories { mavenCentral() diff --git a/core/src/main/java/dev/triumphteam/gui/builder/gui/PaginatedBuilder.java b/core/src/main/java/dev/triumphteam/gui/builder/gui/PaginatedBuilder.java index 124d141d..9565a8df 100644 --- a/core/src/main/java/dev/triumphteam/gui/builder/gui/PaginatedBuilder.java +++ b/core/src/main/java/dev/triumphteam/gui/builder/gui/PaginatedBuilder.java @@ -23,6 +23,7 @@ */ package dev.triumphteam.gui.builder.gui; +import dev.triumphteam.gui.components.util.Legacy; import dev.triumphteam.gui.guis.PaginatedGui; import org.jetbrains.annotations.Contract; @@ -55,7 +56,7 @@ public PaginatedBuilder pageSize(final int pageSize) { @Contract(" -> new") @Override public PaginatedGui create() { - final PaginatedGui gui = new PaginatedGui(getRows(), pageSize, getTitle(), getModifiers()); + final PaginatedGui gui = new PaginatedGui(getRows(), pageSize, Legacy.SERIALIZER.serialize(getTitle()), getModifiers()); final Consumer consumer = getConsumer(); if (consumer != null) consumer.accept(gui); diff --git a/core/src/main/java/dev/triumphteam/gui/builder/gui/ScrollingBuilder.java b/core/src/main/java/dev/triumphteam/gui/builder/gui/ScrollingBuilder.java index 3d7507ba..be479657 100644 --- a/core/src/main/java/dev/triumphteam/gui/builder/gui/ScrollingBuilder.java +++ b/core/src/main/java/dev/triumphteam/gui/builder/gui/ScrollingBuilder.java @@ -24,6 +24,7 @@ package dev.triumphteam.gui.builder.gui; import dev.triumphteam.gui.components.ScrollType; +import dev.triumphteam.gui.components.util.Legacy; import dev.triumphteam.gui.guis.ScrollingGui; import net.kyori.adventure.text.Component; import org.jetbrains.annotations.Contract; @@ -81,7 +82,7 @@ public ScrollingBuilder pageSize(final int pageSize) { @Contract(" -> new") @Override public ScrollingGui create() { - final ScrollingGui gui = new ScrollingGui(getRows(), pageSize, getTitle(), scrollType, getModifiers()); + final ScrollingGui gui = new ScrollingGui(getRows(), pageSize, Legacy.SERIALIZER.serialize(getTitle()), scrollType, getModifiers()); final Consumer consumer = getConsumer(); if (consumer != null) consumer.accept(gui); diff --git a/core/src/main/java/dev/triumphteam/gui/builder/gui/SimpleBuilder.java b/core/src/main/java/dev/triumphteam/gui/builder/gui/SimpleBuilder.java index 4e5d40b2..881bacc3 100644 --- a/core/src/main/java/dev/triumphteam/gui/builder/gui/SimpleBuilder.java +++ b/core/src/main/java/dev/triumphteam/gui/builder/gui/SimpleBuilder.java @@ -1,18 +1,18 @@ /** * MIT License - * + *

* Copyright (c) 2021 TriumphTeam - * + *

* Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + *

* The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. - * + *

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -24,6 +24,7 @@ package dev.triumphteam.gui.builder.gui; import dev.triumphteam.gui.components.GuiType; +import dev.triumphteam.gui.components.util.Legacy; import dev.triumphteam.gui.guis.Gui; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; @@ -68,10 +69,11 @@ public SimpleBuilder type(@NotNull final GuiType guiType) { @Override public Gui create() { final Gui gui; + final String title = Legacy.SERIALIZER.serialize(getTitle()); if (guiType == null || guiType == GuiType.CHEST) { - gui = new Gui(getRows(), getTitle(), getModifiers()); + gui = new Gui(getRows(), title, getModifiers()); } else { - gui = new Gui(guiType, getTitle(), getModifiers()); + gui = new Gui(guiType, title, getModifiers()); } final Consumer consumer = getConsumer(); diff --git a/core/src/main/java/dev/triumphteam/gui/builder/gui/StorageBuilder.java b/core/src/main/java/dev/triumphteam/gui/builder/gui/StorageBuilder.java index ed8d578f..639df914 100644 --- a/core/src/main/java/dev/triumphteam/gui/builder/gui/StorageBuilder.java +++ b/core/src/main/java/dev/triumphteam/gui/builder/gui/StorageBuilder.java @@ -1,18 +1,18 @@ /** * MIT License - * + *

* Copyright (c) 2021 TriumphTeam - * + *

* Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + *

* The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. - * + *

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -23,6 +23,7 @@ */ package dev.triumphteam.gui.builder.gui; +import dev.triumphteam.gui.components.util.Legacy; import dev.triumphteam.gui.guis.StorageGui; import org.jetbrains.annotations.Contract; @@ -41,7 +42,7 @@ public final class StorageBuilder extends BaseGuiBuilder new") @Override public StorageGui create() { - final StorageGui gui = new StorageGui(getRows(), getTitle(), getModifiers()); + final StorageGui gui = new StorageGui(getRows(), Legacy.SERIALIZER.serialize(getTitle()), getModifiers()); final Consumer consumer = getConsumer(); if (consumer != null) consumer.accept(gui); diff --git a/core/src/main/java/dev/triumphteam/gui/guis/BaseGui.java b/core/src/main/java/dev/triumphteam/gui/guis/BaseGui.java index 0fd584e0..e31a1e62 100644 --- a/core/src/main/java/dev/triumphteam/gui/guis/BaseGui.java +++ b/core/src/main/java/dev/triumphteam/gui/guis/BaseGui.java @@ -28,9 +28,6 @@ import dev.triumphteam.gui.components.InteractionModifier; import dev.triumphteam.gui.components.exception.GuiException; import dev.triumphteam.gui.components.util.GuiFiller; -import dev.triumphteam.gui.components.util.Legacy; -import dev.triumphteam.gui.components.util.VersionHelper; -import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; @@ -38,7 +35,6 @@ import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryOpenEvent; -import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; @@ -114,34 +110,34 @@ public abstract class BaseGui implements InventoryHolder { private boolean runOpenAction = true; /** - * The main constructor, using {@link Component}. + * The main constructor, using {@link String}. * - * @param rows The amount of rows to use. - * @param title The GUI title using {@link Component}. + * @param rows The amount of rows to use. + * @param title The GUI title using {@link String}. * @param interactionModifiers Modifiers to select which interactions are allowed. * @since 3.0.0. */ - public BaseGui(final int rows, @NotNull final Component title, @NotNull final Set interactionModifiers) { + public BaseGui(final int rows, @NotNull final String title, @NotNull final Set interactionModifiers) { int finalRows = rows; if (!(rows >= 1 && rows <= 6)) finalRows = 1; this.rows = finalRows; this.interactionModifiers = safeCopyOf(interactionModifiers); - inventory = createRowedInventory(title); + inventory = Bukkit.createInventory(this, this.rows * 9, title); } /** * Alternative constructor that takes {@link GuiType} instead of rows number. * - * @param guiType The {@link GuiType} to use. - * @param title The GUI title using {@link Component}. + * @param guiType The {@link GuiType} to use. + * @param title The GUI title using {@link String}. * @param interactionModifiers Modifiers to select which interactions are allowed. * @since 3.0.0 */ - public BaseGui(@NotNull final GuiType guiType, @NotNull final Component title, @NotNull final Set interactionModifiers) { + public BaseGui(@NotNull final GuiType guiType, @NotNull final String title, @NotNull final Set interactionModifiers) { this.guiType = guiType; this.interactionModifiers = safeCopyOf(interactionModifiers); - inventory = createTypedInventory(title); + inventory = Bukkit.createInventory(this, guiType.getInventoryType(), title); } /** @@ -161,7 +157,7 @@ private EnumSet safeCopyOf(@NotNull final Set(inventory.getViewers())) ((Player) viewer).updateInventory(); } + /** + * Updates the title of the GUI. + * This method may cause LAG if used on a loop. + * + * @param title The title to set. + * @return The GUI for easier use when declaring, works like a builder. + */ + public BaseGui updateTitle(@NotNull final String title) { + updating = true; + + final List viewers = new ArrayList<>(inventory.getViewers()); + + inventory = Bukkit.createInventory(this, inventory.getSize(), title); + + for (final HumanEntity player : viewers) { + open(player); + } + + updating = false; + + return this; + } + /** * Updates the specified item in the GUI at runtime, without creating a new {@link GuiItem}. * @@ -469,54 +488,6 @@ public void updateItem(final int row, final int col, @NotNull final GuiItem item updateItem(getSlotFromRowCol(row, col), item); } - /** - * Updates the title of the GUI. - * This method may cause LAG if used on a loop. - * - * @param title The title to set. - * @return The GUI for easier use when declaring, works like a builder. - * @deprecated Should use {@link #updateTitle(Component)} instead. - */ - @Deprecated - public BaseGui updateTitle(@NotNull final String title) { - updating = true; - - final List viewers = new ArrayList<>(inventory.getViewers()); - - inventory = Bukkit.createInventory(this, inventory.getSize(), title); - - for (final HumanEntity player : viewers) { - open(player); - } - - updating = false; - - return this; - } - - /** - * Updates the title of the GUI. - * I do not recommend using this too often. - * - * @param title The title to set. - * @return The GUI for easier use when declaring, works like a builder. - */ - public BaseGui updateTitle(@NotNull final Component title) { - updating = true; - - final List viewers = new ArrayList<>(inventory.getViewers()); - - inventory = createRowedInventory(title); - - for (final HumanEntity player : viewers) { - open(player); - } - - updating = false; - - return this; - } - /** * Disable item placement inside the GUI. * @@ -805,13 +776,8 @@ public void setInventory(@NotNull final Inventory inventory) { this.inventory = inventory; } - /** - * Creates a rowed {@link Inventory}. - * If the server is unfortunately legacy it'll serialize to string using the stupid format. - * - * @param title The title as a {@link Component}. - * @return The new rowed {@link Inventory}. - */ + /* + TODO fix this part, find a better solution for using Paper protected Inventory createRowedInventory(@NotNull final Component title) { if (VersionHelper.IS_COMPONENT_LEGACY) { return Bukkit.createInventory(this, this.rows * 9, Legacy.SERIALIZER.serialize(title)); @@ -820,13 +786,6 @@ protected Inventory createRowedInventory(@NotNull final Component title) { return inventory = Bukkit.createInventory(this, this.rows * 9, title); } - /** - * Creates a typed {@link Inventory}. - * If the server is unfortunately legacy it'll serialize to string using the stupid format. - * - * @param title The title as a {@link Component}. - * @return The new typed {@link Inventory}. - */ private Inventory createTypedInventory(@NotNull final Component title) { final InventoryType inventoryType = guiType.getInventoryType(); if (VersionHelper.IS_COMPONENT_LEGACY) { @@ -834,7 +793,7 @@ private Inventory createTypedInventory(@NotNull final Component title) { } return Bukkit.createInventory(this, inventoryType, title); - } + }*/ /** * Checks if the slot introduces is a valid slot. diff --git a/core/src/main/java/dev/triumphteam/gui/guis/Gui.java b/core/src/main/java/dev/triumphteam/gui/guis/Gui.java index d18bb1f4..2fb3642e 100644 --- a/core/src/main/java/dev/triumphteam/gui/guis/Gui.java +++ b/core/src/main/java/dev/triumphteam/gui/guis/Gui.java @@ -1,18 +1,18 @@ /** * MIT License - * + *

* Copyright (c) 2021 TriumphTeam - * + *

* Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + *

* The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. - * + *

* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -30,11 +30,9 @@ import dev.triumphteam.gui.components.GuiType; import dev.triumphteam.gui.components.InteractionModifier; import dev.triumphteam.gui.components.ScrollType; -import net.kyori.adventure.text.Component; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -import java.util.Collections; import java.util.Set; /** @@ -43,60 +41,28 @@ public class Gui extends BaseGui { /** - * Main constructor for the GUI, now with {@link Component} support + * Main constructor for the GUI * * @param rows The amount of rows the GUI should have - * @param title The GUI's title using {@link Component} + * @param title The GUI's title using {@link String} * @param interactionModifiers A set containing the {@link InteractionModifier} this GUI should use * @author SecretX - * @since 3.0.0 + * @since 3.0.3 */ - public Gui(final int rows, @NotNull final Component title, @NotNull final Set interactionModifiers) { + public Gui(final int rows, @NotNull final String title, @NotNull final Set interactionModifiers) { super(rows, title, interactionModifiers); } - /** - * Alternative constructor to provide a way to create GUIs that don't need any {@link InteractionModifier} - * - * @param rows The amount of rows the GUI should have - * @param title The GUI's title using {@link Component} - * @since 3.0.0 - */ - public Gui(final int rows, @NotNull final Component title) { - this(rows, title, Collections.emptySet()); - } - - /** - * Alternative constructor that defaults to 1 row - * - * @param title The GUI's title using {@link Component} - * @since 3.0.0 - */ - public Gui(@NotNull final Component title) { - super(1, title, Collections.emptySet()); - } - - /** - * Main constructor that takes a {@link GuiType} instead of rows - * - * @param guiType The {@link GuiType} to be used - * @param title The GUI's title using {@link Component} - * @since 3.0.0 - */ - public Gui(@NotNull final GuiType guiType, @NotNull final Component title) { - super(guiType, title, Collections.emptySet()); - } - /** * Alternative constructor that takes both a {@link GuiType} and a set of {@link InteractionModifier} * * @param guiType The {@link GuiType} to be used - * @param title The GUI's title using {@link Component} + * @param title The GUI's title using {@link String} * @param interactionModifiers A set containing the {@link InteractionModifier} this GUI should use * @author SecretX - * @since 3.0.0 + * @since 3.0.3 */ - public Gui(@NotNull final GuiType guiType, @NotNull final Component title, @NotNull final Set interactionModifiers) { + public Gui(@NotNull final GuiType guiType, @NotNull final String title, @NotNull final Set interactionModifiers) { super(guiType, title, interactionModifiers); } @@ -105,7 +71,7 @@ public Gui(@NotNull final GuiType guiType, @NotNull final Component title, @NotN * * @param rows The amount of rows the GUI should have * @param title The GUI's title - * @deprecated In favor of {@link Gui#Gui(int, Component)} + * @deprecated In favor of {@link Gui#Gui(int, String, Set)} */ @Deprecated public Gui(final int rows, @NotNull final String title) { @@ -116,7 +82,7 @@ public Gui(final int rows, @NotNull final String title) { * Alternative constructor that defaults to 1 row * * @param title The GUI's title - * @deprecated In favor of {@link Gui#Gui(Component)} + * @deprecated In favor of {@link Gui#Gui(int, String, Set)} */ @Deprecated public Gui(@NotNull final String title) { @@ -128,7 +94,7 @@ public Gui(@NotNull final String title) { * * @param guiType The {@link GuiType} to be used * @param title The GUI's title - * @deprecated In favor of {@link Gui#Gui(GuiType, Component)} + * @deprecated In favor of {@link Gui#Gui(GuiType, String, Set)} */ @Deprecated public Gui(@NotNull final GuiType guiType, @NotNull final String title) { diff --git a/core/src/main/java/dev/triumphteam/gui/guis/PaginatedGui.java b/core/src/main/java/dev/triumphteam/gui/guis/PaginatedGui.java index 86917031..60dd05a6 100644 --- a/core/src/main/java/dev/triumphteam/gui/guis/PaginatedGui.java +++ b/core/src/main/java/dev/triumphteam/gui/guis/PaginatedGui.java @@ -24,14 +24,19 @@ package dev.triumphteam.gui.guis; import dev.triumphteam.gui.components.InteractionModifier; -import net.kyori.adventure.text.Component; import org.bukkit.Bukkit; import org.bukkit.entity.HumanEntity; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; /** * GUI that allows you to have multiple pages @@ -48,61 +53,27 @@ public class PaginatedGui extends BaseGui { private int pageNum = 1; /** - * Main constructor to provide a way to create PaginatedGui, uses {@link Component} + * Main constructor to provide a way to create PaginatedGui * * @param rows The amount of rows the GUI should have * @param pageSize The page size. - * @param title The GUI's title using {@link Component} + * @param title The GUI's title using {@link String} * @param interactionModifiers A set containing what {@link InteractionModifier} this GUI should have * @author SecretX - * @since 3.0.0 + * @since 3.0.3 */ - public PaginatedGui(final int rows, final int pageSize, @NotNull final Component title, @NotNull final Set interactionModifiers) { + public PaginatedGui(final int rows, final int pageSize, @NotNull final String title, @NotNull final Set interactionModifiers) { super(rows, title, interactionModifiers); this.pageSize = pageSize; } - /** - * Alternative constructor of the PaginatedGui, uses {@link Component} and provides a way to create PaginatedGui that don't use any {@link InteractionModifier} - * - * @param rows The rows the GUI should have - * @param pageSize The pageSize - * @param title The title using {@link Component} - * @since 3.0.0 - */ - public PaginatedGui(final int rows, final int pageSize, @NotNull final Component title) { - this(rows, pageSize, title, Collections.emptySet()); - } - - - /** - * Alternative constructor for the {@link PaginatedGui} without page size - * - * @param rows Number of rows. - * @param title The title using {@link Component} - * @since 3.0.0 - */ - public PaginatedGui(final int rows, @NotNull final Component title) { - this(rows, 0, title); - } - - /** - * Alternative constructor that only requires title - * - * @param title The title using {@link Component} - * @since 3.0.0 - */ - public PaginatedGui(@NotNull final Component title) { - this(2, title); - } - /** * Old main constructor of the PaginatedGui * * @param rows The rows the GUI should have * @param pageSize The pageSize * @param title The GUI's title - * @deprecated In favor of {@link PaginatedGui#PaginatedGui(int, int, Component)} + * @deprecated In favor of {@link PaginatedGui#PaginatedGui(int, int, String, Set)} */ @Deprecated public PaginatedGui(final int rows, final int pageSize, @NotNull final String title) { @@ -115,7 +86,7 @@ public PaginatedGui(final int rows, final int pageSize, @NotNull final String ti * * @param rows The rows the GUI should have * @param title The GUI's title - * @deprecated In favor of {@link PaginatedGui#PaginatedGui(int, Component)} + * @deprecated In favor of {@link PaginatedGui#PaginatedGui(int, int, String, Set)} */ @Deprecated public PaginatedGui(final int rows, @NotNull final String title) { @@ -126,7 +97,7 @@ public PaginatedGui(final int rows, @NotNull final String title) { * Alternative constructor that only requires title * * @param title The GUI's title - * @deprecated In favor of {@link PaginatedGui#PaginatedGui(Component)} + * @deprecated In favor of {@link PaginatedGui#PaginatedGui(int, int, String, Set)} */ @Deprecated public PaginatedGui(@NotNull final String title) { @@ -286,23 +257,6 @@ public BaseGui updateTitle(@NotNull final String title) { return this; } - @Override - public BaseGui updateTitle(@NotNull final Component title) { - setUpdating(true); - - final List viewers = new ArrayList<>(getInventory().getViewers()); - - setInventory(createRowedInventory(title)); - - for (final HumanEntity player : viewers) { - open(player, getPageNum()); - } - - setUpdating(false); - - return this; - } - /** * Gets an immutable {@link Map} with all the current pages items * diff --git a/core/src/main/java/dev/triumphteam/gui/guis/ScrollingGui.java b/core/src/main/java/dev/triumphteam/gui/guis/ScrollingGui.java index 86f8c0ab..e4eac8bf 100644 --- a/core/src/main/java/dev/triumphteam/gui/guis/ScrollingGui.java +++ b/core/src/main/java/dev/triumphteam/gui/guis/ScrollingGui.java @@ -25,12 +25,10 @@ import dev.triumphteam.gui.components.InteractionModifier; import dev.triumphteam.gui.components.ScrollType; -import net.kyori.adventure.text.Component; import org.bukkit.entity.HumanEntity; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Set; @@ -40,7 +38,7 @@ @SuppressWarnings("unused") public class ScrollingGui extends PaginatedGui { - private ScrollType scrollType; + private final ScrollType scrollType; private int scrollSize = 0; /** @@ -48,87 +46,18 @@ public class ScrollingGui extends PaginatedGui { * * @param rows The rows the GUI should have * @param pageSize The Page size - * @param title The title using {@link Component} + * @param title The title using {@link String} * @param scrollType The {@link ScrollType} * @param interactionModifiers A set containing the {@link InteractionModifier} this GUI should use - * @since 3.0.0 + * @since 3.0.3 * @author SecretX */ - public ScrollingGui(final int rows, final int pageSize, @NotNull final Component title, @NotNull final ScrollType scrollType, @NotNull final Set interactionModifiers) { + public ScrollingGui(final int rows, final int pageSize, @NotNull final String title, @NotNull final ScrollType scrollType, @NotNull final Set interactionModifiers) { super(rows, pageSize, title, interactionModifiers); this.scrollType = scrollType; } - /** - * Alternative constructor of the Scrolling GUI, for when the GUI doesn't require any {@link InteractionModifier} - * - * @param rows The rows the GUI should have - * @param pageSize The Page size - * @param title The title using {@link Component} - * @param scrollType The {@link ScrollType} - * @since 3.0.0 - */ - public ScrollingGui(final int rows, final int pageSize, @NotNull final Component title, @NotNull final ScrollType scrollType) { - this(rows, pageSize, title, scrollType, Collections.emptySet()); - } - - /** - * Alternative constructor that doesn't require the {@link ScrollType} - * - * @param rows The rows the GUI should have - * @param pageSize The Page size - * @param title The title using {@link Component} - * @since 3.0.0 - */ - public ScrollingGui(final int rows, final int pageSize, @NotNull final Component title) { - this(rows, pageSize, title, ScrollType.VERTICAL); - } - - /** - * Alternative constructor that doesn't require the page size - * - * @param rows The rows the GUI should have - * @param title The title using {@link Component} - * @param scrollType The {@link ScrollType} - * @since 3.0.0 - */ - public ScrollingGui(final int rows, @NotNull final Component title, @NotNull final ScrollType scrollType) { - this(rows, 0, title, scrollType); - } - - - /** - * Alternative constructor that doesn't require the {@link ScrollType} or page size - * - * @param rows The rows the GUI should have - * @param title The title using {@link Component} - * @since 3.0.0 - */ - public ScrollingGui(final int rows, @NotNull final Component title) { - this(rows, 0, title, ScrollType.VERTICAL); - } - - /** - * Alternative constructor that doesn't require the rows or page size - * - * @param title The title using {@link Component} - * @param scrollType The {@link ScrollType} - * @since 3.0.0 - */ - public ScrollingGui(@NotNull final Component title, @NotNull final ScrollType scrollType) { - this(2, title, scrollType); - } - - /** - * Alternative constructor that only requires title - * - * @param title The title using {@link Component} - */ - public ScrollingGui(@NotNull final Component title) { - this(2, title); - } - /** * Main constructor of the Scrolling GUI * @@ -136,7 +65,7 @@ public ScrollingGui(@NotNull final Component title) { * @param pageSize The Page size * @param title The GUI's title * @param scrollType The {@link ScrollType} - * @deprecated In favor of {@link ScrollingGui#ScrollingGui(int, int, Component, ScrollType)} + * @deprecated In favor of {@link ScrollingGui#ScrollingGui(int, int, String, ScrollType, Set)} */ @Deprecated public ScrollingGui(final int rows, final int pageSize, @NotNull final String title, @NotNull final ScrollType scrollType) { @@ -150,7 +79,7 @@ public ScrollingGui(final int rows, final int pageSize, @NotNull final String ti * @param rows The rows the GUI should have * @param pageSize The Page size * @param title The GUI's title - * @deprecated In favor of {@link ScrollingGui#ScrollingGui(int, int, Component)} + * @deprecated In favor of {@link ScrollingGui#ScrollingGui(int, int, String, ScrollType, Set)} */ @Deprecated public ScrollingGui(final int rows, final int pageSize, @NotNull final String title) { @@ -162,7 +91,7 @@ public ScrollingGui(final int rows, final int pageSize, @NotNull final String ti * * @param rows The rows the GUI should have * @param title The GUI's title - * @deprecated In favor of {@link ScrollingGui#ScrollingGui(int, Component)} + * @deprecated In favor of {@link ScrollingGui#ScrollingGui(int, int, String, ScrollType, Set)} */ @Deprecated public ScrollingGui(final int rows, @NotNull final String title) { @@ -175,7 +104,7 @@ public ScrollingGui(final int rows, @NotNull final String title) { * @param rows The rows the GUI should have * @param title The GUI's title * @param scrollType The {@link ScrollType} - * @deprecated In favor of {@link ScrollingGui#ScrollingGui(int, Component, ScrollType)} + * @deprecated In favor of {@link ScrollingGui#ScrollingGui(int, int, String, ScrollType, Set)} */ @Deprecated public ScrollingGui(final int rows, @NotNull final String title, @NotNull final ScrollType scrollType) { @@ -186,7 +115,7 @@ public ScrollingGui(final int rows, @NotNull final String title, @NotNull final * Alternative constructor that only requires title * * @param title The GUI's title - * @deprecated In favor of {@link ScrollingGui#ScrollingGui(Component)} + * @deprecated In favor of {@link ScrollingGui#ScrollingGui(int, int, String, ScrollType, Set)} */ @Deprecated public ScrollingGui(@NotNull final String title) { @@ -198,7 +127,7 @@ public ScrollingGui(@NotNull final String title) { * * @param title The GUI's title * @param scrollType The {@link ScrollType} - * @deprecated In favor of {@link ScrollingGui#ScrollingGui(Component, ScrollType)} + * @deprecated In favor of {@link ScrollingGui#ScrollingGui(int, int, String, ScrollType, Set)} */ @Deprecated public ScrollingGui(@NotNull final String title, @NotNull final ScrollType scrollType) { diff --git a/core/src/main/java/dev/triumphteam/gui/guis/StorageGui.java b/core/src/main/java/dev/triumphteam/gui/guis/StorageGui.java index 583ad9b5..c69318e8 100644 --- a/core/src/main/java/dev/triumphteam/gui/guis/StorageGui.java +++ b/core/src/main/java/dev/triumphteam/gui/guis/StorageGui.java @@ -23,9 +23,7 @@ */ package dev.triumphteam.gui.guis; -import dev.triumphteam.gui.components.GuiType; import dev.triumphteam.gui.components.InteractionModifier; -import net.kyori.adventure.text.Component; import org.bukkit.entity.HumanEntity; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.NotNull; @@ -42,61 +40,17 @@ public class StorageGui extends BaseGui { /** - * Main constructor for the StorageGui, now with {@link Component} support + * Main constructor for the StorageGui * * @param rows The amount of rows the GUI should have - * @param title The GUI's title using {@link Component} + * @param title The GUI's title using {@link String} * @param interactionModifiers A set containing the {@link InteractionModifier} this GUI should use - * @since 3.0.0 + * @since 3.0.3 */ - public StorageGui(final int rows, @NotNull final Component title, @NotNull final Set interactionModifiers) { + public StorageGui(final int rows, @NotNull final String title, @NotNull final Set interactionModifiers) { super(rows, title, interactionModifiers); } - /** - * Alternative constructor to provide a way to create GUIs that don't need any {@link InteractionModifier} - * - * @param rows The amount of rows the GUI should have - * @param title The GUI's title using {@link Component} - * @since 3.0.0 - */ - public StorageGui(final int rows, @NotNull final Component title) { - this(rows, title, Collections.emptySet()); - } - - /** - * Alternative constructor that defaults to 1 row - * - * @param title The GUI's title using {@link Component} - * @since 3.0.0 - */ - public StorageGui(@NotNull final Component title) { - super(1, title, Collections.emptySet()); - } - - /** - * Main constructor that takes a {@link GuiType} instead of rows - * - * @param guiType The {@link GuiType} to be used - * @param title The GUI's title using {@link Component} - * @since 3.0.0 - */ - public StorageGui(@NotNull final GuiType guiType, @NotNull final Component title) { - super(guiType, title, Collections.emptySet()); - } - - /** - * Alternative constructor that takes both a {@link GuiType} and a set of {@link InteractionModifier} - * - * @param guiType The {@link GuiType} to be used - * @param title The GUI's title using {@link Component} - * @param interactionModifiers A set containing the {@link InteractionModifier} this GUI should use - * @since 3.0.0 - */ - public StorageGui(@NotNull final GuiType guiType, @NotNull final Component title, @NotNull final Set interactionModifiers) { - super(guiType, title, interactionModifiers); - } - /** * Main constructor of the Persistent GUI *