Updates KnarLib

This commit is contained in:
2025-09-03 03:32:20 +02:00
parent 5eab950048
commit c1236d3d91
21 changed files with 64 additions and 64 deletions

View File

@@ -125,7 +125,7 @@
<dependency>
<groupId>net.knarcraft</groupId>
<artifactId>knarlib</artifactId>
<version>1.2.9</version>
<version>1.2.10</version>
<scope>compile</scope>
</dependency>
<dependency>

View File

@@ -303,7 +303,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).build());
replace("{command}", commandName).toString());
}
}

View File

@@ -101,7 +101,7 @@ public class CommandAddTitlePage implements TabExecutor {
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))).build());
replace("{author}", InputCleaningUtil.stripColor(BookMetaUtil.getBookAuthor(bookMeta, null))).toString());
if (index > pages.size()) {
pages.add(pageText);
@@ -142,9 +142,9 @@ public class CommandAddTitlePage implements TabExecutor {
for (int i = 1; i < parts.length; i++) {
builder.append(Formatting.NEUTRAL_TITLE_PAGE_TEXT_FORMAT).replace("{text}", parts[i]);
}
return builder.color().build();
return builder.color().toString();
} else {
return new FormatBuilder(Formatting.NEUTRAL_TITLE_PAGE_HEADER_FORMAT).replace("{header}", input).color().build();
return new FormatBuilder(Formatting.NEUTRAL_TITLE_PAGE_HEADER_FORMAT).replace("{header}", input).color().toString();
}
}

View File

