Skip to content

Commit

Permalink
Fixed emoji-based categorization;
Browse files Browse the repository at this point in the history
Split createSimplePaginator and setHandler into JDA and ShardManager versions.
  • Loading branch information
ygimenez committed Mar 8, 2022
1 parent 3b88664 commit 447955c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.github.ygimenez</groupId>
<artifactId>Pagination-Utils</artifactId>
<version>3.0.7</version>
<version>3.0.8</version>
<packaging>jar</packaging>

<name>Pagination Utils</name>
Expand Down Expand Up @@ -33,7 +33,7 @@
<url>https://github.com/ygimenez/Pagination-Utils</url>
<connection>scm:git:git@github.com:ygimenez/Pagination-Utils.git</connection>
<developerConnection>scm:git:git@github.com:ygimenez/Pagination-Utils.git</developerConnection>
<tag>Pagination-Utils-3.0.7</tag>
<tag>Pagination-Utils-3.0.8</tag>
</scm>

<distributionManagement>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/github/ygimenez/method/Pages.java
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ public void acceptThrows(@Nonnull User u, @Nonnull PaginationEventWrapper wrappe
if (emt == CANCEL) {
finalizeEvent(m, success);
return;
} else if (emoji != null && Objects.equals(emoji, currCat)) {
} else if (emoji != null && !Objects.equals(emoji, currCat)) {
Page pg = cats.get(emoji);
if (pg != null) {
if (currCat != null && pg instanceof InteractPage) {
Expand Down
39 changes: 28 additions & 11 deletions src/main/java/com/github/ygimenez/model/PaginatorBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* {@link Paginator}'s builder, this class allows you to customize Pagination-Utils' behavior
* as you like.<br>
* If you want a quick setup, use {@link #createSimplePaginator(Object)}.
* If you want a quick setup, use {@link #createSimplePaginator(JDA)} or {@link #createSimplePaginator(ShardManager)}.
*/
public class PaginatorBuilder {
private final Paginator paginator;
Expand All @@ -45,11 +45,23 @@ public static PaginatorBuilder createPaginator() {
/**
* Creates a new {@link Paginator} instance using default settings.
*
* @param handler The handler that'll be used for event processing
* (must be either {@link JDA} or {@link ShardManager}).
* @param handler The {@link JDA} instance that'll be used for event processing.
* @return The {@link PaginatorBuilder} instance for chaining convenience.
*/
public static Paginator createSimplePaginator(@Nonnull Object handler) {
public static Paginator createSimplePaginator(@Nonnull JDA handler) {
Paginator p = new Paginator(handler);
p.finishEmotes();

return p;
}

/**
* Creates a new {@link Paginator} instance using default settings.
*
* @param handler The {@link ShardManager} instance that'll be used for event processing.
* @return The {@link PaginatorBuilder} instance for chaining convenience.
*/
public static Paginator createSimplePaginator(@Nonnull ShardManager handler) {
Paginator p = new Paginator(handler);
p.finishEmotes();

Expand All @@ -68,16 +80,21 @@ public Object getHandler() {
/**
* Sets the handler used for event processing.
*
* @param handler The handler that'll be used for event processing
* (must be either {@link JDA} or {@link ShardManager}).
* @param handler The {@link JDA} instance that'll be used for event processing.
* @return The {@link PaginatorBuilder} instance for chaining convenience.
* @throws InvalidHandlerException If the supplied handler is not a {@link JDA} or {@link ShardManager}
* object.
*/
public PaginatorBuilder setHandler(@Nonnull Object handler) throws InvalidHandlerException {
if (!(handler instanceof JDA) && !(handler instanceof ShardManager))
throw new InvalidHandlerException();
public PaginatorBuilder setHandler(@Nonnull JDA handler) {
paginator.setHandler(handler);
return this;
}

/**
* Sets the handler used for event processing.
*
* @param handler The {@link ShardManager} instance that'll be used for event processing.
* @return The {@link PaginatorBuilder} instance for chaining convenience.
*/
public PaginatorBuilder setHandler(@Nonnull ShardManager handler) {
paginator.setHandler(handler);
return this;
}
Expand Down

0 comments on commit 447955c

Please sign in to comment.