Put 3D biome code in spigot 1.18 - still working on grass shading...
This commit is contained in:
parent
983a2a4390
commit
37fd064434
8 changed files with 430 additions and 762 deletions
|
|
@ -101,6 +101,7 @@ import org.dynmap.common.BiomeMap;
|
|||
import org.dynmap.common.DynmapCommandSender;
|
||||
import org.dynmap.common.DynmapPlayer;
|
||||
import org.dynmap.common.DynmapServerInterface;
|
||||
import org.dynmap.common.chunk.GenericChunkCache;
|
||||
import org.dynmap.common.DynmapListenerManager.EventType;
|
||||
import org.dynmap.hdmap.HDMap;
|
||||
import org.dynmap.markers.MarkerAPI;
|
||||
|
|
@ -435,11 +436,16 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
}
|
||||
@Override
|
||||
public double getCacheHitRate() {
|
||||
return SnapshotCache.sscache.getHitRate();
|
||||
return helper.useGenericCache() ? BukkitVersionHelper.gencache.getHitRate() : SnapshotCache.sscache.getHitRate();
|
||||
}
|
||||
@Override
|
||||
public void resetCacheStats() {
|
||||
SnapshotCache.sscache.resetStats();
|
||||
if (helper.useGenericCache()) {
|
||||
BukkitVersionHelper.gencache.resetStats();
|
||||
}
|
||||
else {
|
||||
SnapshotCache.sscache.resetStats();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public DynmapWorld getWorldByName(String wname) {
|
||||
|
|
@ -828,7 +834,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
if (rl != null) { // If resource location, lookup by this
|
||||
bmap = BiomeMap.byBiomeResourceLocation(rl);
|
||||
}
|
||||
if (bmap == BiomeMap.NULL) {
|
||||
else {
|
||||
bmap = BiomeMap.byBiomeID(i);
|
||||
}
|
||||
if (bmap.isDefault()) {
|
||||
|
|
@ -1009,7 +1015,12 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
return;
|
||||
}
|
||||
playerList = core.playerList;
|
||||
SnapshotCache.sscache = new SnapshotCache(core.getSnapShotCacheSize(), core.useSoftRefInSnapShotCache());
|
||||
if (helper.useGenericCache()) {
|
||||
BukkitVersionHelper.gencache = new GenericChunkCache(core.getSnapShotCacheSize(), core.useSoftRefInSnapShotCache());
|
||||
}
|
||||
else {
|
||||
SnapshotCache.sscache = new SnapshotCache(core.getSnapShotCacheSize(), core.useSoftRefInSnapShotCache());
|
||||
}
|
||||
|
||||
/* Get map manager from core */
|
||||
mapManager = core.getMapManager();
|
||||
|
|
@ -1047,6 +1058,10 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
SnapshotCache.sscache.cleanup();
|
||||
SnapshotCache.sscache = null;
|
||||
}
|
||||
if (BukkitVersionHelper.gencache != null) {
|
||||
BukkitVersionHelper.gencache.cleanup();
|
||||
BukkitVersionHelper.gencache = null;
|
||||
}
|
||||
Log.info("Disabled");
|
||||
}
|
||||
|
||||
|
|
@ -1101,13 +1116,13 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
@Override
|
||||
public final int triggerRenderOfVolume(String wid, int minx, int miny, int minz,
|
||||
int maxx, int maxy, int maxz) {
|
||||
SnapshotCache.sscache.invalidateSnapshot(wid, minx, miny, minz, maxx, maxy, maxz);
|
||||
invalidateSnapshot(wid, minx, miny, minz, maxx, maxy, maxz);
|
||||
return core.triggerRenderOfVolume(wid, minx, miny, minz, maxx, maxy, maxz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int triggerRenderOfBlock(String wid, int x, int y, int z) {
|
||||
SnapshotCache.sscache.invalidateSnapshot(wid, x, y, z);
|
||||
invalidateSnapshot(wid, x, y, z);
|
||||
return core.triggerRenderOfBlock(wid, x, y, z);
|
||||
}
|
||||
|
||||
|
|
@ -1233,7 +1248,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
if(btt.typeid == 9) btt.typeid = 8;
|
||||
if((bt != btt.typeid) || (btt.data != w.getBlockAt(loc).getData())) {
|
||||
String wn = getWorld(w).getName();
|
||||
SnapshotCache.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), btt.trigger);
|
||||
}
|
||||
}
|
||||
|
|
@ -1279,6 +1294,23 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
private boolean onblockgrow;
|
||||
private boolean onblockredstone;
|
||||
|
||||
private void invalidateSnapshot(String wn, int x, int y, int z) {
|
||||
if (helper.useGenericCache()) {
|
||||
BukkitVersionHelper.gencache.invalidateSnapshot(wn, x, y, z);
|
||||
}
|
||||
else {
|
||||
SnapshotCache.sscache.invalidateSnapshot(wn, x, y, z);
|
||||
}
|
||||
}
|
||||
private void invalidateSnapshot(String wname, int minx, int miny, int minz, int maxx, int maxy, int maxz) {
|
||||
if (helper.useGenericCache()) {
|
||||
BukkitVersionHelper.gencache.invalidateSnapshot(wname, minx, miny, minz, maxx, maxy, maxz);
|
||||
}
|
||||
else {
|
||||
SnapshotCache.sscache.invalidateSnapshot(wname, minx, miny, minz, maxx, maxy, maxz);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerEvents() {
|
||||
|
||||
// To trigger rendering.
|
||||
|
|
@ -1300,7 +1332,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
SnapshotCache.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockplace");
|
||||
}
|
||||
};
|
||||
|
|
@ -1315,7 +1347,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
if(b == null) return; /* Stupid mod workaround */
|
||||
Location loc = b.getLocation();
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
SnapshotCache.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockbreak");
|
||||
}
|
||||
};
|
||||
|
|
@ -1328,7 +1360,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
public void onLeavesDecay(LeavesDecayEvent event) {
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
SnapshotCache.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
if(onleaves) {
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "leavesdecay");
|
||||
}
|
||||
|
|
@ -1343,7 +1375,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
public void onBlockBurn(BlockBurnEvent event) {
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
SnapshotCache.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
if(onburn) {
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockburn");
|
||||
}
|
||||
|
|
@ -1409,14 +1441,14 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
}
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
int x = loc.getBlockX(), y = loc.getBlockY(), z = loc.getBlockZ();
|
||||
SnapshotCache.sscache.invalidateSnapshot(wn, x, y, z);
|
||||
invalidateSnapshot(wn, x, y, z);
|
||||
if(onpiston)
|
||||
mapManager.touch(wn, x, y, z, "pistonretract");
|
||||
for(int i = 0; i < 2; i++) {
|
||||
x += dir.getModX();
|
||||
y += dir.getModY();
|
||||
z += dir.getModZ();
|
||||
SnapshotCache.sscache.invalidateSnapshot(wn, x, y, z);
|
||||
invalidateSnapshot(wn, x, y, z);
|
||||
mapManager.touch(wn, x, y, z, "pistonretract");
|
||||
}
|
||||
}
|
||||
|
|
@ -1433,14 +1465,14 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
}
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
int x = loc.getBlockX(), y = loc.getBlockY(), z = loc.getBlockZ();
|
||||
SnapshotCache.sscache.invalidateSnapshot(wn, x, y, z);
|
||||
invalidateSnapshot(wn, x, y, z);
|
||||
if(onpiston)
|
||||
mapManager.touch(wn, x, y, z, "pistonretract");
|
||||
for(int i = 0; i < 1+event.getLength(); i++) {
|
||||
x += dir.getModX();
|
||||
y += dir.getModY();
|
||||
z += dir.getModZ();
|
||||
SnapshotCache.sscache.invalidateSnapshot(wn, x, y, z);
|
||||
invalidateSnapshot(wn, x, y, z);
|
||||
mapManager.touch(wn, x, y, z, "pistonretract");
|
||||
}
|
||||
}
|
||||
|
|
@ -1454,7 +1486,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
public void onBlockSpread(BlockSpreadEvent event) {
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
SnapshotCache.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockspread");
|
||||
}
|
||||
};
|
||||
|
|
@ -1467,7 +1499,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
public void onBlockForm(BlockFormEvent event) {
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
SnapshotCache.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockform");
|
||||
}
|
||||
};
|
||||
|
|
@ -1480,7 +1512,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
public void onBlockFade(BlockFadeEvent event) {
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
SnapshotCache.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockfade");
|
||||
}
|
||||
};
|
||||
|
|
@ -1495,7 +1527,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
public void onBlockGrow(BlockGrowEvent event) {
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
SnapshotCache.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockgrow");
|
||||
}
|
||||
};
|
||||
|
|
@ -1508,7 +1540,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
public void onBlockRedstone(BlockRedstoneEvent event) {
|
||||
Location loc = event.getBlock().getLocation();
|
||||
String wn = getWorld(loc.getWorld()).getName();
|
||||
SnapshotCache.sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockredstone");
|
||||
}
|
||||
};
|
||||
|
|
@ -1565,7 +1597,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
if(z < minz) minz = z;
|
||||
if(z > maxz) maxz = z;
|
||||
}
|
||||
SnapshotCache.sscache.invalidateSnapshot(wname, minx, miny, minz, maxx, maxy, maxz);
|
||||
invalidateSnapshot(wname, minx, miny, minz, maxx, maxy, maxz);
|
||||
if(onexplosion) {
|
||||
mapManager.touchVolume(wname, minx, miny, minz, maxx, maxy, maxz, "entityexplode");
|
||||
}
|
||||
|
|
@ -1612,7 +1644,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||
if(z < minz) minz = z;
|
||||
if(z > maxz) maxz = z;
|
||||
}
|
||||
SnapshotCache.sscache.invalidateSnapshot(wname, minx, miny, minz, maxx, maxy, maxz);
|
||||
invalidateSnapshot(wname, minx, miny, minz, maxx, maxy, maxz);
|
||||
if(onstructuregrow) {
|
||||
mapManager.touchVolume(wname, minx, miny, minz, maxx, maxy, maxz, "structuregrow");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue