Search in sources :

Example 26 with ConquerFaction

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

the class ExprFactionWithName method get.

@Override
protected ConquerFaction[] get(Event e) {
    FactionResolver resolver = Conquer.getInstance().getFactions().getFactionResolver();
    List<ConquerFaction> factions = new ArrayList<>();
    String[] names = this.names.getArray(e);
    if (names == null) {
        return null;
    }
    for (String name : names) {
        if (name == null) {
            continue;
        }
        ConquerFaction faction = resolver.getByName(name);
        if (faction != null) {
            factions.add(faction);
        }
    }
    return factions.toArray(new ConquerFaction[factions.size()]);
}
Also used : FactionResolver(me.andrew28.addons.conquer.api.FactionResolver) ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction) ArrayList(java.util.ArrayList)

Example 27 with ConquerFaction

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

the class ExprMembersOfFaction 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(Arrays.asList(faction.getMembers()));
    }
    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 28 with ConquerFaction

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

the class ExprMotdOfFaction 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);
    faction.setMotd((String) delta[0]);
}
Also used : ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction)

Example 29 with ConquerFaction

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

the class ExprNameOfFaction 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.setName((String) delta[0]);
}
Also used : ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction)

Example 30 with ConquerFaction

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

the class ExprWarpNamesOfFaction method change.

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

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