Skip to content

Commit

Permalink
Fix crash if a page gets corrupted, and set the version number as a s…
Browse files Browse the repository at this point in the history
…tring so I don't need to type it out twice.
  • Loading branch information
JunePrimavera committed Aug 2, 2024
1 parent 4b9ecab commit 05bf289
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/main/java/xyz/sillyjune/notebook/Notebook.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,6 @@ public static ButtonTextures getBookIcon() {
public static NotebookConfig CONFIG;
public static final Identifier BOOK_TEXTURE = Identifier.of("textures/gui/book.png");
public static String BOOK_FOLDER = "Notebook";
public static final String VERSION = "4.0.5";
public static boolean GAY = true; // I might be straight but gay people are pretty cool
}
11 changes: 8 additions & 3 deletions src/main/java/xyz/sillyjune/notebook/NotebookScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,12 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
@Override
public boolean charTyped(char chr, int modifiers) {
if (!this.bookNameField.isSelected()) {
if (cursorIndex > DATA.content[pageIndex].length()) { cursorIndex = DATA.content[pageIndex].length(); }
if (DATA.content[pageIndex] == null) {
DATA.content[pageIndex] = " "; // Prevents it from crashing when null values are created, though this shouldn't be able to happen
}
if (cursorIndex > DATA.content[pageIndex].length()) {
cursorIndex = DATA.content[pageIndex].length();
}
DATA.content[pageIndex] = DATA.content[pageIndex].substring(0, cursorIndex) + chr + DATA.content[pageIndex].substring(cursorIndex);
DATA.write();
this.cursorIndex += 1;
Expand All @@ -205,9 +210,9 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta);
if (GAY) { context.drawText(this.textRenderer, Text.translatable("notebook.gay"), 5, this.height - 22, Colors.WHITE, true); }
if (CONFIG.debug()) {
context.drawText(this.textRenderer, Text.of("Notebook v4.0.4 - " + Text.translatable("devwarning.info").getString()), 5, this.height - 10, Colors.WHITE, true);
context.drawText(this.textRenderer, Text.of("Notebook v" + VERSION + " " + Text.translatable("devwarning.info").getString()), 5, this.height - 10, Colors.WHITE, true);
} else {
context.drawText(this.textRenderer, Text.of("Notebook v4.0.4"), 5, this.height - 10, Colors.WHITE, true);
context.drawText(this.textRenderer, Text.of("Notebook v" + VERSION), 5, this.height - 10, Colors.WHITE, true);
}
}
public void renderBackground(DrawContext context, int mouseX, int mouseY, float delta) {
Expand Down

0 comments on commit 05bf289

Please sign in to comment.