Skip to content

Commit

Permalink
feat(gui): 重构部分GUI代码,补全缺失的获取接口
Browse files Browse the repository at this point in the history
  • Loading branch information
CarmJos committed Nov 11, 2023
1 parent de4dbbe commit 1b7f60f
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 19 deletions.
2 changes: 1 addition & 1 deletion base/color/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion base/command-alias/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion base/command/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion base/gui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ public void customAction(Player player) {

}

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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ public void goLastPage() {
*
* @return 最后一页的页码
*/
@Override
public int getLastPageNumber() {
return (this.container.size() / range.length) + ((this.container.size() % range.length) == 0 ? 0 : 1);
return getLastPageNumber(range.length);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,29 @@ protected PagedGUI(@NotNull GUIType type, @NotNull String title) {
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;
Expand Down Expand Up @@ -66,7 +89,7 @@ public void onPageChange(int pageNum) {
*/
public void goPreviousPage() {
if (hasPreviousPage()) {
page--;
this.page--;
this.onPageChange(this.page);
} else throw new IndexOutOfBoundsException();
}
Expand All @@ -77,7 +100,7 @@ public void goPreviousPage() {
*/
public void goNextPage() {
if (hasNextPage()) {
page++;
this.page++;
this.onPageChange(this.page);
} else throw new IndexOutOfBoundsException();
}
Expand Down
2 changes: 1 addition & 1 deletion base/main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion base/messages/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion base/storage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion base/user/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion base/utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion collection/all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion collection/bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion collection/common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion extension/gh-checker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion extension/papi/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion extension/vault/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 1b7f60f

Please sign in to comment.