use of me.andrew28.addons.conquer.api.ConquerFaction in project Conquer by xXAndrew28Xx.
the class MSEventForwarder method onClaimChange.
@EventHandler
public void onClaimChange(EventFactionsChunksChange event) {
ConquerFaction faction = MSFaction.get(plugin, event.getNewFaction());
ConquerPlayer player = MSPlayer.get(plugin, event.getMPlayer());
Set<PS> chunks = event.getChunks();
Map<PS, EventFactionsChunkChangeType> chunkTypeMap = event.getChunkType();
// Check if it's an unclaim all
if (chunks.size() == faction.getClaims().length && chunkTypeMap.values().stream().allMatch(type -> type == EventFactionsChunkChangeType.SELL)) {
ConquerUnclaimAllEvent forwardEvent = new ConquerUnclaimAllEvent(faction, player);
callEvent(forwardEvent);
if (forwardEvent.isCancelled()) {
event.setCancelled(true);
}
}
for (PS chunk : chunks) {
EventFactionsChunkChangeType type = chunkTypeMap.get(chunk);
ConquerClaim claim = MSClaim.get(plugin, chunk);
Event forwardEvent;
switch(type) {
case NONE:
continue;
case BUY:
forwardEvent = new ConquerLandClaimEvent(claim, true, faction, player);
break;
case CONQUER:
case PILLAGE:
forwardEvent = new ConquerLandClaimEvent(claim, false, faction, player);
break;
default:
return;
}
callEvent(forwardEvent);
if (((Cancellable) forwardEvent).isCancelled()) {
event.setCancelled(true);
return;
}
}
}
use of me.andrew28.addons.conquer.api.ConquerFaction in project Conquer by xXAndrew28Xx.
the class MSEventForwarder method onMembershipChange.
@EventHandler
public void onMembershipChange(EventFactionsMembershipChange event) {
ConquerFaction faction = MSFaction.get(plugin, event.getNewFaction());
ConquerPlayer player = MSPlayer.get(plugin, event.getMPlayer());
Event forwardEvent;
switch(event.getReason()) {
case JOIN:
case CREATE:
forwardEvent = new ConquerFactionJoinEvent(faction, player);
break;
case LEAVE:
case KICK:
case DISBAND:
forwardEvent = new ConquerFactionLeaveEvent(faction, player);
break;
default:
return;
}
callEvent(forwardEvent);
if (((Cancellable) forwardEvent).isCancelled()) {
event.setCancelled(true);
}
}
use of me.andrew28.addons.conquer.api.ConquerFaction in project Conquer by xXAndrew28Xx.
the class EffInvitePlayer method execute.
@Override
protected void execute(Event e) {
ConquerPlayer[] players = this.players.getArray(e);
ConquerFaction[] factions = this.factions.getArray(e);
if (players == null || factions == null) {
return;
}
for (ConquerPlayer player : players) {
if (player == null) {
continue;
}
for (ConquerFaction faction : factions) {
if (faction == null) {
continue;
}
if (invite) {
faction.invite(player);
} else {
faction.deinvite(player);
}
}
}
}
use of me.andrew28.addons.conquer.api.ConquerFaction in project Conquer by xXAndrew28Xx.
the class ExprClaimsOfFaction method get.
@Override
protected ConquerClaim[] get(Event e) {
List<ConquerClaim> claims = new ArrayList<>();
ConquerFaction[] factions = this.factions.getArray(e);
for (ConquerFaction faction : factions) {
if (faction == null) {
continue;
}
claims.addAll(Arrays.asList(faction.getClaims()));
}
return claims.toArray(new ConquerClaim[claims.size()]);
}
use of me.andrew28.addons.conquer.api.ConquerFaction in project Conquer by xXAndrew28Xx.
the class ExprFactionAtLocClaim method get.
@Override
protected ConquerFaction[] get(Event e) {
Set<ConquerFaction> factions = new HashSet<>();
FactionResolver factionResolver = Conquer.getInstance().getFactions().getFactionResolver();
Object[] claimObjects = this.targets.getArray(e);
if (claimObjects == null) {
return null;
}
for (Object claimObject : claimObjects) {
if (claimObject instanceof ConquerClaim) {
factions.add(factionResolver.getByClaim((ConquerClaim) claimObject));
} else if (claimObject instanceof Location) {
factions.add(factionResolver.getAtLocation((Location) claimObject));
}
}
return factions.toArray(new ConquerFaction[factions.size()]);
}
Aggregations