@@ -64,7 +64,12 @@ public boolean execute(Player player, String name, String[] args) {
6464
6565 // If the player wants to specify a page (shorthand)
6666 } else if (arg .startsWith ("p:" )) {
67- page = Integer .parseInt (arg .substring (2 ));
67+ try {
68+ page = Integer .parseInt (arg .substring (2 ));
69+ } catch (NumberFormatException exception ) {
70+ sendMessage (player , configuration .GENERAL__PAGE_ERROR , environment , configuration );
71+ return true ;
72+ }
6873
6974 // If the player wants to specify a page
7075 } else if (arg .equalsIgnoreCase ("--page" ) || arg .equalsIgnoreCase ("-p" )) {
@@ -119,14 +124,12 @@ public boolean execute(Player player, String name, String[] args) {
119124 final UUID finalLimitUUID = limitUUID ;
120125 final boolean finalShowNotes = showNotes ;
121126 final int finalPage = page ;
122- final int finalRequestId = requestId ;
123127 final boolean finalIncludeElevated = includeElevated ;
124128 final String finalSearchTerm = searchTerm ;
125- CompletableFuture <Void > future ;
126129
127130 if (page > 0 ) {
128131 if (limitUUID != null ) {
129- future = reqTable .getUserRequests (limitUUID ).thenAccept (requests -> {
132+ reqTable .getUserRequests (limitUUID ).thenAccept (requests -> {
130133 bukkitScheduler .runTask (plugin , () -> {
131134 if (requests .isEmpty ()) {
132135 sendMessage (player , configuration .GENERAL__NO_REQUESTS , environment , configuration );
@@ -154,7 +157,7 @@ public boolean execute(Player player, String name, String[] args) {
154157 Request .RequestStatus .CLAIMED
155158 );
156159
157- future = CompletableFuture .allOf (requestsFuture , countFuture ).thenAccept (ignore -> {
160+ CompletableFuture .allOf (requestsFuture , countFuture ).thenAccept (ignore -> {
158161 List <Request > requests = requestsFuture .join ();
159162 int totalCount = countFuture .join ();
160163
@@ -173,23 +176,20 @@ public boolean execute(Player player, String name, String[] args) {
173176
174177 }
175178 } else if (requestId > 0 ) {
176- future = reqTable .getRequest (requestId ).thenAccept (request -> {
177- bukkitScheduler .runTask (plugin , () -> {
178- if (request == null ) {
179- // Request doesn't exist
180- sendMessage (player , configuration .GENERAL__REQUEST_ERROR , environment , configuration );
181- } else if (finalLimitUUID != null && !request .getPlayerUUID ().equals (finalLimitUUID )) {
182- // Request exists but player doesn't have permission to view it
183- sendMessage (player , configuration .GENERAL__REQUEST_ERROR , environment , configuration );
184- } else {
185- // Show the request details
186- messageRequestToPlayer (player , request , finalShowNotes , environment ,
187- configuration , plugin , plugin .getNoteTable ());
188- }
189- });
190- });
179+ reqTable .getRequest (requestId ).thenAccept (request -> bukkitScheduler .runTask (plugin , () -> {
180+ if (request == null ) {
181+ // Request doesn't exist
182+ sendMessage (player , configuration .GENERAL__REQUEST_ERROR , environment , configuration );
183+ } else if (finalLimitUUID != null && !request .getPlayerUUID ().equals (finalLimitUUID )) {
184+ // Request exists but player doesn't have permission to view it
185+ sendMessage (player , configuration .GENERAL__REQUEST_ERROR , environment , configuration );
186+ } else {
187+ // Show the request details
188+ messageRequestToPlayer (player , request , finalShowNotes , environment ,
189+ configuration , plugin , plugin .getNoteTable ());
190+ }
191+ }));
191192 } else {
192- future = CompletableFuture .completedFuture (null );
193193
194194 bukkitScheduler .runTask (plugin , () ->
195195 sendMessage (player , configuration .GENERAL__NO_REQUESTS , environment , configuration ));
0 commit comments