Skip to content

Commit 4cba88a

Browse files
Update INIConfig.java
Adjust the ini configuration format.
1 parent 40866dd commit 4cba88a

File tree

1 file changed

+14
-15
lines changed
  • src/main/java/org/bytingbulldogs/bulldoglibrary/INIConfiguration

1 file changed

+14
-15
lines changed

src/main/java/org/bytingbulldogs/bulldoglibrary/INIConfiguration/INIConfig.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,23 @@ public INIConfig(String filename) {
3030
public void autoPopulate(Object o) {
3131
if (ini != null) {
3232
Field[] fields = o.getClass().getFields();
33+
String className = o.getClass().getSimpleName();
34+
3335
for (Field field : fields) {
34-
String[] split = field.getName().split("_");
35-
int length = split.length;
36-
if (length >= 2) {
37-
try {
38-
39-
if(getOrDefault(split[split.length - 2], split[split.length - 1], null, field.getType())!=null)
40-
{
41-
field.set(o,
42-
getOrDefault(split[split.length - 2], split[split.length - 1], null, field.getType()));
43-
}
44-
45-
} catch (IllegalArgumentException | IllegalAccessException e) {
46-
DriverStation.reportWarning("Could not load item " + field.getName() + " from file " + filename,
47-
e.getStackTrace());
36+
String fieldName = field.getName();
37+
38+
try {
39+
if (getOrDefault(className, fieldName, null, field.getType()) != null) {
40+
field.setAccessible(true);
41+
42+
field.set(o, getOrDefault(className, fieldName, null, field.getType()));
43+
4844
}
45+
46+
} catch (IllegalArgumentException | IllegalAccessException e) {
47+
DriverStation.reportWarning("Could not load item " + field.getName() + " from file " + filename,
48+
e.getStackTrace());
4949
}
50-
field.getType();
5150
}
5251
}
5352
}

0 commit comments

Comments
 (0)