1
mirror of https://github.com/CarmJos/EasyPlugin.git synced 2024-09-19 19:25:45 +00:00

feat(gui): 重构部分GUI代码,补全缺失的获取接口

This commit is contained in:
Carm Jos 2023-11-12 02:03:03 +08:00
parent de4dbbe637
commit 1b7f60fe43
19 changed files with 51 additions and 19 deletions

View File

@ -6,7 +6,7 @@
<parent>
<groupId>cc.carm.lib</groupId>
<artifactId>easyplugin-parent</artifactId>
<version>1.5.10</version>
<version>1.5.11</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>cc.carm.lib</groupId>
<artifactId>easyplugin-parent</artifactId>
<version>1.5.10</version>
<version>1.5.11</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.5.10</version>
<version>1.5.11</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.5.10</version>
<version>1.5.11</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -78,6 +78,14 @@ public class GUIItem {
}
public Set<GUIClickAction> getActions() {
return actions;
}
public Set<GUIClickAction> getActionsIgnoreActive() {
return actionsIgnoreActive;
}
public abstract static class GUIClickAction {
public abstract void run(ClickType type, Player player);
}

View File

@ -80,8 +80,9 @@ public class CommonPagedGUI extends PagedGUI {
*
* @return 最后一页的页码
*/
@Override
public int getLastPageNumber() {
return (this.container.size() / range.length) + ((this.container.size() % range.length) == 0 ? 0 : 1);
return getLastPageNumber(range.length);
}
/**

View File

@ -19,6 +19,29 @@ public abstract class PagedGUI extends GUI {
super(type, title);
}
public int setCurrentPage(int page) {
this.page = Math.max(1, Math.min(page, getLastPageNumber()));
return this.page;
}
public int getCurrentPage() {
return page;
}
public int getLastPageNumber() {
return getLastPageNumber(getGUIType().getSize());
}
/**
* 得到最后一页的页码
*
* @return 最后一页的页码
*/
public int getLastPageNumber(int size) {
return (this.container.size() / size) + ((this.container.size() % size) == 0 ? 0 : 1);
}
public int addItem(@NotNull GUIItem i) {
container.add(i);
return container.size() - 1;
@ -66,7 +89,7 @@ public abstract class PagedGUI extends GUI {
*/
public void goPreviousPage() {
if (hasPreviousPage()) {
page--;
this.page--;
this.onPageChange(this.page);
} else throw new IndexOutOfBoundsException();
}
@ -77,7 +100,7 @@ public abstract class PagedGUI extends GUI {
*/
public void goNextPage() {
if (hasNextPage()) {
page++;
this.page++;
this.onPageChange(this.page);
} else throw new IndexOutOfBoundsException();
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.5.10</version>
<version>1.5.11</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>cc.carm.lib</groupId>
<artifactId>easyplugin-parent</artifactId>
<version>1.5.10</version>
<version>1.5.11</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.5.10</version>
<version>1.5.11</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -6,7 +6,7 @@
<parent>
<groupId>cc.carm.lib</groupId>
<artifactId>easyplugin-parent</artifactId>
<version>1.5.10</version>
<version>1.5.11</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<properties>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.5.10</version>
<version>1.5.11</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.5.10</version>
<version>1.5.11</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.5.10</version>
<version>1.5.11</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.5.10</version>
<version>1.5.11</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.5.10</version>
<version>1.5.11</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.5.10</version>
<version>1.5.11</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>easyplugin-parent</artifactId>
<groupId>cc.carm.lib</groupId>
<version>1.5.10</version>
<version>1.5.11</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -15,7 +15,7 @@
<groupId>cc.carm.lib</groupId>
<artifactId>easyplugin-parent</artifactId>
<packaging>pom</packaging>
<version>1.5.10</version>
<version>1.5.11</version>
<modules>
<module>base/color</module>
<module>base/utils</module>