Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix/818-journal-lines' into preview
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendan Grieve committed Nov 13, 2018
2 parents 68cd851 + 310d898 commit 5d58e03
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Expand Up @@ -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("\\.");
Expand Down Expand Up @@ -230,8 +230,7 @@ public void generateTexts(String lang) {
}

// 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);
}
}

Expand Down Expand Up @@ -316,8 +315,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('&', '§');
}

/**
Expand Down Expand Up @@ -371,22 +369,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<String> lore = new ArrayList<String>();
List<String> lore = new ArrayList<>();
lore.add(Utils.format(Config.getMessage(lang, "journal_lore")));
meta.setLore(lore);
// add main page and generate pages from texts
List<String> 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();
Expand Down
1 change: 1 addition & 0 deletions docs/02-Installation-and-Configuration.md
Expand Up @@ -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
Expand Down

0 comments on commit 5d58e03

Please sign in to comment.