Add 'structuregrow' trigger event - update on tree grow, giant mushroom grow

This commit is contained in:
Mike Primm 2012-02-13 20:06:37 -06:00
parent f0907ce954
commit f1782fd9f4
2 changed files with 31 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -41,6 +42,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.world.ChunkPopulateEvent;
import org.bukkit.event.world.SpawnChangeEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.event.world.WorldUnloadEvent;
import org.bukkit.plugin.Plugin;
@ -623,6 +625,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
private boolean onplayermove;
private boolean ongeneratechunk;
private boolean onexplosion;
private boolean onstructuregrow;
private void registerEvents() {
Listener blockTrigger = new Listener() {
@ -888,7 +891,34 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
if(w != null)
core.listenerManager.processWorldEvent(EventType.WORLD_UNLOAD, w);
}
@EventHandler(priority=EventPriority.MONITOR)
public void onStructureGrow(StructureGrowEvent event) {
Location loc = event.getLocation();
String wname = loc.getWorld().getName();
int minx, maxx, miny, maxy, minz, maxz;
minx = maxx = loc.getBlockX();
miny = maxy = loc.getBlockY();
minz = maxz = loc.getBlockZ();
/* Calculate volume impacted by explosion */
List<BlockState> blocks = event.getBlocks();
for(BlockState b: blocks) {
int x = b.getX();
if(x < minx) minx = x;
if(x > maxx) maxx = x;
int y = b.getY();
if(y < miny) miny = y;
if(y > maxy) maxy = y;
int z = b.getZ();
if(z < minz) minz = z;
if(z > maxz) maxz = z;
}
sscache.invalidateSnapshot(wname, minx, miny, minz, maxx, maxy, maxz);
if(onstructuregrow) {
mapManager.touchVolume(wname, minx, miny, minz, maxx, maxy, maxz, "structuregrow");
}
}
};
onstructuregrow = core.isTrigger("structuregrow");
// To link configuration to real loaded worlds.
pm.registerEvents(worldTrigger, this);

View File

@ -247,6 +247,7 @@ render-triggers:
- explosion
- blockfromto
- blockphysics
- structuregrow
# Title for the web page - if not specified, defaults to the server's name (unless it is the default of 'Unknown Server')
#webpage-title: "My Awesome Server Map"