2012-01-15 23:58:19 +01:00
|
|
|
package org.dynmap.bukkit;
|
|
|
|
/**
|
|
|
|
* Bukkit specific implementation of DynmapWorld
|
|
|
|
*/
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.World;
|
|
|
|
import org.dynmap.DynmapChunk;
|
|
|
|
import org.dynmap.DynmapLocation;
|
|
|
|
import org.dynmap.DynmapWorld;
|
|
|
|
import org.dynmap.utils.MapChunkCache;
|
|
|
|
|
|
|
|
public class BukkitWorld extends DynmapWorld {
|
|
|
|
private World world;
|
|
|
|
|
|
|
|
public BukkitWorld(World w) {
|
2012-03-10 22:07:13 +01:00
|
|
|
super(w.getName(), w.getMaxHeight(), w.getSeaLevel());
|
2012-01-15 23:58:19 +01:00
|
|
|
|
|
|
|
world = w;
|
|
|
|
}
|
|
|
|
/* Test if world is nether */
|
|
|
|
@Override
|
|
|
|
public boolean isNether() {
|
|
|
|
return world.getEnvironment() == World.Environment.NETHER;
|
|
|
|
}
|
|
|
|
/* Get world spawn location */
|
|
|
|
@Override
|
|
|
|
public DynmapLocation getSpawnLocation() {
|
|
|
|
DynmapLocation dloc = new DynmapLocation();
|
|
|
|
Location sloc = world.getSpawnLocation();
|
|
|
|
dloc.x = sloc.getBlockX(); dloc.y = sloc.getBlockY();
|
2012-02-28 05:14:48 +01:00
|
|
|
dloc.z = sloc.getBlockZ(); dloc.world = normalizeWorldName(sloc.getWorld().getName());
|
2012-01-15 23:58:19 +01:00
|
|
|
return dloc;
|
|
|
|
}
|
|
|
|
/* Get world time */
|
|
|
|
@Override
|
|
|
|
public long getTime() {
|
|
|
|
return world.getTime();
|
|
|
|
}
|
|
|
|
/* World is storming */
|
|
|
|
@Override
|
|
|
|
public boolean hasStorm() {
|
|
|
|
return world.hasStorm();
|
|
|
|
}
|
|
|
|
/* World is thundering */
|
|
|
|
@Override
|
|
|
|
public boolean isThundering() {
|
|
|
|
return world.isThundering();
|
|
|
|
}
|
|
|
|
/* World is loaded */
|
|
|
|
@Override
|
|
|
|
public boolean isLoaded() {
|
|
|
|
return (world != null);
|
|
|
|
}
|
|
|
|
/* Get light level of block */
|
|
|
|
@Override
|
|
|
|
public int getLightLevel(int x, int y, int z) {
|
|
|
|
return world.getBlockAt(x, y, z).getLightLevel();
|
|
|
|
}
|
|
|
|
/* Get highest Y coord of given location */
|
|
|
|
@Override
|
|
|
|
public int getHighestBlockYAt(int x, int z) {
|
|
|
|
return world.getHighestBlockYAt(x, z);
|
|
|
|
}
|
|
|
|
/* Test if sky light level is requestable */
|
|
|
|
@Override
|
|
|
|
public boolean canGetSkyLightLevel() {
|
2012-02-15 03:54:36 +01:00
|
|
|
return true;
|
2012-01-15 23:58:19 +01:00
|
|
|
}
|
|
|
|
/* Return sky light level */
|
|
|
|
@Override
|
|
|
|
public int getSkyLightLevel(int x, int y, int z) {
|
2012-02-15 03:54:36 +01:00
|
|
|
return world.getBlockAt(x, y, z).getLightFromSky();
|
2012-01-15 23:58:19 +01:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Get world environment ID (lower case - normal, the_end, nether)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public String getEnvironment() {
|
|
|
|
return world.getEnvironment().name().toLowerCase();
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Get map chunk cache for world
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public MapChunkCache getChunkCache(List<DynmapChunk> chunks) {
|
2012-01-16 06:56:32 +01:00
|
|
|
NewMapChunkCache c = new NewMapChunkCache();
|
2012-01-16 06:19:01 +01:00
|
|
|
c.setChunks(this, chunks);
|
2012-01-15 23:58:19 +01:00
|
|
|
return c;
|
|
|
|
}
|
2012-01-16 06:19:01 +01:00
|
|
|
|
|
|
|
public World getWorld() {
|
|
|
|
return world;
|
|
|
|
}
|
2012-01-15 23:58:19 +01:00
|
|
|
}
|