Adds an option to only allow saving own books
This commit is contained in:
parent
5d340af6f2
commit
40512dd771
@ -137,6 +137,7 @@ The **_decrypt_** sign must have **\[Decrypt]** on its second line. The third li
|
||||
- Admin_Auto_Decrypt - Whether any admin can decrypt any book regardless of the group it was encrypted for
|
||||
- Author_Only_Copy - Whether to only allow the author of a book to create copies
|
||||
- Author_Only_Unsign - Whether to only allow the author of a book to unsign it
|
||||
- Author_Only_Save - Whether to only allow saving a player's own books with /savebook
|
||||
- Format_Book_After_Signing - Whether to automatically format every book when it's signed
|
||||
- Change_Generation_On_Copy - Whether to display "COPY" or "COPY_OF_COPY" instead of "ORIGINAL" when a book is copied.
|
||||
This also uses the vanilla behavior where a copy of a copy or tattered book cannot be copied further.
|
@ -76,6 +76,12 @@ public class CommandSave implements TabExecutor {
|
||||
return;
|
||||
}
|
||||
|
||||
//Only allow saving of own books if enabled
|
||||
if (BooksWithoutBordersConfig.getAuthorOnlySave() && !saveToPublicFolder &&
|
||||
BookHelper.isNotAuthor(player, book)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String savePath = BookHelper.getBookDirectoryPathString(
|
||||
saveToPublicFolder ? BookDirectory.PUBLIC : BookDirectory.PLAYER, player);
|
||||
|
||||
@ -85,12 +91,14 @@ public class CommandSave implements TabExecutor {
|
||||
//Make sure the used folders exist
|
||||
File file = new File(savePath);
|
||||
if (!file.exists() && !file.mkdir()) {
|
||||
BooksWithoutBorders.sendErrorMessage(player, "Saving Failed! If this continues to happen, consult server admin!");
|
||||
BooksWithoutBorders.sendErrorMessage(player, "Saving Failed! If this continues to happen, consult" +
|
||||
" a server admin!");
|
||||
return;
|
||||
}
|
||||
File[] foundFiles = file.listFiles();
|
||||
if (foundFiles == null) {
|
||||
BooksWithoutBorders.sendErrorMessage(player, "Saving Failed! If this continues to happen, consult server admin!");
|
||||
BooksWithoutBorders.sendErrorMessage(player, "Saving Failed! If this continues to happen, consult" +
|
||||
" a server admin!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ public class BooksWithoutBordersConfig {
|
||||
private static double bookPriceQuantity;
|
||||
private static boolean authorOnlyCopy;
|
||||
private static boolean authorOnlyUnsign;
|
||||
private static boolean authorOnlySave;
|
||||
private static boolean useYml;
|
||||
private static boolean adminDecrypt;
|
||||
private static boolean formatBooks;
|
||||
@ -117,6 +118,15 @@ public class BooksWithoutBordersConfig {
|
||||
return authorOnlyUnsign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether a player can only save their own books with /savebook
|
||||
*
|
||||
* @return <p>Whether a player can only save their own books</p>
|
||||
*/
|
||||
public static boolean getAuthorOnlySave() {
|
||||
return authorOnlySave;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether to use YML, not TXT, for saving books
|
||||
*
|
||||
@ -278,6 +288,7 @@ public class BooksWithoutBordersConfig {
|
||||
config.set(ConfigOption.ADMIN_AUTO_DECRYPT.getConfigNode(), adminDecrypt);
|
||||
config.set(ConfigOption.AUTHOR_ONLY_COPY.getConfigNode(), authorOnlyCopy);
|
||||
config.set(ConfigOption.AUTHOR_ONLY_UNSIGN.getConfigNode(), authorOnlyUnsign);
|
||||
config.set(ConfigOption.AUTHOR_ONLY_SAVE.getConfigNode(), authorOnlySave);
|
||||
config.set(ConfigOption.CHANGE_GENERATION_ON_COPY.getConfigNode(), changeGenerationOnCopy);
|
||||
|
||||
//Handles old book and quill settings
|
||||
@ -314,6 +325,7 @@ public class BooksWithoutBordersConfig {
|
||||
adminDecrypt = getBoolean(config, ConfigOption.ADMIN_AUTO_DECRYPT);
|
||||
authorOnlyCopy = getBoolean(config, ConfigOption.AUTHOR_ONLY_COPY);
|
||||
authorOnlyUnsign = getBoolean(config, ConfigOption.AUTHOR_ONLY_UNSIGN);
|
||||
authorOnlySave = getBoolean(config, ConfigOption.AUTHOR_ONLY_SAVE);
|
||||
firstBooks = config.getStringList(ConfigOption.BOOKS_FOR_NEW_PLAYERS.getConfigNode());
|
||||
welcomeMessage = getString(config, ConfigOption.MESSAGE_FOR_NEW_PLAYERS);
|
||||
formatBooks = getBoolean(config, ConfigOption.FORMAT_AFTER_SIGNING);
|
||||
|
@ -60,6 +60,11 @@ public enum ConfigOption {
|
||||
*/
|
||||
AUTHOR_ONLY_UNSIGN("Options.Author_Only_Unsign", false),
|
||||
|
||||
/**
|
||||
* Whether a player can only save their own books with /savebook
|
||||
*/
|
||||
AUTHOR_ONLY_SAVE("Options.Author_Only_Save", false),
|
||||
|
||||
/**
|
||||
* Whether to turn Original into Copy when copying books
|
||||
*/
|
||||
|
@ -23,6 +23,8 @@ Options:
|
||||
Author_Only_Copy: false
|
||||
# Whether to only allow the author of a book to unsign it
|
||||
Author_Only_Unsign: false
|
||||
# Whether to only allow saving a player's own books with /savebook
|
||||
Author_Only_Save: false
|
||||
# Whether to automatically format every book when it's signed
|
||||
Format_Book_After_Signing: false
|
||||
# Whether to display "COPY" or "COPY_OF_COPY" instead of "ORIGINAL" when a book is copied. This also uses the
|
||||
|
Loading…
Reference in New Issue
Block a user