Add option to consider use of an item as a block use at the player's feet.

Closes WORLDGUARD-3151.
This commit is contained in:
sk89q 2014-08-31 19:30:14 -07:00
parent 59bd11e742
commit cdab004505
2 changed files with 12 additions and 0 deletions

View File

@ -182,6 +182,7 @@ public class WorldConfiguration {
public boolean disableObsidianGenerators;
public boolean strictEntitySpawn;
public TargetMatcherSet allowAllInteract;
public TargetMatcherSet blockUseAtFeet;
private Map<String, Integer> maxRegionCounts;
@ -346,6 +347,7 @@ private void loadConfiguration() {
strictEntitySpawn = getBoolean("event-handling.block-entity-spawns-with-untraceable-cause", false);
allowAllInteract = getTargetMatchers("event-handling.interaction-whitelist");
blockUseAtFeet = getTargetMatchers("event-handling.emit-block-use-at-feet");
itemDurability = getBoolean("protection.item-durability", true);
removeInfiniteStacks = getBoolean("protection.remove-infinite-stacks", false);

View File

@ -392,6 +392,16 @@ public void onPlayerInteract(PlayerInteractEvent event) {
event.setUseItemInHand(Result.DENY);
}
// Check for items that the administrator has configured to
// emit a "use block here" event where the player is
// standing, which is a hack to protect items that don't
// throw events
if (item != null && getWorldConfig(player.getWorld()).blockUseAtFeet.test(item)) {
if (Events.fireAndTestCancel(new UseBlockEvent(event, cause, player.getLocation().getBlock()))) {
event.setCancelled(true);
}
}
break;
}
}