List of usage examples for org.jdom2 Element getAttribute
public Attribute getAttribute(final String attname)
This returns the attribute for this element with the given name and within no namespace, or null if no such attribute exists.
From source file:neon.resources.CClient.java
License:Open Source License
public void setKeys(Element settings) { if (settings != null) { // movement keys switch (settings.getText()) { case "azerty": setKeys(KeyboardSetting.AZERTY); break; case "qwerty": setKeys(KeyboardSetting.QWERTY); break; case "qwertz": setKeys(KeyboardSetting.QWERTZ); break; }//from w ww. ja v a 2s . c o m // andere keys if (settings.getAttribute("map") != null) { map = settings.getAttributeValue("map"); } if (settings.getAttribute("act") != null) { act = settings.getAttributeValue("act"); } if (settings.getAttribute("magic") != null) { magic = settings.getAttributeValue("magic"); } if (settings.getAttribute("shoot") != null) { shoot = settings.getAttributeValue("shoot"); } if (settings.getAttribute("look") != null) { look = settings.getAttributeValue("look"); } if (settings.getAttribute("talk") != null) { talk = settings.getAttributeValue("talk"); } if (settings.getAttribute("unmount") != null) { unmount = settings.getAttributeValue("unmount"); } if (settings.getAttribute("sneak") != null) { sneak = settings.getAttributeValue("sneak"); } if (settings.getAttribute("journal") != null) { journal = settings.getAttributeValue("journal"); } } }
From source file:neon.resources.quest.RQuest.java
License:Open Source License
public RQuest(String id, Element properties, String... path) { super(id, path); name = properties.getAttributeValue("name"); if (properties.getChild("stages") != null) { for (Element e : properties.getChild("stages").getChildren()) { Stage stage = new Stage(id, e); stages.put(stage.getIndex(), stage); }// w w w .ja v a2 s .c o m } if (properties.getChild("pre") != null) { for (Element condition : properties.getChild("pre").getChildren()) { conditions.add(condition.getTextTrim()); } } if (properties.getChild("objects") != null) { variables = properties.getChild("objects").detach(); } repeat = properties.getName().equals("repeat"); if (repeat) { frequency = Integer.parseInt(properties.getAttributeValue("f")); } initial = (properties.getAttribute("init") != null); journal = (properties.getAttribute("journal") != null); if (properties.getChild("dialog") != null) { initDialog(properties.getChild("dialog")); } }
From source file:neon.resources.RCreature.java
License:Open Source License
public RCreature(Element properties, String... path) { super(properties, path); subtypes = new ArrayList<Subtype>(); skills = initSkills(properties.getChild("skills")); color = properties.getAttributeValue("color"); hit = properties.getAttributeValue("hit"); av = properties.getChild("av").getText(); text = properties.getAttributeValue("char"); size = Size.valueOf(properties.getAttributeValue("size")); type = Type.valueOf(properties.getName()); str = Integer.parseInt(properties.getChild("stats").getAttributeValue("str")); con = Integer.parseInt(properties.getChild("stats").getAttributeValue("con")); dex = Integer.parseInt(properties.getChild("stats").getAttributeValue("dex")); iq = Integer.parseInt(properties.getChild("stats").getAttributeValue("int")); wis = Integer.parseInt(properties.getChild("stats").getAttributeValue("wis")); cha = Integer.parseInt(properties.getChild("stats").getAttributeValue("cha")); speed = Integer.parseInt(properties.getAttributeValue("speed")); if (properties.getAttributeValue("mana") != null) { // niet altijd aanwezig mana = Integer.parseInt(properties.getAttributeValue("mana")); }/* w w w . ja v a2 s. c o m*/ if (properties.getChild("dv") != null) { // niet altijd aanwezig dv = Integer.parseInt(properties.getChild("dv").getText()); } if (properties.getAttribute("habitat") != null) { habitat = Habitat.valueOf(properties.getAttributeValue("habitat").toUpperCase()); } Element brain = properties.getChild("ai"); if (brain != null) { if (!brain.getText().isEmpty()) { aiType = AIType.valueOf(brain.getText()); } if (brain.getAttributeValue("r") != null) { aiRange = Integer.parseInt(brain.getAttributeValue("r")); } if (brain.getAttributeValue("a") != null) { aiAggr = Integer.parseInt(brain.getAttributeValue("a")); } if (brain.getAttributeValue("c") != null) { aiConf = Integer.parseInt(brain.getAttributeValue("c")); } } }
From source file:neon.resources.RCreature.java
License:Open Source License
private static EnumMap<Skill, Float> initSkills(Element skills) { EnumMap<Skill, Float> list = new EnumMap<Skill, Float>(Skill.class); for (Skill skill : Skill.values()) { if (skills != null && skills.getAttribute(skill.toString().toLowerCase()) != null) { list.put(skill, Float.parseFloat(skills.getAttributeValue(skill.toString().toLowerCase()))); } else {//from w w w . ja va2s .co m list.put(skill, 0f); } } return list; }
From source file:neon.resources.RItem.java
License:Open Source License
public RItem(Element item, String... path) { super(item, path); type = Type.valueOf(item.getName()); if (item.getAttribute("cost") != null) { cost = Integer.parseInt(item.getAttributeValue("cost")); }// www . j ava2 s . c o m if (item.getAttribute("weight") != null) { weight = Float.parseFloat(item.getAttributeValue("weight")); } top = item.getAttribute("z") != null; if (item.getAttribute("spell") != null) { spell = item.getAttributeValue("spell"); } if (item.getChild("svg") != null) { svg = outputter.outputString((Element) item.getChild("svg").getChildren().get(0)); } }
From source file:neon.resources.RPerson.java
License:Open Source License
public RPerson(Element person, String... path) { super(person.getAttributeValue("id"), path); name = person.getAttributeValue("name"); species = person.getAttributeValue("race"); if (person.getChild("factions") != null) { for (Element f : person.getChild("factions").getChildren()) { int rank = f.getAttribute("rank") != null ? Integer.parseInt(f.getAttributeValue("rank")) : 0; factions.put(f.getAttributeValue("id"), rank); }/* w w w. ja va 2s . com*/ } Element brain = person.getChild("ai"); if (brain != null && !brain.getText().isEmpty()) { aiType = AIType.valueOf(brain.getText()); } else { aiType = null; } if (brain != null && brain.getAttribute("r") != null) { aiRange = Integer.parseInt(brain.getAttributeValue("r")); } else { aiRange = -1; } if (brain != null && brain.getAttribute("a") != null) { aiAggr = Integer.parseInt(brain.getAttributeValue("a")); } else { aiAggr = -1; } if (brain != null && brain.getAttribute("c") != null) { aiConf = Integer.parseInt(brain.getAttributeValue("c")); } else { aiConf = -1; } Element skillList = person.getChild("skills"); if (skillList != null) { for (Element skill : skillList.getChildren()) { skills.put(Skill.valueOf(skill.getAttributeValue("id").toUpperCase()), Integer.parseInt(skill.getAttributeValue("rank"))); } } Element itemList = person.getChild("items"); if (itemList != null) { for (Element item : itemList.getChildren()) { items.add(item.getAttributeValue("id")); } } Element spellList = person.getChild("spells"); if (spellList != null) { for (Element spell : spellList.getChildren()) { spells.add(spell.getAttributeValue("id")); } } // nieuwe arraylist om concurrentmodificationexceptions te vermijden for (Element service : new ArrayList<Element>(person.getChildren("service"))) { services.add(service.detach()); } for (Element script : person.getChildren("script")) { scripts.add(script.getText()); } }
From source file:neon.resources.RRecipe.java
License:Open Source License
public RRecipe(Element properties, String... path) { super(properties.getAttributeValue("id"), path); name = properties.getChild("out").getText(); if (properties.getAttribute("cost") != null) { cost = Integer.parseInt(properties.getAttributeValue("cost")); }// ww w .j av a2 s . c om for (Element in : properties.getChildren("in")) { ingredients.add(in.getText()); } }
From source file:neon.resources.RSpell.java
License:Open Source License
public RSpell(Element spell, String... path) { super(spell, path); type = SpellType.valueOf(spell.getName().toUpperCase()); effect = Effect.valueOf(spell.getAttributeValue("effect").toUpperCase()); script = spell.getText();/*w w w . ja v a 2 s.com*/ if (spell.getAttribute("size") != null) { size = Integer.parseInt(spell.getAttributeValue("size")); } else { size = 0; } if (spell.getAttribute("range") != null) { range = Integer.parseInt(spell.getAttributeValue("range")); } else { range = 0; } if (spell.getAttribute("duration") != null) { duration = Integer.parseInt(spell.getAttributeValue("duration")); } else { duration = 0; } if (spell.getAttribute("area") != null) { radius = Integer.parseInt(spell.getAttributeValue("area")); } else { radius = 0; } }
From source file:neon.resources.RTattoo.java
License:Open Source License
public RTattoo(Element tattoo, String... path) { super(tattoo, path); ability = Ability.valueOf(tattoo.getAttributeValue("ability").toUpperCase()); magnitude = Integer.parseInt(tattoo.getAttributeValue("size")); cost = Integer.parseInt(tattoo.getAttributeValue("cost")); if (tattoo.getAttribute("name") != null) { name = tattoo.getAttributeValue("name"); } else {/*from w ww . ja v a2s .c o m*/ name = id; } }
From source file:neon.resources.RWeapon.java
License:Open Source License
public RWeapon(Element weapon, String... path) { super(weapon, path); damage = weapon.getAttributeValue("dmg"); weaponType = WeaponType.valueOf(weapon.getAttributeValue("type").toUpperCase()); if (weapon.getAttribute("mana") != null) { mana = Integer.parseInt(weapon.getAttributeValue("mana")); }//from w ww. jav a 2 s . co m }