Search in sources :

Example 6 with Region

use of pl.themolka.arcade.region.Region in project Arcade2 by ShootGame.

the class WoolFactory method parseWoolXml.

public Wool parseWoolXml(CaptureGame game, Element xml, Wool wool) {
    DyeColor color;
    try {
        String input = xml.getAttributeValue("color");
        if (input == null) {
            return null;
        }
        color = DyeColor.valueOf(XMLParser.parseEnumValue(xml.getAttributeValue("color")));
    } catch (IllegalArgumentException ex) {
        return null;
    }
    Element monumentElement = xml.getChild("monument");
    Region monument = monumentElement != null ? XMLRegion.parseUnion(game.getGame(), monumentElement) : null;
    if (monument == null) {
        return null;
    }
    // setup
    wool.setColor(color);
    wool.setCraftable(XMLParser.parseBoolean(xml.getAttributeValue("craftable"), false));
    wool.setMonument(monument);
    return wool;
}
Also used : Element(org.jdom2.Element) XMLRegion(pl.themolka.arcade.xml.XMLRegion) Region(pl.themolka.arcade.region.Region) DyeColor(org.bukkit.DyeColor)

Example 7 with Region

use of pl.themolka.arcade.region.Region 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

Region (pl.themolka.arcade.region.Region)7 XMLRegion (pl.themolka.arcade.xml.XMLRegion)6 Element (org.jdom2.Element)2 Handler (net.engio.mbassy.listener.Handler)1 DyeColor (org.bukkit.DyeColor)1 Location (org.bukkit.Location)1 Material (org.bukkit.Material)1 Attribute (org.jdom2.Attribute)1 GoalFireworkHandler (pl.themolka.arcade.goal.GoalFireworkHandler)1 Liquid (pl.themolka.arcade.leak.Liquid)1 Color (pl.themolka.arcade.util.Color)1