Prevent theft using hoppers.
Disallowing placing a hopper or rail beneath a land claim unless the placer has container trust.
This commit is contained in:
parent
50bb2d3298
commit
8344102ed5
|
|
@ -274,17 +274,50 @@ public class BlockEventHandler implements Listener
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if the block is being placed within an existing claim
|
//if the block is being placed within or under an existing claim
|
||||||
PlayerData playerData = this.dataStore.getPlayerData(player.getName());
|
PlayerData playerData = this.dataStore.getPlayerData(player.getName());
|
||||||
Claim claim = this.dataStore.getClaimAt(block.getLocation(), true, playerData.lastClaim);
|
Claim claim = this.dataStore.getClaimAt(block.getLocation(), true, playerData.lastClaim);
|
||||||
if(claim != null)
|
if(claim != null)
|
||||||
{
|
{
|
||||||
//warn about TNT not destroying claimed blocks
|
//FEATURE: prevent theft from container using a hopper when the container is at the very bottom of a land claim
|
||||||
if(block.getType() == Material.TNT && !claim.areExplosivesAllowed)
|
|
||||||
{
|
if(block.getType() == Material.HOPPER)
|
||||||
GriefPrevention.sendMessage(player, TextMode.Warn, Messages.NoTNTDamageClaims);
|
{
|
||||||
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.ClaimExplosivesAdvertisement);
|
//is the above block inside the land claim?
|
||||||
}
|
Block aboveBlock = block.getRelative(BlockFace.UP);
|
||||||
|
if(claim.contains(aboveBlock.getLocation(), false, false))
|
||||||
|
{
|
||||||
|
//then the player needs container trust to place the hopper
|
||||||
|
String failureMessage = claim.allowContainers(player);
|
||||||
|
if(failureMessage != null)
|
||||||
|
{
|
||||||
|
placeEvent.setCancelled(true);
|
||||||
|
GriefPrevention.sendMessage(player, TextMode.Err, failureMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//rails can't be placed ANYWHERE under a claim, because they could be pushed up to the
|
||||||
|
//target container using pistons
|
||||||
|
if(block.getType().name().contains("RAIL"))
|
||||||
|
{
|
||||||
|
//then the player needs container trust to place the hopper
|
||||||
|
String failureMessage = claim.allowContainers(player);
|
||||||
|
if(failureMessage != null)
|
||||||
|
{
|
||||||
|
placeEvent.setCancelled(true);
|
||||||
|
GriefPrevention.sendMessage(player, TextMode.Err, failureMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//warn about TNT not destroying claimed blocks
|
||||||
|
if(block.getType() == Material.TNT && !claim.areExplosivesAllowed)
|
||||||
|
{
|
||||||
|
GriefPrevention.sendMessage(player, TextMode.Warn, Messages.NoTNTDamageClaims);
|
||||||
|
GriefPrevention.sendMessage(player, TextMode.Instr, Messages.ClaimExplosivesAdvertisement);
|
||||||
|
}
|
||||||
|
|
||||||
//if the player has permission for the claim and he's placing UNDER the claim
|
//if the player has permission for the claim and he's placing UNDER the claim
|
||||||
if(block.getY() < claim.lesserBoundaryCorner.getBlockY() && claim.allowBuild(player) == null)
|
if(block.getY() < claim.lesserBoundaryCorner.getBlockY() && claim.allowBuild(player) == null)
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Hopper;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Creature;
|
import org.bukkit.entity.Creature;
|
||||||
import org.bukkit.entity.Creeper;
|
import org.bukkit.entity.Creeper;
|
||||||
|
|
@ -54,7 +55,10 @@ import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||||
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
import org.bukkit.event.vehicle.VehicleDamageEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
|
|
||||||
//handles events related to entities
|
//handles events related to entities
|
||||||
class EntityEventHandler implements Listener
|
class EntityEventHandler implements Listener
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user