Use enum instead of boolean for page switching

This is useless but looks better
This commit is contained in:
Bea 2022-12-20 15:09:35 +01:00
parent 7dcdf9dbde
commit 68dceaff13
2 changed files with 11 additions and 5 deletions

View File

@ -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;
}
}

View File

@ -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);
}