Add ClaimCreatedEvent and ClaimModifiedEvent (#344)

1. Claim creation event... this is fired once all the claim creation checks have been passed.  It can be cancelled. It contains the claim and the creating player
2. Claim modification event - this is fired as the claim is modified - it cannot be cancelled. It contains the claim and the modifier...which can be null.

Use Case:
This could be used so other plugins can hook gp and perform an action if a claim is created or changed. Something as simple as logging claim creations/modifications and deletions.
This commit is contained in:
Narimm
2018-08-13 07:09:05 -07:00
committed by RoboMWM
parent 31c1581ca2
commit 643ad8a7f7
3 changed files with 138 additions and 4 deletions
@@ -0,0 +1,63 @@
package me.ryanhamshire.GriefPrevention.events;
import me.ryanhamshire.GriefPrevention.Claim;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* This Event is thrown when a claim is created but before it is saved. If it is cancelled the claim will not be saved
* however the player will not recieved information as to why it was cancelled.
* <p>
* Created by Narimm on 5/08/2018.
*/
public class ClaimCreatedEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Claim claim;
private final CommandSender creator;
private boolean cancelled = false;
public ClaimCreatedEvent(Claim claim, CommandSender creator) {
this.claim = claim;
this.creator = creator;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean b) {
this.cancelled = b;
}
/**
* The Claim
*
* @return Claim
*/
public Claim getClaim() {
return claim;
}
/**
* The actor creating the claim
*
* @return the CommandSender
*/
public CommandSender getCreator() {
return creator;
}
}
@@ -0,0 +1,47 @@
package me.ryanhamshire.GriefPrevention.events;
import me.ryanhamshire.GriefPrevention.Claim;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* This Event is thrown when a claim is changed....it is not modifiable or cancellable and only serves as a notification
* a claim has changed. The CommandSender can be null in the event that the modification is called by the plugin itself.
* Created by Narimm on 5/08/2018.
*/
public class ClaimModifiedEvent extends Event {
private final HandlerList handlers = new HandlerList();
private final Claim claim;
private CommandSender modifier;
public ClaimModifiedEvent(Claim claim, CommandSender modifier) {
this.claim = claim;
this.modifier = modifier;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
/**
* The claim
*
* @return the claim
*/
public Claim getClaim() {
return claim;
}
/**
* The actor making the change...can be null
*
* @return the CommandSender or null
*/
public CommandSender getModifier() {
return modifier;
}
}