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:
parent
de4dbbe637
commit
1b7f60fe43
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user