Search in sources :

Example 6 with ConquerPlayer

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

the class ExprMembersOfFaction method change.

@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
    if (delta == null || delta.length == 0 || delta[0] == null) {
        return;
    }
    ConquerPlayer player = (ConquerPlayer) delta[0];
    // Just use the first faction because generally people only use one faction in this syntax
    ConquerFaction[] factions = this.factions.getArray(e);
    if (factions.length == 0) {
        return;
    }
    ConquerFaction faction = factions[0];
    if (faction == null) {
        return;
    }
    if (mode == Changer.ChangeMode.ADD) {
        faction.addMember(player);
    } else if (mode == Changer.ChangeMode.REMOVE) {
        faction.removeMember(player);
    }
}
Also used : ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction) ConquerPlayer(me.andrew28.addons.conquer.api.ConquerPlayer)

Example 7 with ConquerPlayer

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

the class ExprPlayerLastActivity method change.

@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
    ConquerPlayer player = getExpr().getSingle(e);
    if (player == null || delta == null || delta.length == 0 || delta[0] == null) {
        return;
    }
    player.setLastActivity(new java.util.Date(((Date) delta[0]).getTimestamp()));
}
Also used : ConquerPlayer(me.andrew28.addons.conquer.api.ConquerPlayer) Date(ch.njol.skript.util.Date)

Example 8 with ConquerPlayer

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

the class ExprTitleOfPlayer method change.

@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
    ConquerPlayer[] players = getExpr().getArray(e);
    if (players == null) {
        return;
    }
    String title = "";
    if (mode == Changer.ChangeMode.SET) {
        if (delta == null || delta.length == 0 || delta[0] == null) {
            return;
        }
        title = (String) delta[0];
    }
    for (ConquerPlayer player : players) {
        if (player == null) {
            continue;
        }
        player.setTitle(title);
    }
}
Also used : ConquerPlayer(me.andrew28.addons.conquer.api.ConquerPlayer)

Example 9 with ConquerPlayer

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

the class ExprPlayerRole method change.

@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
    ConquerPlayer[] players = getExpr().getArray(e);
    if (players == null) {
        return;
    }
    ConquerPlayer.Role role = ConquerPlayer.Role.NORMAL;
    if (mode == Changer.ChangeMode.SET) {
        if (delta == null || delta.length == 0 || delta[0] == null) {
            return;
        }
        role = (ConquerPlayer.Role) delta[0];
    }
    for (ConquerPlayer player : players) {
        if (player == null) {
            continue;
        }
        player.setRole(role);
    }
}
Also used : ConquerPlayer(me.andrew28.addons.conquer.api.ConquerPlayer)

Example 10 with ConquerPlayer

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

the class LFEventForwarder method onLandChange.

@EventHandler
public void onLandChange(EventFactionsLandChange event) {
    boolean claiming = event.getCause() == EventFactionsLandChange.LandChangeCause.Claim;
    ConquerPlayer player = LFPlayer.get(plugin, event.getFPlayer());
    Iterator<Map.Entry<FLocation, Faction>> iterator = event.getTransactions().entrySet().iterator();
    while (iterator.hasNext()) {
        Map.Entry<FLocation, Faction> entry = iterator.next();
        ConquerClaim<Chunk> claim = LFClaim.get(plugin, entry.getKey());
        ConquerFaction faction = LFFaction.get(plugin, entry.getValue());
        ConquerLandClaimEvent forwardEvent = new ConquerLandClaimEvent(claim, claiming, faction, player);
        callEvent(forwardEvent);
        if (forwardEvent.isCancelled()) {
            iterator.remove();
        }
    }
}
Also used : ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction) FLocation(net.redstoneore.legacyfactions.FLocation) ConquerLandClaimEvent(me.andrew28.addons.conquer.api.events.ConquerLandClaimEvent) ConquerPlayer(me.andrew28.addons.conquer.api.ConquerPlayer) Chunk(org.bukkit.Chunk) Map(java.util.Map) ConquerFaction(me.andrew28.addons.conquer.api.ConquerFaction) Faction(net.redstoneore.legacyfactions.entity.Faction) EventHandler(org.bukkit.event.EventHandler)

Aggregations

ConquerPlayer (me.andrew28.addons.conquer.api.ConquerPlayer)16 ConquerFaction (me.andrew28.addons.conquer.api.ConquerFaction)11 EventHandler (org.bukkit.event.EventHandler)7 ConquerFactionRelationWishEvent (me.andrew28.addons.conquer.api.events.ConquerFactionRelationWishEvent)4 ConquerPowerLossEvent (me.andrew28.addons.conquer.api.events.ConquerPowerLossEvent)4 Relation (me.andrew28.addons.conquer.api.Relation)3 ConquerFactionRelationEvent (me.andrew28.addons.conquer.api.events.ConquerFactionRelationEvent)3 ConquerLandClaimEvent (me.andrew28.addons.conquer.api.events.ConquerLandClaimEvent)3 HashSet (java.util.HashSet)2 Map (java.util.Map)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 Cancellable (org.bukkit.event.Cancellable)2 Event (org.bukkit.event.Event)2 Date (ch.njol.skript.util.Date)1 EventFactionsChunkChangeType (com.massivecraft.factions.event.EventFactionsChunkChangeType)1 EventFactionsChunksChange (com.massivecraft.factions.event.EventFactionsChunksChange)1