Search in sources :

Example 1 with Liquid

use of pl.themolka.arcade.leak.Liquid in project Arcade2 by ShootGame.

the class CoreFactory method parseCoreXml.

public Core parseCoreXml(LeakGame game, Element xml, Core core) {
    String paramLiquid = xml.getAttributeValue("liquid");
    String paramMaterial = xml.getAttributeValue("material");
    String paramDetectorLevel = xml.getAttributeValue("detector-level");
    // liquid
    Liquid liquid = Core.DEFAULT_LIQUID;
    if (paramLiquid != null && !paramLiquid.isEmpty()) {
        Liquid type = Liquid.valueOf(XMLParser.parseEnumValue(paramLiquid));
        if (type != null) {
            liquid = type;
        }
    }
    // material
    List<Material> material = Collections.singletonList(Core.DEFAULT_MATERIAL);
    if (paramMaterial != null) {
        material = parseArray(new Attribute("material", paramMaterial), Core.DEFAULT_MATERIAL);
    }
    // detector
    int detectorLevel = Core.DEFAULT_DETECTOR_LEVEL;
    if (paramDetectorLevel != null && !paramDetectorLevel.isEmpty()) {
        try {
            detectorLevel = Integer.parseInt(paramDetectorLevel);
        } catch (NumberFormatException ignored) {
        }
    }
    // region
    Region region = XMLRegion.parseUnion(game.getGame(), xml.getChild("region"));
    if (region == null) {
        return null;
    }
    // setup
    core.setMaterial(material);
    core.build(liquid, region, detectorLevel);
    return core;
}
Also used : Liquid(pl.themolka.arcade.leak.Liquid) Attribute(org.jdom2.Attribute) XMLRegion(pl.themolka.arcade.xml.XMLRegion) Region(pl.themolka.arcade.region.Region) Material(org.bukkit.Material)

Aggregations

Material (org.bukkit.Material)1 Attribute (org.jdom2.Attribute)1 Liquid (pl.themolka.arcade.leak.Liquid)1 Region (pl.themolka.arcade.region.Region)1 XMLRegion (pl.themolka.arcade.xml.XMLRegion)1