Don't allow players without access trust to shoot targets
This commit is contained in:
parent
06109e617b
commit
f5a99cefd3
|
|
@ -294,7 +294,7 @@ public class BlockEventHandler implements Listener
|
||||||
|
|
||||||
//If block is a chest, don't allow a DoubleChest to form across a claim boundary
|
//If block is a chest, don't allow a DoubleChest to form across a claim boundary
|
||||||
denyConnectingDoubleChestsAcrossClaimBoundary(claim, block, player);
|
denyConnectingDoubleChestsAcrossClaimBoundary(claim, block, player);
|
||||||
|
|
||||||
if (claim != null)
|
if (claim != null)
|
||||||
{
|
{
|
||||||
playerData.lastClaim = claim;
|
playerData.lastClaim = claim;
|
||||||
|
|
@ -861,7 +861,7 @@ public class BlockEventHandler implements Listener
|
||||||
Block block = event.getHitBlock();
|
Block block = event.getHitBlock();
|
||||||
|
|
||||||
// Ensure projectile affects block.
|
// Ensure projectile affects block.
|
||||||
if (block == null || block.getType() != Material.CHORUS_FLOWER)
|
if (block == null || !(block.getType() == Material.CHORUS_FLOWER || block.getType() == Material.TARGET))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Claim claim = dataStore.getClaimAt(block.getLocation(), false, null);
|
Claim claim = dataStore.getClaimAt(block.getLocation(), false, null);
|
||||||
|
|
@ -871,8 +871,8 @@ public class BlockEventHandler implements Listener
|
||||||
Player shooter = null;
|
Player shooter = null;
|
||||||
Projectile projectile = event.getEntity();
|
Projectile projectile = event.getEntity();
|
||||||
|
|
||||||
if (projectile.getShooter() instanceof Player)
|
if (projectile.getShooter() instanceof Player player)
|
||||||
shooter = (Player) projectile.getShooter();
|
shooter = player;
|
||||||
|
|
||||||
if (shooter == null)
|
if (shooter == null)
|
||||||
{
|
{
|
||||||
|
|
@ -880,13 +880,20 @@ public class BlockEventHandler implements Listener
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Supplier<String> allowContainer = claim.checkPermission(shooter, ClaimPermission.Inventory, event);
|
Supplier<String> allowAction = claim.checkPermission(
|
||||||
|
shooter,
|
||||||
|
switch (block.getType())
|
||||||
|
{
|
||||||
|
case CHORUS_FLOWER -> ClaimPermission.Inventory;
|
||||||
|
case TARGET -> ClaimPermission.Access;
|
||||||
|
default -> ClaimPermission.Build;
|
||||||
|
},
|
||||||
|
event);
|
||||||
|
|
||||||
if (allowContainer != null)
|
if (allowAction != null)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
GriefPrevention.sendMessage(shooter, TextMode.Err, allowContainer.get());
|
GriefPrevention.sendMessage(shooter, TextMode.Err, allowAction.get());
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user