/** * set achievement progress of a given achievement * * @param achievement - name of achievement to be set * @param progress - progress to set the achievement progress to */ public void setAchievementProgress(String achievement, double progress) { for (AchievementIcon ai : achievementWindow.iconList) { if (ai.getName().equals(achievement)) { ai.setProgress(progress); } } }
@SuppressWarnings("unchecked") public static void writeToFile(Writer writer) { for (AchievementIcon ai : iconList) { JSONObject obj = new JSONObject(); obj.put("name", ai.getName()); obj.put("progress", ai.getProgress()); try { writer.write(obj.toString() + "\n"); } catch (IOException e) { e.printStackTrace(); } } }