sk89q/WorldGuard — pull request #323 by sk89q (2014-08-09 09:00:32+00:00)
Title: Use lambdas for event listeners

**This PR is not complete.**

This is a test to try Java 8 lambdas to handle events, which is to meet the goal of:

* Reducing code duplication in WG's event handlers.
* Reduce the sheer amount of code in the handlers.

I added a Maven plugin that converts the Java 8 lambdas down to Java 6, so everything still works on Java 6 and 7. While Guava has functional classes on its own, you still have to use a lot of code on Java 6 and 7 to use a functional programming paradigm.

With lambdas, the code looks like this:

```java
registerEvents(new BlockFadeListener(
b -> b.getType() == Material.ICE
&& (getConfig(b).disableIceMelting || !testState(b, ICE_MELT))))
```

Previously, it looked like this:

```java
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockFade(BlockFadeEvent event) {
ConfigurationManager cfg = plugin.getGlobalStateManager();
WorldConfiguration wcfg = cfg.get(event.getBlock().getWorld());

switch (event.getBlock().getTypeId()) {
case BlockID.ICE:
if (wcfg.disableIceMelting) {
event.setCancelled(true);
return;
}

if (wcfg.useRegions && !plugin.getGlobalRegionManager().allows(
DefaultFlag.ICE_MELT, event.getBlock().getLocation())) {
event.setCancelled(true);
return;
}
break;
}
}
```

I have to add a cache for `ApplicationRegionSet` at some point, however, because this would result in a ton of repeated spatial search requests due to the multiple listeners.

Opinions? Comments?