Use enum instead of boolean for page switching
This is useless but looks better
This commit is contained in:
parent
7dcdf9dbde
commit
68dceaff13
@ -135,7 +135,7 @@ public class UrbanDictionary
|
||||
}
|
||||
|
||||
|
||||
public static void changePage(ButtonInteractionEvent event, boolean increase)
|
||||
public static void changePage(ButtonInteractionEvent event, ChangeType changeType)
|
||||
{
|
||||
String messageId = event.getMessageId();
|
||||
DatabaseSource database = Cache.getDatabaseSource();
|
||||
@ -163,9 +163,10 @@ public class UrbanDictionary
|
||||
serializedExamples, serializedContributors, serializedDates);
|
||||
|
||||
// move to new page
|
||||
if(increase)
|
||||
if(changeType == ChangeType.NEXT)
|
||||
page++;
|
||||
else page--;
|
||||
else if(changeType == ChangeType.PREVIOUS)
|
||||
page--;
|
||||
|
||||
term = UrbanDictionary.sanitizeArgs(term, false);
|
||||
|
||||
@ -341,4 +342,9 @@ public class UrbanDictionary
|
||||
}
|
||||
}
|
||||
|
||||
public enum ChangeType
|
||||
{
|
||||
NEXT,
|
||||
PREVIOUS;
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ public class ButtonInteractionListener extends ListenerAdapter
|
||||
case "generic_dismiss" -> CommandUtil.delete(event);
|
||||
|
||||
// urban dictionary navigation
|
||||
case "urban_nextpage" -> UrbanDictionary.changePage(event, true);
|
||||
case "urban_previouspage" -> UrbanDictionary.changePage(event, false);
|
||||
case "urban_nextpage" -> UrbanDictionary.changePage(event, UrbanDictionary.ChangeType.NEXT);
|
||||
case "urban_previouspage" -> UrbanDictionary.changePage(event, UrbanDictionary.ChangeType.PREVIOUS);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user