Search in sources :

Example 1 with FactionResolver

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

the class ExprFactionAtLocClaim method get.

@Override
protected ConquerFaction[] get(Event e) {
    Set<ConquerFaction> factions = new HashSet<>();
    FactionResolver factionResolver = Conquer.getInstance().getFactions().getFactionResolver();
    Object[] claimObjects = this.targets.getArray(e);
    if (claimObjects == null) {
        return null;
    }
    for (Object claimObject : claimObjects) {
        if (claimObject instanceof ConquerClaim) {
            factions.add(factionResolver.getByClaim((ConquerClaim) claimObject));
        } else if (claimObject instanceof Location) {
            factions.add(factionResolver.getAtLocation((Location) claimObject));
        }
    }
    return factions.toArray(new ConquerFaction[factions.size()]);
}
Also used : FactionResolver(me.andrew28.addons.conquer.api.FactionResolver) ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction) ConquerClaim(me.andrew28.addons.conquer.api.ConquerClaim) HashSet(java.util.HashSet) Location(org.bukkit.Location)

Example 2 with FactionResolver

use of me.andrew28.addons.conquer.api.FactionResolver 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)

Aggregations

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