Splits translatable strings to make them more manageable
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good
This commit is contained in:
@@ -29,7 +29,12 @@ import net.knarcraft.bookswithoutborders.command.CommandUnSign;
|
||||
import net.knarcraft.bookswithoutborders.config.BwBCommand;
|
||||
import net.knarcraft.bookswithoutborders.config.BwBConfig;
|
||||
import net.knarcraft.bookswithoutborders.config.StaticMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.BookshelfMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.CostMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.GiveMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.SaveMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.container.MigrationRequest;
|
||||
import net.knarcraft.bookswithoutborders.handler.BookshelfHandler;
|
||||
import net.knarcraft.bookswithoutborders.listener.BookEventListener;
|
||||
@@ -207,6 +212,12 @@ public class BooksWithoutBorders extends JavaPlugin {
|
||||
|
||||
Translator translator = new Translator();
|
||||
translator.registerMessageCategory(Translatable.SUCCESS_COPY);
|
||||
translator.registerMessageCategory(GiveMessage.SUCCESS_GIVE_SENT);
|
||||
translator.registerMessageCategory(BookshelfMessage.SUCCESS_BOOKSHELF_TITLE_SET);
|
||||
translator.registerMessageCategory(Formatting.ACTION_COPY);
|
||||
translator.registerMessageCategory(CostMessage.SUCCESS_COST_ITEM_SET);
|
||||
translator.registerMessageCategory(SaveMessage.SUCCESS_SAVED);
|
||||
|
||||
stringFormatter = new StringFormatter(this.getDescription().getName(), translator);
|
||||
stringFormatter.setColorConversion(ColorConversion.RGB);
|
||||
stringFormatter.setSuccessColor(ChatColor.of("#A9FF84"));
|
||||
|
@@ -1,7 +1,8 @@
|
||||
package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.utility.BookFormatter;
|
||||
import net.knarcraft.bookswithoutborders.utility.BookHelper;
|
||||
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
|
||||
@@ -44,9 +45,9 @@ public class CommandAddTitlePage implements TabExecutor {
|
||||
if (arguments.length < 1) {
|
||||
if (InventoryHelper.notHoldingOneWrittenBookCheck(player,
|
||||
stringFormatter.replacePlaceholder(Translatable.ERROR_NOT_HOLDING_WRITTEN_BOOK, "{action}",
|
||||
stringFormatter.getUnFormattedColoredMessage(Translatable.ACTION_ADD_TITLE_AUTHOR_PAGE)),
|
||||
stringFormatter.getUnFormattedColoredMessage(Formatting.ACTION_ADD_TITLE_AUTHOR_PAGE)),
|
||||
stringFormatter.replacePlaceholder(Translatable.ERROR_ONLY_ONE_BOOK, "{action}",
|
||||
stringFormatter.getUnFormattedColoredMessage(Translatable.ACTION_ADD_TITLE_AUTHOR_PAGE)))) {
|
||||
stringFormatter.getUnFormattedColoredMessage(Formatting.ACTION_ADD_TITLE_AUTHOR_PAGE)))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -86,7 +87,7 @@ public class CommandAddTitlePage implements TabExecutor {
|
||||
if (title == null && heldBook.getType() == Material.WRITTEN_BOOK) {
|
||||
// Add a page with the book title and book author
|
||||
String loreSeparator = BooksWithoutBorders.getConfiguration().getLoreSeparator();
|
||||
String pageText = formatTitle(stringFormatter.replacePlaceholders(Translatable.NEUTRAL_TITLE_PAGE_TITLE_AUTHOR_FORMAT,
|
||||
String pageText = formatTitle(stringFormatter.replacePlaceholders(Formatting.NEUTRAL_TITLE_PAGE_TITLE_AUTHOR_FORMAT,
|
||||
List.of("{title}", "{separator}", "{author}"), List.of(BookHelper.getBookTitle(bookMeta),
|
||||
loreSeparator, BookHelper.getBookAuthor(bookMeta, null))));
|
||||
|
||||
@@ -128,11 +129,11 @@ public class CommandAddTitlePage implements TabExecutor {
|
||||
if (input.contains(loreSeparator)) {
|
||||
String[] parts = input.split(loreSeparator);
|
||||
StringBuilder output = new StringBuilder();
|
||||
output.append(stringFormatter.replacePlaceholder(Translatable.NEUTRAL_TITLE_PAGE_HEADER_FORMAT,
|
||||
output.append(stringFormatter.replacePlaceholder(Formatting.NEUTRAL_TITLE_PAGE_HEADER_FORMAT,
|
||||
"{header}", BookFormatter.stripColor(parts[0])));
|
||||
|
||||
for (int i = 1; i < parts.length; i++) {
|
||||
output.append(stringFormatter.replacePlaceholder(Translatable.NEUTRAL_TITLE_PAGE_TEXT_FORMAT,
|
||||
output.append(stringFormatter.replacePlaceholder(Formatting.NEUTRAL_TITLE_PAGE_TEXT_FORMAT,
|
||||
"{text}", BookFormatter.stripColor(parts[i])));
|
||||
}
|
||||
return output.toString();
|
||||
|
@@ -5,7 +5,9 @@ import net.knarcraft.bookswithoutborders.config.BwBCommand;
|
||||
import net.knarcraft.bookswithoutborders.config.BwBConfig;
|
||||
import net.knarcraft.bookswithoutborders.config.Permission;
|
||||
import net.knarcraft.bookswithoutborders.config.StaticMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.CostMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.manager.EconomyManager;
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
import net.knarcraft.knarlib.util.TabCompletionHelper;
|
||||
@@ -50,7 +52,7 @@ public class CommandBooksWithoutBorders implements TabExecutor {
|
||||
commandExplanation = getCommandExplanation(true);
|
||||
}
|
||||
stringFormatter.displaySuccessMessage(sender, stringFormatter.replacePlaceholders(
|
||||
Translatable.NEUTRAL_COMMANDS_HEADER, List.of("{bookPrice}", "{commands}", "{commandExplanation}"),
|
||||
Formatting.NEUTRAL_COMMANDS_HEADER, List.of("{bookPrice}", "{commands}", "{commandExplanation}"),
|
||||
List.of(getBookPrice(), commands, commandExplanation)));
|
||||
return true;
|
||||
}
|
||||
@@ -87,15 +89,15 @@ public class CommandBooksWithoutBorders implements TabExecutor {
|
||||
Material bookPriceType = config.getBookPriceType();
|
||||
double bookPriceQuantity = config.getBookPriceQuantity();
|
||||
if (bookPriceType != Material.AIR) {
|
||||
return stringFormatter.replacePlaceholders(Translatable.NEUTRAL_COMMANDS_BOOK_PRICE_ITEM,
|
||||
return stringFormatter.replacePlaceholders(Formatting.NEUTRAL_COMMANDS_BOOK_PRICE_ITEM,
|
||||
List.of("{quantity}", "{type}"),
|
||||
List.of(String.valueOf((int) bookPriceQuantity), bookPriceType.toString()));
|
||||
} else {
|
||||
EconomyManager economyManager = BooksWithoutBorders.getConfiguration().getEconomyManager();
|
||||
if (economyManager.getEconomy() == null) {
|
||||
return BooksWithoutBorders.getStringFormatter().getUnFormattedColoredMessage(Translatable.ERROR_VAULT_COST_BUT_UNAVAILABLE) + "\n";
|
||||
return BooksWithoutBorders.getStringFormatter().getUnFormattedColoredMessage(CostMessage.ERROR_VAULT_COST_BUT_UNAVAILABLE) + "\n";
|
||||
} else {
|
||||
return stringFormatter.replacePlaceholder(Translatable.NEUTRAL_COMMANDS_BOOK_PRICE_ECO,
|
||||
return stringFormatter.replacePlaceholder(Formatting.NEUTRAL_COMMANDS_BOOK_PRICE_ECO,
|
||||
"{price}", economyManager.getEconomy().format(bookPriceQuantity));
|
||||
}
|
||||
}
|
||||
@@ -164,18 +166,18 @@ public class CommandBooksWithoutBorders implements TabExecutor {
|
||||
} else {
|
||||
commandUsage = pluginCommand.getUsage().replace("<command>", pluginCommand.getName());
|
||||
description = pluginCommand.getDescription();
|
||||
aliases = stringFormatter.replacePlaceholder(Translatable.NEUTRAL_COMMANDS_ALIASES, "{aliases}",
|
||||
aliases = stringFormatter.replacePlaceholder(Formatting.NEUTRAL_COMMANDS_ALIASES, "{aliases}",
|
||||
String.join(",", pluginCommand.getAliases()));
|
||||
}
|
||||
|
||||
String commandDescription = stringFormatter.replacePlaceholders(Translatable.NEUTRAL_COMMANDS_COMMAND,
|
||||
String commandDescription = stringFormatter.replacePlaceholders(Formatting.NEUTRAL_COMMANDS_COMMAND,
|
||||
List.of("{usage}", "{description}", "{aliases}"), List.of(commandUsage, description, aliases));
|
||||
|
||||
if (!summary && sender.hasPermission(Permission.ADMIN.toString())) {
|
||||
if (permission == null) {
|
||||
permission = stringFormatter.getUnFormattedColoredMessage(Translatable.NEUTRAL_COMMANDS_COMMAND_NO_PERMISSION_REQUIRED);
|
||||
permission = stringFormatter.getUnFormattedColoredMessage(Formatting.NEUTRAL_COMMANDS_COMMAND_NO_PERMISSION_REQUIRED);
|
||||
}
|
||||
commandDescription += stringFormatter.replacePlaceholder(Translatable.NEUTRAL_COMMANDS_COMMAND_PERMISSION, "{permission}", permission);
|
||||
commandDescription += stringFormatter.replacePlaceholder(Formatting.NEUTRAL_COMMANDS_COMMAND_PERMISSION, "{permission}", permission);
|
||||
}
|
||||
return commandDescription;
|
||||
}
|
||||
@@ -190,13 +192,13 @@ public class CommandBooksWithoutBorders implements TabExecutor {
|
||||
private String getCommandExplanation(boolean summary) {
|
||||
StringFormatter stringFormatter = BooksWithoutBorders.getStringFormatter();
|
||||
if (summary) {
|
||||
return stringFormatter.replacePlaceholders(Translatable.NEUTRAL_COMMANDS_COMMAND,
|
||||
return stringFormatter.replacePlaceholders(Formatting.NEUTRAL_COMMANDS_COMMAND,
|
||||
List.of("{usage}", "{description}", "{aliases}"), List.of("Command", "Usage summary", ""));
|
||||
} else {
|
||||
return stringFormatter.replacePlaceholders(Translatable.NEUTRAL_COMMANDS_COMMAND,
|
||||
return stringFormatter.replacePlaceholders(Formatting.NEUTRAL_COMMANDS_COMMAND,
|
||||
List.of("{usage}", "{description}", "{aliases}"), List.of("Command and arguments", "Full description",
|
||||
stringFormatter.replacePlaceholder(Translatable.NEUTRAL_COMMANDS_ALIASES, "{aliases}", "Alias list"))) +
|
||||
stringFormatter.replacePlaceholder(Translatable.NEUTRAL_COMMANDS_COMMAND_PERMISSION, "{permission}", "Required permission");
|
||||
stringFormatter.replacePlaceholder(Formatting.NEUTRAL_COMMANDS_ALIASES, "{aliases}", "Alias list"))) +
|
||||
stringFormatter.replacePlaceholder(Formatting.NEUTRAL_COMMANDS_COMMAND_PERMISSION, "{permission}", "Required permission");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,8 @@
|
||||
package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -34,9 +35,9 @@ public class CommandClear implements TabExecutor {
|
||||
|
||||
if (InventoryHelper.notHoldingOneWritableBookCheck(player,
|
||||
stringFormatter.replacePlaceholder(Translatable.ERROR_NOT_HOLDING_WRITABLE_BOOK, "{action}",
|
||||
stringFormatter.getUnFormattedColoredMessage(Translatable.ACTION_CLEAR)),
|
||||
stringFormatter.getUnFormattedColoredMessage(Formatting.ACTION_CLEAR)),
|
||||
stringFormatter.replacePlaceholder(Translatable.ERROR_ONLY_ONE_BOOK, "{action}",
|
||||
stringFormatter.getUnFormattedColoredMessage(Translatable.ACTION_CLEAR)))) {
|
||||
stringFormatter.getUnFormattedColoredMessage(Formatting.ACTION_CLEAR)))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,8 @@ package net.knarcraft.bookswithoutborders.command;
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.BwBConfig;
|
||||
import net.knarcraft.bookswithoutborders.config.Permission;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.utility.BookHelper;
|
||||
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
|
||||
import net.knarcraft.bookswithoutborders.utility.TabCompletionTypeHelper;
|
||||
@@ -39,9 +40,9 @@ public class CommandCopy implements TabExecutor {
|
||||
|
||||
if (InventoryHelper.notHoldingOneWrittenBookCheck(player,
|
||||
stringFormatter.replacePlaceholder(Translatable.ERROR_NOT_HOLDING_WRITTEN_BOOK, "{action}",
|
||||
stringFormatter.getUnFormattedColoredMessage(Translatable.ACTION_COPY)),
|
||||
stringFormatter.getUnFormattedColoredMessage(Formatting.ACTION_COPY)),
|
||||
stringFormatter.replacePlaceholder(Translatable.ERROR_ONLY_ONE_BOOK, "{action}",
|
||||
stringFormatter.getUnFormattedColoredMessage(Translatable.ACTION_COPY)))) {
|
||||
stringFormatter.getUnFormattedColoredMessage(Formatting.ACTION_COPY)))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,8 @@ package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.Permission;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.utility.BookHelper;
|
||||
import net.knarcraft.bookswithoutborders.utility.EncryptionHelper;
|
||||
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
|
||||
@@ -36,9 +37,9 @@ public class CommandDecrypt implements TabExecutor {
|
||||
|
||||
if (InventoryHelper.notHoldingOneWrittenBookCheck(player,
|
||||
stringFormatter.replacePlaceholder(Translatable.ERROR_NOT_HOLDING_WRITTEN_BOOK, "{action}",
|
||||
stringFormatter.getUnFormattedColoredMessage(Translatable.ACTION_DECRYPT)),
|
||||
stringFormatter.getUnFormattedColoredMessage(Formatting.ACTION_DECRYPT)),
|
||||
stringFormatter.replacePlaceholder(Translatable.ERROR_ONLY_ONE_BOOK, "{action}",
|
||||
stringFormatter.getUnFormattedColoredMessage(Translatable.ACTION_DECRYPT)))) {
|
||||
stringFormatter.getUnFormattedColoredMessage(Formatting.ACTION_DECRYPT)))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.gui.PagedBookIndex;
|
||||
import net.knarcraft.bookswithoutborders.state.BookDirectory;
|
||||
import net.knarcraft.bookswithoutborders.utility.BookFileHelper;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
import org.bukkit.command.Command;
|
||||
|
@@ -1,7 +1,8 @@
|
||||
package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.encryption.EncryptionStyle;
|
||||
import net.knarcraft.bookswithoutborders.state.ItemSlot;
|
||||
import net.knarcraft.bookswithoutborders.utility.EncryptionHelper;
|
||||
@@ -64,9 +65,9 @@ public class CommandEncrypt implements TabExecutor {
|
||||
|
||||
if (InventoryHelper.notHoldingOneWrittenBookCheck(player,
|
||||
stringFormatter.replacePlaceholder(Translatable.ERROR_NOT_HOLDING_WRITTEN_BOOK, "{action}",
|
||||
stringFormatter.getUnFormattedColoredMessage(Translatable.ACTION_ENCRYPT)),
|
||||
stringFormatter.getUnFormattedColoredMessage(Formatting.ACTION_ENCRYPT)),
|
||||
stringFormatter.replacePlaceholder(Translatable.ERROR_ONLY_ONE_BOOK, "{action}",
|
||||
stringFormatter.getUnFormattedColoredMessage(Translatable.ACTION_ENCRYPT)))) {
|
||||
stringFormatter.getUnFormattedColoredMessage(Formatting.ACTION_ENCRYPT)))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.utility.BookFormatter;
|
||||
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
|
@@ -1,7 +1,8 @@
|
||||
package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.GiveMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.gui.PagedBookIndex;
|
||||
import net.knarcraft.bookswithoutborders.utility.BookLoader;
|
||||
import net.knarcraft.bookswithoutborders.utility.InputCleaningHelper;
|
||||
@@ -59,7 +60,7 @@ public class CommandGive implements TabExecutor {
|
||||
|
||||
StringFormatter stringFormatter = BooksWithoutBorders.getStringFormatter();
|
||||
if (arguments.length == 1) {
|
||||
stringFormatter.displayErrorMessage(sender, Translatable.ERROR_GIVE_NO_RECIPIENT);
|
||||
stringFormatter.displayErrorMessage(sender, GiveMessage.ERROR_GIVE_NO_RECIPIENT);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -91,13 +92,13 @@ public class CommandGive implements TabExecutor {
|
||||
//Try and find the target player
|
||||
Player receivingPlayer = booksWithoutBorders.getServer().getPlayerExact(receivingPlayerName);
|
||||
if (receivingPlayer == null) {
|
||||
stringFormatter.displayErrorMessage(sender, Translatable.ERROR_GIVE_RECIPIENT_UNKNOWN);
|
||||
stringFormatter.displayErrorMessage(sender, GiveMessage.ERROR_GIVE_RECIPIENT_UNKNOWN);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Make sure the receiver is able to fit the book
|
||||
if (receivingPlayer.getInventory().firstEmpty() == -1) {
|
||||
stringFormatter.displayErrorMessage(sender, Translatable.ERROR_GIVE_RECIPIENT_FULL);
|
||||
stringFormatter.displayErrorMessage(sender, GiveMessage.ERROR_GIVE_RECIPIENT_FULL);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -191,11 +192,11 @@ public class CommandGive implements TabExecutor {
|
||||
if (newBook != null) {
|
||||
//NOTE: As this method bypasses cost, it should also bypass the generation change
|
||||
receivingPlayer.getInventory().addItem(newBook);
|
||||
stringFormatter.displaySuccessMessage(sender, Translatable.SUCCESS_GIVE_SENT);
|
||||
stringFormatter.displaySuccessMessage(receivingPlayer, Translatable.SUCCESS_GIVE_RECEIVED);
|
||||
stringFormatter.displaySuccessMessage(sender, GiveMessage.SUCCESS_GIVE_SENT);
|
||||
stringFormatter.displaySuccessMessage(receivingPlayer, GiveMessage.SUCCESS_GIVE_RECEIVED);
|
||||
return true;
|
||||
} else {
|
||||
stringFormatter.displayErrorMessage(sender, Translatable.ERROR_GIVE_LOAD_FAILED);
|
||||
stringFormatter.displayErrorMessage(sender, GiveMessage.ERROR_GIVE_LOAD_FAILED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.encryption.EncryptionStyle;
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
import org.bukkit.command.Command;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.gui.PagedBookIndex;
|
||||
import net.knarcraft.bookswithoutborders.utility.BookLoader;
|
||||
import net.knarcraft.bookswithoutborders.utility.InputCleaningHelper;
|
||||
|
@@ -2,7 +2,7 @@ package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.StaticMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.container.MigrationRequest;
|
||||
import net.knarcraft.bookswithoutborders.thread.MigrationQueueThread;
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@@ -4,7 +4,9 @@ import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.BwBConfig;
|
||||
import net.knarcraft.bookswithoutborders.config.Permission;
|
||||
import net.knarcraft.bookswithoutborders.config.StaticMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.SaveMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.state.BookDirectory;
|
||||
import net.knarcraft.bookswithoutborders.utility.BookFileHelper;
|
||||
import net.knarcraft.bookswithoutborders.utility.BookHelper;
|
||||
@@ -94,7 +96,7 @@ public class CommandSave implements TabExecutor {
|
||||
String savePath = BookHelper.getBookDirectoryPathString(saveToPublicFolder ?
|
||||
BookDirectory.PUBLIC : BookDirectory.PLAYER, player);
|
||||
if (savePath == null) {
|
||||
stringFormatter.displayErrorMessage(player, Translatable.ERROR_SAVE_INVALID_PATH);
|
||||
stringFormatter.displayErrorMessage(player, SaveMessage.ERROR_SAVE_INVALID_PATH);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -110,7 +112,7 @@ public class CommandSave implements TabExecutor {
|
||||
//Make sure the used folders exist
|
||||
File file = new File(savePath);
|
||||
if (!file.exists() && !file.mkdir()) {
|
||||
stringFormatter.displayErrorMessage(player, Translatable.ERROR_SAVE_FILE_SYSTEM_ERROR);
|
||||
stringFormatter.displayErrorMessage(player, SaveMessage.ERROR_SAVE_FILE_SYSTEM_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -127,7 +129,7 @@ public class CommandSave implements TabExecutor {
|
||||
//Update the relevant book list
|
||||
BooksWithoutBorders.updateBooks(player, saveToPublicFolder);
|
||||
stringFormatter.displaySuccessMessage(player,
|
||||
stringFormatter.replacePlaceholder(Translatable.SUCCESS_SAVED, "{fileName}", newName));
|
||||
stringFormatter.replacePlaceholder(SaveMessage.SUCCESS_SAVED, "{fileName}", newName));
|
||||
} catch (IOException exception) {
|
||||
BooksWithoutBorders.log(Level.SEVERE, StaticMessage.EXCEPTION_SAVE_BOOK_FAILED.toString());
|
||||
}
|
||||
@@ -162,7 +164,7 @@ public class CommandSave implements TabExecutor {
|
||||
StringFormatter stringFormatter = BooksWithoutBorders.getStringFormatter();
|
||||
File[] foundFiles = directory.listFiles();
|
||||
if (foundFiles == null) {
|
||||
stringFormatter.displayErrorMessage(player, Translatable.ERROR_SAVE_FILE_SYSTEM_ERROR);
|
||||
stringFormatter.displayErrorMessage(player, SaveMessage.ERROR_SAVE_FILE_SYSTEM_ERROR);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -177,22 +179,22 @@ public class CommandSave implements TabExecutor {
|
||||
String fullCommand = "/" + command + " true";
|
||||
|
||||
boolean isUnnamed = fileName.contains(stringFormatter.getUnFormattedColoredMessage(
|
||||
Translatable.NEUTRAL_UNKNOWN_TITLE) + separator);
|
||||
Formatting.NEUTRAL_UNKNOWN_TITLE) + separator);
|
||||
|
||||
// Skip duplicate unnamed book saving
|
||||
if (!isUnnamed && !overwrite) {
|
||||
stringFormatter.displayErrorMessage(player, Translatable.ERROR_SAVE_DUPLICATE_NAMED);
|
||||
stringFormatter.displayErrorMessage(player, SaveMessage.ERROR_SAVE_DUPLICATE_NAMED);
|
||||
stringFormatter.displayErrorMessage(player, stringFormatter.replacePlaceholder(
|
||||
Translatable.ERROR_SAVE_OVERWRITE_REQUIRED, "{command}", fullCommand));
|
||||
SaveMessage.ERROR_SAVE_OVERWRITE_REQUIRED, "{command}", fullCommand));
|
||||
return null;
|
||||
}
|
||||
|
||||
// Skip if duplicate limit is reached
|
||||
if (foundDuplicates > duplicateLimit) {
|
||||
stringFormatter.displayErrorMessage(player, stringFormatter.replacePlaceholder(
|
||||
Translatable.ERROR_SAVE_DUPLICATE_UNNAMED, "{fileName}", fileName));
|
||||
SaveMessage.ERROR_SAVE_DUPLICATE_UNNAMED, "{fileName}", fileName));
|
||||
stringFormatter.displayErrorMessage(player, stringFormatter.replacePlaceholder(
|
||||
Translatable.ERROR_SAVE_OVERWRITE_REQUIRED, "{command}", fullCommand));
|
||||
SaveMessage.ERROR_SAVE_OVERWRITE_REQUIRED, "{command}", fullCommand));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,8 @@
|
||||
package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.state.ItemSlot;
|
||||
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
@@ -40,9 +41,9 @@ public class CommandSetAuthor implements TabExecutor {
|
||||
|
||||
if (InventoryHelper.notHoldingOneWrittenBookCheck(player,
|
||||
stringFormatter.replacePlaceholder(Translatable.ERROR_NOT_HOLDING_WRITTEN_BOOK, "{action}",
|
||||
stringFormatter.getUnFormattedColoredMessage(Translatable.ACTION_SET_AUTHOR)),
|
||||
stringFormatter.getUnFormattedColoredMessage(Formatting.ACTION_SET_AUTHOR)),
|
||||
stringFormatter.replacePlaceholder(Translatable.ERROR_ONLY_ONE_BOOK, "{action}",
|
||||
stringFormatter.getUnFormattedColoredMessage(Translatable.ACTION_SET_AUTHOR)))) {
|
||||
stringFormatter.getUnFormattedColoredMessage(Formatting.ACTION_SET_AUTHOR)))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -4,7 +4,8 @@ import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.BwBConfig;
|
||||
import net.knarcraft.bookswithoutborders.config.ConfigOption;
|
||||
import net.knarcraft.bookswithoutborders.config.StaticMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.CostMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.manager.EconomyManager;
|
||||
import net.knarcraft.bookswithoutborders.utility.InventoryHelper;
|
||||
import net.knarcraft.bookswithoutborders.utility.TabCompletionTypeHelper;
|
||||
@@ -41,7 +42,7 @@ public class CommandSetBookPrice implements TabExecutor {
|
||||
|
||||
//Warn about missing arguments
|
||||
if (arguments.length < 2) {
|
||||
stringFormatter.displayErrorMessage(sender, Translatable.ERROR_COST_NOT_SPECIFIED);
|
||||
stringFormatter.displayErrorMessage(sender, CostMessage.ERROR_COST_NOT_SPECIFIED);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -49,11 +50,11 @@ public class CommandSetBookPrice implements TabExecutor {
|
||||
try {
|
||||
price = Double.parseDouble(arguments[1]);
|
||||
if (price <= 0) {
|
||||
stringFormatter.displayErrorMessage(sender, Translatable.ERROR_COST_INVALID_QUANTITY);
|
||||
stringFormatter.displayErrorMessage(sender, CostMessage.ERROR_COST_INVALID_QUANTITY);
|
||||
return false;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
stringFormatter.displayErrorMessage(sender, Translatable.ERROR_COST_INVALID_QUANTITY);
|
||||
stringFormatter.displayErrorMessage(sender, CostMessage.ERROR_COST_INVALID_QUANTITY);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -61,7 +62,7 @@ public class CommandSetBookPrice implements TabExecutor {
|
||||
case "item" -> setItemPrice(sender, price);
|
||||
case "economy" -> setEconomyPrice(sender, price);
|
||||
default -> {
|
||||
stringFormatter.displayErrorMessage(sender, Translatable.ERROR_COST_INVALID_TYPE);
|
||||
stringFormatter.displayErrorMessage(sender, CostMessage.ERROR_COST_INVALID_TYPE);
|
||||
yield false;
|
||||
}
|
||||
};
|
||||
@@ -80,7 +81,7 @@ public class CommandSetBookPrice implements TabExecutor {
|
||||
booksWithoutBorders.getConfig().set(ConfigOption.PRICE_QUANTITY.getConfigNode(), config.getBookPriceQuantity());
|
||||
booksWithoutBorders.saveConfig();
|
||||
|
||||
BooksWithoutBorders.getStringFormatter().displaySuccessMessage(sender, Translatable.SUCCESS_COST_REMOVED);
|
||||
BooksWithoutBorders.getStringFormatter().displaySuccessMessage(sender, CostMessage.SUCCESS_COST_REMOVED);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,7 +100,7 @@ public class CommandSetBookPrice implements TabExecutor {
|
||||
|
||||
ItemStack heldItem = InventoryHelper.getHeldItem(player, true);
|
||||
if (heldItem.getType() == Material.AIR) {
|
||||
stringFormatter.displayErrorMessage(sender, Translatable.ERROR_COST_ITEM_MISSING);
|
||||
stringFormatter.displayErrorMessage(sender, CostMessage.ERROR_COST_ITEM_MISSING);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -113,7 +114,7 @@ public class CommandSetBookPrice implements TabExecutor {
|
||||
booksWithoutBorders.saveConfig();
|
||||
|
||||
stringFormatter.displaySuccessMessage(sender, stringFormatter.replacePlaceholders(
|
||||
Translatable.SUCCESS_COST_ITEM_SET, List.of("{quantity}", "{price}"),
|
||||
CostMessage.SUCCESS_COST_ITEM_SET, List.of("{quantity}", "{price}"),
|
||||
List.of(String.valueOf((int) newPriceQuantity), newPriceType)));
|
||||
return true;
|
||||
}
|
||||
@@ -138,7 +139,7 @@ public class CommandSetBookPrice implements TabExecutor {
|
||||
booksWithoutBorders.saveConfig();
|
||||
|
||||
stringFormatter.displaySuccessMessage(sender, stringFormatter.replacePlaceholder(
|
||||
Translatable.SUCCESS_COST_ECONOMY_SET, "{cost}", economyManager.getEconomy().format(newPriceQuantity)));
|
||||
CostMessage.SUCCESS_COST_ECONOMY_SET, "{cost}", economyManager.getEconomy().format(newPriceQuantity)));
|
||||
return true;
|
||||
} else {
|
||||
BooksWithoutBorders.sendErrorMessage(sender, StaticMessage.EXCEPTION_VAULT_PRICE_NOT_CHANGED.toString());
|
||||
|
@@ -1,7 +1,8 @@
|
||||
package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.BookshelfMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.container.Bookshelf;
|
||||
import net.knarcraft.bookswithoutborders.handler.BookshelfHandler;
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
@@ -35,7 +36,7 @@ public class CommandSetBookshelfData implements TabExecutor {
|
||||
|
||||
Block targetBlock = player.getTargetBlockExact(7);
|
||||
if (targetBlock == null || targetBlock.getType() != Material.CHISELED_BOOKSHELF) {
|
||||
stringFormatter.displayErrorMessage(sender, Translatable.ERROR_BOOKSHELF_NOT_FOUND);
|
||||
stringFormatter.displayErrorMessage(sender, BookshelfMessage.ERROR_BOOKSHELF_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -47,9 +48,9 @@ public class CommandSetBookshelfData implements TabExecutor {
|
||||
if (bookshelf != null) {
|
||||
shelfHandler.unregisterBookshelf(bookshelf);
|
||||
shelfHandler.save();
|
||||
stringFormatter.displaySuccessMessage(sender, Translatable.SUCCESS_BOOKSHELF_DATA_DELETED);
|
||||
stringFormatter.displaySuccessMessage(sender, BookshelfMessage.SUCCESS_BOOKSHELF_DATA_DELETED);
|
||||
} else {
|
||||
stringFormatter.displayErrorMessage(sender, Translatable.ERROR_BOOKSHELF_NOT_REGISTERED);
|
||||
stringFormatter.displayErrorMessage(sender, BookshelfMessage.ERROR_BOOKSHELF_NOT_REGISTERED);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
@@ -72,16 +73,16 @@ public class CommandSetBookshelfData implements TabExecutor {
|
||||
bookshelf.setTitle(builder.toString());
|
||||
}
|
||||
shelfHandler.save();
|
||||
stringFormatter.displaySuccessMessage(sender, Translatable.SUCCESS_BOOKSHELF_TITLE_SET);
|
||||
stringFormatter.displaySuccessMessage(sender, BookshelfMessage.SUCCESS_BOOKSHELF_TITLE_SET);
|
||||
return true;
|
||||
case "lore":
|
||||
if (bookshelf == null) {
|
||||
stringFormatter.displayErrorMessage(sender, Translatable.ERROR_BOOKSHELF_NAME_REQUIRED);
|
||||
stringFormatter.displayErrorMessage(sender, BookshelfMessage.ERROR_BOOKSHELF_NAME_REQUIRED);
|
||||
} else {
|
||||
List<String> loreParts = Arrays.asList(builder.toString().split(BooksWithoutBorders.getConfiguration().getLoreSeparator()));
|
||||
bookshelf.setLore(loreParts);
|
||||
shelfHandler.save();
|
||||
stringFormatter.displaySuccessMessage(sender, Translatable.SUCCESS_BOOKSHELF_LORE_SET);
|
||||
stringFormatter.displaySuccessMessage(sender, BookshelfMessage.SUCCESS_BOOKSHELF_LORE_SET);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -0,0 +1,47 @@
|
||||
package net.knarcraft.bookswithoutborders.config.translation;
|
||||
|
||||
import net.knarcraft.knarlib.formatting.TranslatableMessage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Translatable messages related to the set bookshelf data command
|
||||
*/
|
||||
public enum BookshelfMessage implements TranslatableMessage {
|
||||
|
||||
/**
|
||||
* The success message displayed when a bookshelf's data has been successfully removed
|
||||
*/
|
||||
SUCCESS_BOOKSHELF_DATA_DELETED,
|
||||
|
||||
/**
|
||||
* The success message displayed when a bookshelf's title is successfully set
|
||||
*/
|
||||
SUCCESS_BOOKSHELF_TITLE_SET,
|
||||
|
||||
/**
|
||||
* The success message displayed when a bookshelf's lore is successfully set
|
||||
*/
|
||||
SUCCESS_BOOKSHELF_LORE_SET,
|
||||
|
||||
/**
|
||||
* The error displayed when attempting to alter bookshelf data while not looking at a bookshelf
|
||||
*/
|
||||
ERROR_BOOKSHELF_NOT_FOUND,
|
||||
|
||||
/**
|
||||
* The error displayed when attempting to deleting a bookshelf while looking at a non-registered bookshelf
|
||||
*/
|
||||
ERROR_BOOKSHELF_NOT_REGISTERED,
|
||||
|
||||
/**
|
||||
* The error displayed when attempting to set other bookshelf data before setting the name
|
||||
*/
|
||||
ERROR_BOOKSHELF_NAME_REQUIRED,
|
||||
;
|
||||
|
||||
@Override
|
||||
public @NotNull TranslatableMessage[] getAllMessages() {
|
||||
return Translatable.values();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
package net.knarcraft.bookswithoutborders.config.translation;
|
||||
|
||||
import net.knarcraft.knarlib.formatting.TranslatableMessage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Messages related to book cost
|
||||
*/
|
||||
public enum CostMessage implements TranslatableMessage {
|
||||
|
||||
/**
|
||||
* The success message displayed when the book creation cost is successfully removed
|
||||
*/
|
||||
SUCCESS_COST_REMOVED,
|
||||
|
||||
/**
|
||||
* The success message displayed when the book creation cost is successfully set to an item
|
||||
*/
|
||||
SUCCESS_COST_ITEM_SET,
|
||||
|
||||
/**
|
||||
* The success message displayed when the book creation cost is successfully set to an economy cost
|
||||
*/
|
||||
SUCCESS_COST_ECONOMY_SET,
|
||||
|
||||
/**
|
||||
* The error displayed when trying to do a Vault transaction while Vault is unavailable
|
||||
*/
|
||||
ERROR_VAULT_COST_BUT_UNAVAILABLE,
|
||||
|
||||
/**
|
||||
* The error displayed when attempting to specify a cost without necessary arguments
|
||||
*/
|
||||
ERROR_COST_NOT_SPECIFIED,
|
||||
|
||||
/**
|
||||
* The error displayed when specifying an invalid cost quantity when setting a cost
|
||||
*/
|
||||
ERROR_COST_INVALID_QUANTITY,
|
||||
|
||||
/**
|
||||
* The error displayed when specifying an invalid cost type when setting a cost
|
||||
*/
|
||||
ERROR_COST_INVALID_TYPE,
|
||||
|
||||
/**
|
||||
* The error displayed when attempting to set an item cost without providing an item
|
||||
*/
|
||||
ERROR_COST_ITEM_MISSING,
|
||||
;
|
||||
|
||||
@Override
|
||||
public @NotNull TranslatableMessage[] getAllMessages() {
|
||||
return Translatable.values();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,107 @@
|
||||
package net.knarcraft.bookswithoutborders.config.translation;
|
||||
|
||||
import net.knarcraft.knarlib.formatting.TranslatableMessage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Customizable formatting
|
||||
*/
|
||||
public enum Formatting implements TranslatableMessage {
|
||||
|
||||
/**
|
||||
* The header displayed before printing all commands
|
||||
*/
|
||||
NEUTRAL_COMMANDS_HEADER,
|
||||
|
||||
/**
|
||||
* The format used when displaying a book's economy price
|
||||
*/
|
||||
NEUTRAL_COMMANDS_BOOK_PRICE_ECO,
|
||||
|
||||
/**
|
||||
* The format used when displaying a book's item price
|
||||
*/
|
||||
NEUTRAL_COMMANDS_BOOK_PRICE_ITEM,
|
||||
|
||||
/**
|
||||
* The format used when displaying one command entry
|
||||
*/
|
||||
NEUTRAL_COMMANDS_COMMAND,
|
||||
|
||||
/**
|
||||
* The string used when displaying that a command requires no permission
|
||||
*/
|
||||
NEUTRAL_COMMANDS_COMMAND_NO_PERMISSION_REQUIRED,
|
||||
|
||||
/**
|
||||
* The format used when displaying a command's required permission
|
||||
*/
|
||||
NEUTRAL_COMMANDS_COMMAND_PERMISSION,
|
||||
|
||||
/**
|
||||
* The format used when printing aliases
|
||||
*/
|
||||
NEUTRAL_COMMANDS_ALIASES,
|
||||
|
||||
/**
|
||||
* The translation of unknown author for a book
|
||||
*/
|
||||
NEUTRAL_UNKNOWN_AUTHOR,
|
||||
|
||||
/**
|
||||
* The translation of unknown title for a book
|
||||
*/
|
||||
NEUTRAL_UNKNOWN_TITLE,
|
||||
|
||||
/**
|
||||
* The format used when generating a title + author title page
|
||||
*/
|
||||
NEUTRAL_TITLE_PAGE_TITLE_AUTHOR_FORMAT,
|
||||
|
||||
/**
|
||||
* The formatting used when formatting the header on a title page
|
||||
*/
|
||||
NEUTRAL_TITLE_PAGE_HEADER_FORMAT,
|
||||
|
||||
/**
|
||||
* The format used when formatting text on a title page
|
||||
*/
|
||||
NEUTRAL_TITLE_PAGE_TEXT_FORMAT,
|
||||
|
||||
/**
|
||||
* The translation of the copy action
|
||||
*/
|
||||
ACTION_COPY,
|
||||
|
||||
/**
|
||||
* The translation of the clear action
|
||||
*/
|
||||
ACTION_CLEAR,
|
||||
|
||||
/**
|
||||
* The translation of the decrypt action
|
||||
*/
|
||||
ACTION_DECRYPT,
|
||||
|
||||
/**
|
||||
* The translation of the encrypt action
|
||||
*/
|
||||
ACTION_ENCRYPT,
|
||||
|
||||
/**
|
||||
* The translation of the add title page action
|
||||
*/
|
||||
ACTION_ADD_TITLE_AUTHOR_PAGE,
|
||||
|
||||
/**
|
||||
* The translation of the set author action
|
||||
*/
|
||||
ACTION_SET_AUTHOR,
|
||||
;
|
||||
|
||||
@Override
|
||||
public @NotNull TranslatableMessage[] getAllMessages() {
|
||||
return Translatable.values();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
package net.knarcraft.bookswithoutborders.config.translation;
|
||||
|
||||
import net.knarcraft.knarlib.formatting.TranslatableMessage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Translatable messages related to the give command
|
||||
*/
|
||||
public enum GiveMessage implements TranslatableMessage {
|
||||
|
||||
/**
|
||||
* The success message displayed when a book is successfully sent
|
||||
*/
|
||||
SUCCESS_GIVE_SENT,
|
||||
|
||||
/**
|
||||
* The success message displayed when a book is successfully received
|
||||
*/
|
||||
SUCCESS_GIVE_RECEIVED,
|
||||
|
||||
/**
|
||||
* The error displayed after using the give command without specifying a recipient
|
||||
*/
|
||||
ERROR_GIVE_NO_RECIPIENT,
|
||||
|
||||
/**
|
||||
* The error displayed when using the give command with an invalid recipient
|
||||
*/
|
||||
ERROR_GIVE_RECIPIENT_UNKNOWN,
|
||||
|
||||
/**
|
||||
* The error displayed when using the give command with a recipient with a full inventory
|
||||
*/
|
||||
ERROR_GIVE_RECIPIENT_FULL,
|
||||
|
||||
/**
|
||||
* The error displayed when a book is not properly loaded when using the give command
|
||||
*/
|
||||
ERROR_GIVE_LOAD_FAILED,
|
||||
;
|
||||
|
||||
@Override
|
||||
public @NotNull TranslatableMessage[] getAllMessages() {
|
||||
return Translatable.values();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
package net.knarcraft.bookswithoutborders.config.translation;
|
||||
|
||||
import net.knarcraft.knarlib.formatting.TranslatableMessage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Translatable messages related to saving
|
||||
*/
|
||||
public enum SaveMessage implements TranslatableMessage {
|
||||
|
||||
/**
|
||||
* The success message displayed when a book is successfully saved
|
||||
*/
|
||||
SUCCESS_SAVED,
|
||||
|
||||
/**
|
||||
* The error displayed when unable to generate a valid save path for a book
|
||||
*/
|
||||
ERROR_SAVE_INVALID_PATH,
|
||||
|
||||
/**
|
||||
* The error displayed when unable to create necessary folders for saving a book
|
||||
*/
|
||||
ERROR_SAVE_FILE_SYSTEM_ERROR,
|
||||
|
||||
/**
|
||||
* The error displayed when enabling overwriting is necessary to save a book
|
||||
*/
|
||||
ERROR_SAVE_OVERWRITE_REQUIRED,
|
||||
|
||||
/**
|
||||
* The error displayed when attempting to save a duplicate unnamed book
|
||||
*/
|
||||
ERROR_SAVE_DUPLICATE_NAMED,
|
||||
|
||||
/**
|
||||
* The error displayed when attempting to save a duplicate named book exceeding the duplicate limit
|
||||
*/
|
||||
ERROR_SAVE_DUPLICATE_UNNAMED,
|
||||
;
|
||||
|
||||
@Override
|
||||
public @NotNull TranslatableMessage[] getAllMessages() {
|
||||
return Translatable.values();
|
||||
}
|
||||
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
package net.knarcraft.bookswithoutborders.config;
|
||||
package net.knarcraft.bookswithoutborders.config.translation;
|
||||
|
||||
import net.knarcraft.knarlib.formatting.TranslatableMessage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -38,16 +38,6 @@ public enum Translatable implements TranslatableMessage {
|
||||
*/
|
||||
SUCCESS_FORMATTED,
|
||||
|
||||
/**
|
||||
* The success message displayed when a book is successfully sent
|
||||
*/
|
||||
SUCCESS_GIVE_SENT,
|
||||
|
||||
/**
|
||||
* The success message displayed when a book is successfully received
|
||||
*/
|
||||
SUCCESS_GIVE_RECEIVED,
|
||||
|
||||
/**
|
||||
* The success message displayed when a title page is successfully added
|
||||
*/
|
||||
@@ -73,46 +63,11 @@ public enum Translatable implements TranslatableMessage {
|
||||
*/
|
||||
SUCCESS_RELOADED,
|
||||
|
||||
/**
|
||||
* The success message displayed when a book is successfully saved
|
||||
*/
|
||||
SUCCESS_SAVED,
|
||||
|
||||
/**
|
||||
* The success message displayed when a book author is successfully set
|
||||
*/
|
||||
SUCCESS_SET_AUTHOR,
|
||||
|
||||
/**
|
||||
* The success message displayed when the book creation cost is successfully removed
|
||||
*/
|
||||
SUCCESS_COST_REMOVED,
|
||||
|
||||
/**
|
||||
* The success message displayed when the book creation cost is successfully set to an item
|
||||
*/
|
||||
SUCCESS_COST_ITEM_SET,
|
||||
|
||||
/**
|
||||
* The success message displayed when the book creation cost is successfully set to an economy cost
|
||||
*/
|
||||
SUCCESS_COST_ECONOMY_SET,
|
||||
|
||||
/**
|
||||
* The success message displayed when a bookshelf's data has been successfully removed
|
||||
*/
|
||||
SUCCESS_BOOKSHELF_DATA_DELETED,
|
||||
|
||||
/**
|
||||
* The success message displayed when a bookshelf's title is successfully set
|
||||
*/
|
||||
SUCCESS_BOOKSHELF_TITLE_SET,
|
||||
|
||||
/**
|
||||
* The success message displayed when a bookshelf's lore is successfully set
|
||||
*/
|
||||
SUCCESS_BOOKSHELF_LORE_SET,
|
||||
|
||||
/**
|
||||
* The error to display when the console attempts to run a player-only command
|
||||
*/
|
||||
@@ -163,11 +118,6 @@ public enum Translatable implements TranslatableMessage {
|
||||
*/
|
||||
ERROR_INVENTORY_FULL,
|
||||
|
||||
/**
|
||||
* The error displayed when trying to do a Vault transaction while Vault is unavailable
|
||||
*/
|
||||
ERROR_VAULT_COST_BUT_UNAVAILABLE,
|
||||
|
||||
/**
|
||||
* The error displayed when trying to decrypt a book without displaying the key
|
||||
*/
|
||||
@@ -223,31 +173,11 @@ public enum Translatable implements TranslatableMessage {
|
||||
*/
|
||||
ERROR_ENCRYPT_EMPTY,
|
||||
|
||||
/**
|
||||
* The error displayed after using the give command without specifying a recipient
|
||||
*/
|
||||
ERROR_GIVE_NO_RECIPIENT,
|
||||
|
||||
/**
|
||||
* The error displayed when using the give command with an invalid recipient
|
||||
*/
|
||||
ERROR_GIVE_RECIPIENT_UNKNOWN,
|
||||
|
||||
/**
|
||||
* The error displayed when using the give command with a recipient with a full inventory
|
||||
*/
|
||||
ERROR_GIVE_RECIPIENT_FULL,
|
||||
|
||||
/**
|
||||
* The error displayed when using the give command with an invalid number of copies (unlikely to ever happen)
|
||||
*/
|
||||
ERROR_INVALID_COPIES_AMOUNT,
|
||||
|
||||
/**
|
||||
* The error displayed when a book is not properly loaded when using the give command
|
||||
*/
|
||||
ERROR_GIVE_LOAD_FAILED,
|
||||
|
||||
/**
|
||||
* The error displayed when running a command without holding any book in the main hand
|
||||
*/
|
||||
@@ -288,31 +218,6 @@ public enum Translatable implements TranslatableMessage {
|
||||
*/
|
||||
ERROR_RELOAD_FAILED,
|
||||
|
||||
/**
|
||||
* The error displayed when unable to generate a valid save path for a book
|
||||
*/
|
||||
ERROR_SAVE_INVALID_PATH,
|
||||
|
||||
/**
|
||||
* The error displayed when unable to create necessary folders for saving a book
|
||||
*/
|
||||
ERROR_SAVE_FILE_SYSTEM_ERROR,
|
||||
|
||||
/**
|
||||
* The error displayed when enabling overwriting is necessary to save a book
|
||||
*/
|
||||
ERROR_SAVE_OVERWRITE_REQUIRED,
|
||||
|
||||
/**
|
||||
* The error displayed when attempting to save a duplicate unnamed book
|
||||
*/
|
||||
ERROR_SAVE_DUPLICATE_NAMED,
|
||||
|
||||
/**
|
||||
* The error displayed when attempting to save a duplicate named book exceeding the duplicate limit
|
||||
*/
|
||||
ERROR_SAVE_DUPLICATE_UNNAMED,
|
||||
|
||||
/**
|
||||
* The error displayed when specifying a command, but the command is unknown
|
||||
*/
|
||||
@@ -322,136 +227,6 @@ public enum Translatable implements TranslatableMessage {
|
||||
* The error displayed when changing a book's author without providing the new author
|
||||
*/
|
||||
ERROR_AUTHOR_BLANK,
|
||||
|
||||
/**
|
||||
* The error displayed when attempting to specify a cost without necessary arguments
|
||||
*/
|
||||
ERROR_COST_NOT_SPECIFIED,
|
||||
|
||||
/**
|
||||
* The error displayed when specifying an invalid cost quantity when setting a cost
|
||||
*/
|
||||
ERROR_COST_INVALID_QUANTITY,
|
||||
|
||||
/**
|
||||
* The error displayed when specifying an invalid cost type when setting a cost
|
||||
*/
|
||||
ERROR_COST_INVALID_TYPE,
|
||||
|
||||
/**
|
||||
* The error displayed when attempting to set an item cost without providing an item
|
||||
*/
|
||||
ERROR_COST_ITEM_MISSING,
|
||||
|
||||
/**
|
||||
* The error displayed when attempting to alter bookshelf data while not looking at a bookshelf
|
||||
*/
|
||||
ERROR_BOOKSHELF_NOT_FOUND,
|
||||
|
||||
/**
|
||||
* The error displayed when attempting to deleting a bookshelf while looking at a non-registered bookshelf
|
||||
*/
|
||||
ERROR_BOOKSHELF_NOT_REGISTERED,
|
||||
|
||||
/**
|
||||
* The error displayed when attempting to set other bookshelf data before setting the name
|
||||
*/
|
||||
ERROR_BOOKSHELF_NAME_REQUIRED,
|
||||
|
||||
/**
|
||||
* The header displayed before printing all commands
|
||||
*/
|
||||
NEUTRAL_COMMANDS_HEADER,
|
||||
|
||||
/**
|
||||
* The format used when displaying a book's economy price
|
||||
*/
|
||||
NEUTRAL_COMMANDS_BOOK_PRICE_ECO,
|
||||
|
||||
/**
|
||||
* The format used when displaying a book's item price
|
||||
*/
|
||||
NEUTRAL_COMMANDS_BOOK_PRICE_ITEM,
|
||||
|
||||
/**
|
||||
* The format used when displaying one command entry
|
||||
*/
|
||||
NEUTRAL_COMMANDS_COMMAND,
|
||||
|
||||
/**
|
||||
* The string used when displaying that a command requires no permission
|
||||
*/
|
||||
NEUTRAL_COMMANDS_COMMAND_NO_PERMISSION_REQUIRED,
|
||||
|
||||
/**
|
||||
* The format used when displaying a command's required permission
|
||||
*/
|
||||
NEUTRAL_COMMANDS_COMMAND_PERMISSION,
|
||||
|
||||
/**
|
||||
* The format used when printing aliases
|
||||
*/
|
||||
NEUTRAL_COMMANDS_ALIASES,
|
||||
|
||||
/**
|
||||
* The translation of unknown author for a book
|
||||
*/
|
||||
NEUTRAL_UNKNOWN_AUTHOR,
|
||||
|
||||
/**
|
||||
* The translation of unknown title for a book
|
||||
*/
|
||||
NEUTRAL_UNKNOWN_TITLE,
|
||||
|
||||
/**
|
||||
* The format used when generating a title + author title page
|
||||
*/
|
||||
NEUTRAL_TITLE_PAGE_TITLE_AUTHOR_FORMAT,
|
||||
|
||||
/**
|
||||
* The formatting used when formatting the header on a title page
|
||||
*/
|
||||
NEUTRAL_TITLE_PAGE_HEADER_FORMAT,
|
||||
|
||||
/**
|
||||
* The format used when formatting text on a title page
|
||||
*/
|
||||
NEUTRAL_TITLE_PAGE_TEXT_FORMAT,
|
||||
|
||||
/**
|
||||
* The translation of the copy action
|
||||
*/
|
||||
ACTION_COPY,
|
||||
|
||||
/**
|
||||
* The translation of the clear action
|
||||
*/
|
||||
ACTION_CLEAR,
|
||||
|
||||
/**
|
||||
* The translation of the decrypt action
|
||||
*/
|
||||
ACTION_DECRYPT,
|
||||
|
||||
/**
|
||||
* The translation of the encrypt action
|
||||
*/
|
||||
ACTION_ENCRYPT,
|
||||
|
||||
/**
|
||||
* The translation of the format action
|
||||
*/
|
||||
ACTION_FORMAT,
|
||||
|
||||
/**
|
||||
* The translation of the add title page action
|
||||
*/
|
||||
ACTION_ADD_TITLE_AUTHOR_PAGE,
|
||||
|
||||
/**
|
||||
* The translation of the set author action
|
||||
*/
|
||||
ACTION_SET_AUTHOR,
|
||||
;
|
||||
|
||||
@Override
|
@@ -2,7 +2,7 @@ package net.knarcraft.bookswithoutborders.manager;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.BwBConfig;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.CostMessage;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
@@ -167,7 +167,7 @@ public class EconomyManager {
|
||||
*/
|
||||
private boolean payForBookPrintingEconomy(@NotNull Player player, double cost, int numCopies) {
|
||||
if (economy == null) {
|
||||
BooksWithoutBorders.getStringFormatter().displayErrorMessage(player, Translatable.ERROR_VAULT_COST_BUT_UNAVAILABLE);
|
||||
BooksWithoutBorders.getStringFormatter().displayErrorMessage(player, CostMessage.ERROR_VAULT_COST_BUT_UNAVAILABLE);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package net.knarcraft.bookswithoutborders.utility;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.state.BookDirectory;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -216,7 +216,7 @@ public final class BookFileHelper {
|
||||
if (stripped.contains(separator)) {
|
||||
return stripped.split(separator)[1];
|
||||
} else {
|
||||
return BooksWithoutBorders.getStringFormatter().getUnFormattedColoredMessage(Translatable.NEUTRAL_UNKNOWN_AUTHOR);
|
||||
return BooksWithoutBorders.getStringFormatter().getUnFormattedColoredMessage(Formatting.NEUTRAL_UNKNOWN_AUTHOR);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,7 @@ package net.knarcraft.bookswithoutborders.utility;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.BwBConfig;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.state.BookDirectory;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@@ -193,7 +193,7 @@ public final class BookHelper {
|
||||
} else {
|
||||
authorName = book.getAuthor();
|
||||
if (authorName == null) {
|
||||
authorName = BooksWithoutBorders.getStringFormatter().getUnFormattedColoredMessage(Translatable.NEUTRAL_UNKNOWN_AUTHOR);
|
||||
authorName = BooksWithoutBorders.getStringFormatter().getUnFormattedColoredMessage(Formatting.NEUTRAL_UNKNOWN_AUTHOR);
|
||||
}
|
||||
}
|
||||
return authorName;
|
||||
@@ -211,7 +211,7 @@ public final class BookHelper {
|
||||
bookName = book.getTitle();
|
||||
}
|
||||
if (bookName == null) {
|
||||
bookName = BooksWithoutBorders.getStringFormatter().getUnFormattedColoredMessage(Translatable.NEUTRAL_UNKNOWN_TITLE);
|
||||
bookName = BooksWithoutBorders.getStringFormatter().getUnFormattedColoredMessage(Formatting.NEUTRAL_UNKNOWN_TITLE);
|
||||
}
|
||||
return bookName;
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package net.knarcraft.bookswithoutborders.utility;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.encryption.AESConfiguration;
|
||||
import net.knarcraft.bookswithoutborders.encryption.EncryptionStyle;
|
||||
import net.knarcraft.knarlib.formatting.StringFormatter;
|
||||
@@ -207,9 +207,9 @@ public final class BookToFromTextHelper {
|
||||
|
||||
bookMetadata.setGeneration(BookMeta.Generation.valueOf(bookYml.getString("Generation", "ORIGINAL")));
|
||||
bookMetadata.setTitle(bookYml.getString("Title",
|
||||
stringFormatter.getUnFormattedColoredMessage(Translatable.NEUTRAL_UNKNOWN_TITLE)));
|
||||
stringFormatter.getUnFormattedColoredMessage(Formatting.NEUTRAL_UNKNOWN_TITLE)));
|
||||
bookMetadata.setAuthor(authorFromUUID(bookYml.getString("Author",
|
||||
stringFormatter.getUnFormattedColoredMessage(Translatable.NEUTRAL_UNKNOWN_AUTHOR))));
|
||||
stringFormatter.getUnFormattedColoredMessage(Formatting.NEUTRAL_UNKNOWN_AUTHOR))));
|
||||
bookMetadata.setPages(bookYml.getStringList("Pages"));
|
||||
bookMetadata.setLore(bookYml.getStringList("Lore"));
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
@@ -55,6 +55,8 @@ commands:
|
||||
Encrypts book so that only players with the bookswithoutborders.decrypt.<groupName> permission may decrypt the
|
||||
book by holding and interacting with the book in their hand. The key isn't necessary for decryption, it's only
|
||||
used for properly scrambling the book's contents.
|
||||
"style" is not required. Possible values are "dna", "substitution", "aes", "onetimepad" and "magic".
|
||||
If real encryption is enabled, possible methods are restricted.
|
||||
aliases:
|
||||
- bwbgencrypt
|
||||
usage: /<command> <group name> <key> [encryption style]
|
||||
|
@@ -25,7 +25,6 @@ en:
|
||||
ACTION_CLEAR: "clear"
|
||||
ACTION_DECRYPT: "decrypt"
|
||||
ACTION_ENCRYPT: "encrypt"
|
||||
ACTION_FORMAT: "format"
|
||||
ACTION_ADD_TITLE_AUTHOR_PAGE: "add an author title page to"
|
||||
ACTION_SET_AUTHOR: "set author"
|
||||
ERROR_PLAYER_ONLY: "This command can only be used by a player!"
|
||||
|
Reference in New Issue
Block a user