@@ -87,14 +87,14 @@ public class CommandBooksWithoutBorders implements TabExecutor {
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()).build();
String.valueOf((int) bookPriceQuantity)).replace("{type}", bookPriceType.toString()).toString();
} else {
EconomyManager economyManager = BooksWithoutBorders.getConfiguration().getEconomyManager();
if (economyManager.getEconomy() == null) {
return new FormatBuilder(CostMessage.ERROR_VAULT_COST_BUT_UNAVAILABLE).build() + "\n";
return new FormatBuilder(CostMessage.ERROR_VAULT_COST_BUT_UNAVAILABLE) + "\n";
} else {
return new FormatBuilder(Formatting.NEUTRAL_COMMANDS_BOOK_PRICE_ECO).replace("{price}",
economyManager.getEconomy().format(bookPriceQuantity)).build();
economyManager.getEconomy().format(bookPriceQuantity)).toString();
}
}
}
@@ -141,7 +141,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()).build());
replace("{command}", bwBCommand.toString()).toString());
return "";
}
@@ -162,17 +162,17 @@ public class CommandBooksWithoutBorders implements TabExecutor {
commandUsage = pluginCommand.getUsage().replace("<command>", pluginCommand.getName());
description = pluginCommand.getDescription();
aliases = new FormatBuilder(Formatting.NEUTRAL_COMMANDS_ALIASES).replace("{aliases}",
String.join(",", pluginCommand.getAliases())).build();
String.join(",", pluginCommand.getAliases())).toString();
}
String commandDescription = new FormatBuilder(Formatting.NEUTRAL_COMMANDS_COMMAND).replace("{usage}",
commandUsage).replace("{description}", description).replace("{aliases}", aliases).build();
commandUsage).replace("{description}", description).replace("{aliases}", aliases).toString();
if (!summary && sender.hasPermission(Permission.ADMIN.toString())) {
if (permission == null) {
permission = new FormatBuilder(Formatting.NEUTRAL_COMMANDS_COMMAND_NO_PERMISSION_REQUIRED).build();
permission = new FormatBuilder(Formatting.NEUTRAL_COMMANDS_COMMAND_NO_PERMISSION_REQUIRED).toString();
}
commandDescription += new FormatBuilder(Formatting.NEUTRAL_COMMANDS_COMMAND_PERMISSION).replace("{permission}", permission).build();
commandDescription += new FormatBuilder(Formatting.NEUTRAL_COMMANDS_COMMAND_PERMISSION).replace("{permission}", permission).toString();
}
return commandDescription;
}
@@ -186,9 +186,9 @@ public class CommandBooksWithoutBorders implements TabExecutor {
@NotNull
private String getCommandExplanation(boolean summary) {
if (summary) {
return new FormatBuilder(Formatting.NEUTRAL_COMMANDS_SUMMARY).build();
return new FormatBuilder(Formatting.NEUTRAL_COMMANDS_SUMMARY).toString();
} else {
return new FormatBuilder(Formatting.NEUTRAL_COMMANDS_DESCRIPTION).build();
return new FormatBuilder(Formatting.NEUTRAL_COMMANDS_DESCRIPTION).toString();
}
}

View File

@@ -32,7 +32,7 @@ public class CommandEncrypt implements TabExecutor {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label,
@NotNull String[] arguments) {
if (performPreChecks(sender, arguments, 1, 2,
new FormatBuilder(Translatable.ERROR_ENCRYPT_NO_KEY).build()) == null) {
new FormatBuilder(Translatable.ERROR_ENCRYPT_NO_KEY).toString()) == null) {
return false;
}

View File

@@ -26,7 +26,7 @@ public class CommandGroupEncrypt extends CommandEncrypt implements TabExecutor {
}
BookMeta bookMetadata = performPreChecks(sender, arguments, 2, 1,
new FormatBuilder(Translatable.ERROR_GROUP_ENCRYPT_ARGUMENTS_MISSING).build());
new FormatBuilder(Translatable.ERROR_GROUP_ENCRYPT_ARGUMENTS_MISSING).toString());
if (bookMetadata == null) {
return false;

View File

@@ -62,7 +62,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()).build());
replace("{folder}", folder.getName()).toString());
return;
}
for (File file : files) {

View File

@@ -173,7 +173,7 @@ public class CommandSave implements TabExecutor {
String fullCommand = "/" + command + " true";
boolean isUnnamed = fileName.contains(new FormatBuilder(Formatting.NEUTRAL_UNKNOWN_TITLE).build() + separator);
boolean isUnnamed = fileName.contains(new FormatBuilder(Formatting.NEUTRAL_UNKNOWN_TITLE) + separator);
// Skip duplicate unnamed book saving
if (!isUnnamed && !overwrite) {

View File

@@ -50,7 +50,7 @@ public class CommandSetTitle implements TabExecutor {
} else {
title = String.join(" ", arguments);
}
title = new FormatBuilder(title).color().build();
title = new FormatBuilder(title).color().toString();
ItemMeta itemMetadata = heldItem.getItemMeta();
if (itemMetadata == null) {

View File

@@ -60,7 +60,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().build());
componentBuilder.append(new FormatBuilder(message).replace("{author}", authorName).color().toString());
displayBookList(componentBuilder, command, page, availableBooks);
@@ -86,13 +86,13 @@ public class AuthorBookIndex extends BookIndex {
for (int bookIndex = startIndex; bookIndex < Math.min(startIndex + booksPerPage, availableBooks.size()); bookIndex++) {
String title = BookFileUtil.getBookTitleFromPath(availableBooks.get(bookIndex));
String author = BookFileUtil.getBookAuthorFromPath(availableBooks.get(bookIndex));
String niceName = new FormatBuilder(title).append(Formatting.NEUTRAL_BOOK_LIST_AUTHOR_SEPARATOR).append(author).color().build();
String niceName = new FormatBuilder(title).append(Formatting.NEUTRAL_BOOK_LIST_AUTHOR_SEPARATOR).append(author).color().toString();
componentBuilder.append(niceName).color(ChatColor.WHITE).event(
new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + command + " " +
availableBooks.get(bookIndex))).event(
new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
new FormatBuilder(Formatting.NEUTRAL_AUTHOR_BOOKS_PATH).color().build())));
new FormatBuilder(Formatting.NEUTRAL_AUTHOR_BOOKS_PATH).color().toString())));
componentBuilder.append("\n");
}
}

View File

