Adds book reloading, and fixes a RegEx expression
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good

This commit is contained in:
2025-08-03 00:47:36 +02:00
parent 32d31fced6
commit 0aff3fad02
3 changed files with 13 additions and 1 deletions

View File

@@ -139,6 +139,14 @@ public class BooksWithoutBorders extends JavaPlugin {
} }
} }
/**
* Clears book data such as per-player lists and per-player character indexes
*/
public static void clearBookData() {
playerBooksList = new HashMap<>();
playerLetterIndex = new HashMap<>();
}
@Override @Override
public void onEnable() { public void onEnable() {

View File

@@ -23,6 +23,10 @@ public class CommandReload implements TabExecutor {
BooksWithoutBorders.sendErrorMessage(sender, "Reload Failed!"); BooksWithoutBorders.sendErrorMessage(sender, "Reload Failed!");
BooksWithoutBorders.sendErrorMessage(sender, "See console for details"); BooksWithoutBorders.sendErrorMessage(sender, "See console for details");
} }
// Reload books
BooksWithoutBorders.updateBooks(sender, true);
BooksWithoutBorders.clearBookData();
return true; return true;
} }

View File

@@ -75,7 +75,7 @@ public final class InputCleaningHelper {
*/ */
public static int parsePageNumber(@NotNull String input) { public static int parsePageNumber(@NotNull String input) {
try { try {
Pattern pattern = Pattern.compile("page([0-9])+"); Pattern pattern = Pattern.compile("page([0-9]+)");
Matcher matcher = pattern.matcher(input); Matcher matcher = pattern.matcher(input);
if (matcher.matches()) { if (matcher.matches()) {
return Integer.parseInt(matcher.group(1)); return Integer.parseInt(matcher.group(1));