Include inspectedBlock in ClaimInspectionEvent (#949)

This commit is contained in:
Frank van der Heijden 2020-08-07 21:50:37 +02:00 committed by GitHub
parent 4b3852d624
commit abfb53b1cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 6 deletions

View File

@ -1958,7 +1958,7 @@ class PlayerEventHandler implements Listener
Set<Claim> claims = this.dataStore.getNearbyClaims(player.getLocation());
// alert plugins of a claim inspection, return if cancelled
ClaimInspectionEvent inspectionEvent = new ClaimInspectionEvent(player, claims, true);
ClaimInspectionEvent inspectionEvent = new ClaimInspectionEvent(player, null, claims, true);
Bukkit.getPluginManager().callEvent(inspectionEvent);
if (inspectionEvent.isCancelled()) return;
@ -2008,7 +2008,7 @@ class PlayerEventHandler implements Listener
if (claim == null)
{
// alert plugins of a claim inspection, return if cancelled
ClaimInspectionEvent inspectionEvent = new ClaimInspectionEvent(player, null);
ClaimInspectionEvent inspectionEvent = new ClaimInspectionEvent(player, clickedBlock, null);
Bukkit.getPluginManager().callEvent(inspectionEvent);
if (inspectionEvent.isCancelled()) return;
@ -2024,7 +2024,7 @@ class PlayerEventHandler implements Listener
else
{
// alert plugins of a claim inspection, return if cancelled
ClaimInspectionEvent inspectionEvent = new ClaimInspectionEvent(player, claim);
ClaimInspectionEvent inspectionEvent = new ClaimInspectionEvent(player, clickedBlock, claim);
Bukkit.getPluginManager().callEvent(inspectionEvent);
if (inspectionEvent.isCancelled()) return;

View File

@ -1,6 +1,7 @@
package me.ryanhamshire.GriefPrevention.events;
import me.ryanhamshire.GriefPrevention.Claim;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
@ -23,30 +24,39 @@ public class ClaimInspectionEvent extends PlayerEvent implements Cancellable
}
private final Collection<Claim> claims;
private final Block inspectedBlock;
private final boolean inspectingNearbyClaims;
private boolean cancelled;
/**
* Constructs a new ClaimInspectionEvent with a player and claim instance.
* @param player The player actor
* @param inspectedBlock The inspected block
* @param claim The claim involved
*/
public ClaimInspectionEvent(Player player, Claim claim) {
this(player, Collections.singleton(claim), false);
public ClaimInspectionEvent(Player player, Block inspectedBlock, Claim claim) {
this(player, inspectedBlock, Collections.singleton(claim), false);
}
/**
* Constructs a new ClaimInspectionEvent with a player, list of claims and boolean flag inspectingNearbyClaims.
* @param player The player actor
* @param inspectedBlock The inspected block
* @param claims The list of claims involved
* @param inspectingNearbyClaims Whether or not the user is inspecting nearby claims ("shift-clicking")
*/
public ClaimInspectionEvent(Player player, Collection<Claim> claims, boolean inspectingNearbyClaims) {
public ClaimInspectionEvent(Player player, Block inspectedBlock, Collection<Claim> claims, boolean inspectingNearbyClaims) {
super(player);
this.inspectedBlock = inspectedBlock;
this.claims = claims;
this.inspectingNearbyClaims = inspectingNearbyClaims;
}
public Block getInspectedBlock()
{
return inspectedBlock;
}
public Collection<Claim> getClaims()
{
return claims;