Merge pull request #3893 from webbukkit/v3.0

v3.5-beta-1
This commit is contained in:
mikeprimm 2022-12-12 00:38:46 -06:00 committed by GitHub
commit e092543cc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
139 changed files with 9053 additions and 151 deletions

View File

@ -286,6 +286,8 @@ public class Client {
private static PolicyFactory sanitizer = null;
private static PolicyFactory OLDTAGS = new HtmlPolicyBuilder().allowElements("center", "basefont", "hr").toFactory();
public static String sanitizeHTML(String html) {
// Don't sanitize if null or no html markup
if ((html == null) || (html.indexOf('<') < 0)) return html;
PolicyFactory s = sanitizer;
if (s == null) {
// Generous but safe html formatting allowances

View File

@ -177,6 +177,8 @@ public class DynmapCore implements DynmapCommonAPI {
private Boolean webserverCompConfigWarn = false;
private final String CompConfigWiki = "https://github.com/webbukkit/dynmap/wiki/Component-Configuration";
private final String[] defaultTemplates = {"vlowres", "lowres", "medres", "hires", "low_boost_hi",
"hi_boost_vhi", "hi_boost_xhi"};
/* Constructor for core */
public DynmapCore() {
}
@ -701,7 +703,7 @@ public class DynmapCore implements DynmapCommonAPI {
/* Print version info */
Log.info("version " + plugin_ver + " is enabled - core version " + version );
Log.info("For support, visit our Discord at https://discord.gg/s3rd5qn");
Log.info("For news, visit https://reddit.com/r/Dynmap or follow https://twitter.com/Dynmap");
Log.info("For news, visit https://reddit.com/r/Dynmap or follow https://universeodon.com/@dynmap");
Log.info("To report or track bugs, visit https://github.com/webbukkit/dynmap/issues");
Log.info("If you'd like to donate, please visit https://www.patreon.com/dynmap or https://ko-fi.com/michaelprimm");
@ -2167,6 +2169,9 @@ public class DynmapCore implements DynmapCommonAPI {
ConfigurationNode getDefaultTemplateConfigurationNode(DynmapWorld world) {
String environmentName = world.getEnvironment();
if(deftemplatesuffix.length() > 0) {
if(!Arrays.asList(defaultTemplates).contains(deftemplatesuffix)) {
Log.warning("Not using a default defined template, worlds might not be accessible.");
}
environmentName += "-" + deftemplatesuffix;
}
Log.verboseinfo("Using environment as template: " + environmentName);

View File

@ -27,6 +27,7 @@ import org.json.simple.parser.ParseException;
import static org.dynmap.JSONUtils.*;
import java.nio.charset.Charset;
import java.util.concurrent.CompletableFuture;
public class JsonFileClientUpdateComponent extends ClientUpdateComponent {
protected long jsonInterval;
@ -338,9 +339,12 @@ public class JsonFileClientUpdateComponent extends ClientUpdateComponent {
else {
outputFile = "dynmap_" + dynmapWorld.getName() + ".json";
}
byte[] content = Json.stringifyJson(update).getBytes(cs_utf8);
enqueueFileWrite(outputFile, content, dowrap);
CompletableFuture.runAsync(() -> {
byte[] content = Json.stringifyJson(update).getBytes(cs_utf8);
enqueueFileWrite(outputFile, content, dowrap);
});
}
}

View File

@ -28,6 +28,7 @@ public class WebAuthManager {
private static final String PWDHASH_PREFIX = "hash.";
private Random rnd = new Random();
private DynmapCore core;
private String publicRegistrationURL;
public WebAuthManager(DynmapCore core) {
this.core = core;
@ -202,7 +203,8 @@ public class WebAuthManager {
pending_registrations.put(uid.toLowerCase(), regkey.toLowerCase());
sender.sendMessage("Registration pending for user ID: " + uid);
sender.sendMessage("Registration code: " + regkey);
sender.sendMessage("Enter ID and code on registration web page (login.html) to complete registration");
publicRegistrationURL = core.configuration.getString("publicURL", "index.html");
sender.sendMessage("Enter ID and code on registration web page (" + publicRegistrationURL.toString() + ") to complete registration");
if(other) {
DynmapPlayer p = core.getServer().getPlayer(uid);
if(p != null) {

View File

@ -3,6 +3,7 @@ package org.dynmap.common;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.dynmap.hdmap.HDBlockModels;
@ -19,7 +20,7 @@ public class BiomeMap {
public static final BiomeMap EXTREME_HILLS = new BiomeMap(3, "EXTREME_HILLS", 0.2, 0.3, "minecraft:mountains");
public static final BiomeMap FOREST = new BiomeMap(4, "FOREST", 0.7, 0.8, "minecraft:forest");
public static final BiomeMap TAIGA = new BiomeMap(5, "TAIGA", 0.05, 0.8, "minecraft:taiga");
public static final BiomeMap SWAMPLAND = new BiomeMap(6, "SWAMPLAND", 0.8, 0.9, 0xE0FFAE, 0x4E0E4E, 0x4E0E4E, "minecraft:swamp");
public static final BiomeMap SWAMPLAND = new BiomeMap(6, "SWAMPLAND", 0.8, 0.9, 0xE0FFAE, 0x2e282a, 0x902c52, "minecraft:swamp");
public static final BiomeMap RIVER = new BiomeMap(7, "RIVER", "minecraft:river");
public static final BiomeMap HELL = new BiomeMap(8, "HELL", 2.0, 0.0, "minecraft:nether");
public static final BiomeMap SKY = new BiomeMap(9, "SKY", "minecraft:the_end");
@ -44,6 +45,7 @@ public class BiomeMap {
private int watercolormult;
private int grassmult;
private int foliagemult;
private Optional<?> biomeObj = Optional.empty();
private final String id;
private final String resourcelocation;
private final int index;
@ -61,7 +63,7 @@ public class BiomeMap {
new BiomeMap(26, "COLD_BEACH", 0.05, 0.3, "minecraft:snowy_beach");
new BiomeMap(27, "BIRCH_FOREST", 0.6, 0.6, "minecraft:birch_forest");
new BiomeMap(28, "BIRCH_FOREST_HILLS", 0.6, 0.6, "minecraft:birch_forest_hills");
new BiomeMap(29, "ROOFED_FOREST", 0.7, 0.8, "minecraft:dark_forest");
new BiomeMap(29, "ROOFED_FOREST", 0.7, 0.8, 0xFFFFFF, 0x28340A, 0, "minecraft:dark_forest");
new BiomeMap(30, "COLD_TAIGA", -0.5, 0.4, "minecraft:snowy_taiga");
new BiomeMap(31, "COLD_TAIGA_HILLS", -0.5, 0.4, "minecraft:snowy_taiga_hills");
new BiomeMap(32, "MEGA_TAIGA", 0.3, 0.8, "minecraft:giant_tree_taiga");
@ -69,30 +71,32 @@ public class BiomeMap {
new BiomeMap(34, "EXTREME_HILLS_PLUS", 0.2, 0.3, "minecraft:wooded_mountains");
new BiomeMap(35, "SAVANNA", 1.2, 0.0, "minecraft:savanna");
new BiomeMap(36, "SAVANNA_PLATEAU", 1.0, 0.0, "minecraft:savanna_plateau");
new BiomeMap(37, "MESA", 2.0, 0.0, "minecraft:badlands");
new BiomeMap(38, "MESA_PLATEAU_FOREST", 2.0, 0.0, "minecraft:wooded_badlands_plateau");
new BiomeMap(39, "MESA_PLATEAU", 2.0, 0.0, "minecraft:badlands_plateau");
new BiomeMap(37, "MESA", 2.0, 0.0, 0xFFFFFF, 0x624c46, 0x8e5e70, "minecraft:badlands");
new BiomeMap(129, "SUNFLOWER_PLAINS", 0.8, 0.4, "minecraft:sunflower_plains");
new BiomeMap(130, "DESERT_MOUNTAINS", 2.0, 0.0, "minecraft:desert_lakes");
new BiomeMap(131, "EXTREME_HILLS_MOUNTAINS", 0.2, 0.3, "minecraft:gravelly_mountains");
new BiomeMap(132, "FLOWER_FOREST", 0.7, 0.8, "minecraft:flower_forest");
new BiomeMap(133, "TAIGA_MOUNTAINS", 0.05, 0.8, "minecraft:taiga_mountains");
new BiomeMap(134, "SWAMPLAND_MOUNTAINS", 0.8, 0.9, 0xE0FFAE, 0x4E0E4E, 0x4E0E4E, "minecraft:swamp_hills");
new BiomeMap(140, "ICE_PLAINS_SPIKES", 0.0, 0.5, "minecraft:ice_spikes");
new BiomeMap(149, "JUNGLE_MOUNTAINS", 1.2, 0.9, "minecraft:modified_jungle");
new BiomeMap(151, "JUNGLE_EDGE_MOUNTAINS", 0.95, 0.8, "minecraft:modified_jungle_edge");
new BiomeMap(155, "BIRCH_FOREST_MOUNTAINS", 0.6, 0.6, "minecraft:tall_birch_forest");
new BiomeMap(156, "BIRCH_FOREST_HILLS_MOUNTAINS", 0.6, 0.6, "minecraft:tall_birch_hills");
new BiomeMap(157, "ROOFED_FOREST_MOUNTAINS", 0.7, 0.8, "minecraft:dark_forest_hills");
new BiomeMap(157, "ROOFED_FOREST_MOUNTAINS", 0.7, 0.8, 0xFFFFFF, 0x28340A, 0, "minecraft:dark_forest_hills");
new BiomeMap(158, "COLD_TAIGA_MOUNTAINS", -0.5, 0.4, "minecraft:snowy_taiga_mountains");
new BiomeMap(160, "MEGA_SPRUCE_TAIGA", 0.25, 0.8, "minecraft:giant_spruce_taiga");
new BiomeMap(161, "MEGA_SPRUCE_TAIGA_HILLS", 0.3, 0.8, "minecraft:giant_spruce_taiga_hills");
new BiomeMap(162, "EXTREME_HILLS_PLUS_MOUNTAINS", 0.2, 0.3, "minecraft:modified_gravelly_mountains");
new BiomeMap(163, "SAVANNA_MOUNTAINS", 1.2, 0.0, "minecraft:shattered_savanna");
new BiomeMap(164, "SAVANNA_PLATEAU_MOUNTAINS", 1.0, 0.0, "minecraft:shattered_savanna_plateau");
new BiomeMap(165, "MESA_BRYCE", 2.0, 0.0, "minecraft:eroded_badlands");
new BiomeMap(166, "MESA_PLATEAU_FOREST_MOUNTAINS", 2.0, 0.0, "minecraft:modified_wooded_badlands_plateau");
new BiomeMap(167, "MESA_PLATEAU_MOUNTAINS", 2.0, 0.0, "minecraft:modified_badlands_plateau");
new BiomeMap(165, "MESA_BRYCE", 2.0, 0.0,0xFFFFFF, 0x624c46, 0x8e5e70, "minecraft:eroded_badlands");
}
if (HDBlockModels.checkVersionRange(mcver, "1.7.0-1.17.1")) {
new BiomeMap(38, "MESA_PLATEAU_FOREST", 2.0, 0.0, 0xFFFFFF, 0x624c46, 0x8e5e70, "minecraft:wooded_badlands_plateau");
new BiomeMap(39, "MESA_PLATEAU", 2.0, 0.0, 0xFFFFFF, 0x624c46, 0x8e5e70, "minecraft:badlands_plateau");
new BiomeMap(134, "SWAMPLAND_MOUNTAINS", 0.8, 0.9, 0xE0FFAE, 0x2e282a, 0x902c52, "minecraft:swamp_hills");
new BiomeMap(166, "MESA_PLATEAU_FOREST_MOUNTAINS", 2.0, 0.0,0xFFFFFF, 0x624c46, 0x8e5e70, "minecraft:modified_wooded_badlands_plateau");
new BiomeMap(167, "MESA_PLATEAU_MOUNTAINS", 2.0, 0.0,0xFFFFFF, 0x624c46, 0x8e5e70, "minecraft:modified_badlands_plateau");
}
if (HDBlockModels.checkVersionRange(mcver, "1.9.0-")) {
new BiomeMap(127, "THE_VOID", "minecraft:the_void");
@ -124,6 +128,9 @@ public class BiomeMap {
new BiomeMap(174, "DRIPSTONE_CAVES", "minecraft:dripstone_caves");
new BiomeMap(175, "LUSH_CAVES", "minecraft:lush_caves");
}
if (HDBlockModels.checkVersionRange(mcver, "1.18.0-")) {
new BiomeMap(38, "MESA_FOREST", 2.0, 0.0, 0xFFFFFF, 0x624c46, 0x8e5e70, "minecraft:wooded_badlands");
}
loadDone = true;
}
@ -303,4 +310,10 @@ public class BiomeMap {
public String toString() {
return String.format("%s(%s)", id, resourcelocation);
}
public @SuppressWarnings("unchecked") <T> Optional<T> getBiomeObject() {
return (Optional<T>) biomeObj;
}
public void setBiomeObject(Object biomeObj) {
this.biomeObj = Optional.of(biomeObj);
}
}

View File

@ -18,6 +18,7 @@ public class GenericChunkCache {
};
private CacheHashMap snapcache;
private final Object snapcachelock;
private ReferenceQueue<ChunkCacheRec> refqueue;
private long cache_attempts;
private long cache_success;
@ -50,6 +51,7 @@ public class GenericChunkCache {
* Create snapshot cache
*/
public GenericChunkCache(int max_size, boolean softref) {
snapcachelock = new Object();
snapcache = new CacheHashMap(max_size);
refqueue = new ReferenceQueue<ChunkCacheRec>();
this.softref = softref;
@ -62,8 +64,8 @@ public class GenericChunkCache {
*/
public void invalidateSnapshot(String w, int x, int y, int z) {
String key = getKey(w, x>>4, z>>4);
synchronized(snapcache) {
CacheRec rec = snapcache.remove(key);
synchronized(snapcachelock) {
CacheRec rec = (snapcache != null) ? snapcache.remove(key) : null;
if(rec != null) {
snapcache.reverselookup.remove(rec.ref);
rec.ref.clear();
@ -78,8 +80,8 @@ public class GenericChunkCache {
for(int xx = (x0>>4); xx <= (x1>>4); xx++) {
for(int zz = (z0>>4); zz <= (z1>>4); zz++) {
String key = getKey(w, xx, zz);
synchronized(snapcache) {
CacheRec rec = snapcache.remove(key);
synchronized(snapcachelock) {
CacheRec rec = (snapcache != null) ? snapcache.remove(key) : null;
if(rec != null) {
snapcache.reverselookup.remove(rec.ref);
rec.ref.clear();
@ -97,8 +99,8 @@ public class GenericChunkCache {
processRefQueue();
ChunkCacheRec ss = null;
CacheRec rec;
synchronized(snapcache) {
rec = snapcache.get(key);
synchronized(snapcachelock) {
rec = (snapcache != null) ? snapcache.get(key) : null;
if(rec != null) {
ss = rec.ref.get();
if(ss == null) {
@ -123,8 +125,8 @@ public class GenericChunkCache {
rec.ref = new SoftReference<ChunkCacheRec>(ss, refqueue);
else
rec.ref = new WeakReference<ChunkCacheRec>(ss, refqueue);
synchronized(snapcache) {
CacheRec prevrec = snapcache.put(key, rec);
synchronized(snapcachelock) {
CacheRec prevrec = (snapcache != null) ? snapcache.put(key, rec) : null;
if(prevrec != null) {
snapcache.reverselookup.remove(prevrec.ref);
}
@ -137,8 +139,8 @@ public class GenericChunkCache {
private void processRefQueue() {
Reference<? extends ChunkCacheRec> ref;
while((ref = refqueue.poll()) != null) {
synchronized(snapcache) {
String k = snapcache.reverselookup.remove(ref);
synchronized(snapcachelock) {
String k = (snapcache != null) ? snapcache.reverselookup.remove(ref) : null;
if(k != null) {
snapcache.remove(k);
}
@ -164,11 +166,13 @@ public class GenericChunkCache {
* Cleanup
*/
public void cleanup() {
if(snapcache != null) {
snapcache.clear();
snapcache.reverselookup.clear();
snapcache.reverselookup = null;
snapcache = null;
}
synchronized(snapcachelock) {
if(snapcache != null) {
snapcache.clear();
snapcache.reverselookup.clear();
snapcache.reverselookup = null;
snapcache = null;
}
}
}
}

View File

@ -181,7 +181,7 @@ public abstract class GenericMapChunkCache extends MapChunkCache {
for (int dz = -1; dz <= 1; dz++) {
BiomeMap bm = getBiomeRel(dx, dz);
if (bm == BiomeMap.NULL) continue;
int rmult = bm.getModifiedGrassMultiplier(colormap[bm.biomeLookup()]);
int rmult = getGrassColor(bm, colormap, getX() + dx, getZ() + dz);
raccum += (rmult >> 16) & 0xFF;
gaccum += (rmult >> 8) & 0xFF;
baccum += rmult & 0xFF;
@ -212,7 +212,7 @@ public abstract class GenericMapChunkCache extends MapChunkCache {
for (int dz = -1; dz <= 1; dz++) {
BiomeMap bm = getBiomeRel(dx, dz);
if (bm == BiomeMap.NULL) continue;
int rmult = bm.getModifiedFoliageMultiplier(colormap[bm.biomeLookup()]);
int rmult = getFoliageColor(bm, colormap, getX() + dx, getZ() + dz);
raccum += (rmult >> 16) & 0xFF;
gaccum += (rmult >> 8) & 0xFF;
baccum += rmult & 0xFF;
@ -546,6 +546,14 @@ public abstract class GenericMapChunkCache extends MapChunkCache {
}
}
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.getModifiedGrassMultiplier(colormap[bm.biomeLookup()]);
}
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.getModifiedFoliageMultiplier(colormap[bm.biomeLookup()]);
}
private class OurEndMapIterator extends OurMapIterator {
OurEndMapIterator(int x0, int y0, int z0) {
super(x0, y0, z0);

View File

@ -255,7 +255,7 @@ public class HDBlockModels {
}
}
} catch (IOException iox) {
Log.severe("Error processing nodel files");
Log.severe("Error processing model files");
} finally {
if (in != null) {
try { in.close(); } catch (IOException iox) {}

View File

@ -72,9 +72,9 @@ class AreaMarkerImpl implements AreaMarker, EnterExitMarker {
AreaMarkerImpl(String id, String lbl, boolean markup, String world, double x[], double z[], boolean persistent, MarkerSetImpl set) {
markerid = id;
if(lbl != null)
label = markup ? lbl : Client.encodeForHTML(lbl);
label = markup ? Client.sanitizeHTML(lbl) : Client.encodeForHTML(lbl);
else
label = markup ? id : Client.encodeForHTML(id);
label = markup ? Client.sanitizeHTML(id) : Client.encodeForHTML(id);
this.markup = markup;
this.corners = new ArrayList<Coord>();
for(int i = 0; i < x.length; i++) {
@ -118,9 +118,10 @@ class AreaMarkerImpl implements AreaMarker, EnterExitMarker {
* Load marker from configuration node
* @param node - configuration node
*/
boolean loadPersistentData(ConfigurationNode node) {
boolean loadPersistentData(ConfigurationNode node, boolean isSafe) {
markup = node.getBoolean("markup", false);
label = MarkerAPIImpl.escapeForHTMLIfNeeded(node.getString("label", markerid), markup);
if (!isSafe) label = Client.sanitizeHTML(label);
ytop = node.getDouble("ytop", 64.0);
ybottom = node.getDouble("ybottom", 64.0);
List<Double> xx = node.getList("x");
@ -133,6 +134,7 @@ class AreaMarkerImpl implements AreaMarker, EnterExitMarker {
world = node.getString("world", "world");
normalized_world = DynmapWorld.normalizeWorldName(world);
desc = node.getString("desc", null);
if (!isSafe) desc = Client.sanitizeHTML(desc);
lineweight = node.getInteger("strokeWeight", -1);
if(lineweight == -1) { /* Handle typo-saved value */
lineweight = node.getInteger("stokeWeight", 3);
@ -215,12 +217,7 @@ class AreaMarkerImpl implements AreaMarker, EnterExitMarker {
@Override
public void setLabel(String lbl, boolean markup) {
if(markerset == null) return;
if (markup) {
label = lbl;
}
else { // If not markup, escape any HTML-active characters (<>&"')
label = Client.encodeForHTML(lbl);
}
label = markup ? Client.sanitizeHTML(lbl) : Client.encodeForHTML(lbl);
this.markup = markup;
MarkerAPIImpl.areaMarkerUpdated(this, MarkerUpdate.UPDATED);
if(ispersistent)
@ -298,6 +295,7 @@ class AreaMarkerImpl implements AreaMarker, EnterExitMarker {
@Override
public void setDescription(String desc) {
if(markerset == null) return;
desc = Client.sanitizeHTML(desc);
if((this.desc == null) || (this.desc.equals(desc) == false)) {
this.desc = desc;
MarkerAPIImpl.areaMarkerUpdated(this, MarkerUpdate.UPDATED);

View File

@ -67,6 +67,7 @@ class CircleMarkerImpl implements CircleMarker, EnterExitMarker {
label = markup ? lbl : Client.encodeColorInHTML(lbl);
else
label = markup ? id : Client.encodeColorInHTML(id);
label = Client.sanitizeHTML(label);
this.markup = markup;
this.x = x; this.y = y; this.z = z;
this.xr = xr; this.zr = zr;
@ -86,7 +87,7 @@ class CircleMarkerImpl implements CircleMarker, EnterExitMarker {
CircleMarkerImpl(String id, MarkerSetImpl set) {
markerid = id;
markerset = set;
label = Client.encodeForHTML(id);
label = Client.sanitizeHTML(Client.encodeForHTML(id));
markup = false;
desc = null;
world = normalized_world = "world";
@ -100,9 +101,10 @@ class CircleMarkerImpl implements CircleMarker, EnterExitMarker {
* Load marker from configuration node
* @param node - configuration node
*/
boolean loadPersistentData(ConfigurationNode node) {
boolean loadPersistentData(ConfigurationNode node, boolean isSafe) {
markup = node.getBoolean("markup", false);
label = MarkerAPIImpl.escapeForHTMLIfNeeded(node.getString("label", markerid), markup);
if (!isSafe) label = Client.sanitizeHTML(label);
world = node.getString("world", "world");
normalized_world = DynmapWorld.normalizeWorldName(world);
x = node.getDouble("x", 0);
@ -111,6 +113,7 @@ class CircleMarkerImpl implements CircleMarker, EnterExitMarker {
xr = node.getDouble("xr", 0);
zr = node.getDouble("zr", 0);
desc = node.getString("desc", null);
if (!isSafe) desc = Client.sanitizeHTML(desc);
lineweight = node.getInteger("strokeWeight", -1);
if(lineweight == -1) { /* Handle typo-saved value */
lineweight = node.getInteger("stokeWeight", 3);
@ -192,6 +195,7 @@ class CircleMarkerImpl implements CircleMarker, EnterExitMarker {
@Override
public void setLabel(String lbl, boolean markup) {
label = markup ? lbl : Client.encodeForHTML(lbl);
label = Client.sanitizeHTML(label);
this.markup = markup;
MarkerAPIImpl.circleMarkerUpdated(this, MarkerUpdate.UPDATED);
if(ispersistent)
@ -262,6 +266,7 @@ class CircleMarkerImpl implements CircleMarker, EnterExitMarker {
}
@Override
public void setDescription(String desc) {
desc = Client.sanitizeHTML(desc);
if((this.desc == null) || (this.desc.equals(desc) == false)) {
this.desc = desc;
MarkerAPIImpl.circleMarkerUpdated(this, MarkerUpdate.UPDATED);

View File

@ -102,14 +102,14 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
public MarkerUpdated(Marker m, boolean deleted) {
this.id = m.getMarkerID();
this.label = Client.sanitizeHTML(m.getLabel());
this.label = m.getLabel();
this.x = m.getX();
this.y = m.getY();
this.z = m.getZ();
this.set = m.getMarkerSet().getMarkerSetID();
this.icon = m.getMarkerIcon().getMarkerIconID();
this.markup = true; // We are markup format all the time now
this.desc = Client.sanitizeHTML(m.getDescription());
this.desc = m.getDescription();
this.dim = m.getMarkerIcon().getMarkerIconSize().getSize();
this.minzoom = m.getMinZoom();
this.maxzoom = m.getMaxZoom();
@ -153,7 +153,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
public AreaMarkerUpdated(AreaMarker m, boolean deleted) {
this.id = m.getMarkerID();
this.label = Client.sanitizeHTML(m.getLabel());
this.label = m.getLabel();
this.ytop = m.getTopY();
this.ybottom = m.getBottomY();
int cnt = m.getCornerCount();
@ -168,7 +168,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
opacity = m.getLineOpacity();
fillcolor = String.format("#%06X", m.getFillColor());
fillopacity = m.getFillOpacity();
desc = Client.sanitizeHTML(m.getDescription());
desc = m.getDescription();
this.minzoom = m.getMinZoom();
this.maxzoom = m.getMaxZoom();
this.markup = true; // We are markup format all the time now
@ -211,7 +211,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
public PolyLineMarkerUpdated(PolyLineMarker m, boolean deleted) {
this.id = m.getMarkerID();
this.label = Client.sanitizeHTML(m.getLabel());
this.label = m.getLabel();
this.markup = true; // We are markup format all the time now
int cnt = m.getCornerCount();
x = new double[cnt];
@ -225,7 +225,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
color = String.format("#%06X", m.getLineColor());
weight = m.getLineWeight();
opacity = m.getLineOpacity();
desc = Client.sanitizeHTML(m.getDescription());
desc = m.getDescription();
this.minzoom = m.getMinZoom();
this.maxzoom = m.getMaxZoom();
@ -271,7 +271,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
public CircleMarkerUpdated(CircleMarker m, boolean deleted) {
this.id = m.getMarkerID();
this.label = Client.sanitizeHTML(m.getLabel());
this.label = m.getLabel();
this.x = m.getCenterX();
this.y = m.getCenterY();
this.z = m.getCenterZ();
@ -283,7 +283,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
opacity = m.getLineOpacity();
fillcolor = String.format("#%06X", m.getFillColor());
fillopacity = m.getFillOpacity();
desc = Client.sanitizeHTML(m.getDescription());
desc = m.getDescription();
this.minzoom = m.getMinZoom();
this.maxzoom = m.getMaxZoom();
@ -822,6 +822,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
final ConfigurationNode conf = new ConfigurationNode(api.markerpersist); /* Make configuration object */
/* First, save icon definitions */
HashMap<String, Object> icons = new HashMap<String,Object>();
conf.put("isSafe", true); // Mark as safe (sanitized)
for(String id : api.markericons.keySet()) {
MarkerIconImpl ico = api.markericons.get(id);
Map<String,Object> dat = ico.getPersistentData();
@ -885,13 +886,14 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
ConfigurationNode conf = new ConfigurationNode(api.markerpersist); /* Make configuration object */
conf.load(); /* Load persistence */
lock.writeLock().lock();
boolean isSafe = conf.getBoolean("isSafe", false);
try {
/* Get icons */
ConfigurationNode icons = conf.getNode("icons");
if(icons == null) return false;
for(String id : icons.keySet()) {
MarkerIconImpl ico = new MarkerIconImpl(id);
if(ico.loadPersistentData(icons.getNode(id))) {
if(ico.loadPersistentData(icons.getNode(id), isSafe)) {
markericons.put(id, ico);
}
}
@ -900,7 +902,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
if(sets != null) {
for(String id: sets.keySet()) {
MarkerSetImpl set = new MarkerSetImpl(id);
if(set.loadPersistentData(sets.getNode(id))) {
if(set.loadPersistentData(sets.getNode(id), isSafe)) {
markersets.put(id, set);
}
}
@ -910,7 +912,7 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
if(psets != null) {
for(String id: psets.keySet()) {
PlayerSetImpl set = new PlayerSetImpl(id);
if(set.loadPersistentData(sets.getNode(id))) {
if(set.loadPersistentData(sets.getNode(id), isSafe)) {
playersets.put(id, set);
}
}
@ -3329,10 +3331,10 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
mi = MarkerAPIImpl.getMarkerIconImpl(MarkerIcon.DEFAULT);
mdata.put("icon", mi.getMarkerIconID());
mdata.put("dim", mi.getMarkerIconSize().getSize());
mdata.put("label", Client.sanitizeHTML(m.getLabel()));
mdata.put("label", m.getLabel());
mdata.put("markup", m.isLabelMarkup());
if(m.getDescription() != null)
mdata.put("desc", Client.sanitizeHTML(m.getDescription()));
mdata.put("desc", m.getDescription());
if (m.getMinZoom() >= 0) {
mdata.put("minzoom", m.getMinZoom());
}
@ -3365,10 +3367,10 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
mdata.put("opacity", m.getLineOpacity());
mdata.put("fillopacity", m.getFillOpacity());
mdata.put("weight", m.getLineWeight());
mdata.put("label", Client.sanitizeHTML(m.getLabel()));
mdata.put("label", m.getLabel());
mdata.put("markup", m.isLabelMarkup());
if(m.getDescription() != null)
mdata.put("desc", Client.sanitizeHTML(m.getDescription()));
mdata.put("desc", m.getDescription());
if (m.getMinZoom() >= 0) {
mdata.put("minzoom", m.getMinZoom());
}
@ -3400,10 +3402,10 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
mdata.put("color", String.format("#%06X", m.getLineColor()));
mdata.put("opacity", m.getLineOpacity());
mdata.put("weight", m.getLineWeight());
mdata.put("label", Client.sanitizeHTML(m.getLabel()));
mdata.put("label", m.getLabel());
mdata.put("markup", m.isLabelMarkup());
if(m.getDescription() != null)
mdata.put("desc", Client.sanitizeHTML(m.getDescription()));
mdata.put("desc", m.getDescription());
if (m.getMinZoom() >= 0) {
mdata.put("minzoom", m.getMinZoom());
}
@ -3430,10 +3432,10 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
mdata.put("opacity", m.getLineOpacity());
mdata.put("fillopacity", m.getFillOpacity());
mdata.put("weight", m.getLineWeight());
mdata.put("label", Client.sanitizeHTML(m.getLabel()));
mdata.put("label", m.getLabel());
mdata.put("markup", m.isLabelMarkup());
if(m.getDescription() != null)
mdata.put("desc", Client.sanitizeHTML(m.getDescription()));
mdata.put("desc", m.getDescription());
if (m.getMinZoom() >= 0) {
mdata.put("minzoom", m.getMinZoom());
}

View File

@ -81,7 +81,7 @@ class MarkerIconImpl implements MarkerIcon {
return node;
}
boolean loadPersistentData(ConfigurationNode node) {
boolean loadPersistentData(ConfigurationNode node, boolean isSafe) {
if(is_builtin)
return false;

View File

@ -63,7 +63,7 @@ class MarkerImpl implements Marker {
MarkerImpl(String id, MarkerSetImpl set) {
markerid = id;
markerset = set;
label = Client.encodeForHTML(id);
label = Client.sanitizeHTML(Client.encodeForHTML(id));
markup = false;
desc = null;
x = z = 0; y = 64; world = normalized_world = "world";
@ -75,15 +75,17 @@ class MarkerImpl implements Marker {
* Load marker from configuration node
* @param node - configuration node
*/
boolean loadPersistentData(ConfigurationNode node) {
boolean loadPersistentData(ConfigurationNode node, boolean isSafe) {
markup = node.getBoolean("markup", false);
label = MarkerAPIImpl.escapeForHTMLIfNeeded(node.getString("label", markerid), markup);
if (!isSafe) label = Client.sanitizeHTML(label);
x = node.getDouble("x", 0);
y = node.getDouble("y", 64);
z = node.getDouble("z", 0);
world = node.getString("world", "world");
normalized_world = DynmapWorld.normalizeWorldName(world);
desc = node.getString("desc", null);
if (!isSafe) desc = Client.sanitizeHTML(desc);
minzoom = node.getInteger("minzoom", -1);
maxzoom = node.getInteger("maxzoom", -1);
icon = MarkerAPIImpl.getMarkerIconImpl(node.getString("icon", MarkerIcon.DEFAULT));
@ -168,7 +170,7 @@ class MarkerImpl implements Marker {
@Override
public void setLabel(String lbl, boolean markup) {
if(markerset == null) return;
label = markup ? lbl : Client.encodeForHTML(lbl);
label = Client.sanitizeHTML(markup ? lbl : Client.encodeForHTML(lbl));
this.markup = markup;
MarkerAPIImpl.markerUpdated(this, MarkerUpdate.UPDATED);
if(ispersistent)
@ -239,6 +241,7 @@ class MarkerImpl implements Marker {
@Override
public void setDescription(String desc) {
if(markerset == null) return;
desc = Client.sanitizeHTML(desc);
if((this.desc == null) || (this.desc.equals(desc) == false)) {
this.desc = desc;
MarkerAPIImpl.markerUpdated(this, MarkerUpdate.UPDATED);

View File

@ -449,14 +449,14 @@ class MarkerSetImpl implements MarkerSet {
* Load marker from configuration node
* @param node - configuration node
*/
boolean loadPersistentData(ConfigurationNode node) {
boolean loadPersistentData(ConfigurationNode node, boolean isSafe) {
label = node.getString("label", setid); /* Get label */
ConfigurationNode markernode = node.getNode("markers");
if (markernode != null) {
for(String id : markernode.keySet()) {
MarkerImpl marker = new MarkerImpl(id, this); /* Make and load marker */
ConfigurationNode cfg = markernode.getNode(id);
if ((cfg != null) && marker.loadPersistentData(cfg)) {
if ((cfg != null) && marker.loadPersistentData(cfg, isSafe)) {
markers.put(id, marker);
}
else {
@ -470,7 +470,7 @@ class MarkerSetImpl implements MarkerSet {
for(String id : areamarkernode.keySet()) {
AreaMarkerImpl marker = new AreaMarkerImpl(id, this); /* Make and load marker */
ConfigurationNode cfg = areamarkernode.getNode(id);
if ((cfg != null) && marker.loadPersistentData(cfg)) {
if ((cfg != null) && marker.loadPersistentData(cfg, isSafe)) {
areamarkers.put(id, marker);
if(marker.getBoostFlag()) {
if(boostingareamarkers == null) {
@ -496,7 +496,7 @@ class MarkerSetImpl implements MarkerSet {
for(String id : linemarkernode.keySet()) {
PolyLineMarkerImpl marker = new PolyLineMarkerImpl(id, this); /* Make and load marker */
ConfigurationNode cfg = linemarkernode.getNode(id);
if ((cfg != null) && marker.loadPersistentData(cfg)) {
if ((cfg != null) && marker.loadPersistentData(cfg, isSafe)) {
linemarkers.put(id, marker);
}
else {
@ -510,7 +510,7 @@ class MarkerSetImpl implements MarkerSet {
for(String id : circlemarkernode.keySet()) {
CircleMarkerImpl marker = new CircleMarkerImpl(id, this); /* Make and load marker */
ConfigurationNode cfg = circlemarkernode.getNode(id);
if ((cfg != null) && marker.loadPersistentData(cfg)) {
if ((cfg != null) && marker.loadPersistentData(cfg, isSafe)) {
circlemarkers.put(id, marker);
if(marker.getBoostFlag()) {
if(boostingcirclemarkers == null) {

View File

@ -71,7 +71,7 @@ class PlayerSetImpl implements PlayerSet {
* Load marker from configuration node
* @param node - configuration node
*/
boolean loadPersistentData(ConfigurationNode node) {
boolean loadPersistentData(ConfigurationNode node, boolean isSafe) {
List<String> plist = node.getList("players");
if(plist != null) {
players.clear();

View File

@ -53,6 +53,7 @@ class PolyLineMarkerImpl implements PolyLineMarker {
label = markup ? lbl : Client.encodeForHTML(lbl);
else
label = markup ? id : Client.encodeForHTML(id);
label = Client.sanitizeHTML(label);
this.markup = markup;
this.corners = new ArrayList<Coord>();
for(int i = 0; i < x.length; i++) {
@ -74,7 +75,7 @@ class PolyLineMarkerImpl implements PolyLineMarker {
PolyLineMarkerImpl(String id, MarkerSetImpl set) {
markerid = id;
markerset = set;
label = Client.encodeForHTML(id);
label = Client.sanitizeHTML(Client.encodeForHTML(id));
markup = false;
desc = null;
corners = new ArrayList<Coord>();
@ -86,9 +87,10 @@ class PolyLineMarkerImpl implements PolyLineMarker {
* Load marker from configuration node
* @param node - configuration node
*/
boolean loadPersistentData(ConfigurationNode node) {
boolean loadPersistentData(ConfigurationNode node, boolean isSafe) {
markup = node.getBoolean("markup", false);
label = MarkerAPIImpl.escapeForHTMLIfNeeded(node.getString("label", markerid), markup);
if (!isSafe) label = Client.sanitizeHTML(label);
List<Double> xx = node.getList("x");
List<Double> yy = node.getList("y");
List<Double> zz = node.getList("z");
@ -101,6 +103,7 @@ class PolyLineMarkerImpl implements PolyLineMarker {
world = node.getString("world", "world");
normalized_world = DynmapWorld.normalizeWorldName(world);
desc = node.getString("desc", null);
if (!isSafe) desc = Client.sanitizeHTML(desc);
lineweight = node.getInteger("strokeWeight", -1);
if(lineweight == -1) { /* Handle typo-saved value */
lineweight = node.getInteger("stokeWeight", 3);
@ -164,7 +167,7 @@ class PolyLineMarkerImpl implements PolyLineMarker {
@Override
public void setLabel(String lbl, boolean markup) {
if(markerset == null) return;
label = markup ? lbl : Client.encodeForHTML(lbl);
label = markup ? Client.sanitizeHTML(lbl) : Client.encodeForHTML(lbl);
this.markup = markup;
MarkerAPIImpl.polyLineMarkerUpdated(this, MarkerUpdate.UPDATED);
if(ispersistent)
@ -223,6 +226,7 @@ class PolyLineMarkerImpl implements PolyLineMarker {
@Override
public void setDescription(String desc) {
if(markerset == null) return;
desc = Client.sanitizeHTML(desc);
if((this.desc == null) || (this.desc.equals(desc) == false)) {
this.desc = desc;
MarkerAPIImpl.polyLineMarkerUpdated(this, MarkerUpdate.UPDATED);

View File

@ -3,6 +3,7 @@ package org.dynmap.modsupport.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
import org.dynmap.modsupport.BlockSide;
import org.dynmap.modsupport.ModelBlockModel;
@ -69,16 +70,16 @@ public class ModelBlockModelImpl extends BlockModelImpl implements ModelBlockMod
String line;
line = String.format("modellist:%s", ids);
for (ModelBlockImpl mb: boxes) {
line += String.format(",box=%f/%f/%f", mb.from[0], mb.from[1], mb.from[2]);
line += String.format(Locale.US, ",box=%f/%f/%f", mb.from[0], mb.from[1], mb.from[2]);
if (!mb.shade) { // if shade=false
line += "/false";
}
line += String.format(":%f/%f/%f", mb.to[0], mb.to[1], mb.to[2]);
line += String.format(Locale.US, ":%f/%f/%f", mb.to[0], mb.to[1], mb.to[2]);
if ((mb.xrot != 0) || (mb.yrot != 0) || (mb.zrot != 0)) { // If needed, add rotation
line += String.format("/%f/%f/%f", mb.xrot, mb.yrot, mb.zrot);
line += String.format(Locale.US, "/%f/%f/%f", mb.xrot, mb.yrot, mb.zrot);
// If origin also defined, add it
if (mb.rotorigin != null) {
line += String.format("/%f/%f/%f", mb.rotorigin[0], mb.rotorigin[1], mb.rotorigin[2]);
line += String.format(Locale.US, "/%f/%f/%f", mb.rotorigin[0], mb.rotorigin[1], mb.rotorigin[2]);
}
}
for (BlockSide bs : fromBlockSide.keySet()) {
@ -101,7 +102,7 @@ public class ModelBlockModelImpl extends BlockModelImpl implements ModelBlockMod
break;
}
if (mside.uv != null) {
line += String.format(":%s/%d/%f/%f/%f/%f", rval, mside.textureid, mside.uv[0], mside.uv[1], mside.uv[2], mside.uv[3]);
line += String.format(Locale.US, ":%s/%d/%f/%f/%f/%f", rval, mside.textureid, mside.uv[0], mside.uv[1], mside.uv[2], mside.uv[3]);
}
else {
line += String.format(":%s/%d", rval, mside.textureid);

View File

@ -25,7 +25,11 @@ public class RoundVisibilityLimit implements VisibilityLimit {
else
chunk_corner_z = chunk_z * 16 + 15;
return (chunk_corner_x - x_center) * (chunk_corner_x - x_center) + (chunk_corner_z - z_center) * (chunk_corner_z - z_center) < radius * radius;
// By gmfamily - Use long representation of the distance between tested chunk and center of tested limit
// to avoid int overflow while computing the distance compared to limit radius using square delta value
long chunk_delta_x = chunk_corner_x - x_center;
long chunk_delta_z = chunk_corner_z - z_center;
return chunk_delta_x * chunk_delta_x + chunk_delta_z * chunk_delta_z < (long) radius * radius;
}
@Override

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="images/icons/mstile-150x150.png"/>
<TileColor>#ffffff</TileColor>
</tile>
</msapplication>
</browserconfig>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -0,0 +1,112 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="200.000000pt" height="200.000000pt" viewBox="0 0 200.000000 200.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.14, written by Peter Selinger 2001-2017
</metadata>
<g transform="translate(0.000000,200.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M1205 1970 c3 -5 8 -10 11 -10 2 0 4 5 4 10 0 6 -5 10 -11 10 -5 0
-7 -4 -4 -10z"/>
<path d="M1170 1940 c0 -4 7 -10 15 -14 8 -3 15 -10 15 -15 0 -6 -7 -8 -15 -5
-8 4 -15 1 -15 -5 0 -6 6 -11 13 -11 6 0 12 -12 13 -28 2 -51 15 -103 25 -97
5 4 7 11 3 17 -5 8 -8 40 -13 144 -1 13 -41 27 -41 14z"/>
<path d="M1250 1880 c-21 -21 -28 -80 -10 -80 6 0 10 9 10 19 0 11 8 26 18 33
18 14 26 48 11 48 -5 0 -18 -9 -29 -20z"/>
<path d="M701 1785 c-18 -8 -44 -15 -58 -15 -17 0 -24 -5 -22 -17 3 -34 -1
-41 -21 -36 -11 3 -20 9 -20 14 0 5 -10 9 -23 9 -27 0 -77 -21 -77 -33 0 -13
-27 -37 -42 -37 -10 0 -12 -11 -10 -40 2 -22 9 -40 16 -40 6 0 17 -9 24 -20 7
-11 19 -20 28 -20 11 0 14 -8 12 -26 -3 -29 -17 -39 -61 -49 -15 -3 -25 -10
-22 -15 3 -5 -21 -14 -54 -21 l-60 -11 5 -42 c56 -444 70 -582 62 -587 -5 -3
-4 -41 3 -97 9 -73 9 -95 -1 -107 -10 -12 -9 -15 4 -15 10 0 15 -4 11 -9 -3
-5 5 -17 17 -27 18 -12 19 -15 4 -10 -14 5 -17 2 -12 -9 3 -8 9 -22 13 -31 4
-12 2 -15 -8 -12 -8 2 -15 16 -17 31 -5 39 -25 50 -49 27 -12 -10 -23 -17 -26
-14 -2 3 -7 -2 -10 -10 -4 -9 -2 -18 3 -21 6 -4 10 -13 10 -22 0 -13 -3 -13
-15 -3 -17 14 -38 2 -56 -32 -9 -16 -6 -18 27 -13 21 2 41 10 46 17 7 12 9 11
12 -11 0 -5 4 -13 8 -16 4 -4 3 -16 -3 -26 -9 -17 -6 -19 27 -14 21 2 41 10
46 17 6 9 10 7 14 -9 7 -25 34 -32 34 -9 0 10 14 16 43 18 41 3 42 4 45 43 2
22 7 44 12 49 5 5 58 -26 129 -77 66 -48 125 -87 130 -87 16 0 13 17 -4 24
-23 8 -21 105 3 122 20 15 52 18 52 5 0 -5 10 -13 22 -17 19 -6 20 -7 4 -16
-12 -7 -14 -13 -7 -22 8 -10 4 -16 -14 -24 -38 -17 -33 -50 11 -68 36 -15 36
-16 15 -30 -14 -11 -21 -26 -21 -50 0 -19 -4 -34 -10 -34 -5 0 -10 5 -10 10 0
6 -4 10 -8 10 -4 0 -8 -11 -8 -25 0 -31 7 -31 38 0 l25 25 48 -35 c36 -25 52
-31 61 -24 7 6 18 8 24 4 6 -4 20 1 30 10 11 10 26 14 38 11 16 -5 19 -2 17
25 -2 29 7 37 112 115 62 46 113 88 113 92 0 11 196 153 232 169 15 7 28 17
28 23 0 6 4 9 9 6 15 -9 40 28 43 64 2 25 -1 35 -12 35 -37 2 -49 16 -43 48 3
18 12 37 19 43 8 6 12 19 8 28 -3 9 -1 16 4 16 12 0 10 34 -3 63 -9 22 11 155
28 175 7 9 11 48 9 110 -1 67 2 102 12 116 7 12 17 44 20 71 l7 51 -45 12
c-25 6 -46 16 -46 22 0 5 -7 10 -15 10 -9 0 -15 9 -15 21 0 13 -8 23 -21 26
-12 3 -16 9 -10 12 6 4 13 21 17 38 5 28 3 31 -25 36 -17 4 -38 4 -46 1 -18
-7 -20 -55 -3 -72 8 -8 8 -15 -3 -28 -10 -12 -24 -15 -59 -11 -24 3 -52 1 -62
-4 -14 -7 -19 0 -33 44 -10 28 -33 82 -52 120 -35 67 -36 67 -78 67 -41 0 -43
-1 -60 -47 -10 -27 -27 -63 -37 -81 -18 -29 -24 -32 -52 -27 -57 12 -66 16
-66 35 0 28 -11 51 -21 44 -5 -3 -9 -21 -9 -40 0 -48 -16 -43 -24 8 -5 29 -10
38 -15 29 -5 -8 -7 -27 -4 -42 3 -20 -1 -31 -11 -35 -9 -3 -16 -13 -16 -21 0
-11 -6 -14 -22 -9 -13 3 -38 6 -56 6 l-33 0 3 48 c3 42 6 47 28 50 23 3 25 7
24 49 -1 39 -5 48 -25 55 -13 5 -27 16 -32 24 -10 18 -42 17 -86 -1z m-5 -131
c6 -7 16 -14 23 -14 14 0 15 -86 1 -95 -6 -4 -33 -7 -60 -8 -27 -1 -52 -6 -56
-10 -17 -17 -34 -6 -34 22 0 63 11 90 41 96 20 5 26 11 22 22 -5 13 -1 15 23
9 16 -4 34 -14 40 -22z m509 6 c3 -5 1 -10 -4 -10 -6 0 -11 5 -11 10 0 6 2 10
4 10 3 0 8 -4 11 -10z m-167 -97 c46 -6 52 -18 23 -50 -17 -18 -24 -19 -60
-10 -49 13 -54 25 -8 21 17 -2 23 -1 12 2 -11 3 -27 8 -35 11 -8 3 -21 7 -29
7 -8 1 -16 6 -18 13 -5 13 33 23 57 15 8 -2 34 -7 58 -9z m167 -73 c3 -5 1
-10 -4 -10 -6 0 -11 5 -11 10 0 6 2 10 4 10 3 0 8 -4 11 -10z m211 -15 c-21
-16 -32 -13 -21 4 3 6 14 11 23 11 15 -1 15 -2 -2 -15z m-786 -21 c0 -31 -23
-28 -28 4 -2 15 2 22 12 22 11 0 16 -9 16 -26z m583 -6 c6 -22 1 -38 -11 -38
-10 0 -31 48 -24 55 12 12 30 4 35 -17z m137 -8 c-8 -5 -13 -10 -10 -11 3 0
14 -2 25 -5 64 -13 156 -23 169 -18 9 3 16 1 16 -5 0 -6 -7 -11 -15 -11 -8 0
-15 -7 -15 -15 0 -8 -4 -15 -10 -15 -5 0 -10 4 -10 9 0 5 -15 12 -32 16 -95
23 -159 33 -180 27 -26 -6 -23 11 5 24 29 15 79 18 57 4z m-262 -19 c19 -12
10 -47 -11 -43 -18 3 -23 -13 -7 -23 12 -7 4 -25 -11 -25 -5 0 -9 14 -9 30 0
17 -5 30 -11 30 -5 0 -7 5 -4 10 4 6 11 8 16 5 5 -4 9 1 9 9 0 18 8 20 28 7z
m52 -71 l-8 -35 -1 31 c-1 17 2 34 6 37 11 12 12 3 3 -33z m80 24 c0 -8 -4
-12 -10 -9 -5 3 -10 10 -10 16 0 5 5 9 10 9 6 0 10 -7 10 -16z m-605 -27 c6
-7 55 -28 110 -47 55 -18 107 -40 116 -47 8 -7 21 -13 28 -13 10 0 11 -10 7
-35 -6 -32 -3 -39 23 -63 22 -18 31 -36 31 -57 0 -16 7 -43 15 -59 8 -15 15
-35 15 -42 0 -8 6 -14 14 -14 7 0 19 -7 26 -15 7 -8 8 -15 3 -15 -6 0 -22 -11
-37 -25 -23 -21 -30 -23 -46 -12 -11 6 -20 19 -20 29 0 9 -9 19 -20 23 -12 4
-24 21 -30 45 -6 22 -15 42 -20 45 -6 3 -10 13 -10 20 0 18 -31 55 -45 55 -6
0 -15 15 -20 32 -8 26 -20 37 -55 51 l-46 19 -33 -31 -33 -31 7 -113 c8 -130
10 -133 75 -204 11 -13 20 -35 21 -50 1 -28 15 -74 35 -106 14 -23 51 -30 58
-10 5 11 14 14 36 10 16 -4 32 -2 35 2 3 5 16 8 30 6 14 -1 28 2 31 6 8 13 48
11 62 -3 7 -7 12 -25 12 -40 0 -21 5 -28 20 -28 16 0 20 7 20 33 0 17 7 41 15
51 8 11 15 28 15 38 0 9 8 25 19 35 10 10 21 39 25 68 6 51 26 87 26 48 0 -12
-4 -25 -10 -28 -5 -3 -10 -21 -10 -39 0 -20 -8 -40 -20 -51 -11 -10 -20 -25
-20 -34 0 -9 -7 -26 -15 -38 -9 -12 -15 -26 -14 -30 5 -31 -3 -55 -21 -60 -12
-3 -20 -14 -20 -25 0 -17 5 -19 28 -14 26 6 26 6 8 -9 -11 -8 -23 -15 -28 -15
-4 0 -8 -10 -8 -22 0 -18 -2 -20 -9 -9 -5 8 -21 16 -35 18 -20 3 -27 -2 -32
-21 -8 -35 -38 -42 -72 -17 l-29 20 -26 -32 c-25 -31 -26 -31 -46 -13 -11 10
-20 21 -19 25 2 19 -5 33 -37 65 -19 20 -35 43 -35 52 0 8 -7 29 -16 45 -8 17
-13 37 -10 45 8 22 -12 65 -43 94 -16 14 -31 39 -34 55 -3 17 -13 62 -21 100
-23 112 -22 268 3 314 8 14 11 38 8 59 -6 34 -6 34 26 28 18 -3 37 -12 42 -19z
m593 -36 c15 -47 15 -51 1 -51 -5 0 -7 5 -3 11 4 7 -3 19 -16 29 -15 11 -21
23 -17 34 10 26 23 18 35 -23z m69 17 c-3 -8 -6 -5 -6 6 -1 11 2 17 5 13 3 -3
4 -12 1 -19z m-36 -51 c-13 -13 -15 11 -4 40 7 16 8 15 11 -6 2 -13 -1 -28 -7
-34z m396 1 c-3 -8 -6 -5 -6 6 -1 11 2 17 5 13 3 -3 4 -12 1 -19z m-72 -43
c-2 -31 -8 -61 -13 -68 -6 -7 -14 -47 -18 -90 -4 -43 -10 -80 -15 -83 -12 -7
2 165 17 210 7 22 11 44 8 48 -5 8 13 38 22 38 1 0 1 -25 -1 -55z m-48 -17
c-3 -7 -5 -2 -5 12 0 14 2 19 5 13 2 -7 2 -19 0 -25z m-130 -34 c2 -5 -24 -20
-57 -33 -54 -21 -81 -50 -47 -51 6 0 4 -5 -6 -11 -14 -8 -22 -8 -30 0 -14 14
-18 69 -6 77 5 3 9 -3 9 -13 0 -14 2 -15 9 -4 5 8 7 21 4 30 -4 14 -3 14 6 1
9 -13 15 -12 53 2 45 17 60 18 65 2z m-153 -131 c-4 -16 -10 -30 -13 -33 -3
-3 -6 -11 -7 -17 -2 -30 -4 -36 -11 -30 -10 10 -32 -13 -27 -28 3 -7 1 -16 -5
-20 -17 -10 -24 21 -11 44 8 16 8 21 -1 21 -7 0 -9 3 -5 8 4 4 12 7 18 7 6 0
12 8 14 18 3 21 32 57 46 57 4 0 5 -12 2 -27z m306 -79 c0 -8 -5 -12 -10 -9
-6 4 -8 11 -5 16 9 14 15 11 15 -7z m-996 -248 c8 -18 22 -40 33 -47 10 -8 18
-20 17 -26 -1 -7 -2 -17 -3 -23 0 -5 -5 -10 -10 -10 -5 0 -7 9 -4 20 3 11 1
20 -4 20 -4 0 -17 15 -27 34 -10 19 -25 37 -33 40 -8 3 -11 10 -8 16 11 18 25
10 39 -24z m566 -5 c0 -17 -4 -33 -10 -36 -5 -3 -10 -21 -10 -40 0 -40 -8 -65
-22 -65 -10 0 -4 70 13 133 12 44 29 49 29 8z m-626 -26 c19 -28 21 -44 4 -27
-7 7 -17 8 -30 1 -14 -7 -18 -6 -18 6 0 8 5 15 10 15 6 0 10 5 10 11 0 5 -4 7
-10 4 -5 -3 -10 -1 -10 4 0 20 28 11 44 -14z m6 -60 c11 -13 10 -14 -4 -9 -9
3 -16 10 -16 15 0 13 6 11 20 -6z m-50 1 c0 -3 -4 -8 -10 -11 -5 -3 -10 -1
-10 4 0 6 5 11 10 11 6 0 10 -2 10 -4z m180 -102 c0 -28 -2 -32 -13 -23 -14
14 -10 72 4 63 5 -3 9 -21 9 -40z m-216 -90 c17 -16 21 -34 9 -34 -17 1 -45
29 -38 39 8 14 11 14 29 -5z m651 -153 c-6 -5 -25 10 -25 20 0 5 6 4 14 -3 8
-7 12 -15 11 -17z"/>
<path d="M579 1193 c-13 -16 -12 -17 4 -4 9 7 17 15 17 17 0 8 -8 3 -21 -13z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

@ -0,0 +1,13 @@
{
"name": "",
"short_name": "",
"icons": [
{
"src": "android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff"
}

View File

@ -9,11 +9,16 @@
<meta name="description" content="Minecraft Dynamic Map" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<!-- These 2 lines make us fullscreen on apple mobile products - remove if you don't like that -->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="theme-color" content="#000000">
<link rel="icon" href="images/dynmap.ico" type="image/ico" />
<link rel="apple-touch-icon" sizes="180x180" href="images/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="images/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="images/icons/favicon-16x16.png">
<link rel="manifest" href="images/icons/site.webmanifest">
<link rel="mask-icon" href="images/icons/safari-pinned-tab.svg" color="#000000">
<link rel="shortcut icon" href="images/icons/favicon.ico">
<meta name="msapplication-TileColor" content="#000000">
<meta name="msapplication-config" content="images/icons/browserconfig.xml">
<meta name="theme-color" content="#000000">
<script type="text/javascript" src="js/jquery-3.5.1.js?_=${version}-${buildnumber}"></script>
<link rel="stylesheet" type="text/css" href="css/leaflet.css?_=${version}-${buildnumber}" />

View File

@ -46,10 +46,10 @@ The following target platforms are supported, and you can find them at the links
| Server type | Version | Dynmap JAR | Where? |
| ------------ | ------- | ---------- | ------ |
| Spigot/PaperMC | ≤1.18.2 | `Dynmap-<version>-spigot.jar` | [SpigotMC](https://www.spigotmc.org/resources/dynmap.274/) |
| Spigot/PaperMC | ≤1.18.2 | `Dynmap-<version>-spigot.jar` | [GitHub Releases](https://github.com/webbukkit/dynmap/releases) |
| Forge | 1.12.2 | `Dynmap-<version>-forge-1.12.2.jar` | [GitHub Releases](https://github.com/webbukkit/dynmap/releases) |
| Forge | 1.14.4 | `Dynmap-<version>-forge-1.14.4.jar` | [GitHub Releases](https://github.com/webbukkit/dynmap/releases) |
| Forge | 1.15.2 | `Dynmap-<version>-forge-1.15.2.jar` | [GitHub Releases](https://github.com/webbukkit/dynmap/releases) |
| Spigot/PaperMC | ≤1.18.2 | `Dynmap-<version>-spigot.jar` | [Bukkit](https://dev.bukkit.org/projects/dynmap) |
| Forge | 1.12.2 | `Dynmap-<version>-forge-1.12.2.jar` | [Curseforge](https://www.curseforge.com/minecraft/mc-mods/dynmapforge)|
| Forge | 1.14.4 | `Dynmap-<version>-forge-1.14.4.jar` | [Curseforge](https://www.curseforge.com/minecraft/mc-mods/dynmapforge)|
| Forge | 1.15.2 | `Dynmap-<version>-forge-1.15.2.jar` | [Curseforge](https://www.curseforge.com/minecraft/mc-mods/dynmapforge)|
| Forge | 1.16.5 | `Dynmap-<version>-forge-1.16.5.jar` | [Curseforge](https://www.curseforge.com/minecraft/mc-mods/dynmapforge) |
| Forge | 1.17.1 | `Dynmap-<version>-forge-1.17.1.jar` | [Curseforge](https://www.curseforge.com/minecraft/mc-mods/dynmapforge) |
| Forge | 1.18, 1.18.1 | `Dynmap-<version>-forge-1.18.jar` | [Curseforge](https://www.curseforge.com/minecraft/mc-mods/dynmapforge) |

View File

@ -38,7 +38,7 @@ allprojects {
apply plugin: 'java'
group = 'us.dynmap'
version = '3.4'
version = '3.5-beta-1'
}

View File

@ -20,6 +20,7 @@ import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Optional;
/**
@ -28,10 +29,16 @@ import java.util.List;
public class BukkitVersionHelperSpigot116_4 extends BukkitVersionHelperGeneric {
private final boolean unsafeAsync;
private Field watercolorfield;
private static Field grassColorField;
private static Field foliageColorField;
private static Field grassColorModifierField;
public BukkitVersionHelperSpigot116_4() {
Class biomefog = getNMSClass("net.minecraft.server.BiomeFog");
watercolorfield = getPrivateField(biomefog, new String[] { "c" }, int.class);
grassColorField = getPrivateField(biomefog, new String[] { "g" }, Optional.class);
foliageColorField = getPrivateField(biomefog, new String[] { "f" }, Optional.class);
grassColorModifierField = getPrivateField(biomefog, new String[] { "h" }, BiomeFog.GrassColor.class);
this.unsafeAsync = true;
}
@ -160,6 +167,29 @@ public class BukkitVersionHelperSpigot116_4 extends BukkitVersionHelperGeneric {
}
return 0xFFFFFF;
}
@SuppressWarnings("unchecked")
public static Optional<Integer> getBiomeBaseGrassMult(BiomeBase bb) {
if (bb == null) return Optional.empty();
try {
return (Optional<Integer>) grassColorField.get(bb.l());
} catch (IllegalArgumentException | IllegalAccessException ignored) {}
return Optional.empty();
}
@SuppressWarnings("unchecked")
public static Optional<Integer> getBiomeBaseFoliageMult(BiomeBase bb) {
if (bb == null) return Optional.empty();
try {
return (Optional<Integer>) foliageColorField.get(bb.l());
} catch (IllegalArgumentException | IllegalAccessException ignored) {}
return Optional.empty();
}
public static BiomeFog.GrassColor getBiomeBaseGrassModifier(BiomeBase bb) {
if (bb == null) return BiomeFog.GrassColor.NONE;
try {
return (BiomeFog.GrassColor) grassColorModifierField.get(bb.l());
} catch (IllegalArgumentException | IllegalAccessException ignored) {}
return BiomeFog.GrassColor.NONE;
}
/** Get temperature from biomebase */
@Override

View File

@ -6,12 +6,14 @@ import org.bukkit.World;
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
import org.dynmap.DynmapChunk;
import org.dynmap.bukkit.helper.BukkitWorld;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericChunkCache;
import org.dynmap.common.chunk.GenericMapChunkCache;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
/**
* Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread
@ -62,5 +64,26 @@ public class MapChunkCache116_4 extends GenericMapChunkCache {
this.w = dw.getWorld();
super.setChunks(dw, chunks);
}
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
Optional<BiomeBase> base = bm.getBiomeObject();
return BukkitVersionHelperSpigot116_4.getBiomeBaseFoliageMult(base.orElse(null)).orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeBase base = bm.<BiomeBase>getBiomeObject().orElse(null);
if (base == null) return bm.getModifiedGrassMultiplier(colormap[bm.biomeLookup()]);
int grassMult = BukkitVersionHelperSpigot116_4.getBiomeBaseGrassMult(base).orElse(colormap[bm.biomeLookup()]);
BiomeFog.GrassColor modifier = BukkitVersionHelperSpigot116_4.getBiomeBaseGrassModifier(base);
if (modifier == BiomeFog.GrassColor.DARK_FOREST) {
return ((grassMult & 0xfefefe) + 0x28340a) >> 1;
} else if (modifier == BiomeFog.GrassColor.SWAMP) {
double var5 = BiomeBase.f.a(x * 0.0225, z * 0.0225, false);
return var5 < -0.1 ? 0x4c763c : 0x6a7039;
} else {
return grassMult;
}
}
}

View File

@ -1,9 +1,12 @@
package org.dynmap.bukkit.helper.v117;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.biome.BiomeFog;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.dynmap.DynmapChunk;
import org.dynmap.bukkit.helper.BukkitWorld;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericChunkCache;
import org.dynmap.common.chunk.GenericMapChunkCache;
@ -16,6 +19,7 @@ import net.minecraft.world.level.chunk.storage.ChunkRegionLoader;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
/**
* Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread
@ -66,4 +70,16 @@ public class MapChunkCache117 extends GenericMapChunkCache {
this.w = dw.getWorld();
super.setChunks(dw, chunks);
}
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<BiomeBase>getBiomeObject().map(BiomeBase::l).flatMap(BiomeFog::e).orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeFog fog = bm.<BiomeBase>getBiomeObject().map(BiomeBase::l).orElse(null);
if (fog == null) return colormap[bm.biomeLookup()];
return fog.g().a(x, z, fog.f().orElse(colormap[bm.biomeLookup()]));
}
}

View File

@ -1,6 +1,8 @@
package org.dynmap.bukkit.helper.v118_2;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.biome.BiomeFog;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
@ -9,6 +11,7 @@ import org.dynmap.DynmapChunk;
import org.dynmap.MapManager;
import org.dynmap.bukkit.helper.BukkitVersionHelper;
import org.dynmap.bukkit.helper.BukkitWorld;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericChunkCache;
import org.dynmap.common.chunk.GenericMapChunkCache;
@ -96,4 +99,16 @@ public class MapChunkCache118_2 extends GenericMapChunkCache {
this.w = dw.getWorld();
super.setChunks(dw, chunks);
}
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<BiomeBase>getBiomeObject().map(BiomeBase::j).flatMap(BiomeFog::e).orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeFog fog = bm.<BiomeBase>getBiomeObject().map(BiomeBase::j).orElse(null);
if (fog == null) return colormap[bm.biomeLookup()];
return fog.g().a(x, z, fog.f().orElse(colormap[bm.biomeLookup()]));
}
}

View File

@ -1,5 +1,7 @@
package org.dynmap.bukkit.helper.v118;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.biome.BiomeFog;
import org.bukkit.ChunkSnapshot;
import org.bukkit.World;
import org.bukkit.block.Biome;
@ -85,4 +87,17 @@ public class MapChunkCache118 extends GenericMapChunkCache {
this.w = dw.getWorld();
super.setChunks(dw, chunks);
}
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<BiomeBase>getBiomeObject().map(BiomeBase::j).flatMap(BiomeFog::e).orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeFog fog = bm.<BiomeBase>getBiomeObject().map(BiomeBase::j).orElse(null);
if (fog == null) return colormap[bm.biomeLookup()];
return fog.g().a(x, z, fog.f().orElse(colormap[bm.biomeLookup()]));
}
}

2
bukkit-helper-119-3/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/build/
/bin/

View File

@ -0,0 +1,15 @@
eclipse {
project {
name = "Dynmap(Spigot-1.19.3)"
}
}
description = 'bukkit-helper-1.19.3'
dependencies {
implementation project(':bukkit-helper')
implementation project(':dynmap-api')
implementation project(path: ':DynmapCore', configuration: 'shadow')
implementation group: 'org.spigotmc', name: 'spigot-api', version:'1.19.3-R0.1-SNAPSHOT'
implementation group: 'org.spigotmc', name: 'spigot', version:'1.19.3-R0.1-SNAPSHOT'
}

View File

@ -0,0 +1,130 @@
package org.dynmap.bukkit.helper.v119_3;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.WorldServer;
import net.minecraft.world.level.chunk.Chunk;
import net.minecraft.world.level.chunk.IChunkAccess;
import net.minecraft.world.level.chunk.storage.ChunkRegionLoader;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
import org.dynmap.MapManager;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
/**
* The provider used to work with paper libs
* Because paper libs need java 17 we can't interact with them directly
*/
@SuppressWarnings({"JavaReflectionMemberAccess"}) //java don't know about paper
public class AsyncChunkProvider119_3 {
private final Method getChunk;
private final Method getAsyncSaveData;
private final Method save;
private final Enum<?> data;
private final Enum<?> priority;
private int currTick = MinecraftServer.currentTick;
private int currChunks = 0;
AsyncChunkProvider119_3() {
try {
Method getChunk1 = null;
Method getAsyncSaveData1 = null;
Method save1 = null;
Enum<?> priority1 = null;
Enum<?> data1 = null;
try {
Class<?> threadClass = Class.forName("io.papermc.paper.chunk.system.io.RegionFileIOThread");
Class<?> dataclass = Arrays.stream(threadClass.getDeclaredClasses())
.filter(c -> c.getSimpleName().equals("RegionFileType"))
.findAny()
.orElseThrow(NullPointerException::new);
data1 = Enum.valueOf(cast(dataclass), "CHUNK_DATA");
Class<?> priorityClass = Arrays.stream(Class.forName("ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor").getClasses())
.filter(c -> c.getSimpleName().equals("Priority"))
.findAny()
.orElseThrow(NullPointerException::new);
//Almost lowest priority, but not quite so low as to be considered idle
//COMPLETING->BLOCKING->HIGHEST->HIGHER->HIGH->NORMAL->LOW->LOWER->LOWEST->IDLE
priority1 = Enum.valueOf(cast(priorityClass), "LOWEST");
getAsyncSaveData1 = ChunkRegionLoader.class.getMethod("getAsyncSaveData", WorldServer.class, IChunkAccess.class);
save1 = ChunkRegionLoader.class.getMethod("saveChunk", WorldServer.class, IChunkAccess.class, getAsyncSaveData1.getReturnType());
getChunk1 = threadClass.getMethod("loadDataAsync", WorldServer.class, int.class, int.class, data1.getClass(), BiConsumer.class, boolean.class, priority1.getClass());
} catch (ClassNotFoundException | NoSuchMethodException e) {
e.printStackTrace();
}
getAsyncSaveData = Objects.requireNonNull(getAsyncSaveData1);
save = Objects.requireNonNull(save1);
getChunk = Objects.requireNonNull(getChunk1);
data = Objects.requireNonNull(data1);
priority = Objects.requireNonNull(priority1);
} catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
@SuppressWarnings("unchecked")
private <T> T cast(Object o) {
return (T) o;
}
public CompletableFuture<NBTTagCompound> getChunk(WorldServer world, int x, int y) throws InvocationTargetException, IllegalAccessException {
CompletableFuture<NBTTagCompound> future = new CompletableFuture<>();
getChunk.invoke(null, world, x, y, data, (BiConsumer<NBTTagCompound, Throwable>) (nbt, exception) -> future.complete(nbt), true, priority);
return future;
}
public synchronized Supplier<NBTTagCompound> getLoadedChunk(CraftWorld world, int x, int z) {
if (!world.isChunkLoaded(x, z)) return () -> null;
Chunk c = world.getHandle().getChunkIfLoaded(x, z); //already safe async on vanilla
if ((c == null) || !c.o) return () -> null; // c.loaded
if (currTick != MinecraftServer.currentTick) {
currTick = MinecraftServer.currentTick;
currChunks = 0;
}
//prepare data synchronously
CompletableFuture<?> future = CompletableFuture.supplyAsync(() -> {
//Null will mean that we save with spigot methods, which may be risky on async
//Since we're not in main thread, it now refuses new tasks because of shutdown, the risk is lower
if (!Bukkit.isPrimaryThread()) return null;
try {
return getAsyncSaveData.invoke(null, world.getHandle(), c);
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
}, ((CraftServer) Bukkit.getServer()).getServer());
//we shouldn't stress main thread
if (++currChunks > MapManager.mapman.getMaxChunkLoadsPerTick()) {
try {
Thread.sleep(25); //hold the lock so other threads also won't stress main thread
} catch (InterruptedException ignored) {}
}
//save data asynchronously
return () -> {
Object o = null;
try {
o = future.get();
return (NBTTagCompound) save.invoke(null, world.getHandle(), c, o);
} catch (InterruptedException e) {
return null;
} catch (InvocationTargetException e) {
//We tried to use simple spigot methods at shutdown and failed, hopes for reading from disk
if (o == null) return null;
throw new RuntimeException(e);
} catch (ReflectiveOperationException | ExecutionException e) {
throw new RuntimeException(e);
}
};
}
}

View File

@ -0,0 +1,458 @@
package org.dynmap.bukkit.helper.v119_3;
import org.bukkit.*;
import org.bukkit.craftbukkit.v1_19_R2.CraftChunk;
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.dynmap.DynmapChunk;
import org.dynmap.Log;
import org.dynmap.bukkit.helper.BukkitMaterial;
import org.dynmap.bukkit.helper.BukkitVersionHelper;
import org.dynmap.bukkit.helper.BukkitWorld;
import org.dynmap.bukkit.helper.BukkitVersionHelperGeneric.TexturesPayload;
import org.dynmap.renderer.DynmapBlockState;
import org.dynmap.utils.MapChunkCache;
import org.dynmap.utils.Polygon;
import com.google.common.collect.Iterables;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap;
import net.minecraft.core.RegistryBlockID;
import net.minecraft.core.RegistryBlocks;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.IRegistry;
import net.minecraft.nbt.NBTTagByteArray;
import net.minecraft.nbt.NBTTagByte;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagDouble;
import net.minecraft.nbt.NBTTagFloat;
import net.minecraft.nbt.NBTTagIntArray;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagLong;
import net.minecraft.nbt.NBTTagShort;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.nbt.NBTBase;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.level.BlockAccessAir;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.BlockFluids;
import net.minecraft.world.level.block.entity.TileEntity;
import net.minecraft.world.level.block.state.IBlockData;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.Collection;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Helper for isolation of bukkit version specific issues
*/
public class BukkitVersionHelperSpigot119_3 extends BukkitVersionHelper {
private final boolean unsafeAsync;
public BukkitVersionHelperSpigot119_3() {
boolean unsafeAsync1;
try {
Class.forName("io.papermc.paper.chunk.system.io.RegionFileIOThread");
unsafeAsync1 = false;
} catch (ClassNotFoundException e) {
unsafeAsync1 = true;
}
this.unsafeAsync = unsafeAsync1;
}
@Override
public boolean isUnsafeAsync() {
return unsafeAsync;
}
/**
* Get block short name list
*/
@Override
public String[] getBlockNames() {
RegistryBlockID<IBlockData> bsids = Block.o;
Block baseb = null;
Iterator<IBlockData> iter = bsids.iterator();
ArrayList<String> names = new ArrayList<String>();
while (iter.hasNext()) {
IBlockData bs = iter.next();
Block b = bs.b();
// If this is new block vs last, it's the base block state
if (b != baseb) {
baseb = b;
continue;
}
MinecraftKey id = BuiltInRegistries.f.b(b);
String bn = id.toString();
if (bn != null) {
names.add(bn);
Log.info("block=" + bn);
}
}
return names.toArray(new String[0]);
}
private static IRegistry<BiomeBase> reg = null;
private static IRegistry<BiomeBase> getBiomeReg() {
if (reg == null) {
reg = MinecraftServer.getServer().aW().d(Registries.al);
}
return reg;
}
private Object[] biomelist;
/**
* Get list of defined biomebase objects
*/
@Override
public Object[] getBiomeBaseList() {
if (biomelist == null) {
biomelist = new BiomeBase[256];
Iterator<BiomeBase> iter = getBiomeReg().iterator();
while (iter.hasNext()) {
BiomeBase b = iter.next();
int bidx = getBiomeReg().a(b);
if (bidx >= biomelist.length) {
biomelist = Arrays.copyOf(biomelist, bidx + biomelist.length);
}
biomelist[bidx] = b;
}
}
return biomelist;
}
/** Get ID from biomebase */
@Override
public int getBiomeBaseID(Object bb) {
return getBiomeReg().a((BiomeBase)bb);
}
public static IdentityHashMap<IBlockData, DynmapBlockState> dataToState;
/**
* Initialize block states (org.dynmap.blockstate.DynmapBlockState)
*/
@Override
public void initializeBlockStates() {
dataToState = new IdentityHashMap<IBlockData, DynmapBlockState>();
HashMap<String, DynmapBlockState> lastBlockState = new HashMap<String, DynmapBlockState>();
RegistryBlockID<IBlockData> bsids = Block.o;
Block baseb = null;
Iterator<IBlockData> iter = bsids.iterator();
ArrayList<String> names = new ArrayList<String>();
// Loop through block data states
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
while (iter.hasNext()) {
IBlockData bd = iter.next();
Block b = bd.b();
MinecraftKey id = BuiltInRegistries.f.b(b);
String bname = id.toString();
DynmapBlockState lastbs = lastBlockState.get(bname); // See if we have seen this one
int idx = 0;
if (lastbs != null) { // Yes
idx = lastbs.getStateCount(); // Get number of states so far, since this is next
}
// Build state name
String sb = "";
String fname = bd.toString();
int off1 = fname.indexOf('[');
if (off1 >= 0) {
int off2 = fname.indexOf(']');
sb = fname.substring(off1+1, off2);
}
net.minecraft.world.level.material.Material mat = bd.d();
int lightAtten = b.g(bd, BlockAccessAir.a, BlockPosition.b); // getLightBlock
//Log.info("statename=" + bname + "[" + sb + "], lightAtten=" + lightAtten);
// Fill in base attributes
bld.setBaseState(lastbs).setStateIndex(idx).setBlockName(bname).setStateName(sb).setMaterial(mat.toString()).setAttenuatesLight(lightAtten);
if (mat.b()) { bld.setSolid(); }
if (mat == net.minecraft.world.level.material.Material.a) { bld.setAir(); }
if (mat == net.minecraft.world.level.material.Material.z) { bld.setLog(); }
if (mat == net.minecraft.world.level.material.Material.F) { bld.setLeaves(); }
if ((!bd.q().c()) && ((bd.b() instanceof BlockFluids) == false)) { // Test if fluid type for block is not empty
bld.setWaterlogged();
}
DynmapBlockState dbs = bld.build(); // Build state
dataToState.put(bd, dbs);
lastBlockState.put(bname, (lastbs == null) ? dbs : lastbs);
Log.verboseinfo("blk=" + bname + ", idx=" + idx + ", state=" + sb + ", waterlogged=" + dbs.isWaterlogged());
}
}
/**
* Create chunk cache for given chunks of given world
* @param dw - world
* @param chunks - chunk list
* @return cache
*/
@Override
public MapChunkCache getChunkCache(BukkitWorld dw, List<DynmapChunk> chunks) {
MapChunkCache119_3 c = new MapChunkCache119_3(gencache);
c.setChunks(dw, chunks);
return c;
}
/**
* Get biome base water multiplier
*/
@Override
public int getBiomeBaseWaterMult(Object bb) {
BiomeBase biome = (BiomeBase) bb;
return biome.k(); // waterColor
}
/** Get temperature from biomebase */
@Override
public float getBiomeBaseTemperature(Object bb) {
return ((BiomeBase)bb).i();
}
/** Get humidity from biomebase */
@Override
public float getBiomeBaseHumidity(Object bb) {
return ((BiomeBase)bb).h();
}
@Override
public Polygon getWorldBorder(World world) {
Polygon p = null;
WorldBorder wb = world.getWorldBorder();
if (wb != null) {
Location c = wb.getCenter();
double size = wb.getSize();
if ((size > 1) && (size < 1E7)) {
size = size / 2;
p = new Polygon();
p.addVertex(c.getX()-size, c.getZ()-size);
p.addVertex(c.getX()+size, c.getZ()-size);
p.addVertex(c.getX()+size, c.getZ()+size);
p.addVertex(c.getX()-size, c.getZ()+size);
}
}
return p;
}
// Send title/subtitle to user
public void sendTitleText(Player p, String title, String subtitle, int fadeInTicks, int stayTicks, int fadeOutTIcks) {
if (p != null) {
p.sendTitle(title, subtitle, fadeInTicks, stayTicks, fadeOutTIcks);
}
}
/**
* Get material map by block ID
*/
@Override
public BukkitMaterial[] getMaterialList() {
return new BukkitMaterial[4096]; // Not used
}
@Override
public void unloadChunkNoSave(World w, org.bukkit.Chunk c, int cx, int cz) {
Log.severe("unloadChunkNoSave not implemented");
}
private String[] biomenames;
@Override
public String[] getBiomeNames() {
if (biomenames == null) {
biomenames = new String[256];
Iterator<BiomeBase> iter = getBiomeReg().iterator();
while (iter.hasNext()) {
BiomeBase b = iter.next();
int bidx = getBiomeReg().a(b);
if (bidx >= biomenames.length) {
biomenames = Arrays.copyOf(biomenames, bidx + biomenames.length);
}
biomenames[bidx] = b.toString();
}
}
return biomenames;
}
@Override
public String getStateStringByCombinedId(int blkid, int meta) {
Log.severe("getStateStringByCombinedId not implemented");
return null;
}
@Override
/** Get ID string from biomebase */
public String getBiomeBaseIDString(Object bb) {
return getBiomeReg().b((BiomeBase)bb).a();
}
@Override
public String getBiomeBaseResourceLocsation(Object bb) {
return getBiomeReg().b((BiomeBase)bb).toString();
}
@Override
public Object getUnloadQueue(World world) {
Log.warning("getUnloadQueue not implemented yet");
// TODO Auto-generated method stub
return null;
}
@Override
public boolean isInUnloadQueue(Object unloadqueue, int x, int z) {
Log.warning("isInUnloadQueue not implemented yet");
// TODO Auto-generated method stub
return false;
}
@Override
public Object[] getBiomeBaseFromSnapshot(ChunkSnapshot css) {
Log.warning("getBiomeBaseFromSnapshot not implemented yet");
// TODO Auto-generated method stub
return new Object[256];
}
@Override
public long getInhabitedTicks(Chunk c) {
return ((CraftChunk)c).getHandle().u();
}
@Override
public Map<?, ?> getTileEntitiesForChunk(Chunk c) {
return ((CraftChunk)c).getHandle().i;
}
@Override
public int getTileEntityX(Object te) {
TileEntity tileent = (TileEntity) te;
return tileent.p().u();
}
@Override
public int getTileEntityY(Object te) {
TileEntity tileent = (TileEntity) te;
return tileent.p().v();
}
@Override
public int getTileEntityZ(Object te) {
TileEntity tileent = (TileEntity) te;
return tileent.p().w();
}
@Override
public Object readTileEntityNBT(Object te) {
TileEntity tileent = (TileEntity) te;
NBTTagCompound nbt = tileent.n();
return nbt;
}
@Override
public Object getFieldValue(Object nbt, String field) {
NBTTagCompound rec = (NBTTagCompound) nbt;
NBTBase val = rec.c(field);
if(val == null) return null;
if(val instanceof NBTTagByte) {
return ((NBTTagByte)val).h();
}
else if(val instanceof NBTTagShort) {
return ((NBTTagShort)val).g();
}
else if(val instanceof NBTTagInt) {
return ((NBTTagInt)val).f();
}
else if(val instanceof NBTTagLong) {
return ((NBTTagLong)val).e();
}
else if(val instanceof NBTTagFloat) {
return ((NBTTagFloat)val).j();
}
else if(val instanceof NBTTagDouble) {
return ((NBTTagDouble)val).i();
}
else if(val instanceof NBTTagByteArray) {
return ((NBTTagByteArray)val).d();
}
else if(val instanceof NBTTagString) {
return ((NBTTagString)val).f_();
}
else if(val instanceof NBTTagIntArray) {
return ((NBTTagIntArray)val).f();
}
return null;
}
@Override
public Player[] getOnlinePlayers() {
Collection<? extends Player> p = Bukkit.getServer().getOnlinePlayers();
return p.toArray(new Player[0]);
}
@Override
public double getHealth(Player p) {
return p.getHealth();
}
private static final Gson gson = new GsonBuilder().create();
/**
* Get skin URL for player
* @param player
*/
@Override
public String getSkinURL(Player player) {
String url = null;
CraftPlayer cp = (CraftPlayer)player;
GameProfile profile = cp.getProfile();
if (profile != null) {
PropertyMap pm = profile.getProperties();
if (pm != null) {
Collection<Property> txt = pm.get("textures");
Property textureProperty = Iterables.getFirst(pm.get("textures"), null);
if (textureProperty != null) {
String val = textureProperty.getValue();
if (val != null) {
TexturesPayload result = null;
try {
String json = new String(Base64.getDecoder().decode(val), StandardCharsets.UTF_8);
result = gson.fromJson(json, TexturesPayload.class);
} catch (JsonParseException e) {
} catch (IllegalArgumentException x) {
Log.warning("Malformed response from skin URL check: " + val);
}
if ((result != null) && (result.textures != null) && (result.textures.containsKey("SKIN"))) {
url = result.textures.get("SKIN").url;
}
}
}
}
}
return url;
}
// Get minY for world
@Override
public int getWorldMinY(World w) {
CraftWorld cw = (CraftWorld) w;
return cw.getMinHeight();
}
@Override
public boolean useGenericCache() {
return true;
}
}

View File

@ -0,0 +1,112 @@
package org.dynmap.bukkit.helper.v119_3;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.biome.BiomeFog;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
import org.dynmap.DynmapChunk;
import org.dynmap.bukkit.helper.BukkitVersionHelper;
import org.dynmap.bukkit.helper.BukkitWorld;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericChunkCache;
import org.dynmap.common.chunk.GenericMapChunkCache;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.level.ChunkCoordIntPair;
import net.minecraft.world.level.chunk.storage.ChunkRegionLoader;
import net.minecraft.world.level.chunk.Chunk;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.function.Supplier;
/**
* Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread
*/
public class MapChunkCache119_3 extends GenericMapChunkCache {
private static final AsyncChunkProvider119_3 provider = BukkitVersionHelper.helper.isUnsafeAsync() ? null : new AsyncChunkProvider119_3();
private World w;
/**
* Construct empty cache
*/
public MapChunkCache119_3(GenericChunkCache cc) {
super(cc);
}
// Load generic chunk from existing and already loaded chunk
@Override
protected Supplier<GenericChunk> getLoadedChunkAsync(DynmapChunk chunk) {
Supplier<NBTTagCompound> supplier = provider.getLoadedChunk((CraftWorld) w, chunk.x, chunk.z);
return () -> {
NBTTagCompound nbt = supplier.get();
return nbt != null ? parseChunkFromNBT(new NBT.NBTCompound(nbt)) : null;
};
}
protected GenericChunk getLoadedChunk(DynmapChunk chunk) {
CraftWorld cw = (CraftWorld) w;
if (!cw.isChunkLoaded(chunk.x, chunk.z)) return null;
Chunk c = cw.getHandle().getChunkIfLoaded(chunk.x, chunk.z);
if (c == null || !c.o) return null; // c.loaded
NBTTagCompound nbt = ChunkRegionLoader.a(cw.getHandle(), c);
return nbt != null ? parseChunkFromNBT(new NBT.NBTCompound(nbt)) : null;
}
// Load generic chunk from unloaded chunk
@Override
protected Supplier<GenericChunk> loadChunkAsync(DynmapChunk chunk){
try {
CompletableFuture<NBTTagCompound> nbt = provider.getChunk(((CraftWorld) w).getHandle(), chunk.x, chunk.z);
return () -> {
NBTTagCompound compound;
try {
compound = nbt.get();
} catch (InterruptedException e) {
return null;
} catch (ExecutionException e) {
throw new RuntimeException(e);
}
return compound == null ? null : parseChunkFromNBT(new NBT.NBTCompound(compound));
};
} catch (InvocationTargetException | IllegalAccessException ignored) {
return () -> null;
}
}
protected GenericChunk loadChunk(DynmapChunk chunk) {
CraftWorld cw = (CraftWorld) w;
NBTTagCompound nbt = null;
ChunkCoordIntPair cc = new ChunkCoordIntPair(chunk.x, chunk.z);
GenericChunk gc = null;
try { // BUGBUG - convert this all to asyn properly, since now native async
nbt = cw.getHandle().k().a.f(cc).join().get(); // playerChunkMap
} catch (CancellationException cx) {
} catch (NoSuchElementException snex) {
}
if (nbt != null) {
gc = parseChunkFromNBT(new NBT.NBTCompound(nbt));
}
return gc;
}
public void setChunks(BukkitWorld dw, List<DynmapChunk> chunks) {
this.w = dw.getWorld();
super.setChunks(dw, chunks);
}
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<BiomeBase>getBiomeObject().map(BiomeBase::j).flatMap(BiomeFog::e).orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeFog fog = bm.<BiomeBase>getBiomeObject().map(BiomeBase::j).orElse(null);
if (fog == null) return colormap[bm.biomeLookup()];
return fog.g().a(x, z, fog.f().orElse(colormap[bm.biomeLookup()]));
}
}

View File

@ -0,0 +1,126 @@
package org.dynmap.bukkit.helper.v119_3;
import org.dynmap.common.chunk.GenericBitStorage;
import org.dynmap.common.chunk.GenericNBTCompound;
import org.dynmap.common.chunk.GenericNBTList;
import java.util.Set;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.SimpleBitStorage;
public class NBT {
public static class NBTCompound implements GenericNBTCompound {
private final NBTTagCompound obj;
public NBTCompound(NBTTagCompound t) {
this.obj = t;
}
@Override
public Set<String> getAllKeys() {
return obj.e();
}
@Override
public boolean contains(String s) {
return obj.e(s);
}
@Override
public boolean contains(String s, int i) {
return obj.b(s, i);
}
@Override
public byte getByte(String s) {
return obj.f(s);
}
@Override
public short getShort(String s) {
return obj.g(s);
}
@Override
public int getInt(String s) {
return obj.h(s);
}
@Override
public long getLong(String s) {
return obj.i(s);
}
@Override
public float getFloat(String s) {
return obj.j(s);
}
@Override
public double getDouble(String s) {
return obj.k(s);
}
@Override
public String getString(String s) {
return obj.l(s);
}
@Override
public byte[] getByteArray(String s) {
return obj.m(s);
}
@Override
public int[] getIntArray(String s) {
return obj.n(s);
}
@Override
public long[] getLongArray(String s) {
return obj.o(s);
}
@Override
public GenericNBTCompound getCompound(String s) {
return new NBTCompound(obj.p(s));
}
@Override
public GenericNBTList getList(String s, int i) {
return new NBTList(obj.c(s, i));
}
@Override
public boolean getBoolean(String s) {
return obj.q(s);
}
@Override
public String getAsString(String s) {
return obj.c(s).f_();
}
@Override
public GenericBitStorage makeBitStorage(int bits, int count, long[] data) {
return new OurBitStorage(bits, count, data);
}
public String toString() {
return obj.toString();
}
}
public static class NBTList implements GenericNBTList {
private final NBTTagList obj;
public NBTList(NBTTagList t) {
obj = t;
}
@Override
public int size() {
return obj.size();
}
@Override
public String getString(int idx) {
return obj.j(idx);
}
@Override
public GenericNBTCompound getCompound(int idx) {
return new NBTCompound(obj.a(idx));
}
public String toString() {
return obj.toString();
}
}
public static class OurBitStorage implements GenericBitStorage {
private final SimpleBitStorage bs;
public OurBitStorage(int bits, int count, long[] data) {
bs = new SimpleBitStorage(bits, count, data);
}
@Override
public int get(int idx) {
return bs.a(idx);
}
}
}

View File

@ -17,8 +17,7 @@ import java.util.Arrays;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
/**
@ -27,59 +26,63 @@ import java.util.function.Supplier;
*/
@SuppressWarnings({"JavaReflectionMemberAccess"}) //java don't know about paper
public class AsyncChunkProvider119 {
private final Thread ioThread;
private final Method getChunk;
private final Predicate<NBTTagCompound> ifFailed;
private final Method getAsyncSaveData;
private final Method save;
private final Enum<?> data;
private final Enum<?> priority;
private int currTick = MinecraftServer.currentTick;
private int currChunks = 0;
AsyncChunkProvider119() {
try {
Predicate<NBTTagCompound> ifFailed1 = null;
Method getChunk1 = null, getAsyncSaveData1 = null, save1 = null;
Thread ioThread1 = null;
Method getChunk1 = null;
Method getAsyncSaveData1 = null;
Method save1 = null;
Enum<?> priority1 = null;
Enum<?> data1 = null;
try {
Class<?> threadClass = Class.forName("com.destroystokyo.paper.io.PaperFileIOThread");
Class<?> asyncChunkData = Arrays.stream(ChunkRegionLoader.class.getClasses())
.filter(c -> c.getSimpleName().equals("AsyncSaveData"))
.findFirst()
.orElseThrow(RuntimeException::new);
Class<?> threadClass = Class.forName("io.papermc.paper.chunk.system.io.RegionFileIOThread");
Class<?> dataclass = Arrays.stream(threadClass.getDeclaredClasses())
.filter(c -> c.getSimpleName().equals("RegionFileType"))
.findAny()
.orElseThrow(NullPointerException::new);
data1 = Enum.valueOf(cast(dataclass), "CHUNK_DATA");
Class<?> priorityClass = Arrays.stream(Class.forName("ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor").getClasses())
.filter(c -> c.getSimpleName().equals("Priority"))
.findAny()
.orElseThrow(NullPointerException::new);
//Almost lowest priority, but not quite so low as to be considered idle
//COMPLETING->BLOCKING->HIGHEST->HIGHER->HIGH->NORMAL->LOW->LOWER->LOWEST->IDLE
priority1 = Enum.valueOf(cast(priorityClass), "LOWEST");
getAsyncSaveData1 = ChunkRegionLoader.class.getMethod("getAsyncSaveData", WorldServer.class, IChunkAccess.class);
save1 = ChunkRegionLoader.class.getMethod("saveChunk", WorldServer.class, IChunkAccess.class, asyncChunkData);
Class<?>[] classes = threadClass.getClasses();
Class<?> holder = Arrays.stream(classes).filter(aClass -> aClass.getSimpleName().equals("Holder")).findAny().orElseThrow(RuntimeException::new);
ioThread1 = (Thread) holder.getField("INSTANCE").get(null);
getChunk1 = threadClass.getMethod("loadChunkDataAsync", WorldServer.class, int.class, int.class, int.class, Consumer.class, boolean.class, boolean.class, boolean.class);
NBTTagCompound failure = (NBTTagCompound) threadClass.getField("FAILURE_VALUE").get(null);
ifFailed1 = nbtTagCompound -> nbtTagCompound == failure;
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException | NoSuchMethodException e) {
save1 = ChunkRegionLoader.class.getMethod("saveChunk", WorldServer.class, IChunkAccess.class, getAsyncSaveData1.getReturnType());
getChunk1 = threadClass.getMethod("loadDataAsync", WorldServer.class, int.class, int.class, data1.getClass(), BiConsumer.class, boolean.class, priority1.getClass());
} catch (ClassNotFoundException | NoSuchMethodException e) {
e.printStackTrace();
}
getAsyncSaveData = Objects.requireNonNull(getAsyncSaveData1);
save = Objects.requireNonNull(save1);
ifFailed = Objects.requireNonNull(ifFailed1);
getChunk = Objects.requireNonNull(getChunk1);
ioThread = Objects.requireNonNull(ioThread1);
data = Objects.requireNonNull(data1);
priority = Objects.requireNonNull(priority1);
} catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
@SuppressWarnings("unchecked")
private <T> T cast(Object o) {
return (T) o;
}
public CompletableFuture<NBTTagCompound> getChunk(WorldServer world, int x, int y) throws InvocationTargetException, IllegalAccessException {
CompletableFuture<Object> future = new CompletableFuture<>();
getChunk.invoke(ioThread,world,x,y,5,(Consumer<Object>) future::complete, false, true, true);
return future.thenApply((resultFuture) -> {
if (resultFuture == null) return null;
try {
NBTTagCompound compound = (NBTTagCompound) resultFuture.getClass().getField("chunkData").get(resultFuture);
return ifFailed.test(compound) ? null : compound;
} catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace();
}
return null;
});
CompletableFuture<NBTTagCompound> future = new CompletableFuture<>();
getChunk.invoke(null, world, x, y, data, (BiConsumer<NBTTagCompound, Throwable>) (nbt, exception) -> future.complete(nbt), true, priority);
return future;
}
public synchronized Supplier<NBTTagCompound> getLoadedChunk(CraftWorld world, int x, int z) {

View File

@ -69,7 +69,7 @@ public class BukkitVersionHelperSpigot119 extends BukkitVersionHelper {
public BukkitVersionHelperSpigot119() {
boolean unsafeAsync1;
try {
Class.forName("com.destroystokyo.paper.io.PaperFileIOThread");
Class.forName("io.papermc.paper.chunk.system.io.RegionFileIOThread");
unsafeAsync1 = false;
} catch (ClassNotFoundException e) {
unsafeAsync1 = true;

View File

@ -1,10 +1,13 @@
package org.dynmap.bukkit.helper.v119;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.biome.BiomeFog;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
import org.dynmap.DynmapChunk;
import org.dynmap.bukkit.helper.BukkitVersionHelper;
import org.dynmap.bukkit.helper.BukkitWorld;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericChunkCache;
import org.dynmap.common.chunk.GenericMapChunkCache;
@ -94,4 +97,16 @@ public class MapChunkCache119 extends GenericMapChunkCache {
this.w = dw.getWorld();
super.setChunks(dw, chunks);
}
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<BiomeBase>getBiomeObject().map(BiomeBase::j).flatMap(BiomeFog::e).orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeFog fog = bm.<BiomeBase>getBiomeObject().map(BiomeBase::j).orElse(null);
if (fog == null) return colormap[bm.biomeLookup()];
return fog.g().a(x, z, fog.f().orElse(colormap[bm.biomeLookup()]));
}
}

View File

@ -2,32 +2,35 @@
<projectDescription>
<name>Dynmap(Spigot-Common)</name>
<comment>bukkit-helper</comment>
<projects/>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments/>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments/>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments/>
</buildCommand>
</buildSpec>
<linkedResources/>
<filteredResources>
<filter>
<id>1</id>
<name></name>
<type>30</type>
<name/>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>

View File

@ -2,7 +2,7 @@ arguments=
auto.sync=false
build.scans.enabled=false
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(6.3))
connection.project.dir=../bukkit-helper-118-2
connection.project.dir=../bukkit-helper-119-3
eclipse.preferences.version=1
gradle.user.home=
java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home

View File

@ -1,5 +1,5 @@
#
#Sat Aug 06 12:45:10 CDT 2022
#Thu Dec 08 19:56:33 CST 2022
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8

View File

@ -396,6 +396,7 @@ public class DynmapPlugin {
bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
}
bmap.setBiomeObject(bb);
}
}
if (cnt > 0)

View File

@ -7,12 +7,16 @@ import net.minecraft.server.world.ThreadedAnvilChunkStorage;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.ChunkSerializer;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.chunk.ChunkManager;
import net.minecraft.world.chunk.ChunkStatus;
import org.dynmap.DynmapChunk;
import org.dynmap.Log;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericMapChunkCache;
import org.dynmap.fabric_1_16_4.mixin.BiomeEffectsAccessor;
import java.util.*;
@ -85,5 +89,29 @@ public class FabricMapChunkCache extends GenericMapChunkCache {
}
return gc;
}
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<Biome>getBiomeObject()
.map(Biome::getEffects)
.map(BiomeEffectsAccessor.class::cast)
.flatMap(BiomeEffectsAccessor::getFoliageColor)
.orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeEffectsAccessor effects = (BiomeEffectsAccessor) bm.<Biome>getBiomeObject().map(Biome::getEffects).orElse(null);
if (effects == null) return colormap[bm.biomeLookup()];
int grassMult = effects.getGrassColor().orElse(colormap[bm.biomeLookup()]);
BiomeEffects.GrassColorModifier modifier = effects.getGrassColorModifier();
if (modifier == BiomeEffects.GrassColorModifier.DARK_FOREST) {
return ((grassMult & 0xfefefe) + 0x28340a) >> 1;
} else if (modifier == BiomeEffects.GrassColorModifier.SWAMP) {
double var5 = Biome.FOLIAGE_NOISE.sample(x * 0.0225, z * 0.0225, false);
return var5 < -0.1 ? 0x4c763c : 0x6a7039;
} else {
return grassMult;
}
}
}

View File

@ -4,8 +4,16 @@ import net.minecraft.world.biome.BiomeEffects;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.Optional;
@Mixin(BiomeEffects.class)
public interface BiomeEffectsAccessor {
@Accessor
int getWaterColor();
@Accessor
Optional<Integer> getFoliageColor();
@Accessor
Optional<Integer> getGrassColor();
@Accessor
BiomeEffects.GrassColorModifier getGrassColorModifier();
}

View File

@ -397,6 +397,7 @@ public class DynmapPlugin {
bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
}
bmap.setBiomeObject(bb);
}
}
if (cnt > 0)

View File

@ -7,10 +7,13 @@ import net.minecraft.server.world.ThreadedAnvilChunkStorage;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.ChunkSerializer;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.chunk.ChunkManager;
import net.minecraft.world.chunk.ChunkStatus;
import org.dynmap.DynmapChunk;
import org.dynmap.Log;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericMapChunkCache;
@ -83,4 +86,15 @@ public class FabricMapChunkCache extends GenericMapChunkCache {
}
return gc;
}
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<Biome>getBiomeObject().map(Biome::getEffects).flatMap(BiomeEffects::getFoliageColor).orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeEffects effects = bm.<Biome>getBiomeObject().map(Biome::getEffects).orElse(null);
if (effects == null) return colormap[bm.biomeLookup()];
return effects.getGrassColorModifier().getModifiedGrassColor(x, z, effects.getGrassColor().orElse(colormap[bm.biomeLookup()]));
}
}

View File

@ -374,6 +374,7 @@ public class DynmapPlugin {
bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
}
bmap.setBiomeObject(bb);
}
}
if (cnt > 0)

View File

@ -12,6 +12,7 @@ import net.minecraft.util.registry.Registry;
import net.minecraft.world.ChunkSerializer;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.chunk.ChunkManager;
import net.minecraft.world.chunk.ChunkStatus;
@ -100,4 +101,15 @@ public class FabricMapChunkCache extends GenericMapChunkCache {
}
return gc;
}
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<Biome>getBiomeObject().map(Biome::getEffects).flatMap(BiomeEffects::getFoliageColor).orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeEffects effects = bm.<Biome>getBiomeObject().map(Biome::getEffects).orElse(null);
if (effects == null) return colormap[bm.biomeLookup()];
return effects.getGrassColorModifier().getModifiedGrassColor(x, z, effects.getGrassColor().orElse(colormap[bm.biomeLookup()]));
}
}

View File

@ -367,6 +367,7 @@ public class DynmapPlugin {
bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
}
bmap.setBiomeObject(bb);
}
}
if (cnt > 0)

View File

@ -12,6 +12,7 @@ import net.minecraft.util.registry.Registry;
import net.minecraft.world.ChunkSerializer;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.chunk.ChunkManager;
import net.minecraft.world.chunk.ChunkStatus;
@ -100,4 +101,15 @@ public class FabricMapChunkCache extends GenericMapChunkCache {
}
return gc;
}
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<Biome>getBiomeObject().map(Biome::getEffects).flatMap(BiomeEffects::getFoliageColor).orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeEffects effects = bm.<Biome>getBiomeObject().map(Biome::getEffects).orElse(null);
if (effects == null) return colormap[bm.biomeLookup()];
return effects.getGrassColorModifier().getModifiedGrassColor(x, z, effects.getGrassColor().orElse(colormap[bm.biomeLookup()]));
}
}

View File

@ -362,6 +362,7 @@ public class DynmapPlugin {
bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
}
bmap.setBiomeObject(bb);
}
}
if (cnt > 0)

View File

@ -12,6 +12,7 @@ import net.minecraft.util.registry.Registry;
import net.minecraft.world.ChunkSerializer;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.chunk.ChunkManager;
import net.minecraft.world.chunk.ChunkStatus;
@ -101,4 +102,15 @@ public class FabricMapChunkCache extends GenericMapChunkCache {
}
return gc;
}
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<Biome>getBiomeObject().map(Biome::getEffects).flatMap(BiomeEffects::getFoliageColor).orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeEffects effects = bm.<Biome>getBiomeObject().map(Biome::getEffects).orElse(null);
if (effects == null) return colormap[bm.biomeLookup()];
return effects.getGrassColorModifier().getModifiedGrassColor(x, z, effects.getGrassColor().orElse(colormap[bm.biomeLookup()]));
}
}

32
fabric-1.19.3/.gitignore vendored Normal file
View File

@ -0,0 +1,32 @@
# gradle
.gradle/
build/
out/
classes/
# eclipse
*.launch
# idea
.idea/
*.iml
*.ipr
*.iws
# vscode
.settings/
.vscode/
bin/
.classpath
.project
# fabric
run/
# other
*.log

View File

@ -0,0 +1,67 @@
plugins {
id 'fabric-loom' version '1.0.12'
}
archivesBaseName = "Dynmap"
version = parent.version
group = parent.group
eclipse {
project {
name = "Dynmap(Fabric-1.19.3)"
}
}
configurations {
shadow
implementation.extendsFrom(shadow)
}
repositories {
mavenCentral()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
compileOnly group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
shadow project(path: ':DynmapCore', configuration: 'shadow')
modCompileOnly "me.lucko:fabric-permissions-api:0.1-SNAPSHOT"
compileOnly 'net.luckperms:api:5.4'
}
processResources {
filesMatching('fabric.mod.json') {
expand "version": project.version
}
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}
jar {
from "LICENSE"
from {
configurations.shadow.collect { it.toString().contains("guava") ? null : it.isDirectory() ? it : zipTree(it) }
}
}
remapJar {
archiveFileName = "${archivesBaseName}-${project.version}-fabric-${project.minecraft_version}.jar"
destinationDirectory = file '../target'
}
remapJar.doLast {
task ->
ant.checksum file: task.archivePath
}

View File

@ -0,0 +1,4 @@
minecraft_version=1.19.3
yarn_mappings=1.19.3+build.2
loader_version=0.14.11
fabric_version=0.68.1+1.19.3

View File

@ -0,0 +1,50 @@
package org.dynmap.fabric_1_19_3;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import org.dynmap.DynmapCore;
import org.dynmap.Log;
import java.io.File;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
public class DynmapMod implements ModInitializer {
private static final String MODID = "dynmap";
private static final ModContainer MOD_CONTAINER = FabricLoader.getInstance().getModContainer(MODID)
.orElseThrow(() -> new RuntimeException("Failed to get mod container: " + MODID));
// The instance of your mod that Fabric uses.
public static DynmapMod instance;
public static DynmapPlugin plugin;
public static File jarfile;
public static String ver;
public static boolean useforcedchunks;
@Override
public void onInitialize() {
instance = this;
Path path = MOD_CONTAINER.getRootPath();
try {
jarfile = new File(DynmapCore.class.getProtectionDomain().getCodeSource().getLocation().toURI());
} catch (URISyntaxException e) {
Log.severe("Unable to get DynmapCore jar path", e);
}
if (path.getFileSystem().provider().getScheme().equals("jar")) {
path = Paths.get(path.getFileSystem().toString());
jarfile = path.toFile();
}
ver = MOD_CONTAINER.getMetadata().getVersion().getFriendlyString();
Log.setLogger(new FabricLogger());
org.dynmap.modsupport.ModSupportImpl.init();
// Initialize the plugin, we will enable it fully when the server starts.
plugin = new DynmapPlugin();
}
}

View File

@ -0,0 +1,801 @@
package org.dynmap.fabric_1_19_3;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerWorldEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FluidBlock;
import net.minecraft.block.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.network.ClientConnection;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.Identifier;
import net.minecraft.util.collection.IdList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.EmptyBlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldAccess;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.ChunkSection;
import org.dynmap.*;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.DynmapCommandSender;
import org.dynmap.common.DynmapListenerManager;
import org.dynmap.common.DynmapPlayer;
import org.dynmap.common.chunk.GenericChunkCache;
import org.dynmap.fabric_1_19_3.command.DmapCommand;
import org.dynmap.fabric_1_19_3.command.DmarkerCommand;
import org.dynmap.fabric_1_19_3.command.DynmapCommand;
import org.dynmap.fabric_1_19_3.command.DynmapExpCommand;
import org.dynmap.fabric_1_19_3.event.BlockEvents;
import org.dynmap.fabric_1_19_3.event.CustomServerChunkEvents;
import org.dynmap.fabric_1_19_3.event.CustomServerLifecycleEvents;
import org.dynmap.fabric_1_19_3.event.PlayerEvents;
import org.dynmap.fabric_1_19_3.mixin.BiomeEffectsAccessor;
import org.dynmap.fabric_1_19_3.permissions.*;
import org.dynmap.permissions.PermissionsHandler;
import org.dynmap.renderer.DynmapBlockState;
import java.io.File;
import java.util.*;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.regex.Pattern;
public class DynmapPlugin {
// FIXME: Fix package-private fields after splitting is done
DynmapCore core;
private PermissionProvider permissions;
private boolean core_enabled;
public GenericChunkCache sscache;
public PlayerList playerList;
MapManager mapManager;
/**
* Server is set when running and unset at shutdown.
*/
private net.minecraft.server.MinecraftServer server;
public static DynmapPlugin plugin;
ChatHandler chathandler;
private HashMap<String, Integer> sortWeights = new HashMap<String, Integer>();
private HashMap<String, FabricWorld> worlds = new HashMap<String, FabricWorld>();
private WorldAccess last_world;
private FabricWorld last_fworld;
private Map<String, FabricPlayer> players = new HashMap<String, FabricPlayer>();
private FabricServer fserver;
private boolean tickregistered = false;
// TPS calculator
double tps;
long lasttick;
long avgticklen;
// Per tick limit, in nsec
long perTickLimit = (50000000); // 50 ms
private boolean useSaveFolder = true;
private static final String[] TRIGGER_DEFAULTS = {"blockupdate", "chunkpopulate", "chunkgenerate"};
static final Pattern patternControlCode = Pattern.compile("(?i)\\u00A7[0-9A-FK-OR]");
DynmapPlugin() {
plugin = this;
// Fabric events persist between server instances
ServerLifecycleEvents.SERVER_STARTING.register(this::serverStart);
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> registerCommands(dispatcher));
CustomServerLifecycleEvents.SERVER_STARTED_PRE_WORLD_LOAD.register(this::serverStarted);
ServerLifecycleEvents.SERVER_STOPPING.register(this::serverStop);
}
int getSortWeight(String name) {
return sortWeights.getOrDefault(name, 0);
}
void setSortWeight(String name, int wt) {
sortWeights.put(name, wt);
}
void dropSortWeight(String name) {
sortWeights.remove(name);
}
public static class BlockUpdateRec {
WorldAccess w;
String wid;
int x, y, z;
}
ConcurrentLinkedQueue<BlockUpdateRec> blockupdatequeue = new ConcurrentLinkedQueue<BlockUpdateRec>();
public static DynmapBlockState[] stateByID;
/**
* Initialize block states (org.dynmap.blockstate.DynmapBlockState)
*/
public void initializeBlockStates() {
stateByID = new DynmapBlockState[512 * 32]; // Simple map - scale as needed
Arrays.fill(stateByID, DynmapBlockState.AIR); // Default to air
IdList<BlockState> bsids = Block.STATE_IDS;
DynmapBlockState basebs = null;
Block baseb = null;
int baseidx = 0;
Iterator<BlockState> iter = bsids.iterator();
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
while (iter.hasNext()) {
BlockState bs = iter.next();
int idx = bsids.getRawId(bs);
if (idx >= stateByID.length) {
int plen = stateByID.length;
stateByID = Arrays.copyOf(stateByID, idx*11/10); // grow array by 10%
Arrays.fill(stateByID, plen, stateByID.length, DynmapBlockState.AIR);
}
Block b = bs.getBlock();
// If this is new block vs last, it's the base block state
if (b != baseb) {
basebs = null;
baseidx = idx;
baseb = b;
}
Identifier ui = Registries.BLOCK.getId(b);
if (ui == null) {
continue;
}
String bn = ui.getNamespace() + ":" + ui.getPath();
// Only do defined names, and not "air"
if (!bn.equals(DynmapBlockState.AIR_BLOCK)) {
Material mat = bs.getMaterial();
String statename = "";
for (net.minecraft.state.property.Property<?> p : bs.getProperties()) {
if (statename.length() > 0) {
statename += ",";
}
statename += p.getName() + "=" + bs.get(p).toString();
}
int lightAtten = bs.isOpaqueFullCube(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 15 : (bs.isTranslucent(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 0 : 1);
//Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten);
// Fill in base attributes
bld.setBaseState(basebs).setStateIndex(idx - baseidx).setBlockName(bn).setStateName(statename).setMaterial(mat.toString()).setLegacyBlockID(idx).setAttenuatesLight(lightAtten);
if (mat.isSolid()) { bld.setSolid(); }
if (mat == Material.AIR) { bld.setAir(); }
if (mat == Material.WOOD) { bld.setLog(); }
if (mat == Material.LEAVES) { bld.setLeaves(); }
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof FluidBlock)) {
bld.setWaterlogged();
}
DynmapBlockState dbs = bld.build(); // Build state
stateByID[idx] = dbs;
if (basebs == null) { basebs = dbs; }
}
}
// for (int gidx = 0; gidx < DynmapBlockState.getGlobalIndexMax(); gidx++) {
// DynmapBlockState bs = DynmapBlockState.getStateByGlobalIndex(gidx);
// Log.info(gidx + ":" + bs.toString() + ", gidx=" + bs.globalStateIndex + ", sidx=" + bs.stateIndex);
// }
}
public static final Item getItemByID(int id) {
return Item.byRawId(id);
}
public static final ClientConnection getNetworkManager(ServerPlayNetworkHandler nh) {
return nh.connection;
}
FabricPlayer getOrAddPlayer(ServerPlayerEntity player) {
String name = player.getName().getString();
FabricPlayer fp = players.get(name);
if (fp != null) {
fp.player = player;
} else {
fp = new FabricPlayer(this, player);
players.put(name, fp);
}
return fp;
}
static class ChatMessage {
String message;
ServerPlayerEntity sender;
}
ConcurrentLinkedQueue<ChatMessage> msgqueue = new ConcurrentLinkedQueue<ChatMessage>();
public static class ChatHandler {
private final DynmapPlugin plugin;
ChatHandler(DynmapPlugin plugin) {
this.plugin = plugin;
}
public void handleChat(ServerPlayerEntity player, String message) {
if (!message.startsWith("/")) {
ChatMessage cm = new ChatMessage();
cm.message = message;
cm.sender = player;
plugin.msgqueue.add(cm);
}
}
}
public FabricServer getFabricServer() {
return fserver;
}
private void serverStart(MinecraftServer server) {
// Set the server so we don't NPE during setup
this.server = server;
this.fserver = new FabricServer(this, server);
this.onEnable();
}
private void serverStarted(MinecraftServer server) {
this.onStart();
if (core != null) {
core.serverStarted();
}
}
private void serverStop(MinecraftServer server) {
this.onDisable();
this.server = null;
}
public boolean isOp(String player) {
String[] ops = server.getPlayerManager().getOpList().getNames();
for (String op : ops) {
if (op.equalsIgnoreCase(player)) {
return true;
}
}
// TODO: Consider whether cheats are enabled for integrated server
return server.isSingleplayer() && server.isHost(server.getPlayerManager().getPlayer(player).getGameProfile());
}
boolean hasPerm(PlayerEntity psender, String permission) {
PermissionsHandler ph = PermissionsHandler.getHandler();
if ((ph != null) && (psender != null) && ph.hasPermission(psender.getName().getString(), permission)) {
return true;
}
return permissions.has(psender, permission);
}
boolean hasPermNode(PlayerEntity psender, String permission) {
PermissionsHandler ph = PermissionsHandler.getHandler();
if ((ph != null) && (psender != null) && ph.hasPermissionNode(psender.getName().getString(), permission)) {
return true;
}
return permissions.hasPermissionNode(psender, permission);
}
Set<String> hasOfflinePermissions(String player, Set<String> perms) {
Set<String> rslt = null;
PermissionsHandler ph = PermissionsHandler.getHandler();
if (ph != null) {
rslt = ph.hasOfflinePermissions(player, perms);
}
Set<String> rslt2 = hasOfflinePermissions(player, perms);
if ((rslt != null) && (rslt2 != null)) {
Set<String> newrslt = new HashSet<String>(rslt);
newrslt.addAll(rslt2);
rslt = newrslt;
} else if (rslt2 != null) {
rslt = rslt2;
}
return rslt;
}
boolean hasOfflinePermission(String player, String perm) {
PermissionsHandler ph = PermissionsHandler.getHandler();
if (ph != null) {
if (ph.hasOfflinePermission(player, perm)) {
return true;
}
}
return permissions.hasOfflinePermission(player, perm);
}
void setChatHandler(ChatHandler chatHandler) {
plugin.chathandler = chatHandler;
}
public class TexturesPayload {
public long timestamp;
public String profileId;
public String profileName;
public boolean isPublic;
public Map<String, ProfileTexture> textures;
}
public class ProfileTexture {
public String url;
}
public void loadExtraBiomes(String mcver) {
int cnt = 0;
BiomeMap.loadWellKnownByVersion(mcver);
Registry<Biome> biomeRegistry = getFabricServer().getBiomeRegistry();
Biome[] list = getFabricServer().getBiomeList(biomeRegistry);
for (int i = 0; i < list.length; i++) {
Biome bb = list[i];
if (bb != null) {
String id = biomeRegistry.getId(bb).getPath();
String rl = biomeRegistry.getId(bb).toString();
float tmp = bb.getTemperature(), hum = bb.getDownfall();
int watermult = ((BiomeEffectsAccessor) bb.getEffects()).getWaterColor();
Log.verboseinfo("biome[" + i + "]: hum=" + hum + ", tmp=" + tmp + ", mult=" + Integer.toHexString(watermult));
BiomeMap bmap = BiomeMap.NULL;
if (rl != null) { // If resource location, lookup by this
bmap = BiomeMap.byBiomeResourceLocation(rl);
}
else {
bmap = BiomeMap.byBiomeID(i);
}
if (bmap.isDefault() || (bmap == BiomeMap.NULL)) {
bmap = new BiomeMap((rl != null) ? BiomeMap.NO_INDEX : i, id, tmp, hum, rl);
Log.verboseinfo("Add custom biome [" + bmap.toString() + "] (" + i + ")");
cnt++;
}
else {
bmap.setTemperature(tmp);
bmap.setRainfall(hum);
}
if (watermult != -1) {
bmap.setWaterColorMultiplier(watermult);
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
}
bmap.setBiomeObject(bb);
}
}
if (cnt > 0)
Log.info("Added " + cnt + " custom biome mappings");
}
private String[] getBiomeNames() {
Registry<Biome> biomeRegistry = getFabricServer().getBiomeRegistry();
Biome[] list = getFabricServer().getBiomeList(biomeRegistry);
String[] lst = new String[list.length];
for (int i = 0; i < list.length; i++) {
Biome bb = list[i];
if (bb != null) {
lst[i] = biomeRegistry.getId(bb).getPath();
}
}
return lst;
}
public void onEnable() {
/* Get MC version */
String mcver = server.getVersion();
/* Load extra biomes */
loadExtraBiomes(mcver);
/* Set up player login/quit event handler */
registerPlayerLoginListener();
/* Initialize permissions handler */
if (FabricLoader.getInstance().isModLoaded("luckperms")) {
Log.info("Using luckperms for access control");
permissions = new LuckPermissions();
}
else if (FabricLoader.getInstance().isModLoaded("fabric-permissions-api-v0")) {
Log.info("Using fabric-permissions-api for access control");
permissions = new FabricPermissions();
} else {
/* Initialize permissions handler */
permissions = FilePermissions.create();
if (permissions == null) {
permissions = new OpPermissions(new String[]{"webchat", "marker.icons", "marker.list", "webregister", "stats", "hide.self", "show.self"});
}
}
/* Get and initialize data folder */
File dataDirectory = new File("dynmap");
if (!dataDirectory.exists()) {
dataDirectory.mkdirs();
}
/* Instantiate core */
if (core == null) {
core = new DynmapCore();
}
/* Inject dependencies */
core.setPluginJarFile(DynmapMod.jarfile);
core.setPluginVersion(DynmapMod.ver);
core.setMinecraftVersion(mcver);
core.setDataFolder(dataDirectory);
core.setServer(fserver);
core.setTriggerDefault(TRIGGER_DEFAULTS);
core.setBiomeNames(getBiomeNames());
if (!core.initConfiguration(null)) {
return;
}
// Extract default permission example, if needed
File filepermexample = new File(core.getDataFolder(), "permissions.yml.example");
core.createDefaultFileFromResource("/permissions.yml.example", filepermexample);
DynmapCommonAPIListener.apiInitialized(core);
}
private DynmapCommand dynmapCmd;
private DmapCommand dmapCmd;
private DmarkerCommand dmarkerCmd;
private DynmapExpCommand dynmapexpCmd;
public void registerCommands(CommandDispatcher<ServerCommandSource> cd) {
dynmapCmd = new DynmapCommand(this);
dmapCmd = new DmapCommand(this);
dmarkerCmd = new DmarkerCommand(this);
dynmapexpCmd = new DynmapExpCommand(this);
dynmapCmd.register(cd);
dmapCmd.register(cd);
dmarkerCmd.register(cd);
dynmapexpCmd.register(cd);
Log.info("Register commands");
}
public void onStart() {
initializeBlockStates();
/* Enable core */
if (!core.enableCore(null)) {
return;
}
core_enabled = true;
VersionCheck.runCheck(core);
// Get per tick time limit
perTickLimit = core.getMaxTickUseMS() * 1000000;
// Prep TPS
lasttick = System.nanoTime();
tps = 20.0;
/* Register tick handler */
if (!tickregistered) {
ServerTickEvents.END_SERVER_TICK.register(server -> fserver.tickEvent(server));
tickregistered = true;
}
playerList = core.playerList;
sscache = new GenericChunkCache(core.getSnapShotCacheSize(), core.useSoftRefInSnapShotCache());
/* Get map manager from core */
mapManager = core.getMapManager();
/* Load saved world definitions */
loadWorlds();
for (FabricWorld w : worlds.values()) {
if (core.processWorldLoad(w)) { /* Have core process load first - fire event listeners if good load after */
if (w.isLoaded()) {
core.listenerManager.processWorldEvent(DynmapListenerManager.EventType.WORLD_LOAD, w);
}
}
}
core.updateConfigHashcode();
/* Register our update trigger events */
registerEvents();
Log.info("Register events");
//DynmapCommonAPIListener.apiInitialized(core);
Log.info("Enabled");
}
public void onDisable() {
DynmapCommonAPIListener.apiTerminated();
//if (metrics != null) {
// metrics.stop();
// metrics = null;
//}
/* Save worlds */
saveWorlds();
/* Purge tick queue */
fserver.clearTaskQueue();
/* Disable core */
core.disableCore();
core_enabled = false;
if (sscache != null) {
sscache.cleanup();
sscache = null;
}
Log.info("Disabled");
}
// TODO: Clean a bit
public void handleCommand(ServerCommandSource commandSource, String cmd, String[] args) throws CommandSyntaxException {
DynmapCommandSender dsender;
ServerPlayerEntity psender = null;
// getPlayer throws a CommandSyntaxException, so getEntity and instanceof for safety
if (commandSource.getEntity() instanceof ServerPlayerEntity) {
psender = commandSource.getPlayerOrThrow();
}
if (psender != null) {
// FIXME: New Player? Why not query the current player list.
dsender = new FabricPlayer(this, psender);
} else {
dsender = new FabricCommandSender(commandSource);
}
core.processCommand(dsender, cmd, cmd, args);
}
public class PlayerTracker {
public void onPlayerLogin(ServerPlayerEntity player) {
if (!core_enabled) return;
final DynmapPlayer dp = getOrAddPlayer(player);
/* This event can be called from off server thread, so push processing there */
core.getServer().scheduleServerTask(new Runnable() {
public void run() {
core.listenerManager.processPlayerEvent(DynmapListenerManager.EventType.PLAYER_JOIN, dp);
}
}, 2);
}
public void onPlayerLogout(ServerPlayerEntity player) {
if (!core_enabled) return;
final DynmapPlayer dp = getOrAddPlayer(player);
final String name = player.getName().getString();
/* This event can be called from off server thread, so push processing there */
core.getServer().scheduleServerTask(new Runnable() {
public void run() {
core.listenerManager.processPlayerEvent(DynmapListenerManager.EventType.PLAYER_QUIT, dp);
players.remove(name);
}
}, 0);
}
public void onPlayerChangedDimension(ServerPlayerEntity player) {
if (!core_enabled) return;
getOrAddPlayer(player); // Freshen player object reference
}
public void onPlayerRespawn(ServerPlayerEntity player) {
if (!core_enabled) return;
getOrAddPlayer(player); // Freshen player object reference
}
}
private PlayerTracker playerTracker = null;
private void registerPlayerLoginListener() {
if (playerTracker == null) {
playerTracker = new PlayerTracker();
PlayerEvents.PLAYER_LOGGED_IN.register(player -> playerTracker.onPlayerLogin(player));
PlayerEvents.PLAYER_LOGGED_OUT.register(player -> playerTracker.onPlayerLogout(player));
PlayerEvents.PLAYER_CHANGED_DIMENSION.register(player -> playerTracker.onPlayerChangedDimension(player));
PlayerEvents.PLAYER_RESPAWN.register(player -> playerTracker.onPlayerRespawn(player));
}
}
public class WorldTracker {
public void handleWorldLoad(MinecraftServer server, ServerWorld world) {
if (!core_enabled) return;
final FabricWorld fw = getWorld(world);
// This event can be called from off server thread, so push processing there
core.getServer().scheduleServerTask(new Runnable() {
public void run() {
if (core.processWorldLoad(fw)) // Have core process load first - fire event listeners if good load after
core.listenerManager.processWorldEvent(DynmapListenerManager.EventType.WORLD_LOAD, fw);
}
}, 0);
}
public void handleWorldUnload(MinecraftServer server, ServerWorld world) {
if (!core_enabled) return;
final FabricWorld fw = getWorld(world);
if (fw != null) {
// This event can be called from off server thread, so push processing there
core.getServer().scheduleServerTask(new Runnable() {
public void run() {
core.listenerManager.processWorldEvent(DynmapListenerManager.EventType.WORLD_UNLOAD, fw);
core.processWorldUnload(fw);
}
}, 0);
// Set world unloaded (needs to be immediate, since it may be invalid after event)
fw.setWorldUnloaded();
// Clean up tracker
//WorldUpdateTracker wut = updateTrackers.remove(fw.getName());
//if(wut != null) wut.world = null;
}
}
public void handleChunkGenerate(ServerWorld world, Chunk chunk) {
if (!onchunkgenerate) return;
FabricWorld fw = getWorld(world, false);
ChunkPos chunkPos = chunk.getPos();
int ymax = Integer.MIN_VALUE;
int ymin = Integer.MAX_VALUE;
ChunkSection[] sections = chunk.getSectionArray();
for (int i = 0; i < sections.length; i++) {
if ((sections[i] != null) && (!sections[i].isEmpty())) {
int sy = sections[i].getYOffset();
if (sy < ymin) ymin = sy;
if ((sy+16) > ymax) ymax = sy + 16;
}
}
if (ymax != Integer.MIN_VALUE) {
mapManager.touchVolume(fw.getName(),
chunkPos.getStartX(), ymin, chunkPos.getStartZ(),
chunkPos.getEndX(), ymax, chunkPos.getEndZ(),
"chunkgenerate");
//Log.info("New generated chunk detected at %s[%s]".formatted(fw.getName(), chunkPos.getStartPos()));
}
}
public void handleBlockEvent(World world, BlockPos pos) {
if (!core_enabled) return;
if (!onblockchange) return;
if (!(world instanceof ServerWorld)) return;
BlockUpdateRec r = new BlockUpdateRec();
r.w = world;
FabricWorld fw = getWorld(world, false);
if (fw == null) return;
r.wid = fw.getName();
r.x = pos.getX();
r.y = pos.getY();
r.z = pos.getZ();
blockupdatequeue.add(r);
}
}
private WorldTracker worldTracker = null;
private boolean onblockchange = false;
private boolean onchunkpopulate = false;
private boolean onchunkgenerate = false;
boolean onblockchange_with_id = false;
private void registerEvents() {
// To trigger rendering.
onblockchange = core.isTrigger("blockupdate");
onchunkpopulate = core.isTrigger("chunkpopulate");
onchunkgenerate = core.isTrigger("chunkgenerate");
onblockchange_with_id = core.isTrigger("blockupdate-with-id");
if (onblockchange_with_id)
onblockchange = true;
if (worldTracker == null)
worldTracker = new WorldTracker();
if (onchunkpopulate || onchunkgenerate) {
CustomServerChunkEvents.CHUNK_GENERATE.register((world, chunk) -> worldTracker.handleChunkGenerate(world, chunk));
}
if (onblockchange) {
BlockEvents.BLOCK_EVENT.register((world, pos) -> worldTracker.handleBlockEvent(world, pos));
}
ServerWorldEvents.LOAD.register((server, world) -> worldTracker.handleWorldLoad(server, world));
ServerWorldEvents.UNLOAD.register((server, world) -> worldTracker.handleWorldUnload(server, world));
}
FabricWorld getWorldByName(String name) {
return worlds.get(name);
}
FabricWorld getWorld(World w) {
return getWorld(w, true);
}
private FabricWorld getWorld(World w, boolean add_if_not_found) {
if (last_world == w) {
return last_fworld;
}
String wname = FabricWorld.getWorldName(this, w);
for (FabricWorld fw : worlds.values()) {
if (fw.getRawName().equals(wname)) {
last_world = w;
last_fworld = fw;
if (!fw.isLoaded()) {
fw.setWorldLoaded(w);
}
fw.updateWorld(w);
return fw;
}
}
FabricWorld fw = null;
if (add_if_not_found) {
/* Add to list if not found */
fw = new FabricWorld(this, w);
worlds.put(fw.getName(), fw);
}
last_world = w;
last_fworld = fw;
return fw;
}
private void saveWorlds() {
File f = new File(core.getDataFolder(), FabricWorld.SAVED_WORLDS_FILE);
ConfigurationNode cn = new ConfigurationNode(f);
ArrayList<HashMap<String, Object>> lst = new ArrayList<HashMap<String, Object>>();
for (DynmapWorld fw : core.mapManager.getWorlds()) {
HashMap<String, Object> vals = new HashMap<String, Object>();
vals.put("name", fw.getRawName());
vals.put("height", fw.worldheight);
vals.put("miny", fw.minY);
vals.put("sealevel", fw.sealevel);
vals.put("nether", fw.isNether());
vals.put("the_end", ((FabricWorld) fw).isTheEnd());
vals.put("title", fw.getTitle());
lst.add(vals);
}
cn.put("worlds", lst);
cn.put("useSaveFolderAsName", useSaveFolder);
cn.put("maxWorldHeight", FabricWorld.getMaxWorldHeight());
cn.save();
}
private void loadWorlds() {
File f = new File(core.getDataFolder(), FabricWorld.SAVED_WORLDS_FILE);
if (f.canRead() == false) {
useSaveFolder = true;
return;
}
ConfigurationNode cn = new ConfigurationNode(f);
cn.load();
// If defined, use maxWorldHeight
FabricWorld.setMaxWorldHeight(cn.getInteger("maxWorldHeight", 256));
// If setting defined, use it
if (cn.containsKey("useSaveFolderAsName")) {
useSaveFolder = cn.getBoolean("useSaveFolderAsName", useSaveFolder);
}
List<Map<String, Object>> lst = cn.getMapList("worlds");
if (lst == null) {
Log.warning(String.format("Discarding bad %s", FabricWorld.SAVED_WORLDS_FILE));
return;
}
for (Map<String, Object> world : lst) {
try {
String name = (String) world.get("name");
int height = (Integer) world.get("height");
Integer miny = (Integer) world.get("miny");
int sealevel = (Integer) world.get("sealevel");
boolean nether = (Boolean) world.get("nether");
boolean theend = (Boolean) world.get("the_end");
String title = (String) world.get("title");
if (name != null) {
FabricWorld fw = new FabricWorld(this, name, height, sealevel, nether, theend, title, (miny != null) ? miny : 0);
fw.setWorldUnloaded();
core.processWorldLoad(fw);
worlds.put(fw.getName(), fw);
}
} catch (Exception x) {
Log.warning(String.format("Unable to load saved worlds from %s", FabricWorld.SAVED_WORLDS_FILE));
return;
}
}
}
}

View File

@ -0,0 +1,13 @@
package org.dynmap.fabric_1_19_3;
import net.minecraft.server.world.ServerWorld;
import org.dynmap.DynmapLocation;
public final class FabricAdapter {
public static DynmapLocation toDynmapLocation(DynmapPlugin plugin, ServerWorld world, double x, double y, double z) {
return new DynmapLocation(plugin.getWorld(world).getName(), x, y, z);
}
private FabricAdapter() {
}
}

View File

@ -0,0 +1,47 @@
package org.dynmap.fabric_1_19_3;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.LiteralTextContent;
import net.minecraft.text.Text;
import org.dynmap.common.DynmapCommandSender;
/* Handler for generic console command sender */
public class FabricCommandSender implements DynmapCommandSender {
private ServerCommandSource sender;
protected FabricCommandSender() {
sender = null;
}
public FabricCommandSender(ServerCommandSource send) {
sender = send;
}
@Override
public boolean hasPrivilege(String privid) {
return true;
}
@Override
public void sendMessage(String msg) {
if (sender != null) {
Text ichatcomponent = Text.literal(msg);
sender.sendFeedback(ichatcomponent, false);
}
}
@Override
public boolean isConnected() {
return false;
}
@Override
public boolean isOp() {
return true;
}
@Override
public boolean hasPermissionNode(String node) {
return true;
}
}

View File

@ -0,0 +1,49 @@
package org.dynmap.fabric_1_19_3;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dynmap.utils.DynmapLogger;
public class FabricLogger implements DynmapLogger {
Logger log;
public static final String DM = "[Dynmap] ";
FabricLogger() {
log = LogManager.getLogger("Dynmap");
}
@Override
public void info(String s) {
log.info(DM + s);
}
@Override
public void severe(Throwable t) {
log.fatal(t);
}
@Override
public void severe(String s) {
log.fatal(DM + s);
}
@Override
public void severe(String s, Throwable t) {
log.fatal(DM + s, t);
}
@Override
public void verboseinfo(String s) {
log.info(DM + s);
}
@Override
public void warning(String s) {
log.warn(DM + s);
}
@Override
public void warning(String s, Throwable t) {
log.warn(DM + s, t);
}
}

View File

@ -0,0 +1,116 @@
package org.dynmap.fabric_1_19_3;
import net.minecraft.nbt.*;
import net.minecraft.server.world.ServerChunkManager;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.server.world.ThreadedAnvilChunkStorage;
import net.minecraft.util.collection.PackedIntegerArray;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.WordPackedArray;
import net.minecraft.world.ChunkSerializer;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.chunk.ChunkManager;
import net.minecraft.world.chunk.ChunkStatus;
import org.dynmap.DynmapChunk;
import org.dynmap.DynmapCore;
import org.dynmap.DynmapWorld;
import org.dynmap.Log;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.chunk.GenericChunk;
import org.dynmap.common.chunk.GenericChunkSection;
import org.dynmap.common.chunk.GenericMapChunkCache;
import org.dynmap.hdmap.HDBlockModels;
import org.dynmap.renderer.DynmapBlockState;
import org.dynmap.renderer.RenderPatchFactory;
import org.dynmap.utils.*;
import java.lang.reflect.Field;
import java.util.*;
/**
* Container for managing chunks - dependent upon using chunk snapshots, since rendering is off server thread
*/
public class FabricMapChunkCache extends GenericMapChunkCache {
private World w;
private ServerChunkManager cps;
/**
* Construct empty cache
*/
public FabricMapChunkCache(DynmapPlugin plugin) {
super(plugin.sscache);
}
public void setChunks(FabricWorld dw, List<DynmapChunk> chunks) {
this.w = dw.getWorld();
if (dw.isLoaded()) {
/* Check if world's provider is ServerChunkManager */
ChunkManager cp = this.w.getChunkManager();
if (cp instanceof ServerChunkManager) {
cps = (ServerChunkManager) cp;
} else {
Log.severe("Error: world " + dw.getName() + " has unsupported chunk provider");
}
}
super.setChunks(dw, chunks);
}
// Load generic chunk from existing and already loaded chunk
protected GenericChunk getLoadedChunk(DynmapChunk chunk) {
GenericChunk gc = null;
if (cps.isChunkLoaded(chunk.x, chunk.z)) {
NbtCompound nbt = null;
try {
nbt = ChunkSerializer.serialize((ServerWorld) w, cps.getWorldChunk(chunk.x, chunk.z, false));
} catch (NullPointerException e) {
// TODO: find out why this is happening and why it only seems to happen since 1.16.2
Log.severe("ChunkSerializer.serialize threw a NullPointerException", e);
}
if (nbt != null) {
gc = parseChunkFromNBT(new NBT.NBTCompound(nbt));
}
}
return gc;
}
private NbtCompound readChunk(int x, int z) {
try {
ThreadedAnvilChunkStorage acl = cps.threadedAnvilChunkStorage;
ChunkPos coord = new ChunkPos(x, z);
// Async chunk reading is synchronized here. Perhaps we can do async and improve performance?
return acl.getNbt(coord).join().orElse(null);
} catch (Exception exc) {
Log.severe(String.format("Error reading chunk: %s,%d,%d", dw.getName(), x, z), exc);
return null;
}
}
// Load generic chunk from unloaded chunk
protected GenericChunk loadChunk(DynmapChunk chunk) {
GenericChunk gc = null;
NbtCompound nbt = readChunk(chunk.x, chunk.z);
// If read was good
if (nbt != null) {
gc = parseChunkFromNBT(new NBT.NBTCompound(nbt));
}
return gc;
}
@Override
public int getFoliageColor(BiomeMap bm, int[] colormap, int x, int z) {
return bm.<Biome>getBiomeObject().map(Biome::getEffects).flatMap(BiomeEffects::getFoliageColor).orElse(colormap[bm.biomeLookup()]);
}
@Override
public int getGrassColor(BiomeMap bm, int[] colormap, int x, int z) {
BiomeEffects effects = bm.<Biome>getBiomeObject().map(Biome::getEffects).orElse(null);
if (effects == null) return colormap[bm.biomeLookup()];
return effects.getGrassColorModifier().getModifiedGrassColor(x, z, effects.getGrassColor().orElse(colormap[bm.biomeLookup()]));
}
}

View File

@ -0,0 +1,252 @@
package org.dynmap.fabric_1_19_3;
import com.google.common.collect.Iterables;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import net.minecraft.network.packet.s2c.play.SubtitleS2CPacket;
import net.minecraft.network.packet.s2c.play.TitleFadeS2CPacket;
import net.minecraft.network.packet.s2c.play.TitleS2CPacket;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.LiteralTextContent;
import net.minecraft.text.Text;
import net.minecraft.util.Util;
import net.minecraft.util.math.Vec3d;
import org.dynmap.DynmapLocation;
import org.dynmap.common.DynmapPlayer;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.UUID;
/**
* Player access abstraction class
*/
public class FabricPlayer extends FabricCommandSender implements DynmapPlayer {
private static final Gson GSON = new GsonBuilder().create();
private final DynmapPlugin plugin;
// FIXME: Proper setter
ServerPlayerEntity player;
private final String skinurl;
private final UUID uuid;
public FabricPlayer(DynmapPlugin plugin, ServerPlayerEntity player) {
this.plugin = plugin;
this.player = player;
String url = null;
if (this.player != null) {
uuid = this.player.getUuid();
GameProfile prof = this.player.getGameProfile();
if (prof != null) {
Property textureProperty = Iterables.getFirst(prof.getProperties().get("textures"), null);
if (textureProperty != null) {
DynmapPlugin.TexturesPayload result = null;
try {
String json = new String(Base64.getDecoder().decode(textureProperty.getValue()), StandardCharsets.UTF_8);
result = GSON.fromJson(json, DynmapPlugin.TexturesPayload.class);
} catch (JsonParseException e) {
}
if ((result != null) && (result.textures != null) && (result.textures.containsKey("SKIN"))) {
url = result.textures.get("SKIN").url;
}
}
}
} else {
uuid = null;
}
skinurl = url;
}
@Override
public boolean isConnected() {
return true;
}
@Override
public String getName() {
if (player != null) {
String n = player.getName().getString();
;
return n;
} else
return "[Server]";
}
@Override
public String getDisplayName() {
if (player != null) {
String n = player.getDisplayName().getString();
return n;
} else
return "[Server]";
}
@Override
public boolean isOnline() {
return true;
}
@Override
public DynmapLocation getLocation() {
if (player == null) {
return null;
}
Vec3d pos = player.getPos();
return FabricAdapter.toDynmapLocation(plugin, player.getWorld(), pos.getX(), pos.getY(), pos.getZ());
}
@Override
public String getWorld() {
if (player == null) {
return null;
}
if (player.world != null) {
return plugin.getWorld(player.world).getName();
}
return null;
}
@Override
public InetSocketAddress getAddress() {
if (player != null) {
ServerPlayNetworkHandler networkHandler = player.networkHandler;
if ((networkHandler != null) && (networkHandler.getConnection() != null)) {
SocketAddress sa = networkHandler.getConnection().getAddress();
if (sa instanceof InetSocketAddress) {
return (InetSocketAddress) sa;
}
}
}
return null;
}
@Override
public boolean isSneaking() {
if (player != null) {
return player.isSneaking();
}
return false;
}
@Override
public double getHealth() {
if (player != null) {
double h = player.getHealth();
if (h > 20) h = 20;
return h; // Scale to 20 range
} else {
return 0;
}
}
@Override
public int getArmorPoints() {
if (player != null) {
return player.getArmor();
} else {
return 0;
}
}
@Override
public DynmapLocation getBedSpawnLocation() {
return null;
}
@Override
public long getLastLoginTime() {
return 0;
}
@Override
public long getFirstLoginTime() {
return 0;
}
@Override
public boolean hasPrivilege(String privid) {
if (player != null)
return plugin.hasPerm(player, privid);
return false;
}
@Override
public boolean isOp() {
return plugin.isOp(player.getName().getString());
}
@Override
public void sendMessage(String msg) {
Text ichatcomponent = Text.literal(msg);
player.sendMessage(ichatcomponent);
}
@Override
public boolean isInvisible() {
if (player != null) {
return player.isInvisible();
}
return false;
}
@Override
public int getSortWeight() {
return plugin.getSortWeight(getName());
}
@Override
public void setSortWeight(int wt) {
if (wt == 0) {
plugin.dropSortWeight(getName());
} else {
plugin.setSortWeight(getName(), wt);
}
}
@Override
public boolean hasPermissionNode(String node) {
return player != null && plugin.hasPermNode(player, node);
}
@Override
public String getSkinURL() {
return skinurl;
}
@Override
public UUID getUUID() {
return uuid;
}
/**
* Send title and subtitle text (called from server thread)
*/
@Override
public void sendTitleText(String title, String subtitle, int fadeInTicks, int stayTicks, int fadeOutTicks) {
if (player != null) {
ServerPlayerEntity player = this.player;
TitleFadeS2CPacket times = new TitleFadeS2CPacket(fadeInTicks, stayTicks, fadeOutTicks);
player.networkHandler.sendPacket(times);
if (title != null) {
TitleS2CPacket titlepkt = new TitleS2CPacket(Text.literal(title));
player.networkHandler.sendPacket(titlepkt);
}
if (subtitle != null) {
SubtitleS2CPacket subtitlepkt = new SubtitleS2CPacket(Text.literal(subtitle));
player.networkHandler.sendPacket(subtitlepkt);
}
}
}
}

View File

@ -0,0 +1,610 @@
package org.dynmap.fabric_1_19_3;
import com.mojang.authlib.GameProfile;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.minecraft.block.AbstractSignBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.network.message.MessageType;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.server.BannedIpList;
import net.minecraft.server.BannedPlayerList;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.LiteralTextContent;
import net.minecraft.text.Text;
import net.minecraft.util.UserCache;
import net.minecraft.util.Util;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import org.dynmap.DynmapChunk;
import org.dynmap.DynmapWorld;
import org.dynmap.Log;
import org.dynmap.DynmapCommonAPIListener;
import org.dynmap.common.BiomeMap;
import org.dynmap.common.DynmapListenerManager;
import org.dynmap.common.DynmapPlayer;
import org.dynmap.common.DynmapServerInterface;
import org.dynmap.fabric_1_19_3.event.BlockEvents;
import org.dynmap.fabric_1_19_3.event.ServerChatEvents;
import org.dynmap.utils.MapChunkCache;
import org.dynmap.utils.VisibilityLimit;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.concurrent.*;
import java.util.stream.Collectors;
/**
* Server access abstraction class
*/
public class FabricServer extends DynmapServerInterface {
/* Server thread scheduler */
private final Object schedlock = new Object();
private final DynmapPlugin plugin;
private final MinecraftServer server;
private final Registry<Biome> biomeRegistry;
private long cur_tick;
private long next_id;
private long cur_tick_starttime;
private PriorityQueue<TaskRecord> runqueue = new PriorityQueue<TaskRecord>();
public FabricServer(DynmapPlugin plugin, MinecraftServer server) {
this.plugin = plugin;
this.server = server;
this.biomeRegistry = server.getRegistryManager().get(RegistryKeys.BIOME);
}
private Optional<GameProfile> getProfileByName(String player) {
UserCache cache = server.getUserCache();
return cache.findByName(player);
}
public final Registry<Biome> getBiomeRegistry() {
return biomeRegistry;
}
private Biome[] biomelist = null;
public final Biome[] getBiomeList(Registry<Biome> biomeRegistry) {
if (biomelist == null) {
biomelist = new Biome[256];
Iterator<Biome> iter = biomeRegistry.iterator();
while (iter.hasNext()) {
Biome b = iter.next();
int bidx = biomeRegistry.getRawId(b);
if (bidx >= biomelist.length) {
biomelist = Arrays.copyOf(biomelist, bidx + biomelist.length);
}
biomelist[bidx] = b;
}
}
return biomelist;
}
@Override
public int getBlockIDAt(String wname, int x, int y, int z) {
return -1;
}
@SuppressWarnings("deprecation") /* Not much I can do... fix this if it breaks. */
@Override
public int isSignAt(String wname, int x, int y, int z) {
World world = plugin.getWorldByName(wname).getWorld();
BlockPos pos = new BlockPos(x, y, z);
if (!world.isChunkLoaded(pos))
return -1;
Block block = world.getBlockState(pos).getBlock();
return (block instanceof AbstractSignBlock ? 1 : 0);
}
@Override
public void scheduleServerTask(Runnable run, long delay) {
/* Add task record to queue */
synchronized (schedlock) {
TaskRecord tr = new TaskRecord(cur_tick + delay, next_id++, new FutureTask<Object>(run, null));
runqueue.add(tr);
}
}
@Override
public DynmapPlayer[] getOnlinePlayers() {
if (server.getPlayerManager() == null) return new DynmapPlayer[0];
List<ServerPlayerEntity> players = server.getPlayerManager().getPlayerList();
int playerCount = players.size();
DynmapPlayer[] dplay = new DynmapPlayer[players.size()];
for (int i = 0; i < playerCount; i++) {
ServerPlayerEntity player = players.get(i);
dplay[i] = plugin.getOrAddPlayer(player);
}
return dplay;
}
@Override
public void reload() {
plugin.onDisable();
plugin.onEnable();
plugin.onStart();
}
@Override
public DynmapPlayer getPlayer(String name) {
List<ServerPlayerEntity> players = server.getPlayerManager().getPlayerList();
for (ServerPlayerEntity player : players) {
if (player.getName().getString().equalsIgnoreCase(name)) {
return plugin.getOrAddPlayer(player);
}
}
return null;
}
@Override
public Set<String> getIPBans() {
BannedIpList bl = server.getPlayerManager().getIpBanList();
Set<String> ips = new HashSet<String>();
for (String s : bl.getNames()) {
ips.add(s);
}
return ips;
}
@Override
public <T> Future<T> callSyncMethod(Callable<T> task) {
return callSyncMethod(task, 0);
}
public <T> Future<T> callSyncMethod(Callable<T> task, long delay) {
FutureTask<T> ft = new FutureTask<T>(task);
/* Add task record to queue */
synchronized (schedlock) {
TaskRecord tr = new TaskRecord(cur_tick + delay, next_id++, ft);
runqueue.add(tr);
}
return ft;
}
void clearTaskQueue() {
this.runqueue.clear();
}
@Override
public String getServerName() {
String sn;
if (server.isSingleplayer())
sn = "Integrated";
else
sn = server.getServerIp();
if (sn == null) sn = "Unknown Server";
return sn;
}
@Override
public boolean isPlayerBanned(String pid) {
PlayerManager scm = server.getPlayerManager();
BannedPlayerList bl = scm.getUserBanList();
try {
return bl.contains(getProfileByName(pid).get());
} catch (NoSuchElementException e) {
/* If this profile doesn't exist, default to "banned" for good measure. */
return true;
}
}
@Override
public String stripChatColor(String s) {
return DynmapPlugin.patternControlCode.matcher(s).replaceAll("");
}
private Set<DynmapListenerManager.EventType> registered = new HashSet<DynmapListenerManager.EventType>();
@Override
public boolean requestEventNotification(DynmapListenerManager.EventType type) {
if (registered.contains(type)) {
return true;
}
switch (type) {
case WORLD_LOAD:
case WORLD_UNLOAD:
/* Already called for normal world activation/deactivation */
break;
case WORLD_SPAWN_CHANGE:
/*TODO
pm.registerEvents(new Listener() {
@EventHandler(priority=EventPriority.MONITOR)
public void onSpawnChange(SpawnChangeEvent evt) {
DynmapWorld w = new BukkitWorld(evt.getWorld());
core.listenerManager.processWorldEvent(EventType.WORLD_SPAWN_CHANGE, w);
}
}, DynmapPlugin.this);
*/
break;
case PLAYER_JOIN:
case PLAYER_QUIT:
/* Already handled */
break;
case PLAYER_BED_LEAVE:
/*TODO
pm.registerEvents(new Listener() {
@EventHandler(priority=EventPriority.MONITOR)
public void onPlayerBedLeave(PlayerBedLeaveEvent evt) {
DynmapPlayer p = new BukkitPlayer(evt.getPlayer());
core.listenerManager.processPlayerEvent(EventType.PLAYER_BED_LEAVE, p);
}
}, DynmapPlugin.this);
*/
break;
case PLAYER_CHAT:
if (plugin.chathandler == null) {
plugin.setChatHandler(new DynmapPlugin.ChatHandler(plugin));
ServerChatEvents.EVENT.register((player, message) -> plugin.chathandler.handleChat(player, message));
}
break;
case BLOCK_BREAK:
/* Already handled by BlockEvents logic */
break;
case SIGN_CHANGE:
BlockEvents.SIGN_CHANGE_EVENT.register((world, pos, lines, material, player) -> {
plugin.core.processSignChange("fabric", FabricWorld.getWorldName(plugin, world),
pos.getX(), pos.getY(), pos.getZ(), lines, player.getName().getString());
});
break;
default:
Log.severe("Unhandled event type: " + type);
return false;
}
registered.add(type);
return true;
}
@Override
public boolean sendWebChatEvent(String source, String name, String msg) {
return DynmapCommonAPIListener.fireWebChatEvent(source, name, msg);
}
@Override
public void broadcastMessage(String msg) {
Text component = Text.literal(msg);
server.getPlayerManager().broadcast(component, false);
Log.info(stripChatColor(msg));
}
@Override
public String[] getBiomeIDs() {
BiomeMap[] b = BiomeMap.values();
String[] bname = new String[b.length];
for (int i = 0; i < bname.length; i++) {
bname[i] = b[i].toString();
}
return bname;
}
@Override
public double getCacheHitRate() {
if (plugin.sscache != null)
return plugin.sscache.getHitRate();
return 0.0;
}
@Override
public void resetCacheStats() {
if (plugin.sscache != null)
plugin.sscache.resetStats();
}
@Override
public DynmapWorld getWorldByName(String wname) {
return plugin.getWorldByName(wname);
}
@Override
public DynmapPlayer getOfflinePlayer(String name) {
/*
OfflinePlayer op = getServer().getOfflinePlayer(name);
if(op != null) {
return new BukkitPlayer(op);
}
*/
return null;
}
@Override
public Set<String> checkPlayerPermissions(String player, Set<String> perms) {
if (isPlayerBanned(player)) {
return Collections.emptySet();
}
Set<String> rslt = plugin.hasOfflinePermissions(player, perms);
if (rslt == null) {
rslt = new HashSet<String>();
if (plugin.isOp(player)) {
rslt.addAll(perms);
}
}
return rslt;
}
@Override
public boolean checkPlayerPermission(String player, String perm) {
if (isPlayerBanned(player)) {
return false;
}
return plugin.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) {
FabricMapChunkCache c = (FabricMapChunkCache) w.getChunkCache(chunks);
if (c == null) {
return null;
}
if (w.visibility_limits != null) {
for (VisibilityLimit limit : w.visibility_limits) {
c.setVisibleRange(limit);
}
c.setHiddenFillStyle(w.hiddenchunkstyle);
}
if (w.hidden_limits != null) {
for (VisibilityLimit limit : w.hidden_limits) {
c.setHiddenRange(limit);
}
c.setHiddenFillStyle(w.hiddenchunkstyle);
}
if (!c.setChunkDataTypes(blockdata, biome, highesty, rawbiome)) {
Log.severe("CraftBukkit build does not support biome APIs");
}
if (chunks.size() == 0) /* No chunks to get? */ {
c.loadChunks(0);
return c;
}
//Now handle any chunks in server thread that are already loaded (on server thread)
final FabricMapChunkCache cc = c;
Future<Boolean> f = this.callSyncMethod(new Callable<Boolean>() {
public Boolean call() throws Exception {
// Update busy state on world
//FabricWorld fw = (FabricWorld) cc.getWorld();
//TODO
//setBusy(fw.getWorld());
cc.getLoadedChunks();
return true;
}
}, 0);
try {
f.get();
} catch (CancellationException cx) {
return null;
} catch (InterruptedException cx) {
return null;
} catch (ExecutionException xx) {
Log.severe("Exception while loading chunks", xx.getCause());
return null;
} catch (Exception ix) {
Log.severe(ix);
return null;
}
if (!w.isLoaded()) {
return null;
}
// Now, do rest of chunk reading from calling thread
c.readChunks(chunks.size());
return c;
}
@Override
public int getMaxPlayers() {
return server.getMaxPlayerCount();
}
@Override
public int getCurrentPlayers() {
return server.getPlayerManager().getCurrentPlayerCount();
}
public void tickEvent(MinecraftServer server) {
cur_tick_starttime = System.nanoTime();
long elapsed = cur_tick_starttime - plugin.lasttick;
plugin.lasttick = cur_tick_starttime;
plugin.avgticklen = ((plugin.avgticklen * 99) / 100) + (elapsed / 100);
plugin.tps = (double) 1E9 / (double) plugin.avgticklen;
// Tick core
if (plugin.core != null) {
plugin.core.serverTick(plugin.tps);
}
boolean done = false;
TaskRecord tr = null;
while (!plugin.blockupdatequeue.isEmpty()) {
DynmapPlugin.BlockUpdateRec r = plugin.blockupdatequeue.remove();
BlockState bs = r.w.getBlockState(new BlockPos(r.x, r.y, r.z));
int idx = Block.STATE_IDS.getRawId(bs);
if (!org.dynmap.hdmap.HDBlockModels.isChangeIgnoredBlock(DynmapPlugin.stateByID[idx])) {
if (plugin.onblockchange_with_id)
plugin.mapManager.touch(r.wid, r.x, r.y, r.z, "blockchange[" + idx + "]");
else
plugin.mapManager.touch(r.wid, r.x, r.y, r.z, "blockchange");
}
}
long now;
synchronized (schedlock) {
cur_tick++;
now = System.nanoTime();
tr = runqueue.peek();
/* Nothing due to run */
if ((tr == null) || (tr.getTickToRun() > cur_tick) || ((now - cur_tick_starttime) > plugin.perTickLimit)) {
done = true;
} else {
tr = runqueue.poll();
}
}
while (!done) {
tr.run();
synchronized (schedlock) {
tr = runqueue.peek();
now = System.nanoTime();
/* Nothing due to run */
if ((tr == null) || (tr.getTickToRun() > cur_tick) || ((now - cur_tick_starttime) > plugin.perTickLimit)) {
done = true;
} else {
tr = runqueue.poll();
}
}
}
while (!plugin.msgqueue.isEmpty()) {
DynmapPlugin.ChatMessage cm = plugin.msgqueue.poll();
DynmapPlayer dp = null;
if (cm.sender != null)
dp = plugin.getOrAddPlayer(cm.sender);
else
dp = new FabricPlayer(plugin, null);
plugin.core.listenerManager.processChatEvent(DynmapListenerManager.EventType.PLAYER_CHAT, dp, cm.message);
}
// Check for generated chunks
if ((cur_tick % 20) == 0) {
}
}
private Optional<ModContainer> getModContainerById(String id) {
return FabricLoader.getInstance().getModContainer(id);
}
@Override
public boolean isModLoaded(String name) {
return FabricLoader.getInstance().getModContainer(name).isPresent();
}
@Override
public String getModVersion(String name) {
Optional<ModContainer> mod = getModContainerById(name); // Try case sensitive lookup
return mod.map(modContainer -> modContainer.getMetadata().getVersion().getFriendlyString()).orElse(null);
}
@Override
public double getServerTPS() {
return plugin.tps;
}
@Override
public String getServerIP() {
if (server.isSingleplayer())
return "0.0.0.0";
else
return server.getServerIp();
}
@Override
public File getModContainerFile(String name) {
Optional<ModContainer> container = getModContainerById(name); // Try case sensitive lookup
if (container.isPresent()) {
Path path = container.get().getRootPath();
if (path.getFileSystem().provider().getScheme().equals("jar")) {
path = Paths.get(path.getFileSystem().toString());
}
return path.toFile();
}
return null;
}
@Override
public List<String> getModList() {
return FabricLoader.getInstance()
.getAllMods()
.stream()
.map(container -> container.getMetadata().getId())
.collect(Collectors.toList());
}
@Override
public Map<Integer, String> getBlockIDMap() {
Map<Integer, String> map = new HashMap<Integer, String>();
return map;
}
@Override
public InputStream openResource(String modid, String rname) {
if (modid == null) modid = "minecraft";
if ("minecraft".equals(modid)) {
return MinecraftServer.class.getClassLoader().getResourceAsStream(rname);
} else {
if (rname.startsWith("/") || rname.startsWith("\\")) {
rname = rname.substring(1);
}
final String finalModid = modid;
final String finalRname = rname;
return getModContainerById(modid).map(container -> {
try {
return Files.newInputStream(container.getPath(finalRname));
} catch (IOException e) {
Log.severe("Failed to load resource of mod :" + finalModid, e);
return null;
}
}).orElse(null);
}
}
/**
* Get block unique ID map (module:blockid)
*/
@Override
public Map<String, Integer> getBlockUniqueIDMap() {
HashMap<String, Integer> map = new HashMap<String, Integer>();
return map;
}
/**
* Get item unique ID map (module:itemid)
*/
@Override
public Map<String, Integer> getItemUniqueIDMap() {
HashMap<String, Integer> map = new HashMap<String, Integer>();
return map;
}
}

View File

@ -0,0 +1,236 @@
package org.dynmap.fabric_1_19_3;
import net.minecraft.registry.RegistryKey;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.Heightmap;
import net.minecraft.world.LightType;
import net.minecraft.world.World;
import net.minecraft.world.border.WorldBorder;
import org.dynmap.DynmapChunk;
import org.dynmap.DynmapLocation;
import org.dynmap.DynmapWorld;
import org.dynmap.utils.MapChunkCache;
import org.dynmap.utils.Polygon;
import java.util.List;
public class FabricWorld extends DynmapWorld {
// TODO: Store this relative to World saves for integrated server
public static final String SAVED_WORLDS_FILE = "fabricworlds.yml";
private final DynmapPlugin plugin;
private World world;
private final boolean skylight;
private final boolean isnether;
private final boolean istheend;
private final String env;
private DynmapLocation spawnloc = new DynmapLocation();
private static int maxWorldHeight = 320; // Maximum allows world height
public static int getMaxWorldHeight() {
return maxWorldHeight;
}
public static void setMaxWorldHeight(int h) {
maxWorldHeight = h;
}
public static String getWorldName(DynmapPlugin plugin, World w) {
RegistryKey<World> rk = w.getRegistryKey();
if (rk == World.OVERWORLD) { // Overworld?
return w.getServer().getSaveProperties().getLevelName();
} else if (rk == World.END) {
return "DIM1";
} else if (rk == World.NETHER) {
return "DIM-1";
} else {
return rk.getValue().getNamespace() + "_" + rk.getValue().getPath();
}
}
public void updateWorld(World w) {
this.updateWorldHeights(w.getHeight(), w.getBottomY(), w.getSeaLevel());
}
public FabricWorld(DynmapPlugin plugin, World w) {
this(plugin, getWorldName(plugin, w), w.getHeight(),
w.getSeaLevel(),
w.getRegistryKey() == World.NETHER,
w.getRegistryKey() == World.END,
w.getRegistryKey().getValue().getPath(),
w.getBottomY());
setWorldLoaded(w);
}
public FabricWorld(DynmapPlugin plugin, String name, int height, int sealevel, boolean nether, boolean the_end, String deftitle, int miny) {
super(name, (height > maxWorldHeight) ? maxWorldHeight : height, sealevel, miny);
this.plugin = plugin;
world = null;
setTitle(deftitle);
isnether = nether;
istheend = the_end;
skylight = !(isnether || istheend);
if (isnether) {
env = "nether";
} else if (istheend) {
env = "the_end";
} else {
env = "normal";
}
}
/* Test if world is nether */
@Override
public boolean isNether() {
return isnether;
}
public boolean isTheEnd() {
return istheend;
}
/* Get world spawn location */
@Override
public DynmapLocation getSpawnLocation() {
if (world != null) {
spawnloc.x = world.getLevelProperties().getSpawnX();
spawnloc.y = world.getLevelProperties().getSpawnY();
spawnloc.z = world.getLevelProperties().getSpawnZ();
spawnloc.world = this.getName();
}
return spawnloc;
}
/* Get world time */
@Override
public long getTime() {
if (world != null)
return world.getTimeOfDay();
else
return -1;
}
/* World is storming */
@Override
public boolean hasStorm() {
if (world != null)
return world.isRaining();
else
return false;
}
/* World is thundering */
@Override
public boolean isThundering() {
if (world != null)
return world.isThundering();
else
return false;
}
/* World is loaded */
@Override
public boolean isLoaded() {
return (world != null);
}
/* Set world to unloaded */
@Override
public void setWorldUnloaded() {
getSpawnLocation();
world = null;
}
/* Set world to loaded */
public void setWorldLoaded(World w) {
world = w;
this.sealevel = w.getSeaLevel(); // Read actual current sealevel from world
// Update lighting table
for (int lightLevel = 0; lightLevel < 16; lightLevel++) {
// Algorithm based on LightmapTextureManager.getBrightness()
// We can't call that method because it's client-only.
// This means the code below can stop being correct if Mojang ever
// updates the curve; in that case we should reflect the changes.
float value = (float) lightLevel / 15.0f;
float brightness = value / (4.0f - 3.0f * value);
this.setBrightnessTableEntry(lightLevel, MathHelper.lerp(w.getDimension().ambientLight(), brightness, 1.0F));
}
}
/* Get light level of block */
@Override
public int getLightLevel(int x, int y, int z) {
if (world != null)
return world.getLightLevel(new BlockPos(x, y, z));
else
return -1;
}
/* Get highest Y coord of given location */
@Override
public int getHighestBlockYAt(int x, int z) {
if (world != null) {
return world.getChunk(x >> 4, z >> 4).getHeightmap(Heightmap.Type.MOTION_BLOCKING).get(x & 15, z & 15);
} else
return -1;
}
/* Test if sky light level is requestable */
@Override
public boolean canGetSkyLightLevel() {
return skylight;
}
/* Return sky light level */
@Override
public int getSkyLightLevel(int x, int y, int z) {
if (world != null) {
return world.getLightLevel(LightType.SKY, new BlockPos(x, y, z));
} else
return -1;
}
/**
* Get world environment ID (lower case - normal, the_end, nether)
*/
@Override
public String getEnvironment() {
return env;
}
/**
* Get map chunk cache for world
*/
@Override
public MapChunkCache getChunkCache(List<DynmapChunk> chunks) {
if (world != null) {
FabricMapChunkCache c = new FabricMapChunkCache(plugin);
c.setChunks(this, chunks);
return c;
}
return null;
}
public World getWorld() {
return world;
}
@Override
public Polygon getWorldBorder() {
if (world != null) {
WorldBorder wb = world.getWorldBorder();
if ((wb != null) && (wb.getSize() < 5.9E7)) {
Polygon p = new Polygon();
p.addVertex(wb.getBoundWest(), wb.getBoundNorth());
p.addVertex(wb.getBoundWest(), wb.getBoundSouth());
p.addVertex(wb.getBoundEast(), wb.getBoundSouth());
p.addVertex(wb.getBoundEast(), wb.getBoundNorth());
return p;
}
}
return null;
}
}

View File

@ -0,0 +1,126 @@
package org.dynmap.fabric_1_19_3;
import org.dynmap.common.chunk.GenericBitStorage;
import org.dynmap.common.chunk.GenericNBTCompound;
import org.dynmap.common.chunk.GenericNBTList;
import java.util.Set;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.nbt.NbtList;
import net.minecraft.util.collection.PackedIntegerArray;
public class NBT {
public static class NBTCompound implements GenericNBTCompound {
private final NbtCompound obj;
public NBTCompound(NbtCompound t) {
this.obj = t;
}
@Override
public Set<String> getAllKeys() {
return obj.getKeys();
}
@Override
public boolean contains(String s) {
return obj.contains(s);
}
@Override
public boolean contains(String s, int i) {
return obj.contains(s, i);
}
@Override
public byte getByte(String s) {
return obj.getByte(s);
}
@Override
public short getShort(String s) {
return obj.getShort(s);
}
@Override
public int getInt(String s) {
return obj.getInt(s);
}
@Override
public long getLong(String s) {
return obj.getLong(s);
}
@Override
public float getFloat(String s) {
return obj.getFloat(s);
}
@Override
public double getDouble(String s) {
return obj.getDouble(s);
}
@Override
public String getString(String s) {
return obj.getString(s);
}
@Override
public byte[] getByteArray(String s) {
return obj.getByteArray(s);
}
@Override
public int[] getIntArray(String s) {
return obj.getIntArray(s);
}
@Override
public long[] getLongArray(String s) {
return obj.getLongArray(s);
}
@Override
public GenericNBTCompound getCompound(String s) {
return new NBTCompound(obj.getCompound(s));
}
@Override
public GenericNBTList getList(String s, int i) {
return new NBTList(obj.getList(s, i));
}
@Override
public boolean getBoolean(String s) {
return obj.getBoolean(s);
}
@Override
public String getAsString(String s) {
return obj.get(s).asString();
}
@Override
public GenericBitStorage makeBitStorage(int bits, int count, long[] data) {
return new OurBitStorage(bits, count, data);
}
public String toString() {
return obj.toString();
}
}
public static class NBTList implements GenericNBTList {
private final NbtList obj;
public NBTList(NbtList t) {
obj = t;
}
@Override
public int size() {
return obj.size();
}
@Override
public String getString(int idx) {
return obj.getString(idx);
}
@Override
public GenericNBTCompound getCompound(int idx) {
return new NBTCompound(obj.getCompound(idx));
}
public String toString() {
return obj.toString();
}
}
public static class OurBitStorage implements GenericBitStorage {
private final PackedIntegerArray bs;
public OurBitStorage(int bits, int count, long[] data) {
bs = new PackedIntegerArray(bits, count, data);
}
@Override
public int get(int idx) {
return bs.get(idx);
}
}
}

View File

@ -0,0 +1,38 @@
package org.dynmap.fabric_1_19_3;
import java.util.concurrent.FutureTask;
class TaskRecord implements Comparable<TaskRecord> {
TaskRecord(long ticktorun, long id, FutureTask<?> future) {
this.ticktorun = ticktorun;
this.id = id;
this.future = future;
}
private final long ticktorun;
private final long id;
private final FutureTask<?> future;
void run() {
this.future.run();
}
long getTickToRun() {
return this.ticktorun;
}
@Override
public int compareTo(TaskRecord o) {
if (this.ticktorun < o.ticktorun) {
return -1;
} else if (this.ticktorun > o.ticktorun) {
return 1;
} else if (this.id < o.id) {
return -1;
} else if (this.id > o.id) {
return 1;
} else {
return 0;
}
}
}

View File

@ -0,0 +1,98 @@
package org.dynmap.fabric_1_19_3;
import org.dynmap.DynmapCore;
import org.dynmap.Log;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class VersionCheck {
private static final String VERSION_URL = "http://mikeprimm.com/dynmap/releases.php";
public static void runCheck(final DynmapCore core) {
new Thread(new Runnable() {
public void run() {
doCheck(core);
}
}).start();
}
private static int getReleaseVersion(String s) {
int index = s.lastIndexOf('-');
if (index < 0)
index = s.lastIndexOf('.');
if (index >= 0)
s = s.substring(0, index);
String[] split = s.split("\\.");
int v = 0;
try {
for (int i = 0; (i < split.length) && (i < 3); i++) {
v += Integer.parseInt(split[i]) << (8 * (2 - i));
}
} catch (NumberFormatException nfx) {
}
return v;
}
private static int getBuildNumber(String s) {
int index = s.lastIndexOf('-');
if (index < 0)
index = s.lastIndexOf('.');
if (index >= 0)
s = s.substring(index + 1);
try {
return Integer.parseInt(s);
} catch (NumberFormatException nfx) {
return 99999999;
}
}
private static void doCheck(DynmapCore core) {
String pluginver = core.getDynmapPluginVersion();
String platform = core.getDynmapPluginPlatform();
String platver = core.getDynmapPluginPlatformVersion();
if ((pluginver == null) || (platform == null) || (platver == null))
return;
HttpURLConnection conn = null;
String loc = VERSION_URL;
int cur_ver = getReleaseVersion(pluginver);
int cur_bn = getBuildNumber(pluginver);
try {
while ((loc != null) && (!loc.isEmpty())) {
URL url = new URL(loc);
conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("User-Agent", "Dynmap (" + platform + "/" + platver + "/" + pluginver);
conn.connect();
loc = conn.getHeaderField("Location");
}
BufferedReader rdr = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line = null;
while ((line = rdr.readLine()) != null) {
String[] split = line.split(":");
if (split.length < 4) continue;
/* If our platform and version, or wildcard platform version */
if (split[0].equals(platform) && (split[1].equals("*") || split[1].equals(platver))) {
int recommended_ver = getReleaseVersion(split[2]);
int recommended_bn = getBuildNumber(split[2]);
if ((recommended_ver > cur_ver) || ((recommended_ver == cur_ver) && (recommended_bn > cur_bn))) { /* Newer recommended build */
Log.info("Version obsolete: new recommended version " + split[2] + " is available.");
} else if (cur_ver > recommended_ver) { /* Running dev or prerelease? */
int prerel_ver = getReleaseVersion(split[3]);
int prerel_bn = getBuildNumber(split[3]);
if ((prerel_ver > cur_ver) || ((prerel_ver == cur_ver) && (prerel_bn > cur_bn))) {
Log.info("Version obsolete: new prerelease version " + split[3] + " is available.");
}
}
}
}
} catch (Exception x) {
Log.info("Error checking for latest version");
} finally {
if (conn != null) {
conn.disconnect();
}
}
}
}

View File

@ -0,0 +1,5 @@
package org.dynmap.fabric_1_19_3.access;
public interface ProtoChunkAccessor {
boolean getTouchedByWorldGen();
}

View File

@ -0,0 +1,9 @@
package org.dynmap.fabric_1_19_3.command;
import org.dynmap.fabric_1_19_3.DynmapPlugin;
public class DmapCommand extends DynmapCommandExecutor {
public DmapCommand(DynmapPlugin p) {
super("dmap", p);
}
}

View File

@ -0,0 +1,9 @@
package org.dynmap.fabric_1_19_3.command;
import org.dynmap.fabric_1_19_3.DynmapPlugin;
public class DmarkerCommand extends DynmapCommandExecutor {
public DmarkerCommand(DynmapPlugin p) {
super("dmarker", p);
}
}

View File

@ -0,0 +1,9 @@
package org.dynmap.fabric_1_19_3.command;
import org.dynmap.fabric_1_19_3.DynmapPlugin;
public class DynmapCommand extends DynmapCommandExecutor {
public DynmapCommand(DynmapPlugin p) {
super("dynmap", p);
}
}

View File

@ -0,0 +1,63 @@
package org.dynmap.fabric_1_19_3.command;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.tree.ArgumentCommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode;
import com.mojang.brigadier.tree.RootCommandNode;
import net.minecraft.server.command.ServerCommandSource;
import org.dynmap.fabric_1_19_3.DynmapPlugin;
import java.util.Arrays;
import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
import static net.minecraft.server.command.CommandManager.argument;
import static net.minecraft.server.command.CommandManager.literal;
public class DynmapCommandExecutor implements Command<ServerCommandSource> {
private final String cmd;
private final DynmapPlugin plugin;
DynmapCommandExecutor(String cmd, DynmapPlugin plugin) {
this.cmd = cmd;
this.plugin = plugin;
}
public void register(CommandDispatcher<ServerCommandSource> dispatcher) {
final RootCommandNode<ServerCommandSource> root = dispatcher.getRoot();
final LiteralCommandNode<ServerCommandSource> command = literal(this.cmd)
.executes(this)
.build();
final ArgumentCommandNode<ServerCommandSource, String> args = argument("args", greedyString())
.executes(this)
.build();
// So this becomes "cmd" [args]
command.addChild(args);
// Add command to the command dispatcher via root node.
root.addChild(command);
}
@Override
public int run(CommandContext<ServerCommandSource> context) throws CommandSyntaxException {
// Commands in brigadier may be proxied in Minecraft via a syntax like `/execute ... ... run dmap [args]`
// Dynmap will fail to parse this properly, so we find the starting position of the actual command being parsed after any forks or redirects.
// The start position of the range specifies where the actual command dynmap has registered starts
int start = context.getRange().getStart();
String dynmapInput = context.getInput().substring(start);
String[] args = dynmapInput.split("\\s+");
plugin.handleCommand(context.getSource(), cmd, Arrays.copyOfRange(args, 1, args.length));
return 1;
}
// @Override // TODO: Usage?
public String getUsage(ServerCommandSource commandSource) {
return "Run /" + cmd + " help for details on using command";
}
}

View File

@ -0,0 +1,9 @@
package org.dynmap.fabric_1_19_3.command;
import org.dynmap.fabric_1_19_3.DynmapPlugin;
public class DynmapExpCommand extends DynmapCommandExecutor {
public DynmapExpCommand(DynmapPlugin p) {
super("dynmapexp", p);
}
}

View File

@ -0,0 +1,40 @@
package org.dynmap.fabric_1_19_3.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.block.Material;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class BlockEvents {
private BlockEvents() {
}
public static Event<BlockCallback> BLOCK_EVENT = EventFactory.createArrayBacked(BlockCallback.class,
(listeners) -> (world, pos) -> {
for (BlockCallback callback : listeners) {
callback.onBlockEvent(world, pos);
}
}
);
public static Event<SignChangeCallback> SIGN_CHANGE_EVENT = EventFactory.createArrayBacked(SignChangeCallback.class,
(listeners) -> (world, pos, lines, material, player) -> {
for (SignChangeCallback callback : listeners) {
callback.onSignChange(world, pos, lines, material, player);
}
}
);
@FunctionalInterface
public interface BlockCallback {
void onBlockEvent(World world, BlockPos pos);
}
@FunctionalInterface
public interface SignChangeCallback {
void onSignChange(ServerWorld world, BlockPos pos, String[] lines, Material material, ServerPlayerEntity player);
}
}

View File

@ -0,0 +1,21 @@
package org.dynmap.fabric_1_19_3.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.world.chunk.Chunk;
public class CustomServerChunkEvents {
public static Event<ChunkGenerate> CHUNK_GENERATE = EventFactory.createArrayBacked(ChunkGenerate.class,
(listeners) -> (world, chunk) -> {
for (ChunkGenerate callback : listeners) {
callback.onChunkGenerate(world, chunk);
}
}
);
@FunctionalInterface
public interface ChunkGenerate {
void onChunkGenerate(ServerWorld world, Chunk chunk);
}
}

View File

@ -0,0 +1,14 @@
package org.dynmap.fabric_1_19_3.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
public class CustomServerLifecycleEvents {
public static final Event<ServerLifecycleEvents.ServerStarted> SERVER_STARTED_PRE_WORLD_LOAD =
EventFactory.createArrayBacked(ServerLifecycleEvents.ServerStarted.class, (callbacks) -> (server) -> {
for (ServerLifecycleEvents.ServerStarted callback : callbacks) {
callback.onServerStarted(server);
}
});
}

View File

@ -0,0 +1,62 @@
package org.dynmap.fabric_1_19_3.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.server.network.ServerPlayerEntity;
public class PlayerEvents {
private PlayerEvents() {
}
public static Event<PlayerLoggedIn> PLAYER_LOGGED_IN = EventFactory.createArrayBacked(PlayerLoggedIn.class,
(listeners) -> (player) -> {
for (PlayerLoggedIn callback : listeners) {
callback.onPlayerLoggedIn(player);
}
}
);
public static Event<PlayerLoggedOut> PLAYER_LOGGED_OUT = EventFactory.createArrayBacked(PlayerLoggedOut.class,
(listeners) -> (player) -> {
for (PlayerLoggedOut callback : listeners) {
callback.onPlayerLoggedOut(player);
}
}
);
public static Event<PlayerChangedDimension> PLAYER_CHANGED_DIMENSION = EventFactory.createArrayBacked(PlayerChangedDimension.class,
(listeners) -> (player) -> {
for (PlayerChangedDimension callback : listeners) {
callback.onPlayerChangedDimension(player);
}
}
);
public static Event<PlayerRespawn> PLAYER_RESPAWN = EventFactory.createArrayBacked(PlayerRespawn.class,
(listeners) -> (player) -> {
for (PlayerRespawn callback : listeners) {
callback.onPlayerRespawn(player);
}
}
);
@FunctionalInterface
public interface PlayerLoggedIn {
void onPlayerLoggedIn(ServerPlayerEntity player);
}
@FunctionalInterface
public interface PlayerLoggedOut {
void onPlayerLoggedOut(ServerPlayerEntity player);
}
@FunctionalInterface
public interface PlayerChangedDimension {
void onPlayerChangedDimension(ServerPlayerEntity player);
}
@FunctionalInterface
public interface PlayerRespawn {
void onPlayerRespawn(ServerPlayerEntity player);
}
}

View File

@ -0,0 +1,23 @@
package org.dynmap.fabric_1_19_3.event;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.server.network.ServerPlayerEntity;
public class ServerChatEvents {
private ServerChatEvents() {
}
public static Event<ServerChatCallback> EVENT = EventFactory.createArrayBacked(ServerChatCallback.class,
(listeners) -> (player, message) -> {
for (ServerChatCallback callback : listeners) {
callback.onChatMessage(player, message);
}
}
);
@FunctionalInterface
public interface ServerChatCallback {
void onChatMessage(ServerPlayerEntity player, String message);
}
}

View File

@ -0,0 +1,11 @@
package org.dynmap.fabric_1_19_3.mixin;
import net.minecraft.world.biome.BiomeEffects;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
@Mixin(BiomeEffects.class)
public interface BiomeEffectsAccessor {
@Accessor
int getWaterColor();
}

View File

@ -0,0 +1,16 @@
package org.dynmap.fabric_1_19_3.mixin;
import net.minecraft.server.MinecraftServer;
import org.dynmap.fabric_1_19_3.event.CustomServerLifecycleEvents;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(MinecraftServer.class)
public class MinecraftServerMixin {
@Inject(method = "loadWorld", at = @At("HEAD"))
protected void loadWorld(CallbackInfo info) {
CustomServerLifecycleEvents.SERVER_STARTED_PRE_WORLD_LOAD.invoker().onServerStarted((MinecraftServer) (Object) this);
}
}

View File

@ -0,0 +1,29 @@
package org.dynmap.fabric_1_19_3.mixin;
import net.minecraft.network.ClientConnection;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ServerPlayerEntity;
import org.dynmap.fabric_1_19_3.event.PlayerEvents;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(PlayerManager.class)
public class PlayerManagerMixin {
@Inject(method = "onPlayerConnect", at = @At("TAIL"))
public void onPlayerConnect(ClientConnection connection, ServerPlayerEntity player, CallbackInfo info) {
PlayerEvents.PLAYER_LOGGED_IN.invoker().onPlayerLoggedIn(player);
}
@Inject(method = "remove", at = @At("HEAD"))
public void remove(ServerPlayerEntity player, CallbackInfo info) {
PlayerEvents.PLAYER_LOGGED_OUT.invoker().onPlayerLoggedOut(player);
}
@Inject(method = "respawnPlayer", at = @At("RETURN"))
public void respawnPlayer(ServerPlayerEntity player, boolean alive, CallbackInfoReturnable<ServerPlayerEntity> info) {
PlayerEvents.PLAYER_RESPAWN.invoker().onPlayerRespawn(info.getReturnValue());
}
}

View File

@ -0,0 +1,30 @@
package org.dynmap.fabric_1_19_3.mixin;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.chunk.ProtoChunk;
import org.dynmap.fabric_1_19_3.access.ProtoChunkAccessor;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ProtoChunk.class)
public class ProtoChunkMixin implements ProtoChunkAccessor {
private boolean touchedByWorldGen = false;
@Inject(
method = "setBlockState",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/chunk/ChunkSection;setBlockState(IIILnet/minecraft/block/BlockState;)Lnet/minecraft/block/BlockState;"
)
)
public void setBlockState(BlockPos pos, BlockState state, boolean moved, CallbackInfoReturnable<BlockState> info) {
touchedByWorldGen = true;
}
public boolean getTouchedByWorldGen() {
return touchedByWorldGen;
}
}

View File

@ -0,0 +1,66 @@
package org.dynmap.fabric_1_19_3.mixin;
import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.block.entity.SignBlockEntity;
import net.minecraft.network.message.SignedMessage;
import net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket;
import net.minecraft.server.filter.FilteredMessage;
import net.minecraft.server.filter.TextStream;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.LiteralTextContent;
import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos;
import java.util.List;
import org.dynmap.fabric_1_19_3.event.BlockEvents;
import org.dynmap.fabric_1_19_3.event.ServerChatEvents;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(ServerPlayNetworkHandler.class)
public abstract class ServerPlayNetworkHandlerMixin {
@Shadow
public ServerPlayerEntity player;
@Inject(
method = "handleDecoratedMessage",
at = @At(
value = "HEAD"
)
)
public void onGameMessage(SignedMessage signedMessage, CallbackInfo ci) {
ServerChatEvents.EVENT.invoker().onChatMessage(player, signedMessage.getContent().getString());
}
@Inject(
method = "onSignUpdate",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/block/entity/SignBlockEntity;markDirty()V",
shift = At.Shift.BEFORE
),
locals = LocalCapture.CAPTURE_FAILHARD
)
public void onSignUpdate(UpdateSignC2SPacket packet, List<FilteredMessage> signText, CallbackInfo info,
ServerWorld serverWorld, BlockPos blockPos, BlockState blockState, BlockEntity blockEntity, SignBlockEntity signBlockEntity)
{
// Pull the raw text from the input.
String[] rawTexts = new String[4];
for (int i=0; i<signText.size(); i++)
rawTexts[i] = signText.get(i).raw();
// Fire the event.
BlockEvents.SIGN_CHANGE_EVENT.invoker().onSignChange(serverWorld, blockPos, rawTexts, blockState.getMaterial(), player);
// Put the (possibly updated) texts in the sign. Ignore filtering (is this OK?).
for (int i=0; i<signText.size(); i++)
signBlockEntity.setTextOnRow(i, Text.literal(rawTexts[i]));
}
}

View File

@ -0,0 +1,30 @@
package org.dynmap.fabric_1_19_3.mixin;
import net.minecraft.entity.Entity;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import org.dynmap.fabric_1_19_3.event.PlayerEvents;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ServerPlayerEntity.class)
public class ServerPlayerEntityMixin {
@Inject(method = "teleport", at = @At("RETURN"))
public void teleport(ServerWorld targetWorld, double x, double y, double z, float yaw, float pitch, CallbackInfo info) {
ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
if (targetWorld != player.world) {
PlayerEvents.PLAYER_CHANGED_DIMENSION.invoker().onPlayerChangedDimension(player);
}
}
@Inject(method = "moveToWorld", at = @At("RETURN"))
public void moveToWorld(ServerWorld destination, CallbackInfoReturnable<Entity> info) {
ServerPlayerEntity player = (ServerPlayerEntity) (Object) this;
if (player.getRemovalReason() == null) {
PlayerEvents.PLAYER_CHANGED_DIMENSION.invoker().onPlayerChangedDimension(player);
}
}
}

View File

@ -0,0 +1,32 @@
package org.dynmap.fabric_1_19_3.mixin;
import net.minecraft.server.world.ChunkHolder;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.server.world.ThreadedAnvilChunkStorage;
import net.minecraft.world.chunk.Chunk;
import org.dynmap.fabric_1_19_3.access.ProtoChunkAccessor;
import org.dynmap.fabric_1_19_3.event.CustomServerChunkEvents;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(value = ThreadedAnvilChunkStorage.class, priority = 666 /* fire before Fabric API CHUNK_LOAD event */)
public abstract class ThreadedAnvilChunkStorageMixin {
@Final
@Shadow
ServerWorld world;
@Inject(
/* Same place as fabric-lifecycle-events-v1 event CHUNK_LOAD (we will fire before it) */
method = "method_17227",
at = @At("TAIL")
)
private void onChunkGenerate(ChunkHolder chunkHolder, Chunk protoChunk, CallbackInfoReturnable<Chunk> callbackInfoReturnable) {
if (((ProtoChunkAccessor)protoChunk).getTouchedByWorldGen()) {
CustomServerChunkEvents.CHUNK_GENERATE.invoker().onChunkGenerate(this.world, callbackInfoReturnable.getReturnValue());
}
}
}

View File

@ -0,0 +1,25 @@
package org.dynmap.fabric_1_19_3.mixin;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.WorldChunk;
import org.dynmap.fabric_1_19_3.event.BlockEvents;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(WorldChunk.class)
public abstract class WorldChunkMixin {
@Shadow
public abstract World getWorld();
@Inject(method = "setBlockState", at = @At("RETURN"))
public void setBlockState(BlockPos pos, BlockState state, boolean moved, CallbackInfoReturnable<BlockState> info) {
if (info.getReturnValue() != null) {
BlockEvents.BLOCK_EVENT.invoker().onBlockEvent(this.getWorld(), pos);
}
}
}

View File

@ -0,0 +1,47 @@
package org.dynmap.fabric_1_19_3.permissions;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.entity.player.PlayerEntity;
import org.dynmap.Log;
import org.dynmap.fabric_1_19_3.DynmapPlugin;
import org.dynmap.json.simple.parser.JSONParser;
import java.util.Set;
import java.util.stream.Collectors;
public class FabricPermissions implements PermissionProvider {
private String permissionKey(String perm) {
return "dynmap." + perm;
}
@Override
public Set<String> hasOfflinePermissions(String player, Set<String> perms) {
return perms.stream()
.filter(perm -> hasOfflinePermission(player, perm))
.collect(Collectors.toSet());
}
@Override
public boolean hasOfflinePermission(String player, String perm) {
return DynmapPlugin.plugin.isOp(player.toLowerCase());
}
@Override
public boolean has(PlayerEntity player, String permission) {
if (player == null) return false;
String name = player.getName().getString().toLowerCase();
if (DynmapPlugin.plugin.isOp(name)) return true;
return Permissions.check(player, permissionKey(permission));
}
@Override
public boolean hasPermissionNode(PlayerEntity player, String permission) {
if (player != null) {
String name = player.getName().getString().toLowerCase();
return DynmapPlugin.plugin.isOp(name);
}
return false;
}
}

View File

@ -0,0 +1,103 @@
package org.dynmap.fabric_1_19_3.permissions;
import net.minecraft.entity.player.PlayerEntity;
import org.dynmap.ConfigurationNode;
import org.dynmap.Log;
import org.dynmap.fabric_1_19_3.DynmapPlugin;
import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class FilePermissions implements PermissionProvider {
private HashMap<String, Set<String>> perms;
private Set<String> defperms;
public static FilePermissions create() {
File f = new File("dynmap/permissions.yml");
if (!f.exists())
return null;
ConfigurationNode cfg = new ConfigurationNode(f);
cfg.load();
Log.info("Using permissions.yml for access control");
return new FilePermissions(cfg);
}
private FilePermissions(ConfigurationNode cfg) {
perms = new HashMap<String, Set<String>>();
for (String k : cfg.keySet()) {
List<String> p = cfg.getStrings(k, null);
if (p != null) {
k = k.toLowerCase();
HashSet<String> pset = new HashSet<String>();
for (String perm : p) {
pset.add(perm.toLowerCase());
}
perms.put(k, pset);
if (k.equals("defaultuser")) {
defperms = pset;
}
}
}
}
private boolean hasPerm(String player, String perm) {
Set<String> ps = perms.get(player);
if ((ps != null) && (ps.contains(perm))) {
return true;
}
if (defperms.contains(perm)) {
return true;
}
return false;
}
@Override
public Set<String> hasOfflinePermissions(String player, Set<String> perms) {
player = player.toLowerCase();
HashSet<String> rslt = new HashSet<String>();
if (DynmapPlugin.plugin.isOp(player)) {
rslt.addAll(perms);
} else {
for (String p : perms) {
if (hasPerm(player, p)) {
rslt.add(p);
}
}
}
return rslt;
}
@Override
public boolean hasOfflinePermission(String player, String perm) {
player = player.toLowerCase();
if (DynmapPlugin.plugin.isOp(player)) {
return true;
} else {
return hasPerm(player, perm);
}
}
@Override
public boolean has(PlayerEntity psender, String permission) {
if (psender != null) {
String n = psender.getName().getString().toLowerCase();
return hasPerm(n, permission);
}
return true;
}
@Override
public boolean hasPermissionNode(PlayerEntity psender, String permission) {
if (psender != null) {
String player = psender.getName().getString().toLowerCase();
return DynmapPlugin.plugin.isOp(player);
}
return false;
}
}

View File

@ -0,0 +1,102 @@
package org.dynmap.fabric_1_19_3.permissions;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.luckperms.api.LuckPerms;
import net.luckperms.api.LuckPermsProvider;
import net.luckperms.api.cacheddata.CachedPermissionData;
import net.luckperms.api.model.user.User;
import net.luckperms.api.util.Tristate;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.MinecraftServer;
import org.dynmap.Log;
import org.dynmap.fabric_1_19_3.DynmapPlugin;
import org.dynmap.json.simple.JSONArray;
import org.dynmap.json.simple.JSONObject;
import org.dynmap.json.simple.parser.JSONParser;
import org.dynmap.json.simple.parser.ParseException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
public class LuckPermissions implements PermissionProvider {
private final JSONParser parser = new JSONParser();
private LuckPerms api = null;
private Optional<LuckPerms> getApi() {
if (api != null) return Optional.of(api);
try {
api = LuckPermsProvider.get();
return Optional.of(api);
} catch (Exception ex) {
Log.warning("Trying to access LuckPerms before it has loaded");
return Optional.empty();
}
}
private Optional<UUID> cachedUUID(String username) {
try {
BufferedReader reader = new BufferedReader(new FileReader("usercache.json"));
JSONArray cache = (JSONArray) parser.parse(reader);
for (Object it : cache) {
JSONObject user = (JSONObject) it;
if (user.get("name").toString().equalsIgnoreCase(username)) {
String uuid = user.get("uuid").toString();
return Optional.of(UUID.fromString(uuid));
}
}
reader.close();
} catch (IOException | ParseException ex) {
Log.warning("Unable to read usercache.json");
}
return Optional.empty();
}
private String permissionKey(String perm) {
return "dynmap." + perm;
}
@Override
public Set<String> hasOfflinePermissions(String player, Set<String> perms) {
return perms.stream()
.filter(perm -> hasOfflinePermission(player, perm))
.collect(Collectors.toSet());
}
@Override
public boolean hasOfflinePermission(String player, String perm) {
if (DynmapPlugin.plugin.isOp(player.toLowerCase())) return true;
Optional<LuckPerms> api = getApi();
Optional<UUID> uuid = cachedUUID(player);
if (!uuid.isPresent() || !api.isPresent()) return false;
User user = api.get().getUserManager().loadUser(uuid.get()).join();
CachedPermissionData permissions = user.getCachedData().getPermissionData();
Tristate state = permissions.checkPermission(permissionKey(perm));
return state.asBoolean();
}
@Override
public boolean has(PlayerEntity player, String permission) {
if (player == null) return false;
String name = player.getName().getString().toLowerCase();
if (DynmapPlugin.plugin.isOp(name)) return true;
return Permissions.check(player, permissionKey(permission));
}
@Override
public boolean hasPermissionNode(PlayerEntity player, String permission) {
if (player != null) {
String name = player.getName().getString().toLowerCase();
return DynmapPlugin.plugin.isOp(name);
}
return false;
}
}

View File

@ -0,0 +1,52 @@
package org.dynmap.fabric_1_19_3.permissions;
import net.minecraft.entity.player.PlayerEntity;
import org.dynmap.Log;
import org.dynmap.fabric_1_19_3.DynmapPlugin;
import java.util.HashSet;
import java.util.Set;
public class OpPermissions implements PermissionProvider {
public HashSet<String> usrCommands = new HashSet<String>();
public OpPermissions(String[] usrCommands) {
for (String usrCommand : usrCommands) {
this.usrCommands.add(usrCommand);
}
Log.info("Using ops.txt for access control");
}
@Override
public Set<String> hasOfflinePermissions(String player, Set<String> perms) {
HashSet<String> rslt = new HashSet<String>();
if (DynmapPlugin.plugin.isOp(player)) {
rslt.addAll(perms);
}
return rslt;
}
@Override
public boolean hasOfflinePermission(String player, String perm) {
return DynmapPlugin.plugin.isOp(player);
}
@Override
public boolean has(PlayerEntity psender, String permission) {
if (psender != null) {
if (usrCommands.contains(permission)) {
return true;
}
return DynmapPlugin.plugin.isOp(psender.getName().getString());
}
return true;
}
@Override
public boolean hasPermissionNode(PlayerEntity psender, String permission) {
if (psender != null) {
return DynmapPlugin.plugin.isOp(psender.getName().getString());
}
return true;
}
}

View File

@ -0,0 +1,16 @@
package org.dynmap.fabric_1_19_3.permissions;
import net.minecraft.entity.player.PlayerEntity;
import java.util.Set;
public interface PermissionProvider {
boolean has(PlayerEntity sender, String permission);
boolean hasPermissionNode(PlayerEntity sender, String permission);
Set<String> hasOfflinePermissions(String player, Set<String> perms);
boolean hasOfflinePermission(String player, String perm);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View File

@ -0,0 +1,491 @@
# All paths in this configuration file are relative to Dynmap's data-folder: minecraft_server/dynmap/
# All map templates are defined in the templates directory
# To use the HDMap very-low-res (2 ppb) map templates as world defaults, set value to vlowres
# The definitions of these templates are in normal-vlowres.txt, nether-vlowres.txt, and the_end-vlowres.txt
# To use the HDMap low-res (4 ppb) map templates as world defaults, set value to lowres
# The definitions of these templates are in normal-lowres.txt, nether-lowres.txt, and the_end-lowres.txt
# To use the HDMap hi-res (16 ppb) map templates (these can take a VERY long time for initial fullrender), set value to hires
# The definitions of these templates are in normal-hires.txt, nether-hires.txt, and the_end-hires.txt
# To use the HDMap low-res (4 ppb) map templates, with support for boosting resolution selectively to hi-res (16 ppb), set value to low_boost_hi
# The definitions of these templates are in normal-low_boost_hi.txt, nether-low_boost_hi.txt, and the_end-low_boost_hi.txt
# To use the HDMap hi-res (16 ppb) map templates, with support for boosting resolution selectively to vhi-res (32 ppb), set value to hi_boost_vhi
# The definitions of these templates are in normal-hi_boost_vhi.txt, nether-hi_boost_vhi.txt, and the_end-hi_boost_vhi.txt
# To use the HDMap hi-res (16 ppb) map templates, with support for boosting resolution selectively to xhi-res (64 ppb), set value to hi_boost_xhi
# The definitions of these templates are in normal-hi_boost_xhi.txt, nether-hi_boost_xhi.txt, and the_end-hi_boost_xhi.txt
deftemplatesuffix: hires
# Set default tile scale (0 = 128px x 128x, 1 = 256px x 256px, 2 = 512px x 512px, 3 = 1024px x 1024px, 4 = 2048px x 2048px) - 0 is default
# Note: changing this value will result in all maps that use the default value being required to be fully rendered
#defaulttilescale: 0
# Map storage scheme: only uncommoent one 'type' value
# filetree: classic and default scheme: tree of files, with all map data under the directory indicated by 'tilespath' setting
# sqlite: single SQLite database file (this can get VERY BIG), located at 'dbfile' setting (default is file dynmap.db in data directory)
# mysql: MySQL database, at hostname:port in database, accessed via userid with password
# mariadb: MariaDB database, at hostname:port in database, accessed via userid with password
# postgres: PostgreSQL database, at hostname:port in database, accessed via userid with password
storage:
# Filetree storage (standard tree of image files for maps)
type: filetree
# SQLite db for map storage (uses dbfile as storage location)
#type: sqlite
#dbfile: dynmap.db
# MySQL DB for map storage (at 'hostname':'port' in database 'database' using user 'userid' password 'password' and table prefix 'prefix'
#type: mysql
#hostname: localhost
#port: 3306
#database: dynmap
#userid: dynmap
#password: dynmap
#prefix: ""
#
# AWS S3 backet web site
#type: aws_s3
#bucketname: "dynmap-bucket-name"
#region: us-east-1
#aws_access_key_id: "<aws-access-key-id>"
#aws_secret_access_key: "<aws-secret-access-key>"
#prefix: ""
components:
- class: org.dynmap.ClientConfigurationComponent
- class: org.dynmap.InternalClientUpdateComponent
sendhealth: true
sendposition: true
allowwebchat: true
webchat-interval: 5
hidewebchatip: false
trustclientname: false
includehiddenplayers: false
# (optional) if true, color codes in player display names are used
use-name-colors: false
# (optional) if true, player login IDs will be used for web chat when their IPs match
use-player-login-ip: true
# (optional) if use-player-login-ip is true, setting this to true will cause chat messages not matching a known player IP to be ignored
require-player-login-ip: false
# (optional) block player login IDs that are banned from chatting
block-banned-player-chat: true
# Require login for web-to-server chat (requires login-enabled: true)
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
# 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
# If true, hide players with invisibility potion effects active
hide-if-invisiblity-potion: true
# If true, player names are not shown on map, chat, list
hidenames: false
#- class: org.dynmap.JsonFileClientUpdateComponent
# writeinterval: 1
# sendhealth: true
# sendposition: true
# allowwebchat: true
# webchat-interval: 5
# hidewebchatip: false
# includehiddenplayers: false
# use-name-colors: false
# use-player-login-ip: false
# require-player-login-ip: false
# block-banned-player-chat: true
# hideifshadow: 0
# hideifundercover: 0
# hideifsneaking: false
# # Require login for web-to-server chat (requires login-enabled: true)
# 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
# hide-if-invisiblity-potion: true
# hidenames: false
- class: org.dynmap.SimpleWebChatComponent
allowchat: true
# If true, web UI users can supply name for chat using 'playername' URL parameter. 'trustclientname' must also be set true.
allowurlname: false
# Note: this component is needed for the dmarker commands, and for the Marker API to be available to other plugins
- class: org.dynmap.MarkersComponent
type: markers
showlabel: false
enablesigns: false
# Default marker set for sign markers
default-sign-set: markers
# (optional) add spawn point markers to standard marker layer
showspawn: true
spawnicon: world
spawnlabel: "Spawn"
# (optional) layer for showing offline player's positions (for 'maxofflinetime' minutes after logoff)
showofflineplayers: false
offlinelabel: "Offline"
offlineicon: offlineuser
offlinehidebydefault: true
offlineminzoom: 0
maxofflinetime: 30
# (optional) layer for showing player's spawn beds
showspawnbeds: false
spawnbedlabel: "Spawn Beds"
spawnbedicon: bed
spawnbedhidebydefault: true
spawnbedminzoom: 0
spawnbedformat: "%name%'s bed"
# (optional) Show world border (vanilla 1.8+)
showworldborder: true
worldborderlabel: "Border"
- class: org.dynmap.ClientComponent
type: chat
allowurlname: false
- class: org.dynmap.ClientComponent
type: chatballoon
focuschatballoons: false
- class: org.dynmap.ClientComponent
type: chatbox
showplayerfaces: true
messagettl: 5
# Optional: set number of lines in scrollable message history: if set, messagettl is not used to age out messages
#scrollback: 100
# Optional: set maximum number of lines visible for chatbox
#visiblelines: 10
# Optional: send push button
sendbutton: false
- class: org.dynmap.ClientComponent
type: playermarkers
showplayerfaces: true
showplayerhealth: true
# If true, show player body too (only valid if showplayerfaces=true)
showplayerbody: false
# Option to make player faces small - don't use with showplayerhealth or largeplayerfaces
smallplayerfaces: false
# Option to make player faces larger - don't use with showplayerhealth or smallplayerfaces
largeplayerfaces: false
# Optional - make player faces layer hidden by default
hidebydefault: false
# Optional - ordering priority in layer menu (low goes before high - default is 0)
layerprio: 0
# Optional - label for player marker layer (default is 'Players')
label: "Players"
#- class: org.dynmap.ClientComponent
# type: digitalclock
- class: org.dynmap.ClientComponent
type: link
- class: org.dynmap.ClientComponent
type: timeofdayclock
showdigitalclock: true
#showweather: true
# Mouse pointer world coordinate display
- class: org.dynmap.ClientComponent
type: coord
label: "Location"
hidey: false
show-mcr: false
show-chunk: 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
# timeout: 1800 # in seconds (1800 seconds = 30 minutes)
# redirecturl: inactive.html
# #showmessage: 'You were inactive for too long.'
#- class: org.dynmap.TestComponent
# stuff: "This is some configuration-value"
# Treat hiddenplayers.txt as a whitelist for players to be shown on the map? (Default false)
display-whitelist: false
# How often a tile gets rendered (in seconds).
renderinterval: 1
# How many tiles on update queue before accelerate render interval
renderacceleratethreshold: 60
# How often to render tiles when backlog is above renderacceleratethreshold
renderaccelerateinterval: 0.2
# How many update tiles to work on at once (if not defined, default is 1/2 the number of cores)
tiles-rendered-at-once: 2
# If true, use normal priority threads for rendering (versus low priority) - this can keep rendering
# from starving on busy Windows boxes (Linux JVMs pretty much ignore thread priority), but may result
# in more competition for CPU resources with other processes
usenormalthreadpriority: true
# Save and restore pending tile renders - prevents their loss on server shutdown or /reload
saverestorepending: true
# Save period for pending jobs (in seconds): periodic saving for crash recovery of jobs
save-pending-period: 900
# Zoom-out tile update period - how often to scan for and process tile updates into zoom-out tiles (in seconds)
zoomoutperiod: 30
# Control whether zoom out tiles are validated on startup (can be needed if zoomout processing is interrupted, but can be expensive on large maps)
initial-zoomout-validate: true
# Default delay on processing of updated tiles, in seconds. This can reduce potentially expensive re-rendering
# of frequently updated tiles (such as due to machines, pistons, quarries or other automation). Values can
# also be set on individual worlds and individual maps.
tileupdatedelay: 30
# Tile hashing is used to minimize tile file updates when no changes have occurred - set to false to disable
enabletilehash: true
# Optional - hide ores: render as normal stone (so that they aren't revealed by maps)
#hideores: true
# Optional - enabled BetterGrass style rendering of grass and snow block sides
#better-grass: true
# Optional - enable smooth lighting by default on all maps supporting it (can be set per map as lighting option)
smooth-lighting: true
# Optional - use world provider lighting table (good for custom worlds with custom lighting curves, like nether)
# false=classic Dynmap lighting curve
use-brightness-table: true
# Optional - render specific block names using the textures and models of another block name: 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-alias:
# "minecraft:quartz_ore": "stone"
# "diamond_ore": "coal_ore"
# Default image format for HDMaps (png, jpg, jpg-q75, jpg-q80, jpg-q85, jpg-q90, jpg-q95, jpg-q100, webp, webp-q75, webp-q80, webp-q85, webp-q90, webp-q95, webp-q100, webp-l),
# Note: any webp format requires the presence of the 'webp command line tools' (cwebp, dwebp) (https://developers.google.com/speed/webp/download)
#
# Has no effect on maps with explicit format settings
image-format: jpg-q90
# If cwebp or dwebp are not on the PATH, use these settings to provide their full path. Do not use these settings if the tools are on the PATH
# For Windows, include .exe
#
#cwebpPath: /usr/bin/cwebp
#dwebpPath: /usr/bin/dwebp
# use-generated-textures: if true, use generated textures (same as client); false is static water/lava textures
# correct-water-lighting: if true, use corrected water lighting (same as client); false is legacy water (darker)
# transparent-leaves: if true, leaves are transparent (lighting-wise): false is needed for some Spout versions that break lighting on leaf blocks
use-generated-textures: true
correct-water-lighting: true
transparent-leaves: true
# ctm-support: if true, Connected Texture Mod (CTM) in texture packs is enabled (default)
ctm-support: true
# custom-colors-support: if true, Custom Colors in texture packs is enabled (default)
custom-colors-support: true
# Control loading of player faces (if set to false, skins are never fetched)
#fetchskins: false
# Control updating of player faces, once loaded (if faces are being managed by other apps or manually)
#refreshskins: false
# Customize URL used for fetching player skins (%player% is macro for name, %uuid% for UUID)
skin-url: "http://skins.minecraft.net/MinecraftSkins/%player%.png"
# Control behavior for new (1.0+) compass orientation (sunrise moved 90 degrees: east is now what used to be south)
# default is 'newrose' (preserve pre-1.0 maps, rotate rose)
# 'newnorth' is used to rotate maps and rose (requires fullrender of any HDMap map - same as 'newrose' for FlatMap or KzedMap)
compass-mode: newnorth
# Triggers for automatic updates : blockupdate-with-id is debug for breaking down updates by ID:meta
# To disable, set just 'none' and comment/delete the rest
render-triggers:
- blockupdate
#- blockupdate-with-id
- chunkgenerate
#- none
# Title for the web page - if not specified, defaults to the server's name (unless it is the default of 'Unknown Server')
#webpage-title: "My Awesome Server Map"
# The path where the tile-files are placed.
tilespath: web/tiles
# The path where the web-files are located.
webpath: web
# If set to false, disable extraction of webpath content (good if using custom web UI or 3rd party web UI)
# Note: web interface is unsupported in this configuration - you're on your own
update-webpath-files: true
# The path were the /dynmapexp command exports OBJ ZIP files
exportpath: export
# The network-interface the webserver will bind to (0.0.0.0 for all interfaces, 127.0.0.1 for only local access).
# 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
# Maximum concurrent session on internal web server - limits resources used in Bukkit server
max-sessions: 30
# Disables Webserver portion of Dynmap (Advanced users only)
disable-webserver: false
# Enable/disable having the web server allow symbolic links (true=compatible with existing code, false=more secure (default))
allow-symlinks: true
# Enable login support
login-enabled: false
# Require login to access website (requires login-enabled: true)
login-required: false
# Period between tile renders for fullrender, in seconds (non-zero to pace fullrenders, lessen CPU load)
timesliceinterval: 0.0
# Maximum chunk loads per server tick (1/20th of a second) - reducing this below 90 will impact render performance, but also will reduce server thread load
maxchunkspertick: 200
# Progress report interval for fullrender/radiusrender, in tiles. Must be 100 or greater
progressloginterval: 100
# Parallel fullrender: if defined, number of concurrent threads used for fullrender or radiusrender
# Note: setting this will result in much more intensive CPU use, some additional memory use. Caution should be used when
# setting this to equal or exceed the number of physical cores on the system.
#parallelrendercnt: 4
# Interval the browser should poll for updates.
updaterate: 2000
# If nonzero, server will pause fullrender/radiusrender processing when 'fullrenderplayerlimit' or more users are logged in
fullrenderplayerlimit: 0
# If nonzero, server will pause update render processing when 'updateplayerlimit' or more users are logged in
updateplayerlimit: 0
# Target limit on server thread use - msec per tick
per-tick-time-limit: 50
# If TPS of server is below this setting, update renders processing is paused
update-min-tps: 18.0
# If TPS of server is below this setting, full/radius renders processing is paused
fullrender-min-tps: 18.0
# If TPS of server is below this setting, zoom out processing is paused
zoomout-min-tps: 18.0
showplayerfacesinmenu: true
# Control whether players that are hidden or not on current map are grayed out (true=yes)
grayplayerswhenhidden: true
# Set sidebaropened: 'true' to pin menu sidebar opened permanently, 'pinned' to default the sidebar to pinned, but allow it to unpin
#sidebaropened: true
# Customized HTTP response headers - add 'id: value' pairs to all HTTP response headers (internal web server only)
#http-response-headers:
# Access-Control-Allow-Origin: "my-domain.com"
# X-Custom-Header-Of-Mine: "MyHeaderValue"
# Trusted proxies for web server - which proxy addresses are trusted to supply valid X-Forwarded-For fields
# This now supports both IP address, and subnet ranges (e.g. 192.168.1.0/24 or 202.24.0.0/14 )
trusted-proxies:
- "127.0.0.1"
- "0:0:0:0:0:0:0:1"
joinmessage: "%playername% joined"
quitmessage: "%playername% quit"
spammessage: "You may only chat once every %interval% seconds."
# format for messages from web: %playername% substitutes sender ID (typically IP), %message% includes text
webmsgformat: "&color;2[WEB] %playername%: &color;f%message%"
# Control whether layer control is presented on the UI (default is true)
showlayercontrol: true
# Enable checking for banned IPs via banned-ips.txt (internal web server only)
check-banned-ips: true
# Default selection when map page is loaded
defaultzoom: 0
defaultworld: world
defaultmap: flat
# (optional) Zoom level and map to switch to when following a player, if possible
#followzoom: 3
#followmap: surface
# If true, make persistent record of IP addresses used by player logins, to support web IP to player matching
persist-ids-by-ip: true
# If true, map text to cyrillic
cyrillic-support: false
# Messages to customize
msg:
maptypes: "Map Types"
players: "Players"
chatrequireslogin: "Chat Requires Login"
chatnotallowed: "You are not permitted to send chat messages"
hiddennamejoin: "Player joined"
hiddennamequit: "Player quit"
# URL for client configuration (only need to be tailored for proxies or other non-standard configurations)
url:
# configuration URL
#configuration: "up/configuration"
# update URL
#update: "up/world/{world}/{timestamp}"
# sendmessage URL
#sendmessage: "up/sendmessage"
# login URL
#login: "up/login"
# register URL
#register: "up/register"
# tiles base URL
#tiles: "tiles/"
# markers base URL
#markers: "tiles/"
# Snapshot cache size, in chunks
snapshotcachesize: 500
# Snapshot cache uses soft references (true), else weak references (false)
soft-ref-cache: true
# Player enter/exit title messages for map markers
#
# Processing period - how often to check player positions vs markers - default is 1000ms (1 second)
#enterexitperiod: 1000
# Title message fade in time, in ticks (0.05 second intervals) - default is 10 (1/2 second)
#titleFadeIn: 10
# Title message stay time, in ticks (0.05 second intervals) - default is 70 (3.5 seconds)
#titleStay: 70
# Title message fade out time, in ticks (0.05 seocnd intervals) - default is 20 (1 second)
#titleFadeOut: 20
# Enter/exit messages use on screen titles (true - default), if false chat messages are sent instead
#enterexitUseTitle: true
# Set true if new enter messages should supercede pending exit messages (vs being queued in order), default false
#enterReplacesExits: true
# Published public URL for Dynmap server (allows users to use 'dynmap url' command to get public URL usable to access server
# If not set, 'dynmap url' will not return anything. URL should be fully qualified (e.g. https://mc.westeroscraft.com/)
#publicURL: http://my.greatserver.com/dynmap
# Set to true to enable verbose startup messages - can help with debugging map configuration problems
# Set to false for a much quieter startup log
verbose: false
# Enables debugging.
#debuggers:
# - class: org.dynmap.debug.LogDebugger
# Debug: dump blocks missing render data
dump-missing-blocks: false
# Log4J defense: string substituted for attempts to use macros in web chat
hackAttemptBlurb: "(IaM5uchA1337Haxr-Ban Me!)"

View File

@ -0,0 +1,19 @@
{
"required": true,
"minVersion": "0.8",
"package": "org.dynmap.fabric_1_19_3.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"BiomeEffectsAccessor",
"MinecraftServerMixin",
"PlayerManagerMixin",
"ProtoChunkMixin",
"ServerPlayerEntityMixin",
"ServerPlayNetworkHandlerMixin",
"ThreadedAnvilChunkStorageMixin",
"WorldChunkMixin"
],
"injectors": {
"defaultRequire": 1
}
}

View File

@ -0,0 +1,33 @@
{
"schemaVersion": 1,
"id": "dynmap",
"version": "${version}",
"name": "Dynmap",
"description": "Dynamic, Google-maps style rendered maps for your Minecraft server",
"authors": [
"mikeprimm",
"LolHens",
"i509VCB"
],
"contact": {
"homepage": "https://github.com/webbukkit/dynmap",
"sources": "https://github.com/webbukkit/dynmap"
},
"license": "Apache-2.0",
"icon": "assets/dynmap/icon.png",
"environment": "*",
"entrypoints": {
"main": [
"org.dynmap.fabric_1_19_3.DynmapMod"
]
},
"mixins": [
"dynmap.mixins.json"
],
"depends": {
"fabricloader": ">=0.14.11",
"fabric": ">=0.68.1",
"minecraft": ["1.19.3"]
}
}

Some files were not shown because too many files have changed in this diff Show More