@@ -84,7 +84,7 @@ 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().build();
String.valueOf(page)).replace("{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 +106,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().build()));
new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_INDEX_HOVER).replace("{character}", "" + character).color().toString()));
ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.RUN_COMMAND,
"/" + command + " page" + pageIndex);
@@ -127,11 +127,11 @@ public abstract class BookIndex {
*/
protected static void displayPreviousButton(@NotNull ComponentBuilder componentBuilder,
@NotNull String command, int page) {
String previousPage = new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_PREVIOUS_PAGE).color().build();
String previousPage = new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_PREVIOUS_PAGE).color().toString();
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().build()));
new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_TO_PAGE).replace("{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);
@@ -150,11 +150,11 @@ public abstract class BookIndex {
*/
protected static void displayNextButton(@NotNull ComponentBuilder componentBuilder,
@NotNull String command, int page, int totalPages) {
String nextPage = new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_NEXT_PAGE).color().build();
String nextPage = new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_NEXT_PAGE).color().toString();
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().build()));
new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_TO_PAGE).replace("{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);

View File

@@ -69,7 +69,7 @@ public class PagedBookIndex extends BookIndex {
ComponentBuilder componentBuilder = new ComponentBuilder();
TranslatableMessage message = listPublic ? Formatting.NEUTRAL_BOOK_LIST_PUBLIC_BOOKS_HEADER : Formatting.NEUTRAL_BOOK_LIST_PLAYER_BOOKS_HEADER;
componentBuilder.append(new FormatBuilder(message).color().build());
componentBuilder.append(new FormatBuilder(message).color().toString());
displayBookList(componentBuilder, command, page, availableBooks);
displayPreviousButton(componentBuilder, command, page);
@@ -94,22 +94,22 @@ public class PagedBookIndex extends BookIndex {
@NotNull List<String> availableBooks) {
int startIndex = (page - 1) * booksPerPage;
for (int bookIndex = startIndex; bookIndex < Math.min(startIndex + booksPerPage, availableBooks.size()); bookIndex++) {
String title = new FormatBuilder(BookFileUtil.getBookTitleFromPath(availableBooks.get(bookIndex))).color().build();
String author = new FormatBuilder(BookFileUtil.getBookAuthorFromPath(availableBooks.get(bookIndex))).color().build();
String title = new FormatBuilder(BookFileUtil.getBookTitleFromPath(availableBooks.get(bookIndex))).color().toString();
String author = new FormatBuilder(BookFileUtil.getBookAuthorFromPath(availableBooks.get(bookIndex))).color().toString();
ClickEvent indexClick = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + command + " " + (bookIndex + 1));
HoverEvent indexHover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_BOOK_INDEX_HOVER).color().build()));
HoverEvent indexHover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_BOOK_INDEX_HOVER).color().toString()));
ClickEvent pathClick = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + command + " " + availableBooks.get(bookIndex));
HoverEvent pathHover = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_PATH_HOVER).color().build()));
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().build()));
new Text(new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_AUTHOR_HOVER).replace("{author}", InputCleaningUtil.stripColor(author)).color().toString()));
componentBuilder.append(new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_BOOK_INDEX_NUMBER).replace("{index}",
String.valueOf(bookIndex + 1)).color().build()).color(interactColor).event(indexClick).event(indexHover);
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);
componentBuilder.append(new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_AUTHOR_SEPARATOR).color().build(),
componentBuilder.append(new FormatBuilder(Formatting.NEUTRAL_BOOK_LIST_AUTHOR_SEPARATOR).color().toString(),
ComponentBuilder.FormatRetention.NONE).color(ChatColor.WHITE);
componentBuilder.append(author).color(ChatColor.WHITE).event(authorClick).event(authorHover);
componentBuilder.append("\n");

View File

@@ -94,13 +94,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).build());
lore.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_HEADER_LORE).replace("{lore}", loreLine));
}
} else {
title = new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_HEADER_TITLE_EMPTY).build();
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()).build());
replace("{lore}", lore.toString()));
for (int i = 0; i < bookshelfInventory.getSize(); i++) {
appendBookshelfItem(i, builder, bookshelfInventory);
@@ -120,16 +120,16 @@ public class BookshelfListener implements Listener {
// Show the row header before the first item, and before the fourth item
int index = (counter % 3) + 1;
if (counter == 0) {
builder.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_HEADER_TOP).build());
builder.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_HEADER_TOP));
} else if (counter == 3) {
builder.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_HEADER_BOTTOM).build());
builder.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_HEADER_BOTTOM));
}
builder.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_ENTRY_INDEX).replace("{index}", String.valueOf(index)).build());
builder.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_ENTRY_INDEX).replace("{index}", String.valueOf(index)));
ItemStack itemStack = bookshelfInventory.getItem(counter);
if (itemStack == null) {
builder.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_EMPTY).build());
builder.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_EMPTY));
return;
}
ItemMeta meta = itemStack.getItemMeta();
@@ -139,7 +139,7 @@ public class BookshelfListener implements Listener {
} else if (meta instanceof EnchantmentStorageMeta enchantmentStorageMeta) {
builder.append(getEnchantedBookDescription(enchantmentStorageMeta));
} else if (meta != null) {
builder.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_PLAIN_BOOK_PREFIX).build()).append(getPlainBookDescription(meta));
builder.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_PLAIN_BOOK_PREFIX)).append(getPlainBookDescription(meta));
}
}
@@ -153,7 +153,7 @@ public class BookshelfListener implements Listener {
private String getPlainBookDescription(@NotNull ItemMeta itemMeta) {
String name = itemMeta.getDisplayName();
if (name.isEmpty()) {
name = new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_UNNAMED_PLAIN_BOOK_FORMAT).build();
name = new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_UNNAMED_PLAIN_BOOK_FORMAT).toString();
}
return name;
}
@@ -169,7 +169,7 @@ public class BookshelfListener implements Listener {
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).build();
replace("{author}", author).toString();
}
/**
@@ -181,7 +181,7 @@ public class BookshelfListener implements Listener {
@NotNull
private String getEnchantedBookDescription(@NotNull EnchantmentStorageMeta enchantmentStorageMeta) {
StringBuilder builder = new StringBuilder();
builder.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_ENCHANTED_PREFIX).build());
builder.append(new FormatBuilder(Formatting.NEUTRAL_BOOKSHELF_ENCHANTED_PREFIX));
Map<Enchantment, Integer> enchantmentMap = enchantmentStorageMeta.getStoredEnchants();
List<String> enchantments = new ArrayList<>(enchantmentMap.size());
for (Map.Entry<Enchantment, Integer> enchantmentEntry : enchantmentMap.entrySet()) {

View File

@@ -35,7 +35,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()).build());
replace("{player}", player.getName()).toString());
}
//Handle new players

View File

@@ -56,19 +56,19 @@ public class SignEventListener implements Listener {
}
//Mark the sign as active
event.setLine(0, new FormatBuilder(SignText.SIGN_HEADER).color().build());
event.setLine(0, new FormatBuilder(SignText.SIGN_HEADER).color().toString());
//Check if the sign is of a valid type
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().build());
event.setLine(1, new FormatBuilder(SignText.SIGN_INVALID).replace("{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().build());
event.setLine(1, new FormatBuilder(SignText.SIGN_VALID).replace("{line}", lines[1]).color().toString());
lines = event.getLines();
//Mark valid encryption/decryption sign
@@ -76,8 +76,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().build());
event.setLine(3, new FormatBuilder(SignText.SIGN_VALID).replace("{line}", lines[3]).color().build());
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());
}
}

View File

@@ -68,7 +68,7 @@ public enum SignType {
*/
@NotNull
private static String getText(@NotNull SignText signText) {
return InputCleaningUtil.stripColor(new FormatBuilder(signText).build());
return InputCleaningUtil.stripColor(new FormatBuilder(signText).toString());
}
}

