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);
}
}
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);
}
}
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);
}
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);
}
}
}
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()]);
}
Aggregations