mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-01 06:33:38 +01:00
Merge pull request #239 from mikeprimm/master
Add support for 'chunkgenerated' render trigger, now that CB has functional chunk generate events
This commit is contained in:
commit
3310e07c9b
@ -89,6 +89,7 @@ render-triggers:
|
|||||||
- snowform
|
- snowform
|
||||||
- leavesdecay
|
- leavesdecay
|
||||||
- blockburn
|
- blockburn
|
||||||
|
- chunkgenerated
|
||||||
|
|
||||||
# The path where the tile-files are placed.
|
# The path where the tile-files are placed.
|
||||||
tilespath: web/tiles
|
tilespath: web/tiles
|
||||||
|
@ -52,6 +52,7 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
public Events events = new Events();
|
public Events events = new Events();
|
||||||
/* Flag to let code know that we're doing reload - make sure we don't double-register event handlers */
|
/* Flag to let code know that we're doing reload - make sure we don't double-register event handlers */
|
||||||
public boolean is_reload = false;
|
public boolean is_reload = false;
|
||||||
|
private boolean generate_only = false;
|
||||||
|
|
||||||
public static File dataDirectory;
|
public static File dataDirectory;
|
||||||
public static File tilesDirectory;
|
public static File tilesDirectory;
|
||||||
@ -247,21 +248,44 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
WorldListener renderTrigger = new WorldListener() {
|
WorldListener renderTrigger = new WorldListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onChunkLoad(ChunkLoadEvent event) {
|
public void onChunkLoad(ChunkLoadEvent event) {
|
||||||
int x = event.getChunk().getX() * 16 + 8;
|
if(generate_only) {
|
||||||
int z = event.getChunk().getZ() * 16 + 8;
|
if(!isNewChunk(event))
|
||||||
mm.touch(new Location(event.getWorld(), x, 127, z));
|
return;
|
||||||
|
/* Touch extreme corners */
|
||||||
|
int x = event.getChunk().getX() * 16;
|
||||||
|
int z = event.getChunk().getZ() * 16;
|
||||||
|
mm.touch(new Location(event.getWorld(), x, 0, z));
|
||||||
|
mm.touch(new Location(event.getWorld(), x+15, 127, z));
|
||||||
|
mm.touch(new Location(event.getWorld(), x+15, 0, z+15));
|
||||||
|
mm.touch(new Location(event.getWorld(), x, 127, z+15));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
int x = event.getChunk().getX() * 16 + 8;
|
||||||
|
int z = event.getChunk().getZ() * 16 + 8;
|
||||||
|
mm.touch(new Location(event.getWorld(), x, 127, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private boolean isNewChunk(ChunkLoadEvent event) {
|
||||||
|
return event.isNewChunk();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* @Override public void onChunkGenerated(ChunkLoadEvent event)
|
|
||||||
* { int x = event.getChunk().getX() * 16 + 8; int z =
|
|
||||||
* event.getChunk().getZ() * 16 + 8; mm.touch(new
|
|
||||||
* Location(event.getWorld(), x, 127, z)); }
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
if (isTrigger("chunkloaded"))
|
boolean ongenerate = isTrigger("chunkgenerated");
|
||||||
|
if(ongenerate) {
|
||||||
|
try { /* Test if new enough bukkit to allow this */
|
||||||
|
ChunkLoadEvent.class.getDeclaredMethod("isNewChunk", new Class[0]);
|
||||||
|
} catch (NoSuchMethodException nsmx) {
|
||||||
|
Log.info("Warning: CraftBukkit build does not support function needed for 'chunkgenerated' trigger - disabling");
|
||||||
|
ongenerate = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(isTrigger("chunkloaded")) {
|
||||||
|
generate_only = false;
|
||||||
pm.registerEvent(org.bukkit.event.Event.Type.CHUNK_LOAD, renderTrigger, org.bukkit.event.Event.Priority.Monitor, this);
|
pm.registerEvent(org.bukkit.event.Event.Type.CHUNK_LOAD, renderTrigger, org.bukkit.event.Event.Priority.Monitor, this);
|
||||||
//if (isTrigger("chunkgenerated")) pm.registerEvent(Event.Type.CHUNK_GENERATED, renderTrigger, Priority.Monitor, this);
|
}
|
||||||
|
else if(ongenerate) {
|
||||||
|
generate_only = true;
|
||||||
|
pm.registerEvent(org.bukkit.event.Event.Type.CHUNK_LOAD, renderTrigger, org.bukkit.event.Event.Priority.Monitor, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// To link configuration to real loaded worlds.
|
// To link configuration to real loaded worlds.
|
||||||
|
Loading…
Reference in New Issue
Block a user