View File

@@ -100,7 +100,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).build());
replace("{extension}", extension).toString());
return true;
}
@@ -119,7 +119,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()).build());
replace("{path}", file.getAbsolutePath()).toString());
return false;
}

View File

@@ -245,9 +245,9 @@ public final class BookFileReaderWriterUtil {
return null;
}
bookMetadata.setTitle(bookYml.getString("Title", new FormatBuilder(Formatting.NEUTRAL_UNKNOWN_TITLE).build()));
bookMetadata.setTitle(bookYml.getString("Title", new FormatBuilder(Formatting.NEUTRAL_UNKNOWN_TITLE).toString()));
bookMetadata.setAuthor(BookFileUtil.authorFromUUID(bookYml.getString("Author",
new FormatBuilder(Formatting.NEUTRAL_UNKNOWN_AUTHOR).build())));
new FormatBuilder(Formatting.NEUTRAL_UNKNOWN_AUTHOR).toString())));
bookMetadata.setPages(bookYml.getStringList("Pages"));
bookMetadata.setLore(bookYml.getStringList("Lore"));
bookMetadata.setDisplayName(bookYml.getString("DisplayName"));

View File

@@ -118,7 +118,7 @@ public final class BookFileUtil {
} else if (stripped.contains(",")) {
return stripped.split(",")[1];
} else {
return new FormatBuilder(Formatting.NEUTRAL_UNKNOWN_AUTHOR).color().build();
return new FormatBuilder(Formatting.NEUTRAL_UNKNOWN_AUTHOR).color().toString();
}
}
@@ -212,7 +212,7 @@ public final class BookFileUtil {
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).build());
replace("{separator}", separator).toString());
}
return InputCleaningUtil.cleanString(bookName + separator + authorName);

View File

@@ -111,7 +111,7 @@ public final class BookMetaUtil {
} else {
authorName = book.getAuthor();
if (authorName == null) {
authorName = new FormatBuilder(Formatting.NEUTRAL_UNKNOWN_AUTHOR).color().build();
authorName = new FormatBuilder(Formatting.NEUTRAL_UNKNOWN_AUTHOR).color().toString();
}
}
return authorName;
@@ -129,7 +129,7 @@ public final class BookMetaUtil {
bookName = book.getTitle();
}
if (bookName == null) {
bookName = new FormatBuilder(Formatting.NEUTRAL_UNKNOWN_TITLE).color().build();
bookName = new FormatBuilder(Formatting.NEUTRAL_UNKNOWN_TITLE).color().toString();
}
return bookName;
}

View File

@@ -320,7 +320,7 @@ public final class EncryptedBookUtil {
}
BooksWithoutBorders.log(Level.SEVERE, new FormatBuilder(
StaticMessage.EXCEPTION_ENCRYPTED_FILE_DELETE_FAILED.toString()).
replace("{path}", file.getPath()).build());
replace("{path}", file.getPath()).toString());
}
/**