Make LandUnclaimAllEvent Cancellable

This commit is contained in:
eueln 2014-12-17 20:50:24 -06:00
parent 3733539077
commit 3c2e51e8ed
2 changed files with 16 additions and 2 deletions

View File

@ -44,7 +44,9 @@ public class CmdUnclaimall extends FCommand {
LandUnclaimAllEvent unclaimAllEvent = new LandUnclaimAllEvent(myFaction, fme); LandUnclaimAllEvent unclaimAllEvent = new LandUnclaimAllEvent(myFaction, fme);
Bukkit.getServer().getPluginManager().callEvent(unclaimAllEvent); Bukkit.getServer().getPluginManager().callEvent(unclaimAllEvent);
// this event cannot be cancelled if (unclaimAllEvent.isCancelled()) {
return;
}
Board.getInstance().unclaimAll(myFaction.getId()); Board.getInstance().unclaimAll(myFaction.getId());
myFaction.msg(TL.COMMAND_UNCLAIMALL_UNCLAIMED, fme.describeTo(myFaction, true)); myFaction.msg(TL.COMMAND_UNCLAIMALL_UNCLAIMED, fme.describeTo(myFaction, true));

View File

@ -3,8 +3,10 @@ package com.massivecraft.factions.event;
import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
public class LandUnclaimAllEvent extends FactionPlayerEvent { public class LandUnclaimAllEvent extends FactionPlayerEvent implements Cancellable {
private boolean cancelled;
public LandUnclaimAllEvent(Faction f, FPlayer p) { public LandUnclaimAllEvent(Faction f, FPlayer p) {
super(f, p); super(f, p);
@ -45,4 +47,14 @@ public class LandUnclaimAllEvent extends FactionPlayerEvent {
public Player getPlayer() { public Player getPlayer() {
return getfPlayer().getPlayer(); return getfPlayer().getPlayer();
} }
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
} }