Players with build permission can trample crops.

Previously, no crop trampling - now it's possible if the player has
build permission.  Non-players (animals/monsters) still can't trample
because it's possible they may be manipulated by griefers to do that.
This commit is contained in:
ryanhamshire 2016-04-13 20:14:11 -07:00
parent c92986bf5d
commit 62b3c9098c

View File

@ -138,10 +138,22 @@ public class EntityEventHandler implements Listener
event.setCancelled(true); event.setCancelled(true);
} }
//don't allow crops to be trampled //don't allow crops to be trampled, except by a player with build permission
else if(event.getTo() == Material.DIRT && event.getBlock().getType() == Material.SOIL) else if(event.getTo() == Material.DIRT && event.getBlock().getType() == Material.SOIL)
{ {
event.setCancelled(true); if(event.getEntityType() != EntityType.PLAYER)
{
event.setCancelled(true);
}
else
{
Player player = (Player)event.getEntity();
Block block = event.getBlock();
if(GriefPrevention.instance.allowBreak(player, block, block.getLocation()) != null)
{
event.setCancelled(true);
}
}
} }
//sand cannon fix - when the falling block doesn't fall straight down, take additional anti-grief steps //sand cannon fix - when the falling block doesn't fall straight down, take additional anti-grief steps