Fixes an inconsistency where "," is always used as separator for unsigned books

This commit is contained in:
Kristian Knarvik 2022-08-09 16:07:37 +02:00
parent 5e85dfd3e4
commit 542cd03bdc
3 changed files with 16 additions and 10 deletions

View File

@ -44,14 +44,16 @@ public class CommandDecrypt implements TabExecutor {
return false;
}
String authorSeparator = BooksWithoutBordersConfig.getTitleAuthorSeparator();
//Warning: admin decrypt only allows decrypting files created by the same player. Not sure if intended
if (args.length == 0 && BooksWithoutBordersConfig.getAdminDecrypt() && player.hasPermission("bookswithoutborders.admin")) {
String path = getBookFolder() + "Encrypted" + getSlash();
String fileName;
if (bookMetadata.hasTitle()) {
fileName = bookMetadata.getTitle() + BooksWithoutBordersConfig.getTitleAuthorSeparator() + bookMetadata.getAuthor();
fileName = bookMetadata.getTitle() + authorSeparator + bookMetadata.getAuthor();
} else {
fileName = "Untitled," + player.getName();
fileName = "Untitled" + authorSeparator + player.getName();
}
File encryptedDirectory = new File(path);

View File

@ -85,11 +85,12 @@ public class CommandSave implements TabExecutor {
}
//Generate book filename
String authorSeparator = BooksWithoutBordersConfig.getTitleAuthorSeparator();
String fileName;
if (!book.hasTitle()) {
fileName = "Untitled," + player.getName();
fileName = "Untitled" + authorSeparator + player.getName();
} else {
fileName = book.getTitle() + BooksWithoutBordersConfig.getTitleAuthorSeparator() + book.getAuthor();
fileName = book.getTitle() + authorSeparator + book.getAuthor();
}
fileName = cleanString(fileName);
fileName = fixName(fileName, false);

View File

@ -198,8 +198,9 @@ public final class EncryptionHelper {
return null;
}
String fileName = (!bookMetadata.hasTitle()) ? "Untitled," + player.getName() : bookMetadata.getTitle() +
BooksWithoutBordersConfig.getTitleAuthorSeparator() + bookMetadata.getAuthor();
String authorSeparator = BooksWithoutBordersConfig.getTitleAuthorSeparator();
String fileName = (!bookMetadata.hasTitle()) ? "Untitled" + authorSeparator + player.getName() :
bookMetadata.getTitle() + authorSeparator + bookMetadata.getAuthor();
fileName = "[" + key + "]" + fileName;
fileName = cleanString(fileName);
fileName = fixName(fileName, false);
@ -264,8 +265,9 @@ public final class EncryptionHelper {
}
}
//Creates file
String fileName = (!bookMetadata.hasTitle()) ? "Untitled," + player.getName() :
bookMetadata.getTitle() + BooksWithoutBordersConfig.getTitleAuthorSeparator() + bookMetadata.getAuthor();
String authorSeparator = BooksWithoutBordersConfig.getTitleAuthorSeparator();
String fileName = (!bookMetadata.hasTitle()) ? "Untitled" + authorSeparator + player.getName() :
bookMetadata.getTitle() + authorSeparator + bookMetadata.getAuthor();
fileName = cleanString(fileName);
fileName = fixName(fileName, false);
@ -305,8 +307,9 @@ public final class EncryptionHelper {
*/
private static Boolean saveEncryptedBook(Player player, BookMeta bookMetaData, String key) {
String path = getBookFolder() + "Encrypted" + getSlash();
String fileName = (!bookMetaData.hasTitle()) ? "Untitled," + player.getName() :
bookMetaData.getTitle() + BooksWithoutBordersConfig.getTitleAuthorSeparator() + bookMetaData.getAuthor();
String authorSeparator = BooksWithoutBordersConfig.getTitleAuthorSeparator();
String fileName = (!bookMetaData.hasTitle()) ? "Untitled" + authorSeparator + player.getName() :
bookMetaData.getTitle() + authorSeparator + bookMetaData.getAuthor();
fileName = "[" + key + "]" + fileName;
fileName = cleanString(fileName);