Makes error message formatting more customizable
This commit is contained in:
parent
8f4e400309
commit
2223d41a9c
@ -75,13 +75,13 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean init() {
|
protected boolean init() {
|
||||||
try //initializes Item Factory
|
//initializes Item Factory
|
||||||
{
|
try {
|
||||||
iF = this.getServer().getItemFactory();
|
iF = this.getServer().getItemFactory();
|
||||||
} catch (java.lang.NoSuchMethodError nsmE) {
|
} catch (java.lang.NoSuchMethodError nsmE) {
|
||||||
consoleSender.sendMessage(errorColor + "Warning! [BooksWithoutBorders] failed to initialize!");
|
sendErrorMessage(consoleSender, "Warning! [BooksWithoutBorders] failed to initialize!");
|
||||||
consoleSender.sendMessage(errorColor + "Please confirm the correct version of [BooksWithoutBorders] is");
|
sendErrorMessage(consoleSender, "Please confirm the correct version of [BooksWithoutBorders] is");
|
||||||
consoleSender.sendMessage(errorColor + "being run for this version of bukkit!");
|
sendErrorMessage(consoleSender, "being run for this version of bukkit!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
if (!fTest.exists()) {
|
if (!fTest.exists()) {
|
||||||
try {
|
try {
|
||||||
if (!fTest.mkdir()) {
|
if (!fTest.mkdir()) {
|
||||||
consoleSender.sendMessage(errorColor + "Saving failed! Aborting...");
|
sendErrorMessage(consoleSender, "Saving failed! Aborting...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -141,7 +141,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
if (!efTest.exists()) {
|
if (!efTest.exists()) {
|
||||||
try {
|
try {
|
||||||
if (!efTest.mkdir()) {
|
if (!efTest.mkdir()) {
|
||||||
consoleSender.sendMessage(errorColor + "Saving failed! Aborting...");
|
sendErrorMessage(consoleSender, "Saving failed! Aborting...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -177,7 +177,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
if (setupEconomy())
|
if (setupEconomy())
|
||||||
bookPriceType = Material.AIR;
|
bookPriceType = Material.AIR;
|
||||||
else {
|
else {
|
||||||
consoleSender.sendMessage(errorColor + "BooksWithoutBorders failed to hook into Vault! Book price not set!");
|
sendErrorMessage(consoleSender, "BooksWithoutBorders failed to hook into Vault! Book price not set!");
|
||||||
bookPriceType = null;
|
bookPriceType = null;
|
||||||
}
|
}
|
||||||
} else if (!sMaterial.equalsIgnoreCase(" ")) {
|
} else if (!sMaterial.equalsIgnoreCase(" ")) {
|
||||||
@ -188,17 +188,17 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
bookPriceQuantity = this.getConfig().getDouble("Options.Price_to_create_book.Required_quantity", 0);
|
bookPriceQuantity = this.getConfig().getDouble("Options.Price_to_create_book.Required_quantity", 0);
|
||||||
|
|
||||||
//makes sure TsepA is a valid value
|
//makes sure titleAuthorSeparator is a valid value
|
||||||
titleAuthorSeparator = cleanString(titleAuthorSeparator);
|
titleAuthorSeparator = cleanString(titleAuthorSeparator);
|
||||||
if (titleAuthorSeparator.length() != 1) {
|
if (titleAuthorSeparator.length() != 1) {
|
||||||
consoleSender.sendMessage(errorColor + "Title-Author_Separator is set to an invalid value!");
|
sendErrorMessage(consoleSender, "Title-Author_Separator is set to an invalid value!");
|
||||||
consoleSender.sendMessage(errorColor + "Reverting to default value of \",\"");
|
sendErrorMessage(consoleSender, "Reverting to default value of \",\"");
|
||||||
titleAuthorSeparator = ",";
|
titleAuthorSeparator = ",";
|
||||||
this.getConfig().set("Options.Title-Author_Separator", titleAuthorSeparator);
|
this.getConfig().set("Options.Title-Author_Separator", titleAuthorSeparator);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
consoleSender.sendMessage(errorColor + "Warning! Config.yml failed to load!");
|
sendErrorMessage(consoleSender, "Warning! Config.yml failed to load!");
|
||||||
consoleSender.sendMessage(errorColor + "Try Looking for settings that are missing values!");
|
sendErrorMessage(consoleSender, "Try Looking for settings that are missing values!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
if (!fTest.exists()) {
|
if (!fTest.exists()) {
|
||||||
try {
|
try {
|
||||||
if (!fTest.createNewFile()) {
|
if (!fTest.createNewFile()) {
|
||||||
consoleSender.sendMessage(errorColor + "Could not create Existing Players file! Aborting...");
|
sendErrorMessage(consoleSender, "Could not create Existing Players file! Aborting...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PrintWriter pw = new PrintWriter(new FileWriter(fTest));
|
PrintWriter pw = new PrintWriter(new FileWriter(fTest));
|
||||||
@ -269,7 +269,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
pw.println(playerName);
|
pw.println(playerName);
|
||||||
pw.close();
|
pw.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
consoleSender.sendMessage(errorColor + "Failed to add " + playerName + " to Existing Players list");
|
sendErrorMessage(consoleSender, "Failed to add " + playerName + " to Existing Players list");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,10 +292,11 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
sender.sendMessage(commandColor + "[] denote parameters");
|
sender.sendMessage(commandColor + "[] denote parameters");
|
||||||
|
|
||||||
if (booksHavePrice()) {
|
if (booksHavePrice()) {
|
||||||
if (bookPriceType != Material.AIR)
|
if (bookPriceType != Material.AIR) {
|
||||||
sender.sendMessage(errorColor + "[" + (int) bookPriceQuantity + " " + bookPriceType.toString() + "(s) are required to create a book]");
|
sendErrorMessage(sender, "[" + (int) bookPriceQuantity + " " + bookPriceType.toString() + "(s) are required to create a book]");
|
||||||
else
|
} else {
|
||||||
sender.sendMessage(errorColor + "[" + BooksWithoutBorders.eco.format(bookPriceQuantity) + " is required to create a book]");
|
sendErrorMessage(sender, "[" + BooksWithoutBorders.eco.format(bookPriceQuantity) + " is required to create a book]");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sender.sendMessage(commandColor + "Commands:");
|
sender.sendMessage(commandColor + "Commands:");
|
||||||
|
|
||||||
@ -391,7 +392,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
if (args[0].equalsIgnoreCase("reload")) {
|
if (args[0].equalsIgnoreCase("reload")) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
if (!sender.hasPermission("bookswithoutborders.admin") && !sender.hasPermission("*")) {
|
if (!sender.hasPermission("bookswithoutborders.admin") && !sender.hasPermission("*")) {
|
||||||
sender.sendMessage(errorColor + "You don't have permission to use this command!");
|
sendErrorMessage(sender, "You don't have permission to use this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -399,8 +400,8 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
if (loadConfig() && loadExistingPlayers())
|
if (loadConfig() && loadExistingPlayers())
|
||||||
sender.sendMessage(successColor + "BooksWithoutBorders configuration reloaded!");
|
sender.sendMessage(successColor + "BooksWithoutBorders configuration reloaded!");
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(errorColor + "Reload Failed!");
|
sendErrorMessage(sender, "Reload Failed!");
|
||||||
sender.sendMessage(errorColor + "See console for details");
|
sendErrorMessage(sender, "See console for details");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -410,7 +411,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("savePublic")) {
|
if (args[0].equalsIgnoreCase("savePublic")) {
|
||||||
if (!sender.hasPermission("bookswithoutborders.savepublic")) {
|
if (!sender.hasPermission("bookswithoutborders.savepublic")) {
|
||||||
sender.sendMessage(errorColor + " You don't have permission to use this command!");
|
sendErrorMessage(sender, " You don't have permission to use this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,14 +423,14 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(errorColor + "You must be holding a written book or book and quill to save it!");
|
sendErrorMessage(sender, "You must be holding a written book or book and quill to save it!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("save")) {
|
if (args[0].equalsIgnoreCase("save")) {
|
||||||
if (!sender.hasPermission("bookswithoutborders.save")) {
|
if (!sender.hasPermission("bookswithoutborders.save")) {
|
||||||
sender.sendMessage(errorColor + " You don't have permission to use this command!");
|
sendErrorMessage(sender, " You don't have permission to use this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,19 +442,19 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(errorColor + "You must be holding a written book or book and quill to save it!");
|
sendErrorMessage(sender, "You must be holding a written book or book and quill to save it!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("loadPublic")) {
|
if (args[0].equalsIgnoreCase("loadPublic")) {
|
||||||
if (!sender.hasPermission("bookswithoutborders.loadpublic")) {
|
if (!sender.hasPermission("bookswithoutborders.loadpublic")) {
|
||||||
sender.sendMessage(errorColor + " You don't have permission to use this command!");
|
sendErrorMessage(sender, " You don't have permission to use this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((Player) sender).getInventory().firstEmpty() == -1) {
|
if (((Player) sender).getInventory().firstEmpty() == -1) {
|
||||||
sender.sendMessage(errorColor + "You must have space in your inventory to load books!");
|
sendErrorMessage(sender, "You must have space in your inventory to load books!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,23 +487,23 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
sender.sendMessage(successColor + "Book created!");
|
sender.sendMessage(successColor + "Book created!");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(errorColor + "Book failed to load!");
|
sendErrorMessage(sender, "Book failed to load!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
sender.sendMessage(errorColor + "Invalid number of book copies specified!");
|
sendErrorMessage(sender, "Invalid number of book copies specified!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("load")) {
|
if (args[0].equalsIgnoreCase("load")) {
|
||||||
if (!sender.hasPermission("bookswithoutborders.load")) {
|
if (!sender.hasPermission("bookswithoutborders.load")) {
|
||||||
sender.sendMessage(errorColor + " You don't have permission to use this command!");
|
sendErrorMessage(sender, " You don't have permission to use this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((Player) sender).getInventory().firstEmpty() == -1) {
|
if (((Player) sender).getInventory().firstEmpty() == -1) {
|
||||||
sender.sendMessage(errorColor + "You must have space in your inventory to load books!");
|
sendErrorMessage(sender, "You must have space in your inventory to load books!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -536,23 +537,23 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
sender.sendMessage(successColor + "Book created!");
|
sender.sendMessage(successColor + "Book created!");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(errorColor + "Book failed to load!");
|
sendErrorMessage(sender, "Book failed to load!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
sender.sendMessage(errorColor + "Invalid number of book copies specified!");
|
sendErrorMessage(sender, "Invalid number of book copies specified!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("give")) {
|
if (args[0].equalsIgnoreCase("give")) {
|
||||||
if (!sender.hasPermission("bookswithoutborders.give")) {
|
if (!sender.hasPermission("bookswithoutborders.give")) {
|
||||||
sender.sendMessage(errorColor + " You don't have permission to use this command!");
|
sendErrorMessage(sender, " You don't have permission to use this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(args.length == 1 || args.length == 3 || args.length == 4 || args.length == 5)) {
|
if (args.length == 2 || args.length > 5) {
|
||||||
sender.sendMessage(errorColor + "Incorrect number of arguments for this command!");
|
sendErrorMessage(sender, "Incorrect number of arguments for this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -571,12 +572,12 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
ItemStack newBook;
|
ItemStack newBook;
|
||||||
Player receivingPlayer = this.getServer().getPlayer(args[2]);
|
Player receivingPlayer = this.getServer().getPlayer(args[2]);
|
||||||
if (receivingPlayer == null) {
|
if (receivingPlayer == null) {
|
||||||
sender.sendMessage(errorColor + "Player not found!");
|
sendErrorMessage(sender, "Player not found!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (receivingPlayer.getInventory().firstEmpty() == -1) {
|
if (receivingPlayer.getInventory().firstEmpty() == -1) {
|
||||||
sender.sendMessage(errorColor + "Receiving player must have space in their inventory to receive books!");
|
sendErrorMessage(sender, "Receiving player must have space in their inventory to receive books!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -599,18 +600,18 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
receivingPlayer.sendMessage(successColor + "Book received!");
|
receivingPlayer.sendMessage(successColor + "Book received!");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(errorColor + "Book failed to load!");
|
sendErrorMessage(sender, "Book failed to load!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
sender.sendMessage(errorColor + "Invalid number of book copies specified!");
|
sendErrorMessage(sender, "Invalid number of book copies specified!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("delete")) {
|
if (args[0].equalsIgnoreCase("delete")) {
|
||||||
if (!sender.hasPermission("bookswithoutborders.delete")) {
|
if (!sender.hasPermission("bookswithoutborders.delete")) {
|
||||||
sender.sendMessage(errorColor + " You don't have permission to use this command!");
|
sendErrorMessage(sender, " You don't have permission to use this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,14 +623,14 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
//actual deletion
|
//actual deletion
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
if (!loadList.containsKey(sender.getName())) {
|
if (!loadList.containsKey(sender.getName())) {
|
||||||
sender.sendMessage(errorColor + "You must first use /bwb delete to create a list of delete-able files!");
|
sendErrorMessage(sender, "You must first use /bwb delete to create a list of delete-able files!");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (!loadList.get(sender.getName()).isEmpty()) {
|
if (!loadList.get(sender.getName()).isEmpty()) {
|
||||||
deleteBook(sender, args[1], false);
|
deleteBook(sender, args[1], false);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(errorColor + "No files available to delete!");
|
sendErrorMessage(sender, "No files available to delete!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -638,12 +639,12 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("unsign")) {
|
if (args[0].equalsIgnoreCase("unsign")) {
|
||||||
if (!sender.hasPermission("bookswithoutborders.unsign")) {
|
if (!sender.hasPermission("bookswithoutborders.unsign")) {
|
||||||
sender.sendMessage(errorColor + " You don't have permission to use this command!");
|
sendErrorMessage(sender, " You don't have permission to use this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(((Player) sender).getItemInHand().getType() == Material.WRITTEN_BOOK)) {
|
if (!(((Player) sender).getItemInHand().getType() == Material.WRITTEN_BOOK)) {
|
||||||
sender.sendMessage(errorColor + "You must be holding a written book to unsign it!");
|
sendErrorMessage(sender, "You must be holding a written book to unsign it!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -652,7 +653,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
|
|
||||||
//Find which hand the player is using to hold the book. If holding one in each, throw an error
|
//Find which hand the player is using to hold the book. If holding one in each, throw an error
|
||||||
if (hasBookInMainHand && hasBookInOffHand) {
|
if (hasBookInMainHand && hasBookInOffHand) {
|
||||||
sender.sendMessage(errorColor + "You cannot un-sign two books at once. Please un-equip one " +
|
sendErrorMessage(sender, "You cannot un-sign two books at once. Please un-equip one " +
|
||||||
"of the books you're holding!");
|
"of the books you're holding!");
|
||||||
} else if (hasBookInMainHand) {
|
} else if (hasBookInMainHand) {
|
||||||
unSignHeldBook(player, true);
|
unSignHeldBook(player, true);
|
||||||
@ -664,17 +665,17 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("copy")) {
|
if (args[0].equalsIgnoreCase("copy")) {
|
||||||
if (!sender.hasPermission("bookswithoutborders.copy")) {
|
if (!sender.hasPermission("bookswithoutborders.copy")) {
|
||||||
sender.sendMessage(errorColor + " You don't have permission to use this command!");
|
sendErrorMessage(sender, " You don't have permission to use this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(((Player) sender).getItemInHand().getType() == Material.WRITTEN_BOOK)) {
|
if (!(((Player) sender).getItemInHand().getType() == Material.WRITTEN_BOOK)) {
|
||||||
sender.sendMessage(errorColor + "You must be holding a written book to copy it!");
|
sendErrorMessage(sender, "You must be holding a written book to copy it!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
sender.sendMessage(errorColor + "You must specifiy the number of copies to be made!");
|
sendErrorMessage(sender, "You must specifiy the number of copies to be made!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -694,13 +695,13 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
((Player) sender).getItemInHand().setAmount(((Player) sender).getItemInHand().getAmount() + Integer.parseInt(args[1]));
|
((Player) sender).getItemInHand().setAmount(((Player) sender).getItemInHand().getAmount() + Integer.parseInt(args[1]));
|
||||||
sender.sendMessage(successColor + "Book copied!");
|
sender.sendMessage(successColor + "Book copied!");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(errorColor + "Book not copied!");
|
sendErrorMessage(sender, "Book not copied!");
|
||||||
sender.sendMessage(errorColor + "Number specified was invalid!");
|
sendErrorMessage(sender, "Number specified was invalid!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
sender.sendMessage(errorColor + "Book not copied!");
|
sendErrorMessage(sender, "Book not copied!");
|
||||||
sender.sendMessage(errorColor + "Number specified was invalid!");
|
sendErrorMessage(sender, "Number specified was invalid!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -708,26 +709,26 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("encrypt")) {
|
if (args[0].equalsIgnoreCase("encrypt")) {
|
||||||
if (!sender.hasPermission("bookswithoutborders.encrypt")) {
|
if (!sender.hasPermission("bookswithoutborders.encrypt")) {
|
||||||
sender.sendMessage(errorColor + " You don't have permission to use this command!");
|
sendErrorMessage(sender, " You don't have permission to use this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(((Player) sender).getItemInHand().getType() == Material.WRITTEN_BOOK)) {
|
if (!(((Player) sender).getItemInHand().getType() == Material.WRITTEN_BOOK)) {
|
||||||
sender.sendMessage(errorColor + "You must be holding a written book to encrypt it!");
|
sendErrorMessage(sender, "You must be holding a written book to encrypt it!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
sender.sendMessage(errorColor + "You must specify a key to encrypt a book!");
|
sendErrorMessage(sender, "You must specify a key to encrypt a book!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length > 3) {
|
if (args.length > 3) {
|
||||||
sender.sendMessage(errorColor + "Too many command options specified!");
|
sendErrorMessage(sender, "Too many command options specified!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!((BookMeta) ((Player) sender).getItemInHand().getItemMeta()).hasPages()) {
|
if (!((BookMeta) ((Player) sender).getItemInHand().getItemMeta()).hasPages()) {
|
||||||
sender.sendMessage(errorColor + "Book must have contents to encrypt!");
|
sendErrorMessage(sender, "Book must have contents to encrypt!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -748,32 +749,32 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("groupEncrypt")) {
|
if (args[0].equalsIgnoreCase("groupEncrypt")) {
|
||||||
if (!sender.hasPermission("bookswithoutborders.groupencrypt")) {
|
if (!sender.hasPermission("bookswithoutborders.groupencrypt")) {
|
||||||
sender.sendMessage(errorColor + " You don't have permission to use this command!");
|
sendErrorMessage(sender, " You don't have permission to use this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(((Player) sender).getItemInHand().getType() == Material.WRITTEN_BOOK)) {
|
if (!(((Player) sender).getItemInHand().getType() == Material.WRITTEN_BOOK)) {
|
||||||
sender.sendMessage(errorColor + "You must be holding a written book to encrypt it!");
|
sendErrorMessage(sender, "You must be holding a written book to encrypt it!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length < 3) {
|
if (args.length < 3) {
|
||||||
sender.sendMessage(errorColor + "You must specify a key to encrypt a book!");
|
sendErrorMessage(sender, "You must specify a key to encrypt a book!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length > 4) {
|
if (args.length > 4) {
|
||||||
sender.sendMessage(errorColor + "Too many command options specified!");
|
sendErrorMessage(sender, "Too many command options specified!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!((BookMeta) ((Player) sender).getItemInHand().getItemMeta()).hasPages()) {
|
if (!((BookMeta) ((Player) sender).getItemInHand().getItemMeta()).hasPages()) {
|
||||||
sender.sendMessage(errorColor + "Book must have contents to encrypt!");
|
sendErrorMessage(sender, "Book must have contents to encrypt!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((Player) sender).getItemInHand().getItemMeta().hasLore()
|
if (((Player) sender).getItemInHand().getItemMeta().hasLore()
|
||||||
&& ((Player) sender).getItemInHand().getItemMeta().getLore().get(0).contains(" encrypted]")) {
|
&& ((Player) sender).getItemInHand().getItemMeta().getLore().get(0).contains(" encrypted]")) {
|
||||||
sender.sendMessage(errorColor + "Book is already group encrypted!");
|
sendErrorMessage(sender, "Book is already group encrypted!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -794,12 +795,12 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("decrypt")) {
|
if (args[0].equalsIgnoreCase("decrypt")) {
|
||||||
if (!sender.hasPermission("bookswithoutborders.decrypt")) {
|
if (!sender.hasPermission("bookswithoutborders.decrypt")) {
|
||||||
sender.sendMessage(errorColor + " You don't have permission to use this command!");
|
sendErrorMessage(sender, " You don't have permission to use this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(((Player) sender).getItemInHand().getType() == Material.WRITTEN_BOOK)) {
|
if (!(((Player) sender).getItemInHand().getType() == Material.WRITTEN_BOOK)) {
|
||||||
sender.sendMessage(errorColor + "You must be holding a written book to decrypt it!");
|
sendErrorMessage(sender, "You must be holding a written book to decrypt it!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -826,7 +827,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(errorColor + "No matching encypted book found!");
|
sendErrorMessage(sender, "No matching encrypted book found!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -844,17 +845,17 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("setTitle")) {
|
if (args[0].equalsIgnoreCase("setTitle")) {
|
||||||
if (!sender.hasPermission("bookswithoutborders.settitle")) {
|
if (!sender.hasPermission("bookswithoutborders.settitle")) {
|
||||||
sender.sendMessage(errorColor + " You don't have permission to use this command!");
|
sendErrorMessage(sender, " You don't have permission to use this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
sender.sendMessage(errorColor + "Too few command arguments!");
|
sendErrorMessage(sender, "Too few command arguments!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((Player) sender).getItemInHand().getType() == Material.AIR) {
|
if (((Player) sender).getItemInHand().getType() == Material.AIR) {
|
||||||
sender.sendMessage(errorColor + "You must be holding an item to set title!");
|
sendErrorMessage(sender, "You must be holding an item to set title!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -885,17 +886,17 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("setAuthor")) {
|
if (args[0].equalsIgnoreCase("setAuthor")) {
|
||||||
if (!sender.hasPermission("bookswithoutborders.setauthor")) {
|
if (!sender.hasPermission("bookswithoutborders.setauthor")) {
|
||||||
sender.sendMessage(errorColor + " You don't have permission to use this command!");
|
sendErrorMessage(sender, " You don't have permission to use this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
sender.sendMessage(errorColor + "Too few command arguments!");
|
sendErrorMessage(sender, "Too few command arguments!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(((Player) sender).getItemInHand().getType() == Material.WRITTEN_BOOK)) {
|
if (!(((Player) sender).getItemInHand().getType() == Material.WRITTEN_BOOK)) {
|
||||||
sender.sendMessage(errorColor + "You must be holding a written book to set author!");
|
sendErrorMessage(sender, "You must be holding a written book to set author!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -915,17 +916,17 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("setLore")) {
|
if (args[0].equalsIgnoreCase("setLore")) {
|
||||||
if (!sender.hasPermission("bookswithoutborders.setlore")) {
|
if (!sender.hasPermission("bookswithoutborders.setlore")) {
|
||||||
sender.sendMessage(errorColor + " You don't have permission to use this command!");
|
sendErrorMessage(sender, " You don't have permission to use this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
sender.sendMessage(errorColor + "Missing a command argument!");
|
sendErrorMessage(sender, "Missing a command argument!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((Player) sender).getItemInHand().getType() == Material.AIR) {
|
if (((Player) sender).getItemInHand().getType() == Material.AIR) {
|
||||||
sender.sendMessage(errorColor + "Must be holding an item to set lore!");
|
sendErrorMessage(sender, "Must be holding an item to set lore!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -952,13 +953,13 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
if (args[0].equalsIgnoreCase("givePublic")) {
|
if (args[0].equalsIgnoreCase("givePublic")) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
if (!sender.hasPermission("bookswithoutborders.givepublic")) {
|
if (!sender.hasPermission("bookswithoutborders.givepublic")) {
|
||||||
sender.sendMessage(errorColor + " You don't have permission to use this command!");
|
sendErrorMessage(sender, " You don't have permission to use this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(args.length == 1 || args.length == 3 || args.length == 4 || args.length == 5)) {
|
if (args.length == 2 || args.length > 5) {
|
||||||
sender.sendMessage(errorColor + "Incorrect number of arguments for this command!");
|
sendErrorMessage(sender, "Incorrect number of arguments for this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -977,12 +978,12 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
ItemStack newBook;
|
ItemStack newBook;
|
||||||
Player receivingPlayer = this.getServer().getPlayer(args[2]);
|
Player receivingPlayer = this.getServer().getPlayer(args[2]);
|
||||||
if (receivingPlayer == null) {
|
if (receivingPlayer == null) {
|
||||||
sender.sendMessage(errorColor + "Player not found!");
|
sendErrorMessage(sender, "Player not found!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (receivingPlayer.getInventory().firstEmpty() == -1) {
|
if (receivingPlayer.getInventory().firstEmpty() == -1) {
|
||||||
sender.sendMessage(errorColor + "Receiving player must have space in their inventory to receive books!");
|
sendErrorMessage(sender, "Receiving player must have space in their inventory to receive books!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//bwb give [bookname] [player] [numCopies] [issigned]
|
//bwb give [bookname] [player] [numCopies] [issigned]
|
||||||
@ -1003,11 +1004,11 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
receivingPlayer.sendMessage(successColor + "Book received!");
|
receivingPlayer.sendMessage(successColor + "Book received!");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(errorColor + "Book failed to load!");
|
sendErrorMessage(sender, "Book failed to load!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
sender.sendMessage(errorColor + "Invalid number of book copies specified!");
|
sendErrorMessage(sender, "Invalid number of book copies specified!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1016,7 +1017,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
|
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
if (!sender.hasPermission("bookswithoutborders.admin")) {
|
if (!sender.hasPermission("bookswithoutborders.admin")) {
|
||||||
sender.sendMessage(errorColor + " You don't have permission to use this command!");
|
sendErrorMessage(sender, " You don't have permission to use this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1029,14 +1030,14 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
//actual deletion
|
//actual deletion
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
if (!loadList.containsKey(sender.getName())) {
|
if (!loadList.containsKey(sender.getName())) {
|
||||||
sender.sendMessage(errorColor + "You must first use /bwb deletePublic to create a list of delete-able files!");
|
sendErrorMessage(sender, "You must first use /bwb deletePublic to create a list of delete-able files!");
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (!loadList.get(sender.getName()).isEmpty()) {
|
if (!loadList.get(sender.getName()).isEmpty()) {
|
||||||
deleteBook((sender), args[1], true);
|
deleteBook((sender), args[1], true);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(errorColor + "No files available to delete!");
|
sendErrorMessage(sender, "No files available to delete!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1045,7 +1046,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
|
|
||||||
if (args[0].equalsIgnoreCase("setBookPrice")) {
|
if (args[0].equalsIgnoreCase("setBookPrice")) {
|
||||||
if (!sender.hasPermission("bookswithoutborders.setbookprice")) {
|
if (!sender.hasPermission("bookswithoutborders.setbookprice")) {
|
||||||
sender.sendMessage(errorColor + " You don't have permission to use this command!");
|
sendErrorMessage(sender, " You don't have permission to use this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1061,24 +1062,24 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args.length < 3) {
|
if (args.length < 3) {
|
||||||
sender.sendMessage(errorColor + "[Item/Eco] and [quantity] must be specified!");
|
sendErrorMessage(sender, "[Item/Eco] and [quantity] must be specified!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args[1].equalsIgnoreCase("Item") && !args[1].equalsIgnoreCase("Eco")) {
|
if (!args[1].equalsIgnoreCase("Item") && !args[1].equalsIgnoreCase("Eco")) {
|
||||||
sender.sendMessage(errorColor + "Price type must be \"Item\" or \"Eco\"!");
|
sendErrorMessage(sender, "Price type must be \"Item\" or \"Eco\"!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Double.parseDouble(args[2]) <= 0) {
|
if (Double.parseDouble(args[2]) <= 0) {
|
||||||
sender.sendMessage(errorColor + "[quantity] must be greater than 0!");
|
sendErrorMessage(sender, "[quantity] must be greater than 0!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[1].equalsIgnoreCase("Item")) {
|
if (args[1].equalsIgnoreCase("Item")) {
|
||||||
if (((Player) sender).getItemInHand().getType() == Material.AIR) {
|
if (((Player) sender).getItemInHand().getType() == Material.AIR) {
|
||||||
sender.sendMessage(errorColor + "Must be holding an item to set an [Item] price!");
|
sendErrorMessage(sender, "Must be holding an item to set an [Item] price!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1101,17 +1102,17 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
sender.sendMessage(successColor + "Book creation price set to " + eco.format(bookPriceQuantity) + "!");
|
sender.sendMessage(successColor + "Book creation price set to " + eco.format(bookPriceQuantity) + "!");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(errorColor + "BooksWithoutBorders failed to hook into Vault! Book price not set!");
|
sendErrorMessage(sender, "BooksWithoutBorders failed to hook into Vault! Book price not set!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
sender.sendMessage(errorColor + "[quantity] must be a number!");
|
sendErrorMessage(sender, "[quantity] must be a number!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(errorColor + "Command not recognized! Use " + commandColor + "/BwB" + errorColor + " for more info!");
|
sendErrorMessage(sender, "Command not recognized! Use " + commandColor + "/BwB" + errorColor + " for more info!");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1285,7 +1286,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
//if this is a private save, make sure the dir exists
|
//if this is a private save, make sure the dir exists
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
if (!file.mkdir()) {
|
if (!file.mkdir()) {
|
||||||
player.sendMessage(errorColor + "Saving Failed! If this continues to happen, consult server admin!");
|
sendErrorMessage(player, "Saving Failed! If this continues to happen, consult server admin!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1308,14 +1309,14 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
if (dupes > 0) {
|
if (dupes > 0) {
|
||||||
if (!fname.contains("Untitled") && dupe.equalsIgnoreCase("false")) {
|
if (!fname.contains("Untitled") && dupe.equalsIgnoreCase("false")) {
|
||||||
player.sendMessage(errorColor + "Book is already saved!");
|
sendErrorMessage(player, "Book is already saved!");
|
||||||
player.sendMessage(errorColor + "Use " + commandColor + "/bwb Save true " + errorColor + "to overwrite!");
|
sendErrorMessage(player, "Use " + commandColor + "/bwb Save true " + errorColor + "to overwrite!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dupes > bookDuplicateLimit) {
|
if (dupes > bookDuplicateLimit) {
|
||||||
player.sendMessage(errorColor + "Maximum amount of " + fname + " duplicates reached!");
|
sendErrorMessage(player, "Maximum amount of " + fname + " duplicates reached!");
|
||||||
player.sendMessage(errorColor + "Use " + commandColor + "/bwb Save true " + errorColor + "to overwrite!");
|
sendErrorMessage(player, "Use " + commandColor + "/bwb Save true " + errorColor + "to overwrite!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1373,7 +1374,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
file = null;
|
file = null;
|
||||||
|
|
||||||
if (!file.isFile()) {
|
if (!file.isFile()) {
|
||||||
sender.sendMessage(errorColor + "Incorrect file name!");
|
sendErrorMessage(sender, "Incorrect file name!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
break NameCheck;
|
break NameCheck;
|
||||||
@ -1406,7 +1407,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
file = null;
|
file = null;
|
||||||
|
|
||||||
if (!file.isFile()) {
|
if (!file.isFile()) {
|
||||||
sender.sendMessage(errorColor + "Incorrect file name!");
|
sendErrorMessage(sender, "Incorrect file name!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1422,7 +1423,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
|
|
||||||
bookFromYml(file, bDat);
|
bookFromYml(file, bDat);
|
||||||
if (bDat == null) {
|
if (bDat == null) {
|
||||||
sender.sendMessage(errorColor + "File was blank!!");
|
sendErrorMessage(sender, "File was blank!!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1464,7 +1465,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
bookToYml(path, fname, book);
|
bookToYml(path, fname, book);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
player.sendMessage(errorColor + "Encrypted failed!");
|
sendErrorMessage(player, "Encrypted failed!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -1477,7 +1478,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
if (!dirTest.exists()) {
|
if (!dirTest.exists()) {
|
||||||
try {
|
try {
|
||||||
if (!dirTest.mkdir()) {
|
if (!dirTest.mkdir()) {
|
||||||
consoleSender.sendMessage(errorColor + "Unable to create encryption group folder!");
|
sendErrorMessage(consoleSender, "Unable to create encryption group folder!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -1505,7 +1506,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
bookToYml(path, fname, book);
|
bookToYml(path, fname, book);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
player.sendMessage(errorColor + "Group encrypted failed!");
|
sendErrorMessage(player, "Group encrypted failed!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1527,14 +1528,14 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
file = new File(path + fname + ".txt");
|
file = new File(path + fname + ".txt");
|
||||||
|
|
||||||
if (!file.isFile()) {
|
if (!file.isFile()) {
|
||||||
player.sendMessage(errorColor + "Incorrect decryption key!");
|
sendErrorMessage(player, "Incorrect decryption key!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
book = bookFromYml(file, book);
|
book = bookFromYml(file, book);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
player.sendMessage(errorColor + "Decryption failed!");
|
sendErrorMessage(player, "Decryption failed!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1543,8 +1544,8 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
file.delete();
|
file.delete();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
consoleSender.sendMessage(errorColor + "Book encryption data failed to delete upon decryption!");
|
sendErrorMessage(consoleSender, "Book encryption data failed to delete upon decryption!");
|
||||||
consoleSender.sendMessage(errorColor + "File location:" + file.getPath());
|
sendErrorMessage(consoleSender, "File location:" + file.getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1561,12 +1562,12 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
File[] fl = file.listFiles();
|
File[] fl = file.listFiles();
|
||||||
|
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
sender.sendMessage(errorColor + "No books have been saved!");
|
sendErrorMessage(sender, "No books have been saved!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fl.length == 0) {
|
if (fl.length == 0) {
|
||||||
sender.sendMessage(errorColor + "No books have been saved!");
|
sendErrorMessage(sender, "No books have been saved!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1660,7 +1661,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
BookMeta book = getHeldBookMetadata(player, mainHand);
|
BookMeta book = getHeldBookMetadata(player, mainHand);
|
||||||
|
|
||||||
if (!book.hasPages()) {
|
if (!book.hasPages()) {
|
||||||
player.sendMessage(errorColor + "Book is empty!");
|
sendErrorMessage(player, "Book is empty!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1689,7 +1690,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
encryptedPages.add(sc.encrypt(book.getPage(x + 1), integerKey));
|
encryptedPages.add(sc.encrypt(book.getPage(x + 1), integerKey));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(errorColor + "Invalid encryption style encountered!");
|
sendErrorMessage(player, "Invalid encryption style encountered!");
|
||||||
}
|
}
|
||||||
|
|
||||||
encryptedPages = pageFormat(encryptedPages);
|
encryptedPages = pageFormat(encryptedPages);
|
||||||
@ -1708,6 +1709,15 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends an error message to a player
|
||||||
|
* @param sender <p>The sender to send the message to</p>
|
||||||
|
* @param message <p>The message to send</p>
|
||||||
|
*/
|
||||||
|
private void sendErrorMessage(CommandSender sender, String message) {
|
||||||
|
sender.sendMessage(errorColor + message);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the given book
|
* Deletes the given book
|
||||||
*
|
*
|
||||||
@ -1736,7 +1746,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
|
|
||||||
//Send message if no such file could be found
|
//Send message if no such file could be found
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
sender.sendMessage(errorColor + "Incorrect file name!");
|
sendErrorMessage(sender, "Incorrect file name!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1745,10 +1755,10 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
if (file.delete()) {
|
if (file.delete()) {
|
||||||
sender.sendMessage(successColor + "\"" + fileName + "\" deleted successfully");
|
sender.sendMessage(successColor + "\"" + fileName + "\" deleted successfully");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(errorColor + "Deletion failed without an exception!");
|
sendErrorMessage(sender, "Deletion failed without an exception!");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
sender.sendMessage(errorColor + "Deletion failed!");
|
sendErrorMessage(sender, "Deletion failed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1826,7 +1836,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
payForBookPrintingItem(player, itemCost);
|
payForBookPrintingItem(player, itemCost);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(errorColor + String.valueOf(itemCost) + " " + bookPriceType.toString() +
|
sendErrorMessage(player, itemCost + " " + bookPriceType.toString() +
|
||||||
"(s) are required for this command!");
|
"(s) are required for this command!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1873,7 +1883,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
player.sendMessage(successColor + "New balance: " + economy.format(economy.getBalance(player)));
|
player.sendMessage(successColor + "New balance: " + economy.format(economy.getBalance(player)));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(errorColor + economy.format(cost) + " is required for this command!");
|
sendErrorMessage(player, economy.format(cost) + " is required for this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1891,7 +1901,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(errorColor + "You must be the author of this book to use this command!");
|
sendErrorMessage(player, "You must be the author of this book to use this command!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user