xml.creaturesChange();
addButton.setEnabled(true);
setButton.setForeground(Color.BLACK);
int pos = creatureList.getSelectedIndex();
DefaultCreature actual = (DefaultCreature) filteredCreatures.get(pos);
actual.setCreatureName(creatureName.getText());
actual.setCreatureClass((String) creatureClass.getSelectedItem());
actual.setCreatureSubclass(creatureSubclass.getText());
String[] sizes = creatureSize.getText().split(",");
actual.setSize(Integer.parseInt(sizes[0]),
Integer.parseInt(sizes[1]));
actual.setTileId(creatureTileid.getText());
actual.setLevel(Integer.parseInt(creatureLevel.getText()),
Integer.parseInt(creatureXP.getText()) * 20);
actual.setRespawnTime(Integer.parseInt(creatureRespawn.getText()));
actual.setDescription(creatureDescription.getText());
actual.setRPStats(Integer.parseInt(creatureHP.getText()),
Integer.parseInt(creatureATK.getText()),
Integer.parseInt(creatureDEF.getText()),
Double.parseDouble(creatureSpeed.getText()));
/* Drops */
List<DropItem> dropList = new LinkedList<DropItem>();
BufferedReader reader = new BufferedReader(new StringReader(
creatureDrops.getText()));
String line = reader.readLine();
while (line != null) {
String[] tok = line.split(";");
String[] minmax = tok[1].replace("[", "").replace("]", "").split(
",");
dropList.add(new DropItem(tok[0].trim(),
Double.parseDouble(tok[2].trim()),
Integer.parseInt(minmax[0].trim()),
Integer.parseInt(minmax[1].trim())));
line = reader.readLine();
}
actual.setDropItems(dropList);
List<EquipItem> equipList = new LinkedList<EquipItem>();
reader = new BufferedReader(new StringReader(
creatureEquips.getText()));
line = reader.readLine();
while (line != null) {
String[] tok = line.split(";");
equipList.add(new EquipItem(tok[1].trim(), tok[0].trim(),
Integer.parseInt(tok[2].trim())));
line = reader.readLine();
}
actual.setEquipedItems(equipList);
Map<String, String> profiles = new LinkedHashMap<String, String>();
List<String> noises = new LinkedList<String>();
reader = new BufferedReader(new StringReader(creatureAI.getText()));
line = reader.readLine();
while (line != null) {
if (line.startsWith("says")) {
noises.add(line.replace("says", "").replace(":", "").trim());
} else {
int i = line.indexOf("=");
String key = null;
String val = null;
if (i != -1) {
key = line.substring(0, i - 1).trim();
val = line.substring(i + 1).trim();
} else {
key = line;
}
profiles.put(key, val);
}
line = reader.readLine();
}
actual.setAIProfiles(profiles);
//actual.setNoiseLines(noises);
xml.sortCreatures(filteredCreatures);
xml.updateFrameContents();
refresh();