Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Advancement: fix null string
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFaser committed Dec 3, 2023
1 parent 490234e commit 239f415
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ public FAdvancement(@NotNull Advancement adv) {
Object rawDesc = NMSUtil.getObject(display, "b");

translateKey = getTranslateString(rawTitle);
if (translateKey.isEmpty()) return;

translateDesc = getTranslateString(rawDesc);
if (translateDesc.isEmpty()) return;

String typeName = NMSUtil.checkValue(NMSUtil.getObject(display, "e"), "PROGRESS");
this.type = Type.getType(typeName);
Expand All @@ -75,7 +78,12 @@ public FAdvancement(@NotNull Advancement adv) {
@NotNull
private String getTranslateString(@Nullable Object object) {
String string = String.valueOf(object);
return string.substring(string.indexOf("key='") + 5, string.indexOf("',"));
int start = string.indexOf("key='");
int end = string.indexOf("',");

if (start == -1 || end == -1) return "";

return string.substring(start + 5, end);
}

private boolean getBool(String string) {
Expand Down

0 comments on commit 239f415

Please sign in to comment.