Skip to content

Commit ce8a349

Browse files
Stop inserting line breaks at the end of every GHB line
Hopefully this will let GHB files age more gracefully if Mojang decide to change the book width again Closes #32
1 parent 0315e64 commit ce8a349

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
1313
apply plugin: 'eclipse'
1414
apply plugin: 'maven-publish'
1515

16-
version = '2.2.0'
16+
version = '2.2.1'
1717
group = 'wafflestomper' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
1818
archivesBaseName = '1.16.1-Ghostwriter'
1919

src/main/java/wafflestomper/ghostwriter/BookUtilities.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,14 @@ public static List<String> splitStringIntoLines(String str){
283283
//Split string at newline characters
284284
String[] lines = str.split("\\n");
285285
List<String> out = new ArrayList<>();
286-
for (String line : lines){
287-
out.addAll(Arrays.asList(wrapFormattedStringToWidth(line, BOOK_TEXT_WIDTH).split("" + SPLIT_CHAR)));
286+
for (int i=0; i<lines.length; i++){
287+
String line = lines[i];
288+
// Add newline characters back in
289+
if (i < lines.length - 1){
290+
line += "\n";
291+
}
292+
String splitLine = wrapFormattedStringToWidth(line, BOOK_TEXT_WIDTH);
293+
out.addAll(Arrays.asList(splitLine.split("" + SPLIT_CHAR)));
288294
}
289295
//return Arrays.asList(wrapFormattedStringToWidth(str, BOOK_TEXT_WIDTH).split("" + SPLIT_CHAR));
290296
return out;

src/main/java/wafflestomper/ghostwriter/FileHandler.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public boolean saveBookToGHBFile(String title, String author, List<String> pages
342342
List<String> currPage = BookUtilities.splitStringIntoLines(pageAsString);
343343
// Replace newline characters with double hashes and add the double hashes to the end of each line
344344
for (String line : currPage){
345-
toWrite.add(line.replaceAll("\\n", "##") + "##");
345+
toWrite.add(line.replaceAll("\\n", "##"));
346346
}
347347
// Add page breaks with line numbers
348348
if (i < pages.size()-1){

update.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"homepage": "https://github.com/waffle-stomper/Ghostwriter/releases",
33
"promos":{
4-
"1.16.1-recommended": "2.2.0",
4+
"1.16.1-recommended": "2.2.1",
55
"1.15.2-recommended": "2.0.6",
66
"1.15.1-recommended": "2.0.5",
77
"1.14.4-recommended": "2.0.4",
@@ -13,6 +13,7 @@
1313
"1.10-recommended": "1.8.5"
1414
},
1515
"1.16.1":{
16+
"2.2.1": "Add warnings about excessive characters and lines on a page\nStop inserting GHB line breaks at the end of every line when saving\nDecrease expected page width to 114 pixels to match vanilla",
1617
"2.2.0": "Hide unused buttons when signing\nAdd extra background for contrast when entering long titles",
1718
"2.1.9": "Format buttons can now be used when setting the title\nAdded pasting from the clipboard into the title",
1819
"2.1.8": "Allow titles longer than 15 characters\nThanks Maester Lodish",

0 commit comments

Comments
 (0)