v1.1
This commit is contained in:
parent
7d9ea90485
commit
8b5a40bad1
|
@ -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.Button;
|
||||||
import com.io.yutian.aulib.gui.button.ClickType;
|
import com.io.yutian.aulib.gui.button.ClickType;
|
||||||
import com.io.yutian.aulib.gui.button.ItemButton;
|
import com.io.yutian.aulib.gui.button.ItemButton;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.InventoryAction;
|
import org.bukkit.event.inventory.InventoryAction;
|
||||||
|
@ -16,7 +17,7 @@ public class Gui extends IGui {
|
||||||
|
|
||||||
private Map<Integer, Button> buttons = new HashMap<>();
|
private Map<Integer, Button> buttons = new HashMap<>();
|
||||||
|
|
||||||
public Gui(Player player, String title, int size) {
|
public Gui(Player player, Component title, int size) {
|
||||||
super(player, title, size);
|
super(player, title, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,11 +20,11 @@ public abstract class IGui implements InventoryHolder {
|
||||||
public Inventory inventory;
|
public Inventory inventory;
|
||||||
public Player player;
|
public Player player;
|
||||||
|
|
||||||
private String title;
|
private Component title;
|
||||||
private int size;
|
private int size;
|
||||||
|
|
||||||
public IGui(Player player, String title, int size) {
|
public IGui(Player player, Component title, int size) {
|
||||||
this.inventory = Bukkit.createInventory(this, size, Component.text(title));
|
this.inventory = Bukkit.createInventory(this, size, title);
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
|
@ -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.Button;
|
||||||
import com.io.yutian.aulib.gui.button.ClickType;
|
import com.io.yutian.aulib.gui.button.ClickType;
|
||||||
import com.io.yutian.aulib.gui.button.ItemButton;
|
import com.io.yutian.aulib.gui.button.ItemButton;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.InventoryAction;
|
import org.bukkit.event.inventory.InventoryAction;
|
||||||
|
@ -15,11 +16,11 @@ import java.util.Map;
|
||||||
public class PageGui extends IGui {
|
public class PageGui extends IGui {
|
||||||
|
|
||||||
private int page = 1;
|
private int page = 1;
|
||||||
private int maxPage = 1;
|
private int maxPage;
|
||||||
|
|
||||||
private Map<Integer, Page> pages = new HashMap<>();
|
private Map<Integer, Page> 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);
|
super(player, title, size);
|
||||||
this.maxPage = maxPage;
|
this.maxPage = maxPage;
|
||||||
}
|
}
|
||||||
|
@ -41,8 +42,7 @@ public class PageGui extends IGui {
|
||||||
Button button = entry.getValue();
|
Button button = entry.getValue();
|
||||||
if (button.isAsynchronous()) {
|
if (button.isAsynchronous()) {
|
||||||
AuLib.inst().getServer().getScheduler().runTaskAsynchronously(AuLib.inst(), ()->{
|
AuLib.inst().getServer().getScheduler().runTaskAsynchronously(AuLib.inst(), ()->{
|
||||||
if (button instanceof ItemButton) {
|
if (button instanceof ItemButton itemButton) {
|
||||||
ItemButton itemButton = (ItemButton) button;
|
|
||||||
if (itemButton.getItem() != null) {
|
if (itemButton.getItem() != null) {
|
||||||
inventory.setItem(entry.getKey(), itemButton.getItem());
|
inventory.setItem(entry.getKey(), itemButton.getItem());
|
||||||
return;
|
return;
|
||||||
|
@ -51,8 +51,7 @@ public class PageGui extends IGui {
|
||||||
inventory.setItem(entry.getKey(), button.getItemStack());
|
inventory.setItem(entry.getKey(), button.getItemStack());
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (button instanceof ItemButton) {
|
if (button instanceof ItemButton itemButton) {
|
||||||
ItemButton itemButton = (ItemButton) button;
|
|
||||||
if (itemButton.getItem() != null) {
|
if (itemButton.getItem() != null) {
|
||||||
inventory.setItem(entry.getKey(), itemButton.getItem());
|
inventory.setItem(entry.getKey(), itemButton.getItem());
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user