-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckMoonItems.java
More file actions
68 lines (56 loc) · 2.29 KB
/
Copy pathCheckMoonItems.java
File metadata and controls
68 lines (56 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
// Simple ItemDefinition class for testing
class TestItemDefinition {
private int id;
private String name;
private String examine;
public int getId() { return id; }
public String getName() { return name; }
public String getExamine() { return examine; }
}
public class CheckMoonItems {
public static void main(String[] args) {
try {
System.out.println("Checking moon items in JSON...");
// Read JSON file manually and look for moon items
FileReader reader = new FileReader("server/data/definitions/items.json");
StringBuilder content = new StringBuilder();
int ch;
while ((ch = reader.read()) != -1) {
content.append((char) ch);
}
reader.close();
String json = content.toString();
// Count moon items in JSON
int moonCount = 0;
String[] lines = json.split("\n");
boolean inMoonItem = false;
String currentMoonItem = "";
for (int i = 0; i < lines.length; i++) {
String line = lines[i].trim();
if (line.contains("\"id\": 3100")) {
inMoonItem = true;
currentMoonItem = "ID: " + line.split(":")[1].trim() + " - ";
}
if (inMoonItem && line.contains("\"name\":")) {
String name = line.split(":")[1].trim();
currentMoonItem += name;
if (name.toLowerCase().contains("moon")) {
moonCount++;
System.out.println("Found moon item: " + currentMoonItem);
}
inMoonItem = false;
}
}
System.out.println("Total moon items found: " + moonCount);
// Check if JSON is well-formed at the end
System.out.println("JSON ends with: " + json.substring(json.length() - 50));
} catch (IOException e) {
e.printStackTrace();
}
}
}