Search in sources :

Example 21 with ConquerFaction

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

the class ExprFactionCheckpoint method change.

@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
    if (delta == null || delta.length == 0 || delta[0] == null) {
        return;
    }
    Location location = (Location) delta[0];
    ConquerFaction[] factions = getExpr().getArray(e);
    if (factions == null) {
        return;
    }
    for (ConquerFaction faction : factions) {
        if (faction == null) {
            continue;
        }
        faction.setCheckpoint(location);
    }
}
Also used : ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction) Location(org.bukkit.Location)

Example 22 with ConquerFaction

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

the class ExprFactionOfPlayer method change.

@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
    ConquerPlayer[] players = getExpr().getArray(e);
    if (players == null) {
        return;
    }
    ConquerFaction faction = null;
    if (mode == Changer.ChangeMode.SET) {
        if (delta == null || delta.length == 0) {
            return;
        }
        faction = (ConquerFaction) delta[0];
    }
    for (ConquerPlayer player : players) {
        if (player == null) {
            continue;
        }
        player.setFaction(faction);
    }
}
Also used : ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction) ConquerPlayer(me.andrew28.addons.conquer.api.ConquerPlayer)

Example 23 with ConquerFaction

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

the class ExprFactionRelations method change.

@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
    ConquerFaction[] factions = this.factions.getArray(e);
    ConquerFaction[] otherFactions = this.otherFactions.getArray(e);
    if (factions == null || otherFactions == null) {
        return;
    }
    Relation relation = Relation.NEUTRAL;
    if (mode == Changer.ChangeMode.SET) {
        if (delta == null || delta.length == 0 || delta[0] == null) {
            return;
        }
        relation = (Relation) delta[0];
    }
    for (ConquerFaction faction : factions) {
        if (faction == null) {
            continue;
        }
        for (ConquerFaction otherFaction : otherFactions) {
            if (otherFaction == null) {
                continue;
            }
            faction.setRelationBetween(otherFaction, relation);
        }
    }
}
Also used : Relation(me.andrew28.addons.conquer.api.Relation) ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction)

Example 24 with ConquerFaction

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

the class ExprFactionRelations method get.

@Override
protected Relation[] get(Event e) {
    ConquerFaction[] factions = this.factions.getArray(e);
    ConquerFaction[] otherFactions = this.otherFactions.getArray(e);
    if (factions == null || otherFactions == null) {
        return null;
    }
    List<Relation> relations = new ArrayList<>();
    for (ConquerFaction faction : factions) {
        if (faction == null) {
            continue;
        }
        for (ConquerFaction otherFaction : otherFactions) {
            if (otherFaction == null) {
                continue;
            }
            relations.add(faction.getRelationTo(otherFaction));
        }
    }
    return relations.toArray(new Relation[relations.size()]);
}
Also used : Relation(me.andrew28.addons.conquer.api.Relation) ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction) ArrayList(java.util.ArrayList)

Example 25 with ConquerFaction

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

the class ExprFactionRules method get.

@Override
protected String[] get(Event e) {
    List<String> rules = new ArrayList<>();
    ConquerFaction[] factions = this.factions.getArray(e);
    for (ConquerFaction faction : factions) {
        if (faction == null) {
            continue;
        }
        List<String> factionRules = faction.getRules();
        if (factionRules != null) {
            rules.addAll(factionRules);
        }
    }
    return rules.toArray(new String[rules.size()]);
}
Also used : ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction) ArrayList(java.util.ArrayList)

Aggregations

ConquerFaction (me.andrew28.addons.conquer.api.ConquerFaction)35 ConquerPlayer (me.andrew28.addons.conquer.api.ConquerPlayer)11 EventHandler (org.bukkit.event.EventHandler)7 Relation (me.andrew28.addons.conquer.api.Relation)6 ArrayList (java.util.ArrayList)5 ConquerFactionRelationEvent (me.andrew28.addons.conquer.api.events.ConquerFactionRelationEvent)5 ConquerFactionRelationWishEvent (me.andrew28.addons.conquer.api.events.ConquerFactionRelationWishEvent)5 ConquerClaim (me.andrew28.addons.conquer.api.ConquerClaim)4 Location (org.bukkit.Location)4 HashSet (java.util.HashSet)3 ConquerLandClaimEvent (me.andrew28.addons.conquer.api.events.ConquerLandClaimEvent)3 ConquerPowerLossEvent (me.andrew28.addons.conquer.api.events.ConquerPowerLossEvent)3 Event (org.bukkit.event.Event)3 Map (java.util.Map)2 FactionResolver (me.andrew28.addons.conquer.api.FactionResolver)2 ConquerFactionCreateEvent (me.andrew28.addons.conquer.api.events.ConquerFactionCreateEvent)2 ConquerFactionDisbandEvent (me.andrew28.addons.conquer.api.events.ConquerFactionDisbandEvent)2 ConquerFactionJoinEvent (me.andrew28.addons.conquer.api.events.ConquerFactionJoinEvent)2 ConquerFactionLeaveEvent (me.andrew28.addons.conquer.api.events.ConquerFactionLeaveEvent)2 ConquerUnclaimAllEvent (me.andrew28.addons.conquer.api.events.ConquerUnclaimAllEvent)2