Merge pull request #103 from donington/CustomFactionEvents

Custom faction events
This commit is contained in:
Brett Flannigan
2012-03-13 04:31:52 -07:00
20 changed files with 816 additions and 94 deletions

View File

@@ -3,10 +3,13 @@ package com.massivecraft.factions;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import com.massivecraft.factions.event.FPlayerLeaveEvent;
import com.massivecraft.factions.event.LandClaimEvent;
import com.massivecraft.factions.iface.EconomyParticipator;
import com.massivecraft.factions.iface.RelationParticipator;
import com.massivecraft.factions.integration.Econ;
@@ -507,7 +510,11 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
double cost = Conf.econCostLeave;
if ( ! Econ.modifyMoney(this, -cost, "to leave your faction.", "for leaving your faction.")) return;
}
FPlayerLeaveEvent leaveEvent = new FPlayerLeaveEvent(this,myFaction,FPlayerLeaveEvent.PlayerLeaveReason.LEAVE);
Bukkit.getServer().getPluginManager().callEvent(leaveEvent);
if (leaveEvent.isCancelled()) return;
// Am I the last one in the faction?
if (myFaction.getFPlayers().size() == 1)
{
@@ -654,7 +661,11 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
if ( ! Econ.modifyMoney(this, -cost, "to claim this land", "for claiming this land")) return false;
}
}
LandClaimEvent claimEvent = new LandClaimEvent(flocation, forFaction, this);
Bukkit.getServer().getPluginManager().callEvent(claimEvent);
if(claimEvent.isCancelled()) return false;
if (LWCFeatures.getEnabled() && forFaction.isNormal() && Conf.onCaptureResetLwcLocks)
LWCFeatures.clearOtherChests(flocation, this.getFaction());