diff --git a/src/main/java/com/io/yutian/aulib/gui/Gui.java b/src/main/java/com/io/yutian/aulib/gui/Gui.java index b317d7d..491b206 100644 --- a/src/main/java/com/io/yutian/aulib/gui/Gui.java +++ b/src/main/java/com/io/yutian/aulib/gui/Gui.java @@ -4,6 +4,7 @@ import com.io.yutian.aulib.AuLib; import com.io.yutian.aulib.gui.button.Button; import com.io.yutian.aulib.gui.button.ClickType; import com.io.yutian.aulib.gui.button.ItemButton; +import net.kyori.adventure.text.Component; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryAction; @@ -16,7 +17,7 @@ public class Gui extends IGui { private Map buttons = new HashMap<>(); - public Gui(Player player, String title, int size) { + public Gui(Player player, Component title, int size) { super(player, title, size); } diff --git a/src/main/java/com/io/yutian/aulib/gui/IGui.java b/src/main/java/com/io/yutian/aulib/gui/IGui.java index 21d74d7..3adcf25 100644 --- a/src/main/java/com/io/yutian/aulib/gui/IGui.java +++ b/src/main/java/com/io/yutian/aulib/gui/IGui.java @@ -20,11 +20,11 @@ public abstract class IGui implements InventoryHolder { public Inventory inventory; public Player player; - private String title; + private Component title; private int size; - public IGui(Player player, String title, int size) { - this.inventory = Bukkit.createInventory(this, size, Component.text(title)); + public IGui(Player player, Component title, int size) { + this.inventory = Bukkit.createInventory(this, size, title); this.title = title; this.size = size; this.player = player; diff --git a/src/main/java/com/io/yutian/aulib/gui/PageGui.java b/src/main/java/com/io/yutian/aulib/gui/PageGui.java index d338b48..301a11b 100644 --- a/src/main/java/com/io/yutian/aulib/gui/PageGui.java +++ b/src/main/java/com/io/yutian/aulib/gui/PageGui.java @@ -4,6 +4,7 @@ import com.io.yutian.aulib.AuLib; import com.io.yutian.aulib.gui.button.Button; import com.io.yutian.aulib.gui.button.ClickType; import com.io.yutian.aulib.gui.button.ItemButton; +import net.kyori.adventure.text.Component; import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryAction; @@ -15,11 +16,11 @@ import java.util.Map; public class PageGui extends IGui { private int page = 1; - private int maxPage = 1; + private int maxPage; private Map pages = new HashMap<>(); - public PageGui(Player player, String title, int size, int maxPage) { + public PageGui(Player player, Component title, int size, int maxPage) { super(player, title, size); this.maxPage = maxPage; } @@ -41,8 +42,7 @@ public class PageGui extends IGui { Button button = entry.getValue(); if (button.isAsynchronous()) { AuLib.inst().getServer().getScheduler().runTaskAsynchronously(AuLib.inst(), ()->{ - if (button instanceof ItemButton) { - ItemButton itemButton = (ItemButton) button; + if (button instanceof ItemButton itemButton) { if (itemButton.getItem() != null) { inventory.setItem(entry.getKey(), itemButton.getItem()); return; @@ -51,8 +51,7 @@ public class PageGui extends IGui { inventory.setItem(entry.getKey(), button.getItemStack()); }); } else { - if (button instanceof ItemButton) { - ItemButton itemButton = (ItemButton) button; + if (button instanceof ItemButton itemButton) { if (itemButton.getItem() != null) { inventory.setItem(entry.getKey(), itemButton.getItem()); continue;