Code:
List<ItemDefinition> list = new ArrayList<>();
for(i = 0; i < totalItems; i++) {
ItemDef def = forID(i);
if(def != null) {
ItemDefinition definition = new ItemDefinition();
definition.setId(i);
definition.setName(def.name == null ? "" : def.name);
definition.setNote(def.certTemplateID == 799);
definition.setNoteId(def.certID);
definition.setStackable(def.stackable);
definition.setTradable(true);
definition.setGeneralPrice(def.value);
definition.setHighAlch((int)Math.ceil(def.value * 0.75));
definition.setLowAlch((int)Math.ceil(def.value * 0.25));
list.add(definition);
}
}
try {
Files.write(Paths.get("definitions.xml"), new XStream().toXML(list).getBytes());
} catch (IOException e) {
e.printStackTrace();
}
Code:
public class ItemDefinition {
private int id;
private String name;
private boolean tradable;
private boolean stackable;
private boolean note;
private int noteId;
private int highAlch;
private int lowAlch;
private int generalPrice;
public ItemDefinition() {
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isTradable() {
return tradable;
}
public void setTradable(boolean tradable) {
this.tradable = tradable;
}
public boolean isStackable() {
return stackable;
}
public void setStackable(boolean stackable) {
this.stackable = stackable;
}
public boolean isNote() {
return note;
}
public void setNote(boolean note) {
this.note = note;
}
public int getNoteId() {
return noteId;
}
public void setNoteId(int noteId) {
this.noteId = noteId;
}
public int getHighAlch() {
return highAlch;
}
public void setHighAlch(int highAlc) {
this.highAlch = highAlch;
}
public int getLowAlch() {
return lowAlch;
}
public void setLowAlch(int lowAlch) {
this.lowAlch = lowAlch;
}
public int getGeneralPrice() {
return generalPrice;
}
public void setGeneralPrice(int generalPrice) {
this.generalPrice = generalPrice;
}
}
Code:
<!-- https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream -->
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.9</version>
</dependency>