Merge branch 'master' into knarlib

This commit is contained in:
Kristian Knarvik 2022-11-26 15:52:17 +01:00
commit 16954f22e3
4 changed files with 90 additions and 77 deletions

View File

@ -41,7 +41,7 @@ Books without Borders has got your back!
An in-game description of available commands is available through the /bwb command. An in-game description of available commands is available through the /bwb command.
| Command | Arguments | Description | | Command | Arguments | Description |
| --- | --- | --- | |----------------------|----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| /bookswithoutborders | None | Displays information about commands (and permissions if the user has bookswithoutborders.admin) | | /bookswithoutborders | None | Displays information about commands (and permissions if the user has bookswithoutborders.admin) |
| /copybook | \<# of copies> | Copies the book the player is holding | | /copybook | \<# of copies> | Copies the book the player is holding |
| /decryptbook | \<key> | Decrypts the book the player is holding. "key" is required and MUST be IDENTICAL to the key used to encrypt the held book | | /decryptbook | \<key> | Decrypts the book the player is holding. "key" is required and MUST be IDENTICAL to the key used to encrypt the held book |
@ -67,7 +67,7 @@ An in-game description of available commands is available through the /bwb comma
### Permissions: ### Permissions:
| Node | Description | | Node | Description |
| --- | --- | |--------------------------------------------|----------------------------------------------------------------------------------------------------------|
| bookswithoutborders.* | Grants all permissions | | bookswithoutborders.* | Grants all permissions |
| bookswithoutborders.admin | Grants all permissions | | bookswithoutborders.admin | Grants all permissions |
| bookswithoutborders.use | Allows player to use commands to save/load/delete in their personal directory | | bookswithoutborders.use | Allows player to use commands to save/load/delete in their personal directory |
@ -122,7 +122,7 @@ The **_decrypt_** sign must have **\[Decrypt]** on its second line. The third li
### Configuration options: ### Configuration options:
| Option | Description | | Option | Description |
| --- | --- | |----------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Save_Books_in_Yaml_Format | Whether to use YAML for saved books instead of just storing them as text | | Save_Books_in_Yaml_Format | Whether to use YAML for saved books instead of just storing them as text |
| Max_Number_of_Duplicates | The maximum number of duplicates of a saved book allowed | | Max_Number_of_Duplicates | The maximum number of duplicates of a saved book allowed |
| Author_Separator | The separator used to separate the book title and the book author | | Author_Separator | The separator used to separate the book title and the book author |

View File

@ -6,7 +6,7 @@
<groupId>net.knarcraft</groupId> <groupId>net.knarcraft</groupId>
<artifactId>BooksWithoutBorders</artifactId> <artifactId>BooksWithoutBorders</artifactId>
<version>1.3.2</version> <version>1.3.3</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<licenses> <licenses>

View File

@ -158,9 +158,8 @@ public final class BookFileHelper {
String userName = data[1].substring(0, data[1].length() - 4); String userName = data[1].substring(0, data[1].length() - 4);
data[1] = BookHelper.authorFromUUID(userName) + extension; data[1] = BookHelper.authorFromUUID(userName) + extension;
fileList.add(String.join(separator, data)); fileList.add(String.join(separator, data));
} else {
fileList.add(fileName);
} }
fileList.add(fileName);
} }
return fileList; return fileList;

View File

@ -3,6 +3,7 @@ package net.knarcraft.bookswithoutborders.utility;
import net.knarcraft.bookswithoutborders.BooksWithoutBorders; import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
import net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig; import net.knarcraft.bookswithoutborders.config.BooksWithoutBordersConfig;
import net.knarcraft.bookswithoutborders.state.BookDirectory; import net.knarcraft.bookswithoutborders.state.BookDirectory;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -60,8 +61,23 @@ public final class BookLoader {
//Get the full path of the book to load //Get the full path of the book to load
File file = getFullPath(sender, fileName, bookDirectory, directory); File file = getFullPath(sender, fileName, bookDirectory, directory);
if (file == null) { if (file == null) {
//Try converting the username to UUID
String titleAuthorSeparator = BooksWithoutBordersConfig.getTitleAuthorSeparator();
String[] data = fileName.split(titleAuthorSeparator);
String extension = data[1].substring(data[1].length() - 4);
String userName = data[1].substring(0, data[1].length() - 4);
Player player = Bukkit.getPlayer(userName);
if (player != null) {
data[1] = player.getUniqueId() + extension;
file = getFullPath(sender, String.join(titleAuthorSeparator, data), bookDirectory, directory);
if (file == null) {
BooksWithoutBorders.sendErrorMessage(sender, "Incorrect file name!");
return null; return null;
} }
} else {
return null;
}
}
//Make sure the player can pay for the book //Make sure the player can pay for the book
if (BooksWithoutBordersConfig.booksHavePrice() && if (BooksWithoutBordersConfig.booksHavePrice() &&
@ -124,9 +140,7 @@ public final class BookLoader {
} else { } else {
file = BookFileHelper.getBookFile(BookHelper.getBookDirectoryPathString(bookDirectory, sender) + fileName); file = BookFileHelper.getBookFile(BookHelper.getBookDirectoryPathString(bookDirectory, sender) + fileName);
} }
if (file == null || !file.isFile()) { if (file == null || !file.isFile()) {
BooksWithoutBorders.sendErrorMessage(sender, "Incorrect file name!");
return null; return null;
} else { } else {
return file; return file;