List of usage examples for org.jdom2 Element getName
public String getName()
From source file:neon.resources.builder.ModLoader.java
License:Open Source License
public RMod loadMod(CGame game, CClient client) { // main.xml laden Element mod = files.getFile(new XMLTranslator(), path, "main.xml").getRootElement(); // cc.xml laden Element cc = null;/*from w w w . ja v a 2s . co m*/ if (files.exists(path, "cc.xml")) { cc = files.getFile(new XMLTranslator(), path, "cc.xml").getRootElement(); } RMod rmod = new RMod(mod, cc); rmod.addMaps(initMaps(path, "maps")); initMain(client, mod); if (mod.getName().equals("extension")) { if (!resources.hasResource(mod.getChild("master").getText(), "mods")) { System.err.println("Extension master not found: " + path + "."); } } // terrain if (files.exists(path, "terrain.xml")) { initTerrain(path, "terrain.xml"); } // books if (files.listFiles(path, "books") != null) { initBooks(path, "books"); // laden voor items, anders vindt book zijn text niet } // items initItems(path, "items.xml"); // items initItems(path, "crafting.xml"); // crafting // themes (na terrain en items, want themes bevatten terrain en items) initThemes(path, "themes", "dungeons.xml"); // dungeons initThemes(path, "themes", "zones.xml"); // zones initThemes(path, "themes", "regions.xml"); // regions // creatures initCreatures(path, "monsters.xml"); // species initCreatures(path, "npc.xml"); // people // scripts if (files.listFiles(path, "scripts") != null) { initScripts(path, "scripts"); } // events if (files.exists(path, "events.xml")) { initTasks(path, "events.xml"); } // character creation if (files.exists(path, "cc.xml")) { initCC(game, path, "cc.xml"); } // random quests if (files.listFiles(path, "quests") != null) { initQuests(path, "quests"); } // magic initMagic(path, "spells.xml"); // spells initMagic(path, "alchemy.xml"); // alchemy initMagic(path, "signs.xml"); // birth signs initMagic(path, "tattoos.xml"); // tattoos return rmod; }
From source file:neon.resources.builder.ModLoader.java
License:Open Source License
private void initCreatures(String... file) { if (files.exists(file)) { Element creatures = files.getFile(new XMLTranslator(), file).getRootElement(); for (Element c : creatures.getChildren()) { switch (c.getName()) { case "npc": resources.addResource(new RPerson(c)); break; case "list": resources.addResource(new LCreature(c)); break; default: resources.addResource(new RCreature(c)); break; }// ww w .j av a2s . com } } }
From source file:neon.resources.builder.ModLoader.java
License:Open Source License
private void initItems(String... file) { if (files.exists(file)) { Element items = files.getFile(new XMLTranslator(), file).getRootElement(); for (Element e : items.getChildren()) { switch (e.getName()) { case "book": case "scroll": resources.addResource(new RItem.Text(e)); break; case "weapon": resources.addResource(new RWeapon(e)); break; case "craft": resources.addResource(new RCraft(e), "craft"); break; case "door": resources.addResource(new RItem.Door(e)); break; case "potion": resources.addResource(new RItem.Potion(e)); break; case "container": resources.addResource(new RItem.Container(e)); break; case "list": resources.addResource(new LItem(e)); break; case "armor": case "clothing": resources.addResource(new RClothing(e)); break; default: resources.addResource(new RItem(e)); break; }//from w w w . j a v a2 s. c o m } } }
From source file:neon.resources.builder.ModLoader.java
License:Open Source License
private void initThemes(String... file) { if (files.exists(file)) { Element themes = files.getFile(new XMLTranslator(), file).getRootElement(); for (Element theme : themes.getChildren()) { switch (theme.getName()) { case "dungeon": resources.addResource(new RDungeonTheme(theme), "theme"); break; case "zone": resources.addResource(new RZoneTheme(theme), "theme"); break; case "region": resources.addResource(new RRegionTheme(theme), "theme"); break; }// w w w.j a v a 2 s. c om } } }
From source file:neon.resources.builder.ModLoader.java
License:Open Source License
private void initMagic(String... file) { if (files.exists(file)) { Element spells = files.getFile(new XMLTranslator(), file).getRootElement(); for (Element resource : spells.getChildren()) { switch (resource.getName()) { case "sign": resources.addResource(new RSign(resource), "magic"); break; case "tattoo": resources.addResource(new RTattoo(resource), "magic"); break; case "recipe": resources.addResource(new RRecipe(resource), "magic"); break; case "list": resources.addResource(new LSpell(resource), "magic"); break; case "power": resources.addResource(new RSpell.Power(resource), "magic"); break; case "enchant": resources.addResource(new RSpell.Enchantment(resource), "magic"); break; default: resources.addResource(new RSpell(resource), "magic"); break; }//from w w w.j a v a 2 s . com } } }
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); }/*from w w w .j ava2s . 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.RClothing.java
License:Open Source License
public RClothing(Element cloth, String... path) { super(cloth, path); Element stats = cloth.getChild("stats"); slot = Slot.valueOf(stats.getAttributeValue("slot").toUpperCase()); if (cloth.getName().equals("armor")) { rating = Integer.parseInt(stats.getAttributeValue("ar")); kind = ArmorType.valueOf(stats.getAttributeValue("class").toUpperCase()); } else {/*from w w w. j a va 2s . c om*/ rating = 0; kind = ArmorType.NONE; } if (cloth.getChild("enchant") != null) { Element enchantment = cloth.getChild("enchant"); magnitude = Integer.parseInt(enchantment.getAttributeValue("mag")); mana = Integer.parseInt(enchantment.getAttributeValue("mana")); effect = Effect.valueOf(enchantment.getAttributeValue("effect").toUpperCase()); } else { magnitude = 0; mana = 0; effect = null; } }
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")); }// ww w. j ava 2 s . co 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.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")); }//from ww w.jav a 2s . c om 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.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();/*from ww w . j a va 2 s . co m*/ 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; } }