use of me.andrew28.addons.conquer.api.ConquerFaction in project Conquer by xXAndrew28Xx.
the class ExprFactionRules method change.
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode) {
ConquerFaction[] factions = this.factions.getArray(e);
if (factions == null) {
return;
}
for (ConquerFaction faction : factions) {
if (faction == null) {
continue;
}
List<String> rules = faction.getRules();
if (rules == null) {
continue;
}
switch(mode) {
case SET:
if (delta == null) {
return;
}
rules.clear();
rules.addAll(Arrays.asList((String[]) delta));
break;
case RESET:
case DELETE:
rules.clear();
break;
case ADD:
if (delta == null || delta.length == 0 || delta[0] == null) {
return;
}
rules.add((String) delta[0]);
break;
}
}
}
use of me.andrew28.addons.conquer.api.ConquerFaction in project Conquer by xXAndrew28Xx.
the class ExprHomeOfFaction 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.setHome((Location) delta[0]);
}
use of me.andrew28.addons.conquer.api.ConquerFaction in project Conquer by xXAndrew28Xx.
the class ExprIdOfFaction 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.setId((String) delta[0]);
}
use of me.andrew28.addons.conquer.api.ConquerFaction in project Conquer by xXAndrew28Xx.
the class ExprInvitedPlayers method get.
@Override
protected ConquerPlayer[] get(Event e) {
Set<ConquerPlayer> players = new HashSet<>();
ConquerFaction[] factions = this.factions.getArray(e);
for (ConquerFaction faction : factions) {
if (faction == null) {
continue;
}
players.addAll(faction.getInvited());
}
return players.toArray(new ConquerPlayer[players.size()]);
}
use of me.andrew28.addons.conquer.api.ConquerFaction 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);
}
}
Aggregations