mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-09-12 06:08:07 +02:00
Switch chunkgenerate to onChunkPopulate event: chunk is better "cooked" by then
This commit is contained in:
parent
58d359fc1d
commit
6e5482466d
@ -47,6 +47,7 @@ import org.bukkit.event.player.PlayerListener;
|
|||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.world.ChunkLoadEvent;
|
import org.bukkit.event.world.ChunkLoadEvent;
|
||||||
|
import org.bukkit.event.world.ChunkPopulateEvent;
|
||||||
import org.bukkit.event.world.WorldListener;
|
import org.bukkit.event.world.WorldListener;
|
||||||
import org.bukkit.event.world.WorldLoadEvent;
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@ -544,16 +545,16 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
public void onChunkLoad(ChunkLoadEvent event) {
|
public void onChunkLoad(ChunkLoadEvent event) {
|
||||||
if(ignore_chunk_loads)
|
if(ignore_chunk_loads)
|
||||||
return;
|
return;
|
||||||
if(onloadchunk || ongeneratechunk) {
|
/* Touch extreme corners */
|
||||||
if(generate_only) {
|
int x = event.getChunk().getX() << 4;
|
||||||
if(!event.isNewChunk())
|
int z = event.getChunk().getZ() << 4;
|
||||||
return;
|
mapManager.touchVolume(new Location(event.getWorld(), x, 0, z), new Location(event.getWorld(), x+15, 127, z+15));
|
||||||
}
|
}
|
||||||
/* Touch extreme corners */
|
@Override
|
||||||
int x = event.getChunk().getX() << 4;
|
public void onChunkPopulate(ChunkPopulateEvent event) {
|
||||||
int z = event.getChunk().getZ() << 4;
|
int x = event.getChunk().getX() << 4;
|
||||||
mapManager.touchVolume(new Location(event.getWorld(), x, 0, z), new Location(event.getWorld(), x+15, 127, z+15));
|
int z = event.getChunk().getZ() << 4;
|
||||||
}
|
mapManager.touchVolume(new Location(event.getWorld(), x, 0, z), new Location(event.getWorld(), x+15, 127, z+15));
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onWorldLoad(WorldLoadEvent event) {
|
public void onWorldLoad(WorldLoadEvent event) {
|
||||||
@ -563,21 +564,12 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
ongeneratechunk = isTrigger("chunkgenerated");
|
ongeneratechunk = isTrigger("chunkgenerated");
|
||||||
if(ongeneratechunk) {
|
if(ongeneratechunk) {
|
||||||
try { /* Test if new enough bukkit to allow this */
|
registerEvent(Event.Type.CHUNK_POPULATED, worldTrigger);
|
||||||
ChunkLoadEvent.class.getDeclaredMethod("isNewChunk", new Class[0]);
|
|
||||||
} catch (NoSuchMethodException nsmx) {
|
|
||||||
Log.info("Warning: CraftBukkit build does not support function needed for 'chunkgenerated' trigger - disabling");
|
|
||||||
ongeneratechunk = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
onloadchunk = isTrigger("chunkloaded");
|
onloadchunk = isTrigger("chunkloaded");
|
||||||
if(onloadchunk) {
|
if(onloadchunk) {
|
||||||
generate_only = false;
|
registerEvent(Event.Type.CHUNK_LOAD, worldTrigger);
|
||||||
}
|
}
|
||||||
else if (ongeneratechunk) {
|
|
||||||
generate_only = true;
|
|
||||||
}
|
|
||||||
registerEvent(Event.Type.CHUNK_LOAD, worldTrigger);
|
|
||||||
|
|
||||||
// To link configuration to real loaded worlds.
|
// To link configuration to real loaded worlds.
|
||||||
registerEvent(Event.Type.WORLD_LOAD, worldTrigger);
|
registerEvent(Event.Type.WORLD_LOAD, worldTrigger);
|
||||||
@ -1053,6 +1045,16 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void onChunkPopulate(ChunkPopulateEvent event) {
|
||||||
|
/* Call listeners */
|
||||||
|
List<Listener> ll = event_handlers.get(event.getType());
|
||||||
|
if(ll != null) {
|
||||||
|
for(Listener l : ll) {
|
||||||
|
((WorldListener)l).onChunkPopulate(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private CustomEventListener ourCustomEventHandler = new CustomEventListener() {
|
private CustomEventListener ourCustomEventHandler = new CustomEventListener() {
|
||||||
@ -1112,6 +1114,7 @@ public class DynmapPlugin extends JavaPlugin {
|
|||||||
break;
|
break;
|
||||||
case WORLD_LOAD:
|
case WORLD_LOAD:
|
||||||
case CHUNK_LOAD:
|
case CHUNK_LOAD:
|
||||||
|
case CHUNK_POPULATED:
|
||||||
pm.registerEvent(type, ourWorldEventHandler, Event.Priority.Monitor, this);
|
pm.registerEvent(type, ourWorldEventHandler, Event.Priority.Monitor, this);
|
||||||
break;
|
break;
|
||||||
case CUSTOM_EVENT:
|
case CUSTOM_EVENT:
|
||||||
|
Loading…
Reference in New Issue
Block a user