Search in sources :

Example 1 with ClaimType

use of me.andrew28.addons.conquer.api.ClaimType in project Conquer by xXAndrew28Xx.

the class EffChangeClaimOwnership method execute.

@Override
protected void execute(Event e) {
    Object[] claimObjects = this.claims.getArray(e);
    if (claimObjects == null) {
        return;
    }
    List<ConquerClaim> claims = new ArrayList<>();
    for (Object claimObject : claimObjects) {
        if (claimObject instanceof ConquerClaim) {
            claims.add((ConquerClaim) claimObject);
        } else if (claimObject instanceof Location) {
            claims.add(Conquer.getInstance().getFactions().getClaim((Location) claimObject));
        }
    }
    if (claiming) {
        if (forFactions) {
            ConquerFaction faction = (ConquerFaction) this.type.getSingle(e);
            if (faction == null) {
                return;
            }
            claims.forEach(faction::claim);
        } else {
            ClaimType type = (ClaimType) this.type.getSingle(e);
            if (type == null) {
                return;
            }
            claims.forEach(claim -> claim.setTo(type));
        }
    } else {
        claims.forEach(claim -> claim.setTo(ClaimType.WILDERNESS));
    }
}
Also used : ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction) ArrayList(java.util.ArrayList) ConquerClaim(me.andrew28.addons.conquer.api.ConquerClaim) Location(org.bukkit.Location) ClaimType(me.andrew28.addons.conquer.api.ClaimType)

Example 2 with ClaimType

use of me.andrew28.addons.conquer.api.ClaimType in project Conquer by xXAndrew28Xx.

the class ExprTypeOfClaim method change.

@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
    ConquerClaim[] claims = getExpr().getArray(e);
    if (claims == null) {
        return;
    }
    ClaimType type = ClaimType.WILDERNESS;
    if (mode == Changer.ChangeMode.SET) {
        if (delta == null || delta.length == 0) {
            return;
        }
        type = (ClaimType) delta[0];
        if (type == null) {
            type = ClaimType.WILDERNESS;
        }
    }
    for (ConquerClaim claim : claims) {
        if (claim == null) {
            continue;
        }
        claim.setTo(type);
    }
}
Also used : ConquerClaim(me.andrew28.addons.conquer.api.ConquerClaim) ClaimType(me.andrew28.addons.conquer.api.ClaimType)

Example 3 with ClaimType

use of me.andrew28.addons.conquer.api.ClaimType in project Conquer by xXAndrew28Xx.

the class CondClaimType method check.

@Override
public boolean check(Event e) {
    ClaimType type = this.type.getSingle(e);
    if (type == null) {
        type = ClaimType.WILDERNESS;
    }
    ClaimType finalType = type;
    return claims.check(e, claim -> claim.getType().equals(finalType), isNegated());
}
Also used : ClaimType(me.andrew28.addons.conquer.api.ClaimType)

Aggregations

ClaimType (me.andrew28.addons.conquer.api.ClaimType)3 ConquerClaim (me.andrew28.addons.conquer.api.ConquerClaim)2 ArrayList (java.util.ArrayList)1 ConquerFaction (me.andrew28.addons.conquer.api.ConquerFaction)1 Location (org.bukkit.Location)1