Search in sources :

Example 1 with Relation

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

the class LFEventForwarder method onRelationWish.

@EventHandler
public void onRelationWish(EventFactionsRelationChange event) {
    ConquerPlayer caller = LFPlayer.get(plugin, event.getfPlayer());
    Relation oldRelation = plugin.translate(event.getCurrentRelation());
    Relation newRelation = plugin.translate(event.getTargetRelation());
    ConquerFaction faction = LFFaction.get(plugin, event.getFaction());
    ConquerFaction targetFaction = LFFaction.get(plugin, event.getTargetFaction());
    ConquerFactionRelationWishEvent forwardEvent = new ConquerFactionRelationWishEvent(caller, faction, targetFaction, oldRelation, newRelation);
    callEvent(forwardEvent);
    if (forwardEvent.isCancelled()) {
        event.setCancelled(true);
    }
}
Also used : Relation(me.andrew28.addons.conquer.api.Relation) EventFactionsRelation(net.redstoneore.legacyfactions.event.EventFactionsRelation) ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction) ConquerFactionRelationWishEvent(me.andrew28.addons.conquer.api.events.ConquerFactionRelationWishEvent) ConquerPlayer(me.andrew28.addons.conquer.api.ConquerPlayer) EventHandler(org.bukkit.event.EventHandler)

Example 2 with Relation

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

the class MSEventForwarder method onRelationChange.

@EventHandler
public void onRelationChange(EventFactionsRelationChange event) {
    ConquerPlayer player = MSPlayer.get(plugin, event.getMPlayer());
    ConquerFaction faction = MSFaction.get(plugin, event.getFaction());
    ConquerFaction otherFaction = MSFaction.get(plugin, event.getOtherFaction());
    Relation oldRelation = plugin.translateRelation(event.getFaction().getRelationTo(event.getOtherFaction()));
    Relation newRelation = plugin.translateRelation(event.getNewRelation());
    ConquerFactionRelationWishEvent forwardWishEvent = new ConquerFactionRelationWishEvent(player, faction, otherFaction, oldRelation, newRelation);
    callEvent(forwardWishEvent);
    if (forwardWishEvent.isCancelled()) {
        event.setCancelled(true);
        return;
    }
    ConquerFactionRelationEvent forwardEvent = new ConquerFactionRelationEvent(faction, otherFaction, oldRelation, newRelation);
    callEvent(forwardEvent);
    if (forwardEvent.isCancelled()) {
        event.setCancelled(true);
    }
}
Also used : Relation(me.andrew28.addons.conquer.api.Relation) ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction) ConquerFactionRelationWishEvent(me.andrew28.addons.conquer.api.events.ConquerFactionRelationWishEvent) ConquerFactionRelationEvent(me.andrew28.addons.conquer.api.events.ConquerFactionRelationEvent) ConquerPlayer(me.andrew28.addons.conquer.api.ConquerPlayer) EventHandler(org.bukkit.event.EventHandler)

Example 3 with Relation

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

the class LFEventForwarder method onRelationChange.

@EventHandler
public void onRelationChange(EventFactionsRelation event) {
    Relation oldRelation = plugin.translate(event.getOldRelation());
    Relation newRelation = plugin.translate(event.getRelation());
    ConquerFaction faction = LFFaction.get(plugin, event.getFaction());
    ConquerFaction targetFaction = LFFaction.get(plugin, event.getTargetFaction());
    ConquerFactionRelationEvent forwardEvent = new ConquerFactionRelationEvent(faction, targetFaction, oldRelation, newRelation);
    callEvent(forwardEvent);
}
Also used : Relation(me.andrew28.addons.conquer.api.Relation) EventFactionsRelation(net.redstoneore.legacyfactions.event.EventFactionsRelation) ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction) ConquerFactionRelationEvent(me.andrew28.addons.conquer.api.events.ConquerFactionRelationEvent) EventHandler(org.bukkit.event.EventHandler)

Example 4 with Relation

use of me.andrew28.addons.conquer.api.Relation 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 5 with Relation

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

Aggregations

ConquerFaction (me.andrew28.addons.conquer.api.ConquerFaction)5 Relation (me.andrew28.addons.conquer.api.Relation)5 EventHandler (org.bukkit.event.EventHandler)3 ConquerPlayer (me.andrew28.addons.conquer.api.ConquerPlayer)2 ConquerFactionRelationEvent (me.andrew28.addons.conquer.api.events.ConquerFactionRelationEvent)2 ConquerFactionRelationWishEvent (me.andrew28.addons.conquer.api.events.ConquerFactionRelationWishEvent)2 EventFactionsRelation (net.redstoneore.legacyfactions.event.EventFactionsRelation)2 ArrayList (java.util.ArrayList)1