Replaces hard-coded placeholder string with translatable messages
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:
@@ -33,6 +33,7 @@ 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.Placeholder;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.SaveMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.SignText;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
@@ -212,6 +213,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
||||
translator.registerMessageCategory(CostMessage.SUCCESS_COST_ITEM_SET);
|
||||
translator.registerMessageCategory(SaveMessage.SUCCESS_SAVED);
|
||||
translator.registerMessageCategory(SignText.SIGN_HEADER);
|
||||
translator.registerMessageCategory(Placeholder.AUTHOR);
|
||||
|
||||
StringFormatter stringFormatter = new StringFormatter(this.getDescription().getName(), translator);
|
||||
stringFormatter.setColorConversion(ColorConversion.RGB);
|
||||
@@ -303,7 +305,7 @@ public class BooksWithoutBorders extends JavaPlugin {
|
||||
pluginCommand.setExecutor(executor);
|
||||
} else {
|
||||
getLogger().log(Level.SEVERE, new FormatBuilder(StaticMessage.EXCEPTION_COMMAND_REGISTRATION_FAILED.toString()).
|
||||
replace("{command}", commandName).toString());
|
||||
replace(Placeholder.COMMAND, commandName).toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,7 @@ package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Placeholder;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.utility.BookMetaUtil;
|
||||
import net.knarcraft.bookswithoutborders.utility.InputCleaningUtil;
|
||||
@@ -44,8 +45,7 @@ public class CommandAddTitlePage implements TabExecutor {
|
||||
int index;
|
||||
if (arguments.length < 1) {
|
||||
if (InventoryUtil.notHoldingOneWrittenBookCheck(player,
|
||||
new FormatBuilder(Translatable.ERROR_NOT_HOLDING_WRITTEN_BOOK).replace("{action}", Translatable.ACTION_ADD_TITLE_AUTHOR_PAGE),
|
||||
new FormatBuilder(Translatable.ERROR_ONLY_ONE_BOOK).replace("{action}", Translatable.ACTION_ADD_TITLE_AUTHOR_PAGE))) {
|
||||
Translatable.ACTION_ADD_TITLE_AUTHOR_PAGE)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -99,9 +99,9 @@ public class CommandAddTitlePage implements TabExecutor {
|
||||
// Add a page with the book title and book author
|
||||
String loreSeparator = BooksWithoutBorders.getConfiguration().getLoreSeparator();
|
||||
String pageText = formatTitle(new FormatBuilder(Formatting.NEUTRAL_TITLE_PAGE_TITLE_AUTHOR_FORMAT).
|
||||
replace("{title}", InputCleaningUtil.stripColor(BookMetaUtil.getBookTitle(bookMeta))).
|
||||
replace("{separator}", loreSeparator).
|
||||
replace("{author}", InputCleaningUtil.stripColor(BookMetaUtil.getBookAuthor(bookMeta, null))).toString());
|
||||
replace(Placeholder.TITLE, InputCleaningUtil.stripColor(BookMetaUtil.getBookTitle(bookMeta))).
|
||||
replace(Placeholder.SEPARATOR, loreSeparator).
|
||||
replace(Placeholder.AUTHOR, InputCleaningUtil.stripColor(BookMetaUtil.getBookAuthor(bookMeta, null))).toString());
|
||||
|
||||
if (index > pages.size()) {
|
||||
pages.add(pageText);
|
||||
@@ -138,13 +138,13 @@ public class CommandAddTitlePage implements TabExecutor {
|
||||
String loreSeparator = BooksWithoutBorders.getConfiguration().getLoreSeparator();
|
||||
if (input.contains(loreSeparator)) {
|
||||
String[] parts = input.split(loreSeparator);
|
||||
FormatBuilder builder = new FormatBuilder(Formatting.NEUTRAL_TITLE_PAGE_HEADER_FORMAT).replace("{header}", parts[0]);
|
||||
FormatBuilder builder = new FormatBuilder(Formatting.NEUTRAL_TITLE_PAGE_HEADER_FORMAT).replace(Placeholder.HEADER, parts[0]);
|
||||
for (int i = 1; i < parts.length; i++) {
|
||||
builder.append(Formatting.NEUTRAL_TITLE_PAGE_TEXT_FORMAT).replace("{text}", parts[i]);
|
||||
builder.append(Formatting.NEUTRAL_TITLE_PAGE_TEXT_FORMAT).replace(Placeholder.TEXT, parts[i]);
|
||||
}
|
||||
return builder.color().toString();
|
||||
} else {
|
||||
return new FormatBuilder(Formatting.NEUTRAL_TITLE_PAGE_HEADER_FORMAT).replace("{header}", input).color().toString();
|
||||
return new FormatBuilder(Formatting.NEUTRAL_TITLE_PAGE_HEADER_FORMAT).replace(Placeholder.HEADER, input).color().toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -7,6 +7,7 @@ import net.knarcraft.bookswithoutborders.config.Permission;
|
||||
import net.knarcraft.bookswithoutborders.config.StaticMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.CostMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Placeholder;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.manager.EconomyManager;
|
||||
import net.knarcraft.knarlib.formatting.FormatBuilder;
|
||||
@@ -49,8 +50,8 @@ public class CommandBooksWithoutBorders implements TabExecutor {
|
||||
commands = getCommands(sender);
|
||||
commandExplanation = getCommandExplanation(true);
|
||||
}
|
||||
new FormatBuilder(Formatting.NEUTRAL_COMMANDS_HEADER).replace("{bookPrice}", getBookPrice()).
|
||||
replace("{commands}", commands).replace("{commandExplanation}", commandExplanation).
|
||||
new FormatBuilder(Formatting.NEUTRAL_COMMANDS_HEADER).replace(Placeholder.BOOK_PRICE, getBookPrice()).
|
||||
replace(Placeholder.COMMANDS, commands).replace(Placeholder.COMMAND_EXPLANATION, commandExplanation).
|
||||
success(sender);
|
||||
return true;
|
||||
}
|
||||
@@ -86,14 +87,14 @@ public class CommandBooksWithoutBorders implements TabExecutor {
|
||||
Material bookPriceType = config.getBookPriceType();
|
||||
double bookPriceQuantity = config.getBookPriceQuantity();
|
||||
if (bookPriceType != Material.AIR) {
|
||||
return new FormatBuilder(Formatting.NEUTRAL_COMMANDS_BOOK_PRICE_ITEM).replace("{quantity}",
|
||||
String.valueOf((int) bookPriceQuantity)).replace("{type}", bookPriceType.toString()).toString();
|
||||
return new FormatBuilder(Formatting.NEUTRAL_COMMANDS_BOOK_PRICE_ITEM).replace(Placeholder.QUANTITY,
|
||||
String.valueOf((int) bookPriceQuantity)).replace(Placeholder.TYPE, bookPriceType.toString()).toString();
|
||||
} else {
|
||||
EconomyManager economyManager = BooksWithoutBorders.getConfiguration().getEconomyManager();
|
||||
if (economyManager.getEconomy() == null) {
|
||||
return new FormatBuilder(CostMessage.ERROR_VAULT_COST_BUT_UNAVAILABLE) + "\n";
|
||||
} else {
|
||||
return new FormatBuilder(Formatting.NEUTRAL_COMMANDS_BOOK_PRICE_ECO).replace("{price}",
|
||||
return new FormatBuilder(Formatting.NEUTRAL_COMMANDS_BOOK_PRICE_ECO).replace(Placeholder.COST,
|
||||
economyManager.getEconomy().format(bookPriceQuantity)).toString();
|
||||
}
|
||||
}
|
||||
@@ -141,7 +142,7 @@ public class CommandBooksWithoutBorders implements TabExecutor {
|
||||
PluginCommand pluginCommand = BooksWithoutBorders.getInstance().getCommand(bwBCommand.toString());
|
||||
if (pluginCommand == null) {
|
||||
BooksWithoutBorders.log(Level.SEVERE, new FormatBuilder(StaticMessage.EXCEPTION_COMMAND_NOT_REGISTERED.toString()).
|
||||
replace("{command}", bwBCommand.toString()).toString());
|
||||
replace(Placeholder.COMMAND, bwBCommand.toString()).toString());
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -161,18 +162,18 @@ public class CommandBooksWithoutBorders implements TabExecutor {
|
||||
} else {
|
||||
commandUsage = pluginCommand.getUsage().replace("<command>", pluginCommand.getName());
|
||||
description = pluginCommand.getDescription();
|
||||
aliases = new FormatBuilder(Formatting.NEUTRAL_COMMANDS_ALIASES).replace("{aliases}",
|
||||
aliases = new FormatBuilder(Formatting.NEUTRAL_COMMANDS_ALIASES).replace(Placeholder.ALIASES,
|
||||
String.join(",", pluginCommand.getAliases())).toString();
|
||||
}
|
||||
|
||||
String commandDescription = new FormatBuilder(Formatting.NEUTRAL_COMMANDS_COMMAND).replace("{usage}",
|
||||
commandUsage).replace("{description}", description).replace("{aliases}", aliases).toString();
|
||||
String commandDescription = new FormatBuilder(Formatting.NEUTRAL_COMMANDS_COMMAND).replace(Placeholder.USAGE,
|
||||
commandUsage).replace(Placeholder.DESCRIPTION, description).replace(Placeholder.ALIASES, aliases).toString();
|
||||
|
||||
if (!summary && sender.hasPermission(Permission.ADMIN.toString())) {
|
||||
if (permission == null) {
|
||||
permission = new FormatBuilder(Formatting.NEUTRAL_COMMANDS_COMMAND_NO_PERMISSION_REQUIRED).toString();
|
||||
}
|
||||
commandDescription += new FormatBuilder(Formatting.NEUTRAL_COMMANDS_COMMAND_PERMISSION).replace("{permission}", permission).toString();
|
||||
commandDescription += new FormatBuilder(Formatting.NEUTRAL_COMMANDS_COMMAND_PERMISSION).replace(Placeholder.PERMISSION, permission).toString();
|
||||
}
|
||||
return commandDescription;
|
||||
}
|
||||
|
@@ -30,9 +30,7 @@ public class CommandClear implements TabExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (InventoryUtil.notHoldingOneWritableBookCheck(player,
|
||||
new FormatBuilder(Translatable.ERROR_NOT_HOLDING_WRITABLE_BOOK).replace("{action}", Translatable.ACTION_CLEAR),
|
||||
new FormatBuilder(Translatable.ERROR_ONLY_ONE_BOOK).replace("{action}", Translatable.ACTION_CLEAR))) {
|
||||
if (InventoryUtil.notHoldingOneWritableBookCheck(player, Translatable.ACTION_CLEAR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -36,8 +36,7 @@ public class CommandCopy implements TabExecutor {
|
||||
}
|
||||
|
||||
if (InventoryUtil.notHoldingOneWrittenBookCheck(player,
|
||||
new FormatBuilder(Translatable.ERROR_NOT_HOLDING_WRITTEN_BOOK).replace("{action}", Translatable.ACTION_COPY),
|
||||
new FormatBuilder(Translatable.ERROR_ONLY_ONE_BOOK).replace("{action}", Translatable.ACTION_COPY))) {
|
||||
Translatable.ACTION_COPY)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -34,8 +34,7 @@ public class CommandDecrypt implements TabExecutor {
|
||||
}
|
||||
|
||||
if (InventoryUtil.notHoldingOneWrittenBookCheck(player,
|
||||
new FormatBuilder(Translatable.ERROR_NOT_HOLDING_WRITTEN_BOOK).replace("{action}", Translatable.ACTION_DECRYPT),
|
||||
new FormatBuilder(Translatable.ERROR_ONLY_ONE_BOOK).replace("{action}", Translatable.ACTION_DECRYPT))) {
|
||||
Translatable.ACTION_DECRYPT)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Placeholder;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.gui.PagedBookIndex;
|
||||
import net.knarcraft.bookswithoutborders.state.BookDirectory;
|
||||
@@ -92,7 +93,7 @@ public class CommandDelete implements TabExecutor {
|
||||
//Try to delete the file
|
||||
try {
|
||||
if (file.delete()) {
|
||||
new FormatBuilder(Translatable.SUCCESS_DELETED).replace("{file}", fileName).success(sender);
|
||||
new FormatBuilder(Translatable.SUCCESS_DELETED).replace(Placeholder.FILE, fileName).success(sender);
|
||||
} else {
|
||||
new FormatBuilder(Translatable.ERROR_DELETE_FAILED_SILENT).error(sender);
|
||||
}
|
||||
|
@@ -69,8 +69,7 @@ public class CommandEncrypt implements TabExecutor {
|
||||
}
|
||||
|
||||
if (InventoryUtil.notHoldingOneWrittenBookCheck(player,
|
||||
new FormatBuilder(Translatable.ERROR_NOT_HOLDING_WRITTEN_BOOK).replace("{action}", Translatable.ACTION_ENCRYPT),
|
||||
new FormatBuilder(Translatable.ERROR_ONLY_ONE_BOOK).replace("{action}", Translatable.ACTION_ENCRYPT))) {
|
||||
Translatable.ACTION_ENCRYPT)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,7 @@ package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.StaticMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Placeholder;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.container.MigrationRequest;
|
||||
import net.knarcraft.bookswithoutborders.thread.MigrationQueueThread;
|
||||
@@ -62,7 +63,7 @@ public class CommandMigrate implements TabExecutor {
|
||||
File[] files = folder.listFiles();
|
||||
if (files == null) {
|
||||
BooksWithoutBorders.log(Level.WARNING, new FormatBuilder(StaticMessage.EXCEPTION_DIRECTORY_UNAVAILABLE.toString()).
|
||||
replace("{folder}", folder.getName()).toString());
|
||||
replace(Placeholder.FOLDER, folder.getName()).toString());
|
||||
return;
|
||||
}
|
||||
for (File file : files) {
|
||||
|
@@ -5,6 +5,7 @@ import net.knarcraft.bookswithoutborders.config.BwBConfig;
|
||||
import net.knarcraft.bookswithoutborders.config.Permission;
|
||||
import net.knarcraft.bookswithoutborders.config.StaticMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Placeholder;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.SaveMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.state.BookDirectory;
|
||||
@@ -125,7 +126,7 @@ public class CommandSave implements TabExecutor {
|
||||
|
||||
//Update the relevant book list
|
||||
BooksWithoutBorders.updateBooks(player, saveToPublicFolder);
|
||||
new FormatBuilder(SaveMessage.SUCCESS_SAVED).replace("{fileName}", newName).success(player);
|
||||
new FormatBuilder(SaveMessage.SUCCESS_SAVED).replace(Placeholder.FILE, newName).success(player);
|
||||
} catch (IOException exception) {
|
||||
BooksWithoutBorders.log(Level.SEVERE, StaticMessage.EXCEPTION_SAVE_BOOK_FAILED.toString());
|
||||
}
|
||||
@@ -178,14 +179,14 @@ public class CommandSave implements TabExecutor {
|
||||
// Skip duplicate unnamed book saving
|
||||
if (!isUnnamed && !overwrite) {
|
||||
new FormatBuilder(SaveMessage.ERROR_SAVE_DUPLICATE_NAMED).error(player);
|
||||
new FormatBuilder(SaveMessage.ERROR_SAVE_OVERWRITE_REQUIRED).replace("{command}", fullCommand).error(player);
|
||||
new FormatBuilder(SaveMessage.ERROR_SAVE_OVERWRITE_REQUIRED).replace(Placeholder.COMMAND, fullCommand).error(player);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Skip if duplicate limit is reached
|
||||
if (foundDuplicates > duplicateLimit) {
|
||||
new FormatBuilder(SaveMessage.ERROR_SAVE_DUPLICATE_UNNAMED).replace("{fileName}", fileName).error(player);
|
||||
new FormatBuilder(SaveMessage.ERROR_SAVE_OVERWRITE_REQUIRED).replace("{command}", fullCommand).error(player);
|
||||
new FormatBuilder(SaveMessage.ERROR_SAVE_DUPLICATE_UNNAMED).replace(Placeholder.FILE, fileName).error(player);
|
||||
new FormatBuilder(SaveMessage.ERROR_SAVE_OVERWRITE_REQUIRED).replace(Placeholder.COMMAND, fullCommand).error(player);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Placeholder;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.state.ItemSlot;
|
||||
import net.knarcraft.bookswithoutborders.utility.InventoryUtil;
|
||||
@@ -38,8 +39,7 @@ public class CommandSetAuthor implements TabExecutor {
|
||||
}
|
||||
|
||||
if (InventoryUtil.notHoldingOneWrittenBookCheck(player,
|
||||
new FormatBuilder(Translatable.ERROR_NOT_HOLDING_WRITTEN_BOOK).replace("{action}", Translatable.ACTION_SET_AUTHOR),
|
||||
new FormatBuilder(Translatable.ERROR_ONLY_ONE_BOOK).replace("{action}", Translatable.ACTION_SET_AUTHOR))) {
|
||||
Translatable.ACTION_SET_AUTHOR)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class CommandSetAuthor implements TabExecutor {
|
||||
String author = ColorHelper.translateColorCodes(String.join(" ", arguments), ColorConversion.RGB);
|
||||
bookMetaData.setAuthor(author);
|
||||
heldBook.setItemMeta(bookMetaData);
|
||||
new FormatBuilder(Translatable.SUCCESS_SET_AUTHOR).replace("{author}", author).success(player);
|
||||
new FormatBuilder(Translatable.SUCCESS_SET_AUTHOR).replace(Placeholder.AUTHOR, author).success(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -5,6 +5,7 @@ import net.knarcraft.bookswithoutborders.config.BwBConfig;
|
||||
import net.knarcraft.bookswithoutborders.config.ConfigOption;
|
||||
import net.knarcraft.bookswithoutborders.config.StaticMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.CostMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Placeholder;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.manager.EconomyManager;
|
||||
import net.knarcraft.bookswithoutborders.state.ItemSlot;
|
||||
@@ -112,8 +113,8 @@ public class CommandSetBookPrice implements TabExecutor {
|
||||
booksWithoutBorders.getConfig().set(ConfigOption.PRICE_QUANTITY.getConfigNode(), newPriceQuantity);
|
||||
booksWithoutBorders.saveConfig();
|
||||
|
||||
new FormatBuilder(CostMessage.SUCCESS_COST_ITEM_SET).replace("{quantity}",
|
||||
String.valueOf((int) newPriceQuantity)).replace("{price}", newPriceType).success(sender);
|
||||
new FormatBuilder(CostMessage.SUCCESS_COST_ITEM_SET).replace(Placeholder.QUANTITY,
|
||||
String.valueOf((int) newPriceQuantity)).replace(Placeholder.COST, newPriceType).success(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -135,7 +136,7 @@ public class CommandSetBookPrice implements TabExecutor {
|
||||
booksWithoutBorders.getConfig().set(ConfigOption.PRICE_QUANTITY.getConfigNode(), newPriceQuantity);
|
||||
booksWithoutBorders.saveConfig();
|
||||
|
||||
new FormatBuilder(CostMessage.SUCCESS_COST_ECONOMY_SET).replace("{cost}",
|
||||
new FormatBuilder(CostMessage.SUCCESS_COST_ECONOMY_SET).replace(Placeholder.COST,
|
||||
economyManager.getEconomy().format(newPriceQuantity)).success(sender);
|
||||
return true;
|
||||
} else {
|
||||
|
@@ -29,8 +29,7 @@ public class CommandSetGeneration implements TabExecutor {
|
||||
}
|
||||
|
||||
if (InventoryUtil.notHoldingOneWrittenBookCheck(player,
|
||||
new FormatBuilder(Translatable.ERROR_NOT_HOLDING_WRITTEN_BOOK).replace("{action}", Translatable.ACTION_CHANGE_GENERATION),
|
||||
new FormatBuilder(Translatable.ERROR_ONLY_ONE_BOOK).replace("{action}", Translatable.ACTION_CHANGE_GENERATION))) {
|
||||
Translatable.ACTION_CHANGE_GENERATION)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package net.knarcraft.bookswithoutborders.command;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Placeholder;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.state.ItemSlot;
|
||||
import net.knarcraft.bookswithoutborders.utility.InputParsingUtil;
|
||||
@@ -77,9 +78,9 @@ public class CommandSetTitle implements TabExecutor {
|
||||
heldItem.setItemMeta(newMetaData);
|
||||
|
||||
if (heldItem.getType() == Material.WRITTEN_BOOK && !setDisplayName) {
|
||||
new FormatBuilder(Translatable.SUCCESS_TITLE_SET).replace("{title}", title).success(player);
|
||||
new FormatBuilder(Translatable.SUCCESS_TITLE_SET).replace(Placeholder.TITLE, title).success(player);
|
||||
} else {
|
||||
new FormatBuilder(Translatable.SUCCESS_DISPLAY_NAME_SET).replace("{displayName}", title).success(player);
|
||||
new FormatBuilder(Translatable.SUCCESS_DISPLAY_NAME_SET).replace(Placeholder.DISPLAY_NAME, title).success(player);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@@ -34,8 +34,7 @@ public class CommandUnSign implements TabExecutor {
|
||||
}
|
||||
|
||||
if (InventoryUtil.notHoldingOneWrittenBookCheck(player,
|
||||
new FormatBuilder(Translatable.ERROR_NOT_HOLDING_WRITTEN_BOOK).replace("{action}", Translatable.ACTION_UNSIGN),
|
||||
new FormatBuilder(Translatable.ERROR_ONLY_ONE_BOOK).replace("{action}", Translatable.ACTION_UNSIGN))) {
|
||||
Translatable.ACTION_UNSIGN)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,54 @@
|
||||
package net.knarcraft.bookswithoutborders.config.translation;
|
||||
|
||||
import net.knarcraft.knarlib.formatting.TranslatableMessage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Placeholders used in other translatable messages
|
||||
*/
|
||||
public enum Placeholder implements TranslatableMessage {
|
||||
|
||||
FILE,
|
||||
AUTHOR,
|
||||
ACTION,
|
||||
DATA,
|
||||
INDEX,
|
||||
QUANTITY,
|
||||
COST,
|
||||
TITLE,
|
||||
DISPLAY_NAME,
|
||||
LINE,
|
||||
PASSWORD,
|
||||
COMMAND,
|
||||
EXCEPTION,
|
||||
PATH,
|
||||
EXTENSION,
|
||||
HEADER,
|
||||
TEXT,
|
||||
SEPARATOR,
|
||||
CURRENT,
|
||||
TOTAL,
|
||||
CHARACTER,
|
||||
PAGE,
|
||||
BOOK_PRICE,
|
||||
COMMANDS,
|
||||
COMMAND_EXPLANATION,
|
||||
PLAYER,
|
||||
CURRENCY,
|
||||
FOLDER,
|
||||
TYPE,
|
||||
PERMISSION,
|
||||
USAGE,
|
||||
DESCRIPTION,
|
||||
ALIASES,
|
||||
LORE,
|
||||
COPIES,
|
||||
BALANCE,
|
||||
;
|
||||
|
||||
@Override
|
||||
public @NotNull TranslatableMessage[] getAllMessages() {
|
||||
return Placeholder.values();
|
||||
}
|
||||
|
||||
}
|
@@ -2,6 +2,7 @@ package net.knarcraft.bookswithoutborders.gui;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Placeholder;
|
||||
import net.knarcraft.bookswithoutborders.utility.BookFileUtil;
|
||||
import net.knarcraft.bookswithoutborders.utility.InputCleaningUtil;
|
||||
import net.knarcraft.knarlib.formatting.FormatBuilder;
|
||||
@@ -60,7 +61,7 @@ public class AuthorBookIndex extends BookIndex {
|
||||
String navigationCommand = command + " author" + authorName;
|
||||
|
||||
TranslatableMessage message = listPublic ? Formatting.NEUTRAL_AUTHOR_PUBLIC_BOOKS_HEADER : Formatting.NEUTRAL_AUTHOR_PLAYER_BOOKS_HEADER;
|
||||
componentBuilder.append(new FormatBuilder(message).replace("{author}", authorName).color().toString());
|
||||
componentBuilder.append(new FormatBuilder(message).replace(Placeholder.AUTHOR, authorName).color().toString());
|
||||
|
||||
|
||||
displayBookList(componentBuilder, command, page, availableBooks);
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package net.knarcraft.bookswithoutborders.gui;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Placeholder;
|
||||
import net.knarcraft.bookswithoutborders.utility.InputParsingUtil;
|
||||
import net.knarcraft.knarlib.formatting.FormatBuilder;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
@@ -83,8 +84,8 @@ public abstract class BookIndex {
|
||||
*/
|
||||
protected static void displayTotalPages(@NotNull ComponentBuilder componentBuilder, @NotNull String command,
|
||||
int page, int totalPages) {
|
||||
String pageDisplay = new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_TOTAL_PAGES).replace("{current}",
|
||||
String.valueOf(page)).replace("{total}", String.valueOf(totalPages)).color().toString();
|
||||
String pageDisplay = new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_TOTAL_PAGES).replace(Placeholder.CURRENT,
|
||||
String.valueOf(page)).replace(Placeholder.TOTAL, String.valueOf(totalPages)).color().toString();
|
||||
componentBuilder.append(pageDisplay,
|
||||
ComponentBuilder.FormatRetention.NONE).color(interactColor).event(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT, new Text("/" + command + " page" + page))).event(
|
||||
@@ -106,7 +107,7 @@ public abstract class BookIndex {
|
||||
if (firstInstances.containsKey(character)) {
|
||||
int pageIndex = (firstInstances.get(character) / booksPerPage) + 1;
|
||||
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
|
||||
new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_INDEX_HOVER).replace("{character}", "" + character).color().toString()));
|
||||
new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_INDEX_HOVER).replace(Placeholder.CHARACTER, "" + character).color().toString()));
|
||||
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/" + command + " page" + pageIndex);
|
||||
|
||||
@@ -131,7 +132,7 @@ public abstract class BookIndex {
|
||||
if (page > 1) {
|
||||
String fullCommand = "/" + command + " page" + (page - 1);
|
||||
HoverEvent prevPagePreview = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
|
||||
new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_TO_PAGE).replace("{page}", String.valueOf(page - 1)).color().toString()));
|
||||
new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_TO_PAGE).replace(Placeholder.PAGE, String.valueOf(page - 1)).color().toString()));
|
||||
ClickEvent prevPageClick = new ClickEvent(ClickEvent.Action.RUN_COMMAND, fullCommand);
|
||||
componentBuilder.append(previousPage, ComponentBuilder.FormatRetention.NONE).color(interactColor).
|
||||
event(prevPagePreview).event(prevPageClick);
|
||||
@@ -154,7 +155,7 @@ public abstract class BookIndex {
|
||||
if (page < totalPages) {
|
||||
String fullCommand = "/" + command + " page" + (page + 1);
|
||||
HoverEvent nextPagePreview = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
|
||||
new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_TO_PAGE).replace("{page}", String.valueOf(page + 1)).color().toString()));
|
||||
new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_TO_PAGE).replace(Placeholder.PAGE, String.valueOf(page + 1)).color().toString()));
|
||||
ClickEvent nextPageClick = new ClickEvent(ClickEvent.Action.RUN_COMMAND, fullCommand);
|
||||
componentBuilder.append(nextPage, ComponentBuilder.FormatRetention.NONE).color(interactColor)
|
||||
.event(nextPagePreview).event(nextPageClick);
|
||||
|
@@ -2,6 +2,7 @@ package net.knarcraft.bookswithoutborders.gui;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Placeholder;
|
||||
import net.knarcraft.bookswithoutborders.utility.BookFileUtil;
|
||||
import net.knarcraft.bookswithoutborders.utility.InputCleaningUtil;
|
||||
import net.knarcraft.knarlib.formatting.FormatBuilder;
|
||||
@@ -103,9 +104,9 @@ public class PagedBookIndex extends BookIndex {
|
||||
HoverEvent pathHover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_PATH_HOVER).color().toString()));
|
||||
ClickEvent authorClick = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/" + command + " author" + InputCleaningUtil.stripColor(author) + " page1");
|
||||
HoverEvent authorHover = new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new Text(new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_AUTHOR_HOVER).replace("{author}", InputCleaningUtil.stripColor(author)).color().toString()));
|
||||
new Text(new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_AUTHOR_HOVER).replace(Placeholder.AUTHOR, InputCleaningUtil.stripColor(author)).color().toString()));
|
||||
|
||||
componentBuilder.append(new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_BOOK_INDEX_NUMBER).replace("{index}",
|
||||
componentBuilder.append(new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_BOOK_INDEX_NUMBER).replace(Placeholder.INDEX,
|
||||
String.valueOf(bookIndex + 1)).color().toString()).color(interactColor).event(indexClick).event(indexHover);
|
||||
componentBuilder.append(" ", ComponentBuilder.FormatRetention.NONE);
|
||||
componentBuilder.append(title).color(ChatColor.WHITE).event(pathClick).event(pathHover);
|
||||
|
@@ -3,6 +3,7 @@ package net.knarcraft.bookswithoutborders.listener;
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.Permission;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Placeholder;
|
||||
import net.knarcraft.bookswithoutborders.container.Bookshelf;
|
||||
import net.knarcraft.bookswithoutborders.handler.BookshelfHandler;
|
||||
import net.knarcraft.bookswithoutborders.utility.BookMetaUtil;
|
||||
@@ -94,13 +95,13 @@ public class BookshelfListener implements Listener {
|
||||
if (bookshelf != null) {
|
||||
title = bookshelf.getTitle();
|
||||
for (String loreLine : bookshelf.getLore()) {
|
||||
lore.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_HEADER_LORE).replace("{lore}", loreLine));
|
||||
lore.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_HEADER_LORE).replace(Placeholder.LORE, loreLine));
|
||||
}
|
||||
} else {
|
||||
title = new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_HEADER_TITLE_EMPTY).toString();
|
||||
}
|
||||
builder.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_HEADER_TITLE).replace("{name}", title).
|
||||
replace("{lore}", lore.toString()));
|
||||
builder.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_HEADER_TITLE).replace(Placeholder.TITLE, title).
|
||||
replace(Placeholder.LORE, lore.toString()));
|
||||
|
||||
for (int i = 0; i < bookshelfInventory.getSize(); i++) {
|
||||
appendBookshelfItem(i, builder, bookshelfInventory);
|
||||
@@ -125,7 +126,7 @@ public class BookshelfListener implements Listener {
|
||||
builder.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_HEADER_BOTTOM));
|
||||
}
|
||||
|
||||
builder.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_ENTRY_INDEX).replace("{index}", String.valueOf(index)));
|
||||
builder.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_ENTRY_INDEX).replace(Placeholder.INDEX, String.valueOf(index)));
|
||||
|
||||
ItemStack itemStack = bookshelfInventory.getItem(counter);
|
||||
if (itemStack == null) {
|
||||
@@ -168,8 +169,8 @@ public class BookshelfListener implements Listener {
|
||||
private String getBookDescription(@NotNull BookMeta bookMeta) {
|
||||
String title = BookMetaUtil.getBookTitle(bookMeta);
|
||||
String author = BookMetaUtil.getBookAuthor(bookMeta, null);
|
||||
return new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_WRITTEN_FORMAT).replace("{title}", title).
|
||||
replace("{author}", author).toString();
|
||||
return new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_WRITTEN_FORMAT).replace(Placeholder.TITLE, title).
|
||||
replace(Placeholder.AUTHOR, author).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -3,6 +3,7 @@ package net.knarcraft.bookswithoutborders.listener;
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.BwBConfig;
|
||||
import net.knarcraft.bookswithoutborders.config.StaticMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Placeholder;
|
||||
import net.knarcraft.bookswithoutborders.state.BookDirectory;
|
||||
import net.knarcraft.bookswithoutborders.utility.BookLoaderUtil;
|
||||
import net.knarcraft.bookswithoutborders.utility.InputCleaningUtil;
|
||||
@@ -35,7 +36,7 @@ public class PlayerEventListener implements Listener {
|
||||
if (file.exists() && !file.renameTo(new File(bookFolder, player.getUniqueId().toString()))) {
|
||||
BooksWithoutBorders.log(Level.WARNING, new FormatBuilder(
|
||||
StaticMessage.WARNING_USER_BOOK_MIGRATION_IMPOSSIBLE.toString()).
|
||||
replace("{player}", player.getName()).toString());
|
||||
replace(Placeholder.PLAYER, player.getName()).toString());
|
||||
}
|
||||
|
||||
//Handle new players
|
||||
|
@@ -3,6 +3,7 @@ package net.knarcraft.bookswithoutborders.listener;
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.Permission;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.GiveMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Placeholder;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.SignText;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.encryption.EncryptionStyle;
|
||||
@@ -62,13 +63,13 @@ public class SignEventListener implements Listener {
|
||||
SignType type = SignType.fromString(lines[1]);
|
||||
if (type == null || lines[2].trim().isEmpty()) {
|
||||
//Mark the second line as invalid
|
||||
event.setLine(1, new FormatBuilder(SignText.SIGN_INVALID).replace("{line}", lines[1]).color().toString());
|
||||
event.setLine(1, new FormatBuilder(SignText.SIGN_INVALID).replace(Placeholder.LINE, lines[1]).color().toString());
|
||||
new FormatBuilder(SignText.ERROR_SIGN_INVALID).error(player);
|
||||
return;
|
||||
}
|
||||
|
||||
//Mark the second line as valid
|
||||
event.setLine(1, new FormatBuilder(SignText.SIGN_VALID).replace("{line}", lines[1]).color().toString());
|
||||
event.setLine(1, new FormatBuilder(SignText.SIGN_VALID).replace(Placeholder.LINE, lines[1]).color().toString());
|
||||
lines = event.getLines();
|
||||
|
||||
//Mark valid encryption/decryption sign
|
||||
@@ -76,8 +77,8 @@ public class SignEventListener implements Listener {
|
||||
//Generate book giving sign
|
||||
generateGiveSign(event, lines, player);
|
||||
} else {
|
||||
event.setLine(2, new FormatBuilder(SignText.SIGN_PASSWORD).replace("{password}", lines[2]).color().toString());
|
||||
event.setLine(3, new FormatBuilder(SignText.SIGN_VALID).replace("{line}", lines[3]).color().toString());
|
||||
event.setLine(2, new FormatBuilder(SignText.SIGN_PASSWORD).replace(Placeholder.PASSWORD, lines[2]).color().toString());
|
||||
event.setLine(3, new FormatBuilder(SignText.SIGN_VALID).replace(Placeholder.LINE, lines[3]).color().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,8 +133,8 @@ public class SignEventListener implements Listener {
|
||||
giveBook(sign, player);
|
||||
} else {
|
||||
SignSide front = sign.getSide(Side.FRONT);
|
||||
new FormatBuilder(SignText.ERROR_SIGN_COMMAND_INVALID).replace("{action}", front.getLine(1)).
|
||||
replace("{data}", front.getLine(2)).error(player);
|
||||
new FormatBuilder(SignText.ERROR_SIGN_COMMAND_INVALID).replace(Placeholder.ACTION, front.getLine(1)).
|
||||
replace(Placeholder.DATA, front.getLine(2)).error(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -3,6 +3,7 @@ package net.knarcraft.bookswithoutborders.manager;
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.BwBConfig;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.CostMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Placeholder;
|
||||
import net.knarcraft.knarlib.formatting.FormatBuilder;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Material;
|
||||
@@ -83,8 +84,8 @@ public class EconomyManager {
|
||||
payForBookPrintingItem(player, itemCost);
|
||||
return false;
|
||||
} else {
|
||||
new FormatBuilder(CostMessage.ERROR_COST_INSUFFICIENT_AMOUNT).replace("{cost}",
|
||||
String.valueOf(itemCost)).replace("{currency}", bookCurrency.toString()).error(player);
|
||||
new FormatBuilder(CostMessage.ERROR_COST_INSUFFICIENT_AMOUNT).replace(Placeholder.COST,
|
||||
String.valueOf(itemCost)).replace(Placeholder.CURRENCY, bookCurrency.toString()).error(player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -100,7 +101,7 @@ public class EconomyManager {
|
||||
List<ItemStack> books = getPlayersEmptyBooks(player);
|
||||
if (countItems(books) < itemCost) {
|
||||
new FormatBuilder(CostMessage.ERROR_COST_INSUFFICIENT_WRITABLE_BOOK).
|
||||
replace("{cost}", String.valueOf(itemCost)).error(player);
|
||||
replace(Placeholder.COST, String.valueOf(itemCost)).error(player);
|
||||
return false;
|
||||
} else {
|
||||
int clearedAmount = 0;
|
||||
@@ -173,12 +174,12 @@ public class EconomyManager {
|
||||
|
||||
if ((economy.getBalance(player) - cost) >= 0) {
|
||||
economy.withdrawPlayer(player, cost);
|
||||
new FormatBuilder(CostMessage.SUCCESS_COST_PAID).replace("{cost}", economy.format(cost)).
|
||||
replace("{copies}", String.valueOf(numCopies)).
|
||||
replace("{balance}", economy.format(economy.getBalance(player))).success(player);
|
||||
new FormatBuilder(CostMessage.SUCCESS_COST_PAID).replace(Placeholder.COST, economy.format(cost)).
|
||||
replace(Placeholder.COPIES, String.valueOf(numCopies)).
|
||||
replace(Placeholder.BALANCE, economy.format(economy.getBalance(player))).success(player);
|
||||
return true;
|
||||
} else {
|
||||
new FormatBuilder(CostMessage.ERROR_COST_INSUFFICIENT_ECONOMY).replace("{cost}", economy.format(cost)).error(player);
|
||||
new FormatBuilder(CostMessage.ERROR_COST_INSUFFICIENT_ECONOMY).replace(Placeholder.COST, economy.format(cost)).error(player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package net.knarcraft.bookswithoutborders.thread;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.StaticMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Placeholder;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.container.EncryptedBook;
|
||||
import net.knarcraft.bookswithoutborders.container.MigrationRequest;
|
||||
@@ -100,7 +101,7 @@ public class MigrationQueueThread implements Runnable {
|
||||
|
||||
if (!extension.equalsIgnoreCase("txt") && !extension.equalsIgnoreCase("yml")) {
|
||||
BooksWithoutBorders.log(Level.WARNING, new FormatBuilder(StaticMessage.EXCEPTION_UNEXPECTED_EXTENSION.toString()).
|
||||
replace("{extension}", extension).toString());
|
||||
replace(Placeholder.EXTENSION, extension).toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -119,7 +120,7 @@ public class MigrationQueueThread implements Runnable {
|
||||
|
||||
if (loadedBook == null) {
|
||||
BooksWithoutBorders.log(Level.SEVERE, new FormatBuilder(StaticMessage.EXCEPTION_MIGRATE_BOOK_LOAD_FAILED.toString()).
|
||||
replace("{path}", file.getAbsolutePath()).toString());
|
||||
replace(Placeholder.PATH, file.getAbsolutePath()).toString());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -149,8 +150,8 @@ public class MigrationQueueThread implements Runnable {
|
||||
}
|
||||
return deleteBook(file.getParentFile(), newName, file);
|
||||
} catch (IllegalArgumentException | IOException exception) {
|
||||
new FormatBuilder(Translatable.ERROR_MIGRATION_BOOK_FAILED).replace("{file}", file.getName()).
|
||||
replace("{exception}", exception.getMessage()).error(player);
|
||||
new FormatBuilder(Translatable.ERROR_MIGRATION_BOOK_FAILED).replace(Placeholder.FILE, file.getName()).
|
||||
replace(Placeholder.EXCEPTION, exception.getMessage()).error(player);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.BwBConfig;
|
||||
import net.knarcraft.bookswithoutborders.config.StaticMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Formatting;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Placeholder;
|
||||
import net.knarcraft.bookswithoutborders.state.BookDirectory;
|
||||
import net.knarcraft.knarlib.formatting.FormatBuilder;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -211,8 +212,8 @@ public final class BookFileUtil {
|
||||
if (InputCleaningUtil.cleanString(bookName).contains(separator) ||
|
||||
InputCleaningUtil.cleanString(authorName).contains(separator)) {
|
||||
throw new IllegalArgumentException(new FormatBuilder(StaticMessage.EXCEPTION_META_HAS_SEPARATOR.toString()).
|
||||
replace("{author}", authorName).replace("{title}", bookName).
|
||||
replace("{separator}", separator).toString());
|
||||
replace(Placeholder.AUTHOR, authorName).replace(Placeholder.TITLE, bookName).
|
||||
replace(Placeholder.SEPARATOR, separator).toString());
|
||||
}
|
||||
|
||||
return InputCleaningUtil.cleanString(bookName + separator + authorName);
|
||||
|
@@ -3,6 +3,7 @@ package net.knarcraft.bookswithoutborders.utility;
|
||||
import net.knarcraft.bookswithoutborders.BooksWithoutBorders;
|
||||
import net.knarcraft.bookswithoutborders.config.BwBConfig;
|
||||
import net.knarcraft.bookswithoutborders.config.StaticMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Placeholder;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.container.EncryptedBook;
|
||||
import net.knarcraft.bookswithoutborders.encryption.AES;
|
||||
@@ -320,7 +321,7 @@ public final class EncryptedBookUtil {
|
||||
}
|
||||
BooksWithoutBorders.log(Level.SEVERE, new FormatBuilder(
|
||||
StaticMessage.EXCEPTION_ENCRYPTED_FILE_DELETE_FAILED.toString()).
|
||||
replace("{path}", file.getPath()).toString());
|
||||
replace(Placeholder.PATH, file.getPath()).toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,10 +1,12 @@
|
||||
package net.knarcraft.bookswithoutborders.utility;
|
||||
|
||||
import net.knarcraft.bookswithoutborders.config.StaticMessage;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Placeholder;
|
||||
import net.knarcraft.bookswithoutborders.config.translation.Translatable;
|
||||
import net.knarcraft.bookswithoutborders.state.BookHoldingState;
|
||||
import net.knarcraft.bookswithoutborders.state.ItemSlot;
|
||||
import net.knarcraft.knarlib.formatting.FormatBuilder;
|
||||
import net.knarcraft.knarlib.formatting.TranslatableMessage;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -72,23 +74,21 @@ public final class InventoryUtil {
|
||||
/**
|
||||
* Performs checks to validate that a player contains exactly one unwritten book
|
||||
*
|
||||
* @param player <p>The player to validate</p>
|
||||
* @param noBookMessage <p>The message to display if the player is not holding a book</p>
|
||||
* @param twoBooksMessage <p>The message to display if the player is holding one book in each hand</p>
|
||||
* @param player <p>The player to validate</p>
|
||||
* @param action <p>The action to replace the placeholder with</p>
|
||||
* @return <p>False if the player is holding exactly one book</p>
|
||||
*/
|
||||
public static boolean notHoldingOneWritableBookCheck(@NotNull Player player, @NotNull FormatBuilder noBookMessage,
|
||||
@NotNull FormatBuilder twoBooksMessage) {
|
||||
public static boolean notHoldingOneWritableBookCheck(@NotNull Player player, @NotNull TranslatableMessage action) {
|
||||
BookHoldingState holdingState = getBookHoldingState(player);
|
||||
|
||||
if (holdingState == BookHoldingState.NONE || holdingState == BookHoldingState.SIGNED_BOTH_HANDS ||
|
||||
holdingState == BookHoldingState.SIGNED_MAIN_HAND || holdingState == BookHoldingState.SIGNED_OFF_HAND) {
|
||||
noBookMessage.error(player);
|
||||
new FormatBuilder(Translatable.ERROR_NOT_HOLDING_WRITABLE_BOOK).replace(Placeholder.ACTION, action).error(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (holdingState == BookHoldingState.UNSIGNED_BOTH_HANDS) {
|
||||
twoBooksMessage.error(player);
|
||||
new FormatBuilder(Translatable.ERROR_ONLY_ONE_BOOK).replace(Placeholder.ACTION, action).error(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -98,23 +98,21 @@ public final class InventoryUtil {
|
||||
/**
|
||||
* Performs checks to validate that a player contains exactly one written book
|
||||
*
|
||||
* @param player <p>The player to validate</p>
|
||||
* @param noBookMessage <p>The message to display if the player is not holding a book</p>
|
||||
* @param twoBooksMessage <p>The message to display if the player is holding one book in each hand</p>
|
||||
* @param player <p>The player to validate</p>
|
||||
* @param action <p>The action to replace the placeholder with</p>
|
||||
* @return <p>False if the player is holding exactly one book</p>
|
||||
*/
|
||||
public static boolean notHoldingOneWrittenBookCheck(@NotNull Player player, @NotNull FormatBuilder noBookMessage,
|
||||
@NotNull FormatBuilder twoBooksMessage) {
|
||||
public static boolean notHoldingOneWrittenBookCheck(@NotNull Player player, @NotNull TranslatableMessage action) {
|
||||
BookHoldingState holdingState = getBookHoldingState(player);
|
||||
|
||||
if (holdingState == BookHoldingState.NONE || holdingState == BookHoldingState.UNSIGNED_BOTH_HANDS ||
|
||||
holdingState == BookHoldingState.UNSIGNED_MAIN_HAND || holdingState == BookHoldingState.UNSIGNED_OFF_HAND) {
|
||||
noBookMessage.error(player);
|
||||
new FormatBuilder(Translatable.ERROR_NOT_HOLDING_WRITTEN_BOOK).replace(Placeholder.ACTION, action).error(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (holdingState == BookHoldingState.SIGNED_BOTH_HANDS) {
|
||||
twoBooksMessage.error(player);
|
||||
new FormatBuilder(Translatable.ERROR_ONLY_ONE_BOOK).replace(Placeholder.ACTION, action).error(player);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -13,10 +13,10 @@ en:
|
||||
SUCCESS_BOOK_LOADED: "Book created!"
|
||||
SUCCESS_MIGRATION_STARTED: "Starting book migration..."
|
||||
SUCCESS_RELOADED: "Configuration, books and language strings reloaded!"
|
||||
SUCCESS_SAVED: "Book Saved as &e\"{fileName}\"&r"
|
||||
SUCCESS_SAVED: "Book Saved as &e\"{file}\"&r"
|
||||
SUCCESS_SET_AUTHOR: "Book author set to {author}!"
|
||||
SUCCESS_COST_REMOVED: "Price to create books removed!"
|
||||
SUCCESS_COST_ITEM_SET: "Book creation price set to {quantity} {price}(s)!"
|
||||
SUCCESS_COST_ITEM_SET: "Book creation price set to {quantity} {cost}(s)!"
|
||||
SUCCESS_COST_ECONOMY_SET: "Book creation price set to {cost}!"
|
||||
SUCCESS_COST_PAID: |
|
||||
{cost} withdrawn to create {copies} book(s)
|
||||
@@ -81,7 +81,7 @@ en:
|
||||
ERROR_SAVE_FILE_SYSTEM_ERROR: "Saving Failed! If this continues to happen, consult a server admin!"
|
||||
ERROR_SAVE_OVERWRITE_REQUIRED: "Use &e{command}&r to overwrite!"
|
||||
ERROR_SAVE_DUPLICATE_NAMED: "Book is already saved!"
|
||||
ERROR_SAVE_DUPLICATE_UNNAMED: "Maximum amount of {fileName} duplicates reached!"
|
||||
ERROR_SAVE_DUPLICATE_UNNAMED: "Maximum amount of {file} duplicates reached!"
|
||||
ERROR_UNKNOWN_COMMAND: "Invalid command specified"
|
||||
ERROR_AUTHOR_BLANK: "You must specify an author"
|
||||
ERROR_COST_NOT_SPECIFIED: "[Item/Eco] and [quantity] must be specified!"
|
||||
@@ -129,7 +129,7 @@ en:
|
||||
{bookPrice}&eCommands:
|
||||
{commandExplanation}&r
|
||||
{commands}
|
||||
NEUTRAL_COMMANDS_BOOK_PRICE_ECO: "\n&c[{price} is required to create a book]"
|
||||
NEUTRAL_COMMANDS_BOOK_PRICE_ECO: "\n&c[{cost} is required to create a book]"
|
||||
NEUTRAL_COMMANDS_BOOK_PRICE_ITEM: "&c[{quantity} {type} (s) are required to create a book]\n"
|
||||
NEUTRAL_COMMANDS_COMMAND: "\n&e{usage}{aliases}: &a{description}"
|
||||
NEUTRAL_COMMANDS_SUMMARY: "\n&eCommand: &aUsage summary"
|
||||
@@ -156,7 +156,7 @@ en:
|
||||
NEUTRAL_BOOK_LIST_PATH_HOVER: "Select book by path"
|
||||
NEUTRAL_BOOK_LIST_BOOK_INDEX_HOVER: "Select book by index"
|
||||
NEUTRAL_BOOK_LIST_BOOK_INDEX_NUMBER: "[{index}]"
|
||||
NEUTRAL_BOOKSHELF_HEADER_TITLE: "&nBookshelf summary\n&#FF5700Books in {name}&r&#FF5700:{lore}"
|
||||
NEUTRAL_BOOKSHELF_HEADER_TITLE: "&nBookshelf summary\n&#FF5700Books in {title}&r&#FF5700:{lore}"
|
||||
NEUTRAL_BOOKSHELF_HEADER_LORE: "\n &d{lore}&r"
|
||||
NEUTRAL_BOOKSHELF_HEADER_TITLE_EMPTY: "shelf"
|
||||
NEUTRAL_BOOKSHELF_HEADER_TOP: "\n &#FF5700Top Row:&r"
|
||||
@@ -185,4 +185,47 @@ en:
|
||||
SIGN_VALID: "&1{line}"
|
||||
ERROR_SIGN_INVALID: "Invalid sign!"
|
||||
ERROR_SIGN_COMMAND_INVALID: "Sign command {action} {data} is invalid"
|
||||
SUCCESS_SIGN_GIVE: "Received book!"
|
||||
SUCCESS_SIGN_GIVE: "Received book!"
|
||||
# ------------ #
|
||||
# Placeholders #
|
||||
# -------------¤
|
||||
# Warning: Replacing any of these require them to be replaced in every other string in this file that contains the
|
||||
# placeholder. Avoid changing these unless it's necessary, or you know what you're doing! Some placeholders may also
|
||||
# be used in non-customizable error messages.
|
||||
# ------------ #
|
||||
FILE: "{file}"
|
||||
AUTHOR: "{author}"
|
||||
ACTION: "{action}"
|
||||
DATA: "{data}"
|
||||
INDEX: "{index}"
|
||||
QUANTITY: "{quantity}"
|
||||
COST: "{cost}"
|
||||
TITLE: "{title}"
|
||||
DISPLAY_NAME: "{displayName}"
|
||||
LINE: "{line}"
|
||||
PASSWORD: "{password}"
|
||||
COMMAND: "{command}"
|
||||
EXCEPTION: "{exception}"
|
||||
PATH: "{path}"
|
||||
EXTENSION: "{extension}"
|
||||
HEADER: "{header}"
|
||||
TEXT: "{text}"
|
||||
SEPARATOR: "{separator}"
|
||||
CURRENT: "{current}"
|
||||
TOTAL: "{total}"
|
||||
CHARACTER: "{character}"
|
||||
PAGE: "{page}"
|
||||
BOOK_PRICE: "{bookPrice}"
|
||||
COMMANDS: "{commands}"
|
||||
COMMAND_EXPLANATION: "{commandExplanation}"
|
||||
PLAYER: "{player}"
|
||||
CURRENCY: "{currency}"
|
||||
FOLDER: "{folder}"
|
||||
TYPE: "{type}"
|
||||
PERMISSION: "{permission}"
|
||||
USAGE: "{usage}"
|
||||
DESCRIPTION: "{description}"
|
||||
ALIASES: "{aliases}"
|
||||
LORE: "{lore}"
|
||||
COPIES: "{copies}"
|
||||
BALANCE: "{balance}"
|
Reference in New Issue
Block a user