private void setForgePropertyValue(Property forgeProp, ConfigPropertyData propData) { Property.Type type = CONFIG_TYPES.get(propData.getType()); if (type == null) return; switch (type) { case INTEGER: if (propData.getType().isArray()) { forgeProp.setValues((int[]) propData.getValue()); } else { forgeProp.setValue((Integer) propData.getValue()); } break; case DOUBLE: if (propData.getType().equals(Float.class) || propData.getType().equals(float.class)) { if (propData.getType().isArray()) { float[] vals = (float[]) propData.getValue(); double[] dVals = new double[vals.length]; for (int i = 0; i < vals.length; i++) { dVals[i] = vals[i]; } forgeProp.setValues(dVals); } else { forgeProp.setValue((Float) propData.getValue()); } } else { if (propData.getType().isArray()) { forgeProp.setValues((double[]) propData.getValue()); } else { forgeProp.setValue((Double) propData.getValue()); } } break; case BOOLEAN: if (propData.getType().isArray()) { forgeProp.setValues((boolean[]) propData.getValue()); } else { forgeProp.setValue((Boolean) propData.getValue()); } break; case STRING: if (propData.getType().isArray()) { forgeProp.setValues((String[]) propData.getValue()); } else { forgeProp.setValue((String) propData.getValue()); } break; } }
private Property makeProperty(ConfigPropertyData propData) { Property.Type type = CONFIG_TYPES.get(propData.getType()); if (type == null) return null; if (!propData.getType().isArray()) { Property forgeProp = new Property(propData.name(), String.valueOf(propData.getValue()), type); forgeProp.set(String.valueOf(propData.getValue())); return forgeProp; } switch (type) { case INTEGER: { Integer[] val = (Integer[]) propData.getValue(); String[] propVal = new String[val.length]; for (int i = 0; i < val.length; i++) propVal[i] = String.valueOf(val[i]); Property forgeProp = new Property(propData.name(), propVal, type); forgeProp.set(propVal); return forgeProp; } case DOUBLE: if (propData.getType().equals(Float.class) || propData.getType().equals(float.class)) { Float[] val = (Float[]) propData.getValue(); String[] propVal = new String[val.length]; for (int i = 0; i < val.length; i++) propVal[i] = String.valueOf(val[i]); Property forgeProp = new Property(propData.name(), propVal, type); forgeProp.set(propVal); return forgeProp; } else { Double[] val = (Double[]) propData.getValue(); String[] propVal = new String[val.length]; for (int i = 0; i < val.length; i++) propVal[i] = String.valueOf(val[i]); Property forgeProp = new Property(propData.name(), propVal, type); forgeProp.set(propVal); return forgeProp; } case BOOLEAN: { Boolean[] val = (Boolean[]) propData.getValue(); String[] propVal = new String[val.length]; for (int i = 0; i < val.length; i++) propVal[i] = String.valueOf(val[i]); Property forgeProp = new Property(propData.name(), propVal, type); forgeProp.set(propVal); return forgeProp; } case STRING: String[] propVal = (String[]) propData.getValue(); Property forgeProp = new Property(propData.name(), propVal, type); forgeProp.set(propVal); return forgeProp; } return null; }