Is the following mods-or-vanilla-but-not-both behavior intended? I have had to work around it.
Global.getSettings(String path, boolean withMods)
returns the entries from the merged
weapon_data.csv for mods without the entries from the vanilla
weapon_data.csv if
withMods is true; else, it returns the entries from the vanilla
weapon_data.csv with empty JSONObjects corresponding to the entries from merged
weapon_data.csv for mods. To have all
weapon_data.csv entries in one
JSONArray, I have had to load each one and then merge them with this code.
final JSONArray weapon_data_csv, weapon_data_csv_vanilla;
try {
weapon_data_csv = Global.getSettings().loadCSV("data/weapons/weapon_data.csv",
true);
} catch (JSONException | IOException e) { e.printStackTrace(); return; }
try {
weapon_data_csv_vanilla = Global.getSettings().loadCSV("data/weapons/weapon_data.csv",
false);
} catch (JSONException | IOException e) { e.printStackTrace(); return; }
for (int i = 0; i < weapon_data_csv_vanilla.length(); i++) {
final JSONObject row;
try { row = weapon_data_csv_vanilla.getJSONObject(i); }
catch (JSONException e) { e.printStackTrace(); return; }
final String weaponId;
try { weaponId = row.getString("id"); }
catch (JSONException e) { e.printStackTrace(); return; }
if (!weaponId.isEmpty())
try { weapon_data_csv.put(weapon_data_csv.length(), row); }
catch (JSONException e) { e.printStackTrace(); return; }
}
Edit: Users have reported that this code does not work either.
Edit: Trying this code.
Global.getSettings().getMergedSpreadsheetData("id", "data/weapons/weapon_data.csv")
It loads both vanilla and mod
weapon_data.csv into one merged
JSONArray on my end, and I hope it works on theirs. Why does this method require a column name? I had to guess and hope that "id" would work; the method returned everything rather than just "id". I'm confused.
