mirror of
https://github.com/encounter/dynmap.git
synced 2026-03-30 11:08:39 -07:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 96673f0fb3 | |||
| fc451fd002 | |||
| 2f1b1789fd | |||
| 01b054e972 | |||
| 5d35205cae | |||
| 58c7d6378c | |||
| d95213e7dd | |||
| 4f5063155e | |||
| 2d4e233005 | |||
| afc0d9bd6b | |||
| 267b423ff1 | |||
| d523ce8a41 | |||
| ee7e6eedc8 | |||
| 4d6d156e9c | |||
| 177310a949 | |||
| 0707953718 | |||
| 8546b2205e | |||
| d154f23bab | |||
| 0b38a4cec8 |
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.dynmap</groupId>
|
||||
<artifactId>dynmap</artifactId>
|
||||
<version>0.36.2</version>
|
||||
<version>0.40</version>
|
||||
<name>dynmap</name>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@@ -133,7 +133,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>[1.1-R5-SNAPSHOT,1.7)</version>
|
||||
<version>[1.2.5-R1.0,1.7)</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -6,6 +6,8 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.DynmapLocation;
|
||||
import org.dynmap.DynmapWorld;
|
||||
@@ -13,16 +15,21 @@ import org.dynmap.utils.MapChunkCache;
|
||||
|
||||
public class BukkitWorld extends DynmapWorld {
|
||||
private World world;
|
||||
private Permission perm;
|
||||
private World.Environment env;
|
||||
private boolean skylight;
|
||||
|
||||
public BukkitWorld(World w) {
|
||||
super(w.getName(), w.getMaxHeight(), w.getSeaLevel());
|
||||
|
||||
world = w;
|
||||
env = world.getEnvironment();
|
||||
skylight = (env == World.Environment.NORMAL);
|
||||
perm = new Permission("dynmap.world." + getName(), "Dynmap access for world " + getName(), PermissionDefault.OP);
|
||||
}
|
||||
/* Test if world is nether */
|
||||
@Override
|
||||
public boolean isNether() {
|
||||
return world.getEnvironment() == World.Environment.NETHER;
|
||||
return env == World.Environment.NETHER;
|
||||
}
|
||||
/* Get world spawn location */
|
||||
@Override
|
||||
@@ -66,7 +73,7 @@ public class BukkitWorld extends DynmapWorld {
|
||||
/* Test if sky light level is requestable */
|
||||
@Override
|
||||
public boolean canGetSkyLightLevel() {
|
||||
return true;
|
||||
return skylight;
|
||||
}
|
||||
/* Return sky light level */
|
||||
@Override
|
||||
@@ -78,7 +85,7 @@ public class BukkitWorld extends DynmapWorld {
|
||||
*/
|
||||
@Override
|
||||
public String getEnvironment() {
|
||||
return world.getEnvironment().name().toLowerCase();
|
||||
return env.name().toLowerCase();
|
||||
}
|
||||
/**
|
||||
* Get map chunk cache for world
|
||||
|
||||
@@ -57,6 +57,7 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.dynmap.DynmapAPI;
|
||||
import org.dynmap.DynmapChunk;
|
||||
import org.dynmap.DynmapCore;
|
||||
import org.dynmap.DynmapLocation;
|
||||
import org.dynmap.DynmapWebChatEvent;
|
||||
@@ -77,6 +78,7 @@ import org.dynmap.common.DynmapPlayer;
|
||||
import org.dynmap.common.DynmapServerInterface;
|
||||
import org.dynmap.common.DynmapListenerManager.EventType;
|
||||
import org.dynmap.markers.MarkerAPI;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
import org.getspout.spoutapi.plugin.SpoutPlugin;
|
||||
|
||||
public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
@@ -108,6 +110,11 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
* Server access abstraction class
|
||||
*/
|
||||
public class BukkitServer implements DynmapServerInterface {
|
||||
/* Chunk load handling */
|
||||
private Object loadlock = new Object();
|
||||
private int chunks_in_cur_tick = 0;
|
||||
private long cur_tick;
|
||||
|
||||
@Override
|
||||
public void scheduleServerTask(Runnable run, long delay) {
|
||||
getServer().getScheduler().scheduleSyncDelayedTask(DynmapPlugin.this, run, delay);
|
||||
@@ -209,7 +216,9 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
@SuppressWarnings("unused")
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onBlockBreak(BlockBreakEvent evt) {
|
||||
if(evt.isCancelled()) return;
|
||||
Block b = evt.getBlock();
|
||||
if(b == null) return; /* Work around for stupid mods.... */
|
||||
Location l = b.getLocation();
|
||||
core.listenerManager.processBlockEvent(EventType.BLOCK_BREAK, b.getType().getId(),
|
||||
BukkitWorld.normalizeWorldName(l.getWorld().getName()), l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
@@ -221,6 +230,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
@SuppressWarnings("unused")
|
||||
@EventHandler(priority=EventPriority.MONITOR)
|
||||
public void onSignChange(SignChangeEvent evt) {
|
||||
if(evt.isCancelled()) return;
|
||||
Block b = evt.getBlock();
|
||||
Location l = b.getLocation();
|
||||
String[] lines = evt.getLines(); /* Note: changes to this change event - intentional */
|
||||
@@ -302,6 +312,70 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
return false;
|
||||
return permissions.hasOfflinePermission(player, perm);
|
||||
}
|
||||
/**
|
||||
* Render processor helper - used by code running on render threads to request chunk snapshot cache from server/sync thread
|
||||
*/
|
||||
@Override
|
||||
public MapChunkCache createMapChunkCache(DynmapWorld w, List<DynmapChunk> chunks,
|
||||
boolean blockdata, boolean highesty, boolean biome, boolean rawbiome) {
|
||||
MapChunkCache c = w.getChunkCache(chunks);
|
||||
if(w.visibility_limits != null) {
|
||||
for(MapChunkCache.VisibilityLimit limit: w.visibility_limits) {
|
||||
c.setVisibleRange(limit);
|
||||
}
|
||||
c.setHiddenFillStyle(w.hiddenchunkstyle);
|
||||
c.setAutoGenerateVisbileRanges(w.do_autogenerate);
|
||||
}
|
||||
if(w.hidden_limits != null) {
|
||||
for(MapChunkCache.VisibilityLimit limit: w.hidden_limits) {
|
||||
c.setHiddenRange(limit);
|
||||
}
|
||||
c.setHiddenFillStyle(w.hiddenchunkstyle);
|
||||
}
|
||||
if(c.setChunkDataTypes(blockdata, biome, highesty, rawbiome) == false) {
|
||||
Log.severe("CraftBukkit build does not support biome APIs");
|
||||
}
|
||||
if(chunks.size() == 0) { /* No chunks to get? */
|
||||
c.loadChunks(0);
|
||||
return c;
|
||||
}
|
||||
|
||||
final MapChunkCache cc = c;
|
||||
|
||||
while(!cc.isDoneLoading()) {
|
||||
synchronized(loadlock) {
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
if(cur_tick != (now/50)) { /* New tick? */
|
||||
chunks_in_cur_tick = mapManager.getMaxChunkLoadsPerTick();
|
||||
cur_tick = now/50;
|
||||
}
|
||||
}
|
||||
Future<Boolean> f = core.getServer().callSyncMethod(new Callable<Boolean>() {
|
||||
public Boolean call() throws Exception {
|
||||
boolean exhausted;
|
||||
synchronized(loadlock) {
|
||||
if(chunks_in_cur_tick > 0)
|
||||
chunks_in_cur_tick -= cc.loadChunks(chunks_in_cur_tick);
|
||||
exhausted = (chunks_in_cur_tick == 0);
|
||||
}
|
||||
return exhausted;
|
||||
}
|
||||
});
|
||||
Boolean delay;
|
||||
try {
|
||||
delay = f.get();
|
||||
} catch (Exception ix) {
|
||||
Log.severe(ix);
|
||||
return null;
|
||||
}
|
||||
if((delay != null) && delay.booleanValue()) {
|
||||
try { Thread.sleep(25); } catch (InterruptedException ix) {}
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* Player access abstraction class
|
||||
@@ -771,7 +845,9 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Location loc = event.getBlock().getLocation();
|
||||
Block b = event.getBlock();
|
||||
if(b == null) return; /* Stupid mod workaround */
|
||||
Location loc = b.getLocation();
|
||||
String wn = BukkitWorld.normalizeWorldName(loc.getWorld().getName());
|
||||
sscache.invalidateSnapshot(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
mapManager.touch(wn, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), "blockbreak");
|
||||
@@ -825,6 +901,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
return;
|
||||
Block b = event.getBlock();
|
||||
Material m = b.getType();
|
||||
if(m == null) return;
|
||||
switch(m) {
|
||||
case STATIONARY_WATER:
|
||||
case WATER:
|
||||
@@ -832,7 +909,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
case LAVA:
|
||||
case GRAVEL:
|
||||
case SAND:
|
||||
checkBlock(event.getBlock(), "blockphysics");
|
||||
checkBlock(b, "blockphysics");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -847,12 +924,14 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
public void onBlockFromTo(BlockFromToEvent event) {
|
||||
if(event.isCancelled())
|
||||
return;
|
||||
Material m = event.getBlock().getType();
|
||||
if((m != Material.WOOD_PLATE) && (m != Material.STONE_PLATE))
|
||||
checkBlock(event.getBlock(), "blockfromto");
|
||||
m = event.getToBlock().getType();
|
||||
if((m != Material.WOOD_PLATE) && (m != Material.STONE_PLATE))
|
||||
checkBlock(event.getToBlock(), "blockfromto");
|
||||
Block b = event.getBlock();
|
||||
Material m = b.getType();
|
||||
if((m != Material.WOOD_PLATE) && (m != Material.STONE_PLATE) && (m != null))
|
||||
checkBlock(b, "blockfromto");
|
||||
b = event.getToBlock();
|
||||
m = b.getType();
|
||||
if((m != Material.WOOD_PLATE) && (m != Material.STONE_PLATE) && (m != null))
|
||||
checkBlock(b, "blockfromto");
|
||||
}
|
||||
};
|
||||
pm.registerEvents(fromtolistener, this);
|
||||
|
||||
@@ -101,16 +101,21 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
exceptions++;
|
||||
}
|
||||
laststep = BlockStep.Y_MINUS;
|
||||
typeid = blkdata = -1;
|
||||
if((y >= 0) && (y < worldheight))
|
||||
typeid = blkdata = -1;
|
||||
else
|
||||
typeid = blkdata = 0;
|
||||
}
|
||||
public final int getBlockTypeID() {
|
||||
if(typeid < 0)
|
||||
if(typeid < 0) {
|
||||
typeid = snap.getBlockTypeId(bx, y, bz);
|
||||
}
|
||||
return typeid;
|
||||
}
|
||||
public final int getBlockData() {
|
||||
if(blkdata < 0)
|
||||
if(blkdata < 0) {
|
||||
blkdata = snap.getBlockData(bx, y, bz);
|
||||
}
|
||||
return blkdata;
|
||||
}
|
||||
public int getBlockSkyLight() {
|
||||
@@ -353,6 +358,8 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
* Step current position in given direction
|
||||
*/
|
||||
public final void stepPosition(BlockStep step) {
|
||||
typeid = -1;
|
||||
blkdata = -1;
|
||||
switch(step.ordinal()) {
|
||||
case 0:
|
||||
x++;
|
||||
@@ -372,6 +379,9 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
break;
|
||||
case 1:
|
||||
y++;
|
||||
if(y >= worldheight) {
|
||||
typeid = blkdata = 0;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
z++;
|
||||
@@ -407,6 +417,9 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
break;
|
||||
case 4:
|
||||
y--;
|
||||
if(y < 0) {
|
||||
typeid = blkdata = 0;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
z--;
|
||||
@@ -426,8 +439,6 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
break;
|
||||
}
|
||||
laststep = step;
|
||||
typeid = -1;
|
||||
blkdata = -1;
|
||||
}
|
||||
/**
|
||||
* Unstep current position to previous position
|
||||
@@ -449,8 +460,12 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
else
|
||||
laststep = BlockStep.Y_MINUS;
|
||||
this.y = y;
|
||||
typeid = -1;
|
||||
blkdata = -1;
|
||||
if((y < 0) || (y >= worldheight)) {
|
||||
typeid = blkdata = 0;
|
||||
}
|
||||
else {
|
||||
typeid = blkdata = -1;
|
||||
}
|
||||
}
|
||||
public final int getX() {
|
||||
return x;
|
||||
@@ -493,9 +508,12 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
}
|
||||
@Override
|
||||
public final boolean isEmptySection() {
|
||||
if(isSectionNotEmpty[chunkindex] == null)
|
||||
try {
|
||||
return !isSectionNotEmpty[chunkindex][y >> 4];
|
||||
} catch (Exception x) {
|
||||
initSectionData(chunkindex);
|
||||
return !isSectionNotEmpty[chunkindex][y >> 4];
|
||||
return !isSectionNotEmpty[chunkindex][y >> 4];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1060,6 +1078,9 @@ public class NewMapChunkCache implements MapChunkCache {
|
||||
Biome[] b = Biome.values();
|
||||
BiomeMap[] bm = BiomeMap.values();
|
||||
biome_to_bmap = new BiomeMap[b.length];
|
||||
for(int i = 0; i < b.length; i++) {
|
||||
biome_to_bmap[i] = BiomeMap.NULL;
|
||||
}
|
||||
for(int i = 0; i < b.length; i++) {
|
||||
String bs = b[i].toString();
|
||||
for(int j = 0; j < bm.length; j++) {
|
||||
|
||||
@@ -25,6 +25,9 @@ public class NijikokunPermissions implements PermissionProvider {
|
||||
return null;
|
||||
|
||||
server.getPluginManager().enablePlugin(permissionsPlugin);
|
||||
if(permissionsPlugin.isEnabled() == false)
|
||||
return null;
|
||||
|
||||
Log.info("Using Permissions " + permissionsPlugin.getDescription().getVersion() + " for access control");
|
||||
return new NijikokunPermissions(permissionsPlugin, name);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,8 @@ public class PEXPermissions implements PermissionProvider {
|
||||
if (permissionsPlugin == null)
|
||||
return null;
|
||||
server.getPluginManager().enablePlugin(permissionsPlugin);
|
||||
if(permissionsPlugin.isEnabled() == false)
|
||||
return null;
|
||||
if(PermissionsEx.isAvailable() == false)
|
||||
return null;
|
||||
Log.info("Using PermissionsEx " + permissionsPlugin.getDescription().getVersion() + " for access control");
|
||||
|
||||
@@ -28,6 +28,9 @@ public class PermBukkitPermissions extends BukkitPermissions {
|
||||
return null;
|
||||
|
||||
server.getPluginManager().enablePlugin(permissionsPlugin);
|
||||
if(permissionsPlugin.isEnabled() == false)
|
||||
return null;
|
||||
|
||||
Log.info("Using PermissionsBukkit " + permissionsPlugin.getDescription().getVersion() + " for access control");
|
||||
Log.info("Web interface permissions only available for online users");
|
||||
return new PermBukkitPermissions(permissionsPlugin, name, pd);
|
||||
|
||||
@@ -28,6 +28,9 @@ public class bPermPermissions extends BukkitPermissions {
|
||||
if (permissionsPlugin == null)
|
||||
return null;
|
||||
server.getPluginManager().enablePlugin(permissionsPlugin);
|
||||
if(permissionsPlugin.isEnabled() == false)
|
||||
return null;
|
||||
|
||||
Log.info("Using bPermissions " + permissionsPlugin.getDescription().getVersion() + " for access control");
|
||||
return new bPermPermissions(name, pd);
|
||||
}
|
||||
|
||||
@@ -32,12 +32,16 @@ components:
|
||||
webchat-requires-login: false
|
||||
# If set to true, users must have dynmap.webchat permission in order to chat
|
||||
webchat-permissions: false
|
||||
# Limit length of single chat messages
|
||||
chatlengthlimit: 256
|
||||
# # Optional - make players hidden when they are inside/underground/in shadows (#=light level: 0=full shadow,15=sky)
|
||||
# hideifshadow: 4
|
||||
# # Optional - make player hidden when they are under cover (#=sky light level,0=underground,15=open to sky)
|
||||
# hideifundercover: 14
|
||||
# # (Optional) if true, players that are crouching/sneaking will be hidden
|
||||
# hideifsneaking: false
|
||||
hideifsneaking: false
|
||||
# If true, player positions/status is protected (login with ID with dynmap.playermarkers.seeall permission required for info other than self)
|
||||
protected-player-info: false
|
||||
#- class: org.dynmap.JsonFileClientUpdateComponent
|
||||
# writeinterval: 1
|
||||
# sendhealth: true
|
||||
@@ -56,6 +60,8 @@ components:
|
||||
# webchat-requires-login: false
|
||||
# # If set to true, users must have dynmap.webchat permission in order to chat
|
||||
# webchat-permissions: false
|
||||
# # Limit length of single chat messages
|
||||
# chatlengthlimit: 256
|
||||
|
||||
- class: org.dynmap.SimpleWebChatComponent
|
||||
allowchat: true
|
||||
@@ -133,11 +139,14 @@ components:
|
||||
hidey: false
|
||||
show-mcr: false
|
||||
|
||||
# Note: more than one logo component can be defined
|
||||
#- class: org.dynmap.ClientComponent
|
||||
# type: logo
|
||||
# text: "Dynmap"
|
||||
# #logourl: "images/block_surface.png"
|
||||
# linkurl: "http://forums.bukkit.org/threads/dynmap.489/"
|
||||
# # Valid positions: top-left, top-right, bottom-left, bottom-right
|
||||
# position: bottom-right
|
||||
|
||||
#- class: org.dynmap.ClientComponent
|
||||
# type: inactive
|
||||
@@ -206,11 +215,12 @@ correct-water-lighting: true
|
||||
# 'newnorth' is used to rotate maps and rose (requires fullrender of any HDMap map - same as 'newrose' for FlatMap or KzedMap)
|
||||
compass-mode: newnorth
|
||||
|
||||
# Enable Industrial Craft 2 block rendering support (core, Advanced Machines, Charging Bench, Power Converters)
|
||||
# Enable Industrial Craft 2 block rendering support (core, Advanced Machines, Charging Bench, Power Converters, Compact Solars)
|
||||
#ic2-support: true
|
||||
#ic2-advancesmachines-support: true
|
||||
#ic2-chargingbench-support: true
|
||||
#ic2-powerconverters-support: true
|
||||
#ic2-compactsolars-support: true
|
||||
|
||||
# Enable BuildCraft block rendering support
|
||||
#buildcraft-support: true
|
||||
@@ -230,6 +240,12 @@ compass-mode: newnorth
|
||||
# Enabled ComputerCraft block rendering support
|
||||
#computercraft-support: true
|
||||
|
||||
# Enabled LC Trees++ block rendering support
|
||||
#lctrees-support: true
|
||||
|
||||
# Enable Forestry block rending support
|
||||
#forestry-support: true
|
||||
|
||||
render-triggers:
|
||||
#- playermove
|
||||
#- playerjoin
|
||||
@@ -243,8 +259,8 @@ render-triggers:
|
||||
- blockspread
|
||||
- pistonmoved
|
||||
- explosion
|
||||
- blockfromto
|
||||
- blockphysics
|
||||
#- blockfromto
|
||||
#- blockphysics
|
||||
- structuregrow
|
||||
- blockgrow
|
||||
|
||||
|
||||
@@ -155,6 +155,7 @@ permissions:
|
||||
dynmap.dmap.perspectivelist: true
|
||||
dynmap.dmap.shaderlist: true
|
||||
dynmap.dmap.lightinglist: true
|
||||
dynmap.playermarkers.seeall: true
|
||||
dynmap.render:
|
||||
description: Allows /dynmap render command
|
||||
default: true
|
||||
@@ -320,3 +321,6 @@ permissions:
|
||||
dynmap.webchat:
|
||||
description: Allows web chat (if login required for webchat)
|
||||
default: true
|
||||
dynmap.playermarkers.seeall:
|
||||
description: Allow all players to be seen by user on web UI
|
||||
default: op
|
||||
|
||||
Reference in New Issue
Block a user