ariantpq + correct use catch item

This commit is contained in:
Diego Armando de Freitas Matos
2019-03-20 19:51:45 -03:00
parent 0a8efa4238
commit 0d7e8daf8e
36 changed files with 2398 additions and 2443 deletions
+19
View File
@@ -72,6 +72,25 @@ public class MapleDataTool {
return getInt(data);
}
}
public static int getIntConvert(MapleData d, int def) {
if (d == null) {
return def;
}
if (d.getType() == MapleDataType.STRING) {
String dd = getString(d);
if (dd.endsWith("%")) {
dd = dd.substring(0, dd.length() - 1);
}
try {
return Integer.parseInt(dd);
} catch (NumberFormatException nfe) {
return def;
}
} else {
return getInt(d, def);
}
}
public static int getIntConvert(String path, MapleData data) {
MapleData d = data.getChildByPath(path);