1
mirror of https://github.com/CarmJos/UserPrefix.git synced 2024-09-19 20:15:47 +00:00

[v2.3.1] [F] 修复前缀数量超过一页时翻页可能出现错误的问题

This commit is contained in:
Carm Jos 2022-01-13 01:00:46 +08:00
parent 548f1d366f
commit d752461c74
2 changed files with 71 additions and 65 deletions

View File

@ -13,7 +13,7 @@
<groupId>cc.carm.plugin</groupId> <groupId>cc.carm.plugin</groupId>
<artifactId>userprefix</artifactId> <artifactId>userprefix</artifactId>
<version>2.3.0</version> <version>2.3.1</version>
<name>UserPrefix</name> <name>UserPrefix</name>
<description>轻便、高效、实时的用户前缀系统。</description> <description>轻便、高效、实时的用户前缀系统。</description>

View File

@ -7,81 +7,87 @@ import org.bukkit.inventory.ItemStack;
public class AutoPagedGUI extends CommonPagedGUI { public class AutoPagedGUI extends CommonPagedGUI {
ItemStack previousPageUI; ItemStack previousPageUI;
ItemStack nextPageUI; ItemStack nextPageUI;
ItemStack noPreviousPageUI; ItemStack noPreviousPageUI;
ItemStack noNextPageUI; ItemStack noNextPageUI;
int previousPageSlot = -1; int previousPageSlot = -1;
int nextPageSlot = -1; int nextPageSlot = -1;
public AutoPagedGUI(GUIType type, String name, int[] range) { public AutoPagedGUI(GUIType type, String name, int[] range) {
super(type, name, range); super(type, name, range);
} }
public AutoPagedGUI(GUIType type, String name, int a, int b) { public AutoPagedGUI(GUIType type, String name, int a, int b) {
super(type, name, a, b); super(type, name, a, b);
} }
public void setPreviousPageUI(ItemStack lastPageUI) { public void setPreviousPageUI(ItemStack lastPageUI) {
this.previousPageUI = lastPageUI; this.previousPageUI = lastPageUI;
} }
public void setNextPageUI(ItemStack nextPageUI) { public void setNextPageUI(ItemStack nextPageUI) {
this.nextPageUI = nextPageUI; this.nextPageUI = nextPageUI;
} }
public void setNoPreviousPageUI(ItemStack noPreviousPageUI) { public void setNoPreviousPageUI(ItemStack noPreviousPageUI) {
this.noPreviousPageUI = noPreviousPageUI; this.noPreviousPageUI = noPreviousPageUI;
} }
public void setNoNextPageUI(ItemStack noNextPageUI) { public void setNoNextPageUI(ItemStack noNextPageUI) {
this.noNextPageUI = noNextPageUI; this.noNextPageUI = noNextPageUI;
} }
public void setPreviousPageSlot(int slot) { public void setPreviousPageSlot(int slot) {
this.previousPageSlot = slot; this.previousPageSlot = slot;
} }
public void setNextPageSlot(int slot) { public void setNextPageSlot(int slot) {
this.nextPageSlot = slot; this.nextPageSlot = slot;
} }
@Override @Override
public void openGUI(Player user) { public void openGUI(Player user) {
if (previousPageSlot >= 0) if (previousPageSlot >= 0) {
if (hasPreviousPage()) { if (hasPreviousPage()) {
setItem(previousPageSlot, new GUIItem(previousPageUI == null ? PluginConfig.GUI.Items.PREVIOUS_PAGE.get() : previousPageUI) { setItem(previousPageSlot, new GUIItem(previousPageUI == null ? PluginConfig.GUI.Items.PREVIOUS_PAGE.get() : previousPageUI) {
@Override @Override
public void onClick(ClickType type) { public void onClick(ClickType type) {
if (type == ClickType.RIGHT) { if (type == ClickType.RIGHT) {
goFirstPage(); goFirstPage();
} else { } else {
goPreviousPage(); goPreviousPage();
} }
PluginConfig.Sounds.GUI_CLICK.play(user); PluginConfig.Sounds.GUI_CLICK.play(user);
openGUI(user); openGUI(user);
} }
}); });
} } else {
setItem(previousPageSlot, null);
}
}
if (nextPageSlot >= 0) if (nextPageSlot >= 0) {
if (hasNextPage()) { if (hasNextPage()) {
setItem(nextPageSlot, new GUIItem(nextPageUI == null ? PluginConfig.GUI.Items.NEXT_PAGE.get() : nextPageUI) { setItem(nextPageSlot, new GUIItem(nextPageUI == null ? PluginConfig.GUI.Items.NEXT_PAGE.get() : nextPageUI) {
@Override @Override
public void onClick(ClickType type) { public void onClick(ClickType type) {
if (type == ClickType.RIGHT) { if (type == ClickType.RIGHT) {
goLastPage(); goLastPage();
} else { } else {
goNextPage(); goNextPage();
} }
PluginConfig.Sounds.GUI_CLICK.play(user); PluginConfig.Sounds.GUI_CLICK.play(user);
openGUI(user); openGUI(user);
} }
}); });
} } else {
setItem(nextPageSlot, null);
}
}
super.openGUI(user); super.openGUI(user);
} }
} }