mirror of
https://github.com/encounter/dynmap.git
synced 2026-03-30 11:08:39 -07:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c8469d7aba | |||
| e7c92096b2 | |||
| 0c9d397144 | |||
| b4a3b61c11 | |||
| 564c38b44a | |||
| 664e7da659 | |||
| 9046212a47 | |||
| b6ee68c9b0 | |||
| 7854568d88 | |||
| f1c9417237 | |||
| 336f8302c4 | |||
| d8ccc26109 | |||
| d396046249 | |||
| 1793d910d4 | |||
| f0f881d126 |
@@ -138,5 +138,5 @@
|
||||
<version>2.10.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<version>1.8</version>
|
||||
<version>1.9.1</version>
|
||||
</project>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.dynmap.bukkit;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
@@ -21,6 +22,7 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
private Field blockbyid;
|
||||
private Field blockname;
|
||||
private Field material;
|
||||
private Method blockbyidfunc; // 1.7+ method for getting block by id
|
||||
|
||||
BukkitVersionHelperCB() {
|
||||
}
|
||||
@@ -43,17 +45,20 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
nmsblock = getNMSClass("net.minecraft.server.Block");
|
||||
nmsblockarray = getNMSClass("[Lnet.minecraft.server.Block;");
|
||||
nmsmaterial = getNMSClass("net.minecraft.server.Material");
|
||||
blockbyid = getField(nmsblock, new String[] { "byId" }, nmsblockarray);
|
||||
blockbyid = getFieldNoFail(nmsblock, new String[] { "byId" }, nmsblockarray);
|
||||
if (blockbyid == null) {
|
||||
blockbyidfunc = getMethod(nmsblock, new String[] { "e" }, new Class[] { int.class });
|
||||
}
|
||||
blockname = getPrivateField(nmsblock, new String[] { "name", "b" }, String.class);
|
||||
material = getField(nmsblock, new String[] { "material" }, nmsmaterial);
|
||||
material = getPrivateField(nmsblock, new String[] { "material" }, nmsmaterial);
|
||||
|
||||
/* Set up biomebase fields */
|
||||
biomebase = getNMSClass("net.minecraft.server.BiomeBase");
|
||||
biomebasearray = getNMSClass("[Lnet.minecraft.server.BiomeBase;");
|
||||
biomebaselist = getField(biomebase, new String[] { "biomes" }, biomebasearray);
|
||||
biomebaselist = getPrivateField(biomebase, new String[] { "biomes" }, biomebasearray);
|
||||
biomebasetemp = getField(biomebase, new String[] { "temperature", "F" }, float.class);
|
||||
biomebasehumi = getField(biomebase, new String[] { "humidity", "G" }, float.class);
|
||||
biomebaseidstring = getField(biomebase, new String[] { "y" }, String.class);
|
||||
biomebaseidstring = getField(biomebase, new String[] { "y", "af" }, String.class);
|
||||
biomebaseid = getField(biomebase, new String[] { "id" }, int.class);
|
||||
/* n.m.s.World */
|
||||
nmsworld = getNMSClass("net.minecraft.server.WorldServer");
|
||||
@@ -89,15 +94,15 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
nbttagstring = getNMSClass("net.minecraft.server.NBTTagString");
|
||||
nbttagintarray = getNMSClass("net.minecraft.server.NBTTagIntArray");
|
||||
compound_get = getMethod(nbttagcompound, new String[] { "get" }, new Class[] { String.class });
|
||||
nbttagbyte_val = getField(nbttagbyte, new String[] { "data" }, byte.class);
|
||||
nbttagshort_val = getField(nbttagshort, new String[] { "data" }, short.class);
|
||||
nbttagint_val = getField(nbttagint, new String[] { "data" }, int.class);
|
||||
nbttaglong_val = getField(nbttaglong, new String[] { "data" }, long.class);
|
||||
nbttagfloat_val = getField(nbttagfloat, new String[] { "data" }, float.class);
|
||||
nbttagdouble_val = getField(nbttagdouble, new String[] { "data" }, double.class);
|
||||
nbttagbytearray_val = getField(nbttagbytearray, new String[] { "data" }, byte[].class);
|
||||
nbttagstring_val = getField(nbttagstring, new String[] { "data" }, String.class);
|
||||
nbttagintarray_val = getField(nbttagintarray, new String[] { "data" }, int[].class);
|
||||
nbttagbyte_val = getPrivateField(nbttagbyte, new String[] { "data" }, byte.class);
|
||||
nbttagshort_val = getPrivateField(nbttagshort, new String[] { "data" }, short.class);
|
||||
nbttagint_val = getPrivateField(nbttagint, new String[] { "data" }, int.class);
|
||||
nbttaglong_val = getPrivateField(nbttaglong, new String[] { "data" }, long.class);
|
||||
nbttagfloat_val = getPrivateField(nbttagfloat, new String[] { "data" }, float.class);
|
||||
nbttagdouble_val = getPrivateField(nbttagdouble, new String[] { "data" }, double.class);
|
||||
nbttagbytearray_val = getPrivateField(nbttagbytearray, new String[] { "data" }, byte[].class);
|
||||
nbttagstring_val = getPrivateField(nbttagstring, new String[] { "data" }, String.class);
|
||||
nbttagintarray_val = getPrivateField(nbttagintarray, new String[] { "data" }, int[].class);
|
||||
|
||||
/** Tile entity */
|
||||
nms_tileentity = getNMSClass("net.minecraft.server.TileEntity");
|
||||
@@ -117,16 +122,27 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
@Override
|
||||
public String[] getBlockShortNames() {
|
||||
try {
|
||||
Object[] byid = (Object[])blockbyid.get(nmsblock);
|
||||
String[] names = new String[byid.length];
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
if (byid[i] != null) {
|
||||
names[i] = (String)blockname.get(byid[i]);
|
||||
String[] names = new String[4096];
|
||||
if (blockbyid != null) {
|
||||
Object[] byid = (Object[])blockbyid.get(nmsblock);
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
if (byid[i] != null) {
|
||||
names[i] = (String)blockname.get(byid[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
Object blk = blockbyidfunc.invoke(nmsblock, i);
|
||||
if (blk != null) {
|
||||
names[i] = (String)blockname.get(blk);
|
||||
}
|
||||
}
|
||||
}
|
||||
return names;
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
return new String[0];
|
||||
}
|
||||
@@ -153,27 +169,49 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||
*/
|
||||
public int[] getBlockMaterialMap() {
|
||||
try {
|
||||
Object[] byid = (Object[])blockbyid.get(nmsblock);
|
||||
int[] map = new int[byid.length];
|
||||
ArrayList<Object> mats = new ArrayList<Object>();
|
||||
for (int i = 0; i < map.length; i++) {
|
||||
if (byid[i] != null) {
|
||||
Object mat = (Object)material.get(byid[i]);
|
||||
if (mat != null) {
|
||||
map[i] = mats.indexOf(mat);
|
||||
if (map[i] < 0) {
|
||||
map[i] = mats.size();
|
||||
mats.add(mat);
|
||||
int[] map = new int[4096];
|
||||
if (blockbyid != null) {
|
||||
Object[] byid = (Object[])blockbyid.get(nmsblock);
|
||||
ArrayList<Object> mats = new ArrayList<Object>();
|
||||
for (int i = 0; i < map.length; i++) {
|
||||
if (byid[i] != null) {
|
||||
Object mat = (Object)material.get(byid[i]);
|
||||
if (mat != null) {
|
||||
map[i] = mats.indexOf(mat);
|
||||
if (map[i] < 0) {
|
||||
map[i] = mats.size();
|
||||
mats.add(mat);
|
||||
}
|
||||
}
|
||||
else {
|
||||
map[i] = -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
map[i] = -1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ArrayList<Object> mats = new ArrayList<Object>();
|
||||
for (int i = 0; i < map.length; i++) {
|
||||
Object blk = blockbyidfunc.invoke(nmsblock, i);
|
||||
if (blk != null) {
|
||||
Object mat = (Object)material.get(blk);
|
||||
if (mat != null) {
|
||||
map[i] = mats.indexOf(mat);
|
||||
if (map[i] < 0) {
|
||||
map[i] = mats.size();
|
||||
mats.add(mat);
|
||||
}
|
||||
}
|
||||
else {
|
||||
map[i] = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
@@ -91,6 +92,7 @@ import org.dynmap.common.DynmapServerInterface;
|
||||
import org.dynmap.common.DynmapListenerManager.EventType;
|
||||
import org.dynmap.hdmap.HDMap;
|
||||
import org.dynmap.markers.MarkerAPI;
|
||||
import org.dynmap.modsupport.ModSupportImpl;
|
||||
import org.dynmap.utils.MapChunkCache;
|
||||
import org.dynmap.utils.VisibilityLimit;
|
||||
|
||||
@@ -108,6 +110,9 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
private Metrics metrics;
|
||||
private BukkitEnableCoreCallback enabCoreCB = new BukkitEnableCoreCallback();
|
||||
private Method ismodloaded;
|
||||
private Method instance;
|
||||
private Method getindexedmodlist;
|
||||
private Method getversion;
|
||||
private HashMap<String, BukkitWorld> world_by_name = new HashMap<String, BukkitWorld>();
|
||||
private HashSet<String> modsused = new HashSet<String>();
|
||||
// TPS calculator
|
||||
@@ -151,7 +156,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
|
||||
return bw;
|
||||
}
|
||||
private final void removeWorld(World w) {
|
||||
final void removeWorld(World w) {
|
||||
world_by_name.remove(w.getName());
|
||||
if(w == last_world) {
|
||||
last_world = null;
|
||||
@@ -199,6 +204,10 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
try {
|
||||
Class<?> c = Class.forName("cpw.mods.fml.common.Loader");
|
||||
ismodloaded = c.getMethod("isModLoaded", String.class);
|
||||
instance = c.getMethod("instance");
|
||||
getindexedmodlist = c.getMethod("getIndexedModList");
|
||||
c = Class.forName("cpw.mods.fml.common.ModContainer");
|
||||
getversion = c.getMethod("getVersion");
|
||||
} catch (NoSuchMethodException nsmx) {
|
||||
} catch (ClassNotFoundException e) {
|
||||
}
|
||||
@@ -521,11 +530,38 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public String getModVersion(String name) {
|
||||
if((instance != null) && (getindexedmodlist != null) && (getversion != null)) {
|
||||
try {
|
||||
Object inst = instance.invoke(null);
|
||||
Map<?,?> modmap = (Map<?,?>) getindexedmodlist.invoke(inst);
|
||||
Object mod = modmap.get(name);
|
||||
if (mod != null) {
|
||||
return (String) getversion.invoke(mod);
|
||||
}
|
||||
} catch (IllegalArgumentException iax) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public double getServerTPS() {
|
||||
return tps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerIP() {
|
||||
return Bukkit.getServer().getIp();
|
||||
}
|
||||
@Override
|
||||
public File getModContainerFile(String mod) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Player access abstraction class
|
||||
@@ -721,6 +757,8 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
|
||||
helper = BukkitVersionHelper.getHelper();
|
||||
pm = this.getServer().getPluginManager();
|
||||
|
||||
ModSupportImpl.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -748,12 +786,12 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
permissions = PEXPermissions.create(getServer(), "dynmap");
|
||||
if (permissions == null)
|
||||
permissions = bPermPermissions.create(getServer(), "dynmap", perdefs);
|
||||
if (permissions == null)
|
||||
permissions = GroupManagerPermissions.create(getServer(), "dynmap");
|
||||
if (permissions == null)
|
||||
permissions = PermBukkitPermissions.create(getServer(), "dynmap", perdefs);
|
||||
if (permissions == null)
|
||||
permissions = NijikokunPermissions.create(getServer(), "dynmap");
|
||||
if (permissions == null)
|
||||
permissions = GroupManagerPermissions.create(getServer(), "dynmap");
|
||||
if (permissions == null)
|
||||
permissions = BukkitPermissions.create("dynmap", perdefs);
|
||||
if (permissions == null)
|
||||
|
||||
@@ -228,7 +228,10 @@ public class SpoutPluginBlocks {
|
||||
}
|
||||
String rslt = sb.toString();
|
||||
/* Now, generate spout texture file - see if changed */
|
||||
File st = new File(datadir, "renderdata/spout-texture.txt");
|
||||
File renderdata = new File(datadir, "renderdata");
|
||||
if (renderdata.exists() == false)
|
||||
renderdata.mkdirs();
|
||||
File st = new File(renderdata, "spout-texture.txt");
|
||||
if(st.exists()) {
|
||||
FileReader fr = null;
|
||||
StringBuilder sbold = new StringBuilder();
|
||||
|
||||
@@ -35,15 +35,16 @@ public class GroupManagerPermissions implements PermissionProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean has(CommandSender sender, String permission) {
|
||||
public boolean has(CommandSender sender, String permission) {
|
||||
Player player = sender instanceof Player ? (Player) sender : null;
|
||||
return (player != null) ? wh.getWorldPermissions(player).has(player, name + "." + permission) : true;
|
||||
boolean rslt = (player != null) ? gm.getWorldsHolder().getDefaultWorld().getPermissionsHandler().permission(player, name + "." + permission) : true;
|
||||
return rslt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> hasOfflinePermissions(String player, Set<String> perms) {
|
||||
HashSet<String> hasperms = new HashSet<String>();
|
||||
AnjoPermissionsHandler apm = wh.getWorldPermissionsByPlayerName(player);
|
||||
AnjoPermissionsHandler apm = gm.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
if (apm != null) {
|
||||
for (String pp : perms) {
|
||||
if (apm.permission(player, name + "." + pp)) {
|
||||
@@ -55,10 +56,11 @@ public class GroupManagerPermissions implements PermissionProvider {
|
||||
}
|
||||
@Override
|
||||
public boolean hasOfflinePermission(String player, String perm) {
|
||||
AnjoPermissionsHandler apm = wh.getWorldPermissionsByPlayerName(player);
|
||||
AnjoPermissionsHandler apm = gm.getWorldsHolder().getDefaultWorld().getPermissionsHandler();
|
||||
boolean rslt = false;
|
||||
if(apm != null) {
|
||||
return apm.permission(player, name + "." + perm);
|
||||
rslt = apm.permission(player, name + "." + perm);
|
||||
}
|
||||
return false;
|
||||
return rslt;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,8 +24,9 @@ public class PEXPermissions implements PermissionProvider {
|
||||
server.getPluginManager().enablePlugin(permissionsPlugin);
|
||||
if(permissionsPlugin.isEnabled() == false)
|
||||
return null;
|
||||
if(PermissionsEx.isAvailable() == false)
|
||||
return null;
|
||||
//Broken in new dev builds, apparently
|
||||
//if(PermissionsEx.isAvailable() == false)
|
||||
// return null;
|
||||
Log.info("Using PermissionsEx " + permissionsPlugin.getDescription().getVersion() + " for access control");
|
||||
return new PEXPermissions(name);
|
||||
}
|
||||
|
||||
@@ -216,6 +216,13 @@ enabletilehash: true
|
||||
# Optional - enable smooth lighting by default on all maps supporting it (can be set per map as lighting option)
|
||||
smooth-lighting: true
|
||||
|
||||
# Optional - render specific block IDs using the texures and models of another block ID: can be used to hide/disguise specific
|
||||
# blocks (e.g. make ores look like stone, hide chests) or to provide simple support for rendering unsupported custom blocks
|
||||
block-id-alias:
|
||||
# "14": 1
|
||||
# "15": 1
|
||||
# "16": 1
|
||||
|
||||
# Default image format for HDMaps (png, jpg, jpg-q75, jpg-q80, jpg-q85, jpg-q90, jpg-q95, jpg-q100)
|
||||
# Has no effect on maps with explicit format settings
|
||||
image-format: png
|
||||
@@ -275,7 +282,8 @@ tilespath: web/tiles
|
||||
webpath: web
|
||||
|
||||
# The network-interface the webserver will bind to (0.0.0.0 for all interfaces, 127.0.0.1 for only local access).
|
||||
webserver-bindaddress: 0.0.0.0
|
||||
# If not set, uses same setting as server in server.properties (or 0.0.0.0 if not specified)
|
||||
#webserver-bindaddress: 0.0.0.0
|
||||
|
||||
# The TCP-port the webserver will listen on.
|
||||
webserver-port: 8123
|
||||
|
||||
@@ -239,7 +239,7 @@ permissions:
|
||||
dynmap.webregister:
|
||||
description: Allows /dynmap webregister
|
||||
default: true
|
||||
dynmao,webregister.other:
|
||||
dynmap.webregister.other:
|
||||
description: Allows /dynmap webregister userid
|
||||
default: op
|
||||
dynmap.marker.add:
|
||||
|
||||
Reference in New Issue
Block a user