Search in sources :

Example 1 with ConquerFactionRelationWishEvent

use of me.andrew28.addons.conquer.api.events.ConquerFactionRelationWishEvent 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 2 with ConquerFactionRelationWishEvent

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

the class ExprRelationFactionSenderTarget method get.

@Override
protected ConquerFaction[] get(Event e) {
    ConquerFaction faction;
    if (e instanceof ConquerFactionRelationEvent) {
        ConquerFactionRelationEvent event = (ConquerFactionRelationEvent) e;
        faction = sender ? event.getSender() : event.getTarget();
    } else if (e instanceof ConquerFactionRelationWishEvent) {
        ConquerFactionRelationWishEvent event = (ConquerFactionRelationWishEvent) e;
        faction = sender ? event.getSender() : event.getTarget();
    } else {
        return null;
    }
    return new ConquerFaction[] { faction };
}
Also used : ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction) ConquerFactionRelationWishEvent(me.andrew28.addons.conquer.api.events.ConquerFactionRelationWishEvent) ConquerFactionRelationEvent(me.andrew28.addons.conquer.api.events.ConquerFactionRelationEvent)

Example 3 with ConquerFactionRelationWishEvent

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

the class FOEventForwarder method onRelationChange.

@EventHandler
public void onRelationChange(FactionRelationEvent event) {
    callEvent(new ConquerFactionRelationWishEvent(null, FOFaction.get(plugin, event.getFaction()), FOFaction.get(plugin, event.getTargetFaction()), plugin.translateRelation(event.getOldRelation()), plugin.translateRelation(event.getRelation())));
    callEvent(new ConquerFactionRelationEvent(FOFaction.get(plugin, event.getFaction()), FOFaction.get(plugin, event.getTargetFaction()), plugin.translateRelation(event.getOldRelation()), plugin.translateRelation(event.getRelation())));
}
Also used : ConquerFactionRelationWishEvent(me.andrew28.addons.conquer.api.events.ConquerFactionRelationWishEvent) ConquerFactionRelationEvent(me.andrew28.addons.conquer.api.events.ConquerFactionRelationEvent) EventHandler(org.bukkit.event.EventHandler)

Example 4 with ConquerFactionRelationWishEvent

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

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

the class SFEventForwarder method onRelationWish.

@EventHandler
public void onRelationWish(FactionRelationWishEvent event) {
    ConquerFactionRelationWishEvent forwardEvent = new ConquerFactionRelationWishEvent(SFPlayer.get(plugin, event.getfPlayer()), SFFaction.get(plugin, event.getFaction()), SFFaction.get(plugin, event.getTargetFaction()), plugin.translate(event.getCurrentRelation()), plugin.translate(event.getTargetRelation()));
    callEvent(forwardEvent);
    if (forwardEvent.isCancelled()) {
        event.setCancelled(true);
    }
}
Also used : ConquerFactionRelationWishEvent(me.andrew28.addons.conquer.api.events.ConquerFactionRelationWishEvent) EventHandler(org.bukkit.event.EventHandler)

Aggregations

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