Search in sources :

Example 1 with ConquerFaction

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

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

the class CondWarpPassValid method check.

@Override
public boolean check(Event e) {
    String password = this.password.getSingle(e);
    ConquerFaction faction = this.faction.getSingle(e);
    return password != null && faction != null && names.check(e, warp -> faction.isWarpPassword(warp, password), isNegated());
}
Also used : Condition(ch.njol.skript.lang.Condition) Expression(ch.njol.skript.lang.Expression) Examples(ch.njol.skript.doc.Examples) Name(ch.njol.skript.doc.Name) Event(org.bukkit.event.Event) Skript(ch.njol.skript.Skript) Description(ch.njol.skript.doc.Description) Kleenean(ch.njol.util.Kleenean) SkriptParser(ch.njol.skript.lang.SkriptParser) ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction) ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction)

Example 3 with ConquerFaction

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

the class EffChangeClaimOwnership method execute.

@Override
protected void execute(Event e) {
    Object[] claimObjects = this.claims.getArray(e);
    if (claimObjects == null) {
        return;
    }
    List<ConquerClaim> claims = new ArrayList<>();
    for (Object claimObject : claimObjects) {
        if (claimObject instanceof ConquerClaim) {
            claims.add((ConquerClaim) claimObject);
        } else if (claimObject instanceof Location) {
            claims.add(Conquer.getInstance().getFactions().getClaim((Location) claimObject));
        }
    }
    if (claiming) {
        if (forFactions) {
            ConquerFaction faction = (ConquerFaction) this.type.getSingle(e);
            if (faction == null) {
                return;
            }
            claims.forEach(faction::claim);
        } else {
            ClaimType type = (ClaimType) this.type.getSingle(e);
            if (type == null) {
                return;
            }
            claims.forEach(claim -> claim.setTo(type));
        }
    } else {
        claims.forEach(claim -> claim.setTo(ClaimType.WILDERNESS));
    }
}
Also used : ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction) ArrayList(java.util.ArrayList) ConquerClaim(me.andrew28.addons.conquer.api.ConquerClaim) Location(org.bukkit.Location) ClaimType(me.andrew28.addons.conquer.api.ClaimType)

Example 4 with ConquerFaction

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

the class ExprCreationDateOfFaction 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.setCreationDate(new java.util.Date(((Date) delta[0]).getTimestamp()));
}
Also used : ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction) Date(ch.njol.skript.util.Date)

Example 5 with ConquerFaction

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

the class ExprDescriptionOfFaction 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.setDescription((String) delta[0]);
}
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