Added Event System

This commit is contained in:
patrickfreed
2012-03-01 20:16:45 -05:00
parent 54b97651b6
commit 021bf52c62
14 changed files with 458 additions and 6 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)
{
@@ -656,7 +663,11 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
}
}
LandClaimEvent claimEvent = new LandClaimEvent(flocation, forFaction.getId(), this.getId());
Bukkit.getServer().getPluginManager().callEvent(claimEvent);
if(claimEvent.isCancelled()) return false;
if (LWCFeatures.getEnabled() && forFaction.isNormal() && Conf.onCaptureResetLwcLocks)
LWCFeatures.clearOtherChests(flocation, this.getFaction());