Include inspectedBlock in ClaimInspectionEvent (#949)
This commit is contained in:
parent
4b3852d624
commit
abfb53b1cf
|
|
@ -1958,7 +1958,7 @@ class PlayerEventHandler implements Listener
|
||||||
Set<Claim> claims = this.dataStore.getNearbyClaims(player.getLocation());
|
Set<Claim> claims = this.dataStore.getNearbyClaims(player.getLocation());
|
||||||
|
|
||||||
// alert plugins of a claim inspection, return if cancelled
|
// 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);
|
Bukkit.getPluginManager().callEvent(inspectionEvent);
|
||||||
if (inspectionEvent.isCancelled()) return;
|
if (inspectionEvent.isCancelled()) return;
|
||||||
|
|
||||||
|
|
@ -2008,7 +2008,7 @@ class PlayerEventHandler implements Listener
|
||||||
if (claim == null)
|
if (claim == null)
|
||||||
{
|
{
|
||||||
// alert plugins of a claim inspection, return if cancelled
|
// 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);
|
Bukkit.getPluginManager().callEvent(inspectionEvent);
|
||||||
if (inspectionEvent.isCancelled()) return;
|
if (inspectionEvent.isCancelled()) return;
|
||||||
|
|
||||||
|
|
@ -2024,7 +2024,7 @@ class PlayerEventHandler implements Listener
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// alert plugins of a claim inspection, return if cancelled
|
// 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);
|
Bukkit.getPluginManager().callEvent(inspectionEvent);
|
||||||
if (inspectionEvent.isCancelled()) return;
|
if (inspectionEvent.isCancelled()) return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package me.ryanhamshire.GriefPrevention.events;
|
package me.ryanhamshire.GriefPrevention.events;
|
||||||
|
|
||||||
import me.ryanhamshire.GriefPrevention.Claim;
|
import me.ryanhamshire.GriefPrevention.Claim;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
@ -23,30 +24,39 @@ public class ClaimInspectionEvent extends PlayerEvent implements Cancellable
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Collection<Claim> claims;
|
private final Collection<Claim> claims;
|
||||||
|
private final Block inspectedBlock;
|
||||||
private final boolean inspectingNearbyClaims;
|
private final boolean inspectingNearbyClaims;
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new ClaimInspectionEvent with a player and claim instance.
|
* Constructs a new ClaimInspectionEvent with a player and claim instance.
|
||||||
* @param player The player actor
|
* @param player The player actor
|
||||||
|
* @param inspectedBlock The inspected block
|
||||||
* @param claim The claim involved
|
* @param claim The claim involved
|
||||||
*/
|
*/
|
||||||
public ClaimInspectionEvent(Player player, Claim claim) {
|
public ClaimInspectionEvent(Player player, Block inspectedBlock, Claim claim) {
|
||||||
this(player, Collections.singleton(claim), false);
|
this(player, inspectedBlock, Collections.singleton(claim), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new ClaimInspectionEvent with a player, list of claims and boolean flag inspectingNearbyClaims.
|
* Constructs a new ClaimInspectionEvent with a player, list of claims and boolean flag inspectingNearbyClaims.
|
||||||
* @param player The player actor
|
* @param player The player actor
|
||||||
|
* @param inspectedBlock The inspected block
|
||||||
* @param claims The list of claims involved
|
* @param claims The list of claims involved
|
||||||
* @param inspectingNearbyClaims Whether or not the user is inspecting nearby claims ("shift-clicking")
|
* @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);
|
super(player);
|
||||||
|
this.inspectedBlock = inspectedBlock;
|
||||||
this.claims = claims;
|
this.claims = claims;
|
||||||
this.inspectingNearbyClaims = inspectingNearbyClaims;
|
this.inspectingNearbyClaims = inspectingNearbyClaims;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Block getInspectedBlock()
|
||||||
|
{
|
||||||
|
return inspectedBlock;
|
||||||
|
}
|
||||||
|
|
||||||
public Collection<Claim> getClaims()
|
public Collection<Claim> getClaims()
|
||||||
{
|
{
|
||||||
return claims;
|
return claims;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user