Skip to content

Commit

Permalink
update part of the widget parsing code
Browse files Browse the repository at this point in the history
  • Loading branch information
Morazzer committed Nov 17, 2024
1 parent 3c55630 commit a2d17bd
Showing 1 changed file with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package codes.cookies.mod.utils.skyblock.tab.widgets.corpse;

import java.util.ArrayList;
import java.util.List;

import codes.cookies.mod.utils.skyblock.tab.PlayerListReader;
import codes.cookies.mod.utils.skyblock.tab.widgets.PlayerListWidget;
import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

/**
* Widget with information about what corpses are present in the mineshaft.
*/
Expand All @@ -18,12 +18,21 @@ public static String getTitle() {
return "Frozen Corpses";
}

public static boolean doesMatch(String s) {
return s.startsWith(getTitle());
}

@Override
protected void read(PlayerListReader reader) {
int amount = 0;
while (reader.canRead() && !reader.peek().isBlank() && !reader.isTitle()) {
if (!addCorpse(reader.peek())) {
return;
}
if (amount > 5) {
return;
}
amount++;
reader.skip();
}
}
Expand All @@ -34,16 +43,18 @@ private boolean addCorpse(String peek) {
}

final String[] parts = peek.split(":");
if (parts.length != 2) {
return false;
}
if (!"looted".equalsIgnoreCase(parts[1].trim()) && !"not looted".equalsIgnoreCase(parts[1].trim())) {
return false;
}

CorpseType corpseType = CorpseType.getCorpseTypeFromString(parts[0].trim());
boolean found = "looted".equals(parts[1]);
boolean found = "looted".equalsIgnoreCase(parts[1].trim());

corpses.add(new CorpseEntry(corpseType, found));

return true;
}

public static boolean doesMatch(String s) {
return s.startsWith(getTitle());
}
}

0 comments on commit a2d17bd

Please sign in to comment.