From 310d8989d0f0ea4b24a31d58d3567338d1dfe50c Mon Sep 17 00:00:00 2001 From: Brendan Grieve Date: Tue, 13 Nov 2018 13:15:19 +0800 Subject: [PATCH] All Journal Config + Fix Date Issue Notes: * If date is hidden, then the journal won't leave blank lines * Separator can be hidden by setting 'journal.show_separator' to false. Defaults to true * Separator can be customized by adding 'journal_separator' to messages.yml. Defaults to "---------------" Changes: * Updated journal to include date fix * Updated journal to allow hiding separator and customizing through messages. * Updated Documentation. Closes: * Closes #818 --- .../pl/betoncraft/betonquest/Journal.java | 25 +++++++++++++------ docs/02-Installation-and-Configuration.md | 1 + 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/BetonQuest-core/src/main/java/pl/betoncraft/betonquest/Journal.java b/BetonQuest-core/src/main/java/pl/betoncraft/betonquest/Journal.java index ca098f864d..829dcc9461 100644 --- a/BetonQuest-core/src/main/java/pl/betoncraft/betonquest/Journal.java +++ b/BetonQuest-core/src/main/java/pl/betoncraft/betonquest/Journal.java @@ -191,7 +191,7 @@ public void generateTexts(String lang) { if (dateParts.length > 1) { hour = "§" + Config.getString("config.journal_colors.date.hour") + dateParts[1]; } - datePrefix = day + " " + hour; + datePrefix = day + " " + hour + "\n"; } // get package and name of the pointer String[] parts = pointer.getPointer().split("\\."); @@ -217,8 +217,7 @@ public void generateTexts(String lang) { text = "error"; } // add the entry to the list - texts.add(datePrefix + "§" + Config.getString("config.journal_colors.text") + "\n" - + text); + texts.add(datePrefix + "§" + Config.getString("config.journal_colors.text") + text); } } @@ -303,8 +302,7 @@ private String generateMainPage() { for (int i : sorted) { sortedLines.add(lines.get(i)); } - String finalLine = StringUtils.join(sortedLines, '\n').replace('&', '§'); - return finalLine; + return StringUtils.join(sortedLines, '\n').replace('&', '§'); } /** @@ -358,22 +356,33 @@ public ItemStack getAsItem() { BookMeta meta = (BookMeta) item.getItemMeta(); meta.setTitle(Utils.format(Config.getMessage(lang, "journal_title"))); meta.setAuthor(PlayerConverter.getPlayer(playerID).getName()); - List lore = new ArrayList(); + List lore = new ArrayList<>(); lore.add(Utils.format(Config.getMessage(lang, "journal_lore"))); meta.setLore(lore); // add main page and generate pages from texts List finalList = new ArrayList<>(); if (Config.getString("config.journal.one_entry_per_page").equalsIgnoreCase("false")) { String color = Config.getString("config.journal_colors.line"); + String separator = Config.parseMessage(playerID, "journal_separator", null); + if (separator == null) { + separator = "---------------"; + } + String line = "\n§" + color + separator + "\n"; + + if (Config.getString("config.journal.show_separator") != null && + Config.getString("config.journal.show_separator").equalsIgnoreCase("false")) { + line = "\n"; + } + StringBuilder stringBuilder = new StringBuilder(); for (String entry : getText()) { - stringBuilder.append(entry + "\n§" + color + "---------------\n"); + stringBuilder.append(entry).append(line); } if (mainPage != null && mainPage.length() > 0) { if (Config.getString("config.journal.full_main_page").equalsIgnoreCase("true")) { finalList.addAll(Utils.pagesFromString(mainPage)); } else { - stringBuilder.insert(0, mainPage + "\n§" + color + "---------------\n"); + stringBuilder.insert(0, mainPage + line); } } String wholeString = stringBuilder.toString().trim(); diff --git a/docs/02-Installation-and-Configuration.md b/docs/02-Installation-and-Configuration.md index 37f04992c8..ffb39ad14f 100644 --- a/docs/02-Installation-and-Configuration.md +++ b/docs/02-Installation-and-Configuration.md @@ -48,6 +48,7 @@ The configuration of BetonQuest is done mainly in _config.yml_ file. All options - `reversed_order` controls the chronological order of entries in the journal. By default the entries are ordered from newest to oldest. You can reverse it, but it will force players to click through a lot of pages to get to the latest entry. - `hide_date` hides the date of each entry. Set it to true if you don't want this functionality. - `full_main_page` makes the main page take always a full page. If you display a lot of information you should probably make this true. If you use main page only for small notifications, set it to false, so the entries can follow immediately. + - `show_separator` shows a separator between journal entries (default: true). Customize the separator in `messages.yml` with the key `journal_separator`. * `journal_colors` controls the colors used in the journal. It takes color codes without the `&` character. - `date.day` is a day number - `date.hour` is a hour number