From b1c0512b46424d6ce1c8f7bf10cbee74f725bf98 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Tue, 21 Oct 2014 07:48:42 +0200 Subject: [PATCH] Fire FactionsEventDisband when last player leaves faction. Fixes #642. --- .../massivecraft/factions/entity/MPlayer.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/entity/MPlayer.java b/src/main/java/com/massivecraft/factions/entity/MPlayer.java index 355fc560..cfc3efba 100644 --- a/src/main/java/com/massivecraft/factions/entity/MPlayer.java +++ b/src/main/java/com/massivecraft/factions/entity/MPlayer.java @@ -17,6 +17,7 @@ import com.massivecraft.factions.Rel; import com.massivecraft.factions.RelationParticipator; import com.massivecraft.factions.event.EventFactionsChunkChangeType; import com.massivecraft.factions.event.EventFactionsChunksChange; +import com.massivecraft.factions.event.EventFactionsDisband; import com.massivecraft.factions.event.EventFactionsMembershipChange; import com.massivecraft.factions.event.EventFactionsRemovePlayerMillis; import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; @@ -783,17 +784,18 @@ public class MPlayer extends SenderEntity implements EconomyParticipato if (myFaction.isNormal() && !permanent && myFaction.getMPlayers().isEmpty()) { - // Remove this faction - for (MPlayer mplayer : MPlayerColl.get().getAllOnline()) + EventFactionsDisband eventFactionsDisband = new EventFactionsDisband(this.getSender(), myFaction); + eventFactionsDisband.run(); + if ( ! eventFactionsDisband.isCancelled()) { - mplayer.msg("%s was disbanded.", myFaction.describeTo(mplayer, true)); - } - - if (MConf.get().logFactionDisband) - { - Factions.get().log("The faction "+myFaction.getName()+" ("+myFaction.getId()+") was disbanded due to the last player ("+this.getName()+") leaving."); - } - myFaction.detach(); + // Remove this faction + this.msg("%s was disbanded since you were the last player.", myFaction.describeTo(this, true)); + if (MConf.get().logFactionDisband) + { + Factions.get().log("The faction "+myFaction.getName()+" ("+myFaction.getId()+") was disbanded due to the last player ("+this.getName()+") leaving."); + } + myFaction.detach(); + } } }