Skip to content

Commit

Permalink
Ignore ZNPCsPlus hologram serialization errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Krakenied committed Feb 29, 2024
1 parent 888d55b commit 1503f5b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,21 @@ public void onNpcInteract(NpcInteractEvent event) {
if (lineCount > 0) {
StringBuilder nameBuilder = new StringBuilder();
for (int i = 0; i < lineCount; i++) {
String line = hologram.getLine(i);
boolean lastLine = (i == lineCount - 1);

String line;
try {
line = hologram.getLine(i);
} catch (Throwable ignored) {
if (lastLine) {
nameBuilder.deleteCharAt(nameBuilder.length() - 1);
}
continue;
}

nameBuilder.append(line);

if (i != lineCount - 1) {
if (!lastLine) {
nameBuilder.append('\n');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,21 @@ public void onNpcInteract(NpcInteractEvent event) {
if (lineCount > 0) {
StringBuilder nameBuilder = new StringBuilder();
for (int i = 0; i < lineCount; i++) {
String line = hologram.getLine(i);
boolean lastLine = (i == lineCount - 1);

String line;
try {
line = hologram.getLine(i);
} catch (Throwable ignored) {
if (lastLine) {
nameBuilder.deleteCharAt(nameBuilder.length() - 1);
}
continue;
}

nameBuilder.append(line);

if (i != lineCount - 1) {
if (!lastLine) {
nameBuilder.append('\n');
}
}
Expand Down

0 comments on commit 1503f5b

Please sign in to comment.