Search in sources :

Example 6 with ConquerFaction

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

the class ExprFactionRules method change.

@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
    ConquerFaction[] factions = this.factions.getArray(e);
    if (factions == null) {
        return;
    }
    for (ConquerFaction faction : factions) {
        if (faction == null) {
            continue;
        }
        List<String> rules = faction.getRules();
        if (rules == null) {
            continue;
        }
        switch(mode) {
            case SET:
                if (delta == null) {
                    return;
                }
                rules.clear();
                rules.addAll(Arrays.asList((String[]) delta));
                break;
            case RESET:
            case DELETE:
                rules.clear();
                break;
            case ADD:
                if (delta == null || delta.length == 0 || delta[0] == null) {
                    return;
                }
                rules.add((String) delta[0]);
                break;
        }
    }
}
Also used : ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction)

Example 7 with ConquerFaction

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

the class ExprHomeOfFaction method change.

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

Example 8 with ConquerFaction

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

the class ExprIdOfFaction method change.

@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
    if (delta == null || delta.length == 0 || delta[0] == null) {
        return;
    }
    ConquerFaction faction = getExpr().getSingle(e);
    if (faction == null) {
        return;
    }
    faction.setId((String) delta[0]);
}
Also used : ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction)

Example 9 with ConquerFaction

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

the class ExprInvitedPlayers method get.

@Override
protected ConquerPlayer[] get(Event e) {
    Set<ConquerPlayer> players = new HashSet<>();
    ConquerFaction[] factions = this.factions.getArray(e);
    for (ConquerFaction faction : factions) {
        if (faction == null) {
            continue;
        }
        players.addAll(faction.getInvited());
    }
    return players.toArray(new ConquerPlayer[players.size()]);
}
Also used : ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction) ConquerPlayer(me.andrew28.addons.conquer.api.ConquerPlayer) HashSet(java.util.HashSet)

Example 10 with ConquerFaction

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

the class ExprMembersOfFaction method change.

@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
    if (delta == null || delta.length == 0 || delta[0] == null) {
        return;
    }
    ConquerPlayer player = (ConquerPlayer) delta[0];
    // Just use the first faction because generally people only use one faction in this syntax
    ConquerFaction[] factions = this.factions.getArray(e);
    if (factions.length == 0) {
        return;
    }
    ConquerFaction faction = factions[0];
    if (faction == null) {
        return;
    }
    if (mode == Changer.ChangeMode.ADD) {
        faction.addMember(player);
    } else if (mode == Changer.ChangeMode.REMOVE) {
        faction.removeMember(player);
    }
}
Also used : ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction) ConquerPlayer(me.andrew28.addons.conquer.api.ConquerPlayer)

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