Perf: Player interact event.

This commit is contained in:
ryanhamshire 2015-01-26 16:07:33 -08:00
parent 58ea48df06
commit 783c5a9844
3 changed files with 9 additions and 15 deletions

View File

@ -3,7 +3,7 @@ main: me.ryanhamshire.GriefPrevention.GriefPrevention
softdepend: [Vault, Multiverse-Core, My Worlds, MystCraft, Transporter, TheUnderground, WorldGuard, WorldEdit]
dev-url: http://dev.bukkit.org/server-mods/grief-prevention
loadbefore: [TheUnderground]
version: 10.5.3
version: 10.5.5
commands:
abandonclaim:
description: Deletes a claim.

View File

@ -108,6 +108,12 @@ class EntityEventHandler implements Listener
event.setCancelled(true);
}
//don't allow players to trample crops
else if(event.getEntityType() == EntityType.PLAYER && event.getBlock().getType() == Material.SOIL)
{
event.setCancelled(true);
}
//sand cannon fix - when the falling block doesn't fall straight down, take additional anti-grief steps
else if (event.getEntityType() == EntityType.FALLING_BLOCK)
{

View File

@ -1243,6 +1243,7 @@ class PlayerEventHandler implements Listener
//not interested in left-click-on-air actions
Action action = event.getAction();
if(action == Action.LEFT_CLICK_AIR) return;
if(action == Action.PHYSICAL) return;
Player player = event.getPlayer();
Block clickedBlock = event.getClickedBlock(); //null returned here means interacting with air
@ -1257,20 +1258,7 @@ class PlayerEventHandler implements Listener
clickedBlockType = Material.AIR;
}
//apply rule for players trampling tilled soil back to dirt (never allow it)
//NOTE: that this event applies only to players. monsters and animals can still trample.
if(action == Action.PHYSICAL)
{
if(clickedBlockType == Material.SOIL)
{
event.setCancelled(true);
}
//not tracking any other "physical" interaction events right now
return;
}
//don't care about left-clicking on most blocks, this is probably a break action
//don't care about left-clicking on most blocks, this is probably a break action
PlayerData playerData = null;
if(action == Action.LEFT_CLICK_BLOCK && clickedBlock != null)
{