mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-12-26 19:08:03 +01:00
Add </bluemap debug dump> command
This commit is contained in:
parent
d3fe328d8e
commit
8ad048ae2a
@ -29,6 +29,7 @@
|
||||
import de.bluecolored.bluemap.common.web.WebSettings;
|
||||
import de.bluecolored.bluemap.core.MinecraftVersion;
|
||||
import de.bluecolored.bluemap.core.config.*;
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import de.bluecolored.bluemap.core.map.BmMap;
|
||||
import de.bluecolored.bluemap.core.map.hires.RenderSettings;
|
||||
@ -47,6 +48,7 @@
|
||||
/**
|
||||
* This is the attempt to generalize as many actions as possible to have CLI and Plugins run on the same general setup-code.
|
||||
*/
|
||||
@DebugDump
|
||||
public class BlueMapService {
|
||||
private final MinecraftVersion minecraftVersion;
|
||||
private final File configFolder;
|
||||
|
@ -39,6 +39,8 @@
|
||||
import de.bluecolored.bluemap.core.config.CoreConfig;
|
||||
import de.bluecolored.bluemap.core.config.RenderConfig;
|
||||
import de.bluecolored.bluemap.core.config.WebServerConfig;
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import de.bluecolored.bluemap.core.debug.StateDumper;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import de.bluecolored.bluemap.core.map.BmMap;
|
||||
import de.bluecolored.bluemap.core.metrics.Metrics;
|
||||
@ -55,6 +57,7 @@
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@DebugDump
|
||||
public class Plugin {
|
||||
|
||||
public static final String PLUGIN_ID = "bluemap";
|
||||
@ -94,6 +97,8 @@ public Plugin(MinecraftVersion minecraftVersion, String implementationType, Serv
|
||||
this.minecraftVersion = minecraftVersion;
|
||||
this.implementationType = implementationType.toLowerCase();
|
||||
this.serverInterface = serverInterface;
|
||||
|
||||
StateDumper.global().register(this);
|
||||
}
|
||||
|
||||
public void load() throws IOException, ParseResourceException {
|
||||
|
@ -24,6 +24,7 @@
|
||||
*/
|
||||
package de.bluecolored.bluemap.common.plugin;
|
||||
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -31,6 +32,7 @@
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@DebugDump
|
||||
public class PluginConfig {
|
||||
|
||||
private boolean liveUpdatesEnabled = false;
|
||||
|
@ -27,6 +27,7 @@
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
import de.bluecolored.bluemap.common.rendermanager.RenderManager;
|
||||
import de.bluecolored.bluemap.common.rendermanager.WorldRegionRenderTask;
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import de.bluecolored.bluemap.core.map.BmMap;
|
||||
|
||||
@ -47,6 +48,8 @@ public class RegionFileWatchService extends Thread {
|
||||
private volatile boolean closed;
|
||||
|
||||
private Timer delayTimer;
|
||||
|
||||
@DebugDump
|
||||
private final Map<Vector2i, TimerTask> scheduledUpdates;
|
||||
|
||||
public RegionFileWatchService(RenderManager renderManager, BmMap map, boolean verbose) throws IOException {
|
||||
|
@ -49,9 +49,13 @@
|
||||
import de.bluecolored.bluemap.common.plugin.text.Text;
|
||||
import de.bluecolored.bluemap.common.plugin.text.TextColor;
|
||||
import de.bluecolored.bluemap.common.plugin.text.TextFormat;
|
||||
import de.bluecolored.bluemap.common.rendermanager.*;
|
||||
import de.bluecolored.bluemap.common.rendermanager.MapPurgeTask;
|
||||
import de.bluecolored.bluemap.common.rendermanager.MapUpdateTask;
|
||||
import de.bluecolored.bluemap.common.rendermanager.RenderTask;
|
||||
import de.bluecolored.bluemap.common.rendermanager.WorldRegionRenderTask;
|
||||
import de.bluecolored.bluemap.core.BlueMap;
|
||||
import de.bluecolored.bluemap.core.MinecraftVersion;
|
||||
import de.bluecolored.bluemap.core.debug.StateDumper;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import de.bluecolored.bluemap.core.map.BmMap;
|
||||
import de.bluecolored.bluemap.core.map.MapRenderState;
|
||||
@ -136,6 +140,10 @@ public void init() {
|
||||
|
||||
.then(literal("cache")
|
||||
.executes(this::debugClearCacheCommand))
|
||||
|
||||
|
||||
.then(literal("dump")
|
||||
.executes(this::debugDumpCommand))
|
||||
|
||||
.build();
|
||||
|
||||
@ -357,6 +365,7 @@ public int versionCommand(CommandContext<S> context) {
|
||||
}
|
||||
|
||||
source.sendMessage(Text.of(TextFormat.BOLD, TextColor.BLUE, "Version: ", TextColor.WHITE, BlueMap.VERSION));
|
||||
source.sendMessage(Text.of(TextColor.GRAY, "Commit: ", TextColor.WHITE, BlueMap.GIT_HASH + " (" + BlueMap.GIT_CLEAN + ")"));
|
||||
source.sendMessage(Text.of(TextColor.GRAY, "Implementation: ", TextColor.WHITE, plugin.getImplementationType()));
|
||||
source.sendMessage(Text.of(
|
||||
TextColor.GRAY, "Minecraft compatibility: ", TextColor.WHITE, plugin.getMinecraftVersion().getVersionString(),
|
||||
@ -369,6 +378,7 @@ public int versionCommand(CommandContext<S> context) {
|
||||
if (plugin.getMinecraftVersion().isAtLeast(new MinecraftVersion(1, 15))) {
|
||||
String clipboardValue =
|
||||
"Version: " + BlueMap.VERSION + "\n" +
|
||||
"Commit: " + BlueMap.GIT_HASH + " (" + BlueMap.GIT_CLEAN + ")\n" +
|
||||
"Implementation: " + plugin.getImplementationType() + "\n" +
|
||||
"Minecraft compatibility: " + plugin.getMinecraftVersion().getVersionString() + " (" + plugin.getMinecraftVersion().getResource().getVersion().getVersionString() + ")\n" +
|
||||
"Render-threads: " + renderThreadCount + "\n" +
|
||||
@ -541,6 +551,22 @@ public int debugBlockCommand(CommandContext<S> context) {
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int debugDumpCommand(CommandContext<S> context) {
|
||||
final CommandSource source = commandSourceInterface.apply(context.getSource());
|
||||
|
||||
try {
|
||||
Path file = plugin.getCoreConfig().getDataFolder().toPath().resolve("dump.json");
|
||||
StateDumper.global().dump(file);
|
||||
|
||||
source.sendMessage(Text.of(TextColor.GREEN, "Dump created at: " + file));
|
||||
return 1;
|
||||
} catch (IOException ex) {
|
||||
Logger.global.logError("Failed to create dump!", ex);
|
||||
source.sendMessage(Text.of(TextColor.RED, "Exception trying to create dump! See console for details."));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int stopCommand(CommandContext<S> context) {
|
||||
CommandSource source = commandSourceInterface.apply(context.getSource());
|
||||
|
@ -27,6 +27,7 @@
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
@ -41,6 +42,7 @@
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
@DebugDump
|
||||
public class PlayerSkin {
|
||||
|
||||
private final UUID uuid;
|
||||
|
@ -25,6 +25,7 @@
|
||||
package de.bluecolored.bluemap.common.plugin.skins;
|
||||
|
||||
import de.bluecolored.bluemap.common.plugin.serverinterface.ServerEventListener;
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
@ -33,6 +34,7 @@
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@DebugDump
|
||||
public class PlayerSkinUpdater implements ServerEventListener {
|
||||
|
||||
private File storageFolder;
|
||||
|
@ -24,8 +24,14 @@
|
||||
*/
|
||||
package de.bluecolored.bluemap.common.rendermanager;
|
||||
|
||||
import java.util.*;
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@DebugDump
|
||||
public class CombinedRenderTask<T extends RenderTask> implements RenderTask {
|
||||
|
||||
private final String description;
|
||||
|
@ -24,6 +24,7 @@
|
||||
*/
|
||||
package de.bluecolored.bluemap.common.rendermanager;
|
||||
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import de.bluecolored.bluemap.core.map.BmMap;
|
||||
import de.bluecolored.bluemap.core.util.FileUtils;
|
||||
|
||||
@ -35,13 +36,13 @@
|
||||
|
||||
public class MapPurgeTask implements RenderTask {
|
||||
|
||||
private final BmMap map;
|
||||
private final Path directory;
|
||||
private final int subFilesCount;
|
||||
@DebugDump private final BmMap map;
|
||||
@DebugDump private final Path directory;
|
||||
@DebugDump private final int subFilesCount;
|
||||
private final LinkedList<Path> subFiles;
|
||||
|
||||
private volatile boolean hasMoreWork;
|
||||
private volatile boolean cancelled;
|
||||
@DebugDump private volatile boolean hasMoreWork;
|
||||
@DebugDump private volatile boolean cancelled;
|
||||
|
||||
public MapPurgeTask(Path mapDirectory) throws IOException {
|
||||
this(null, mapDirectory);
|
||||
|
@ -25,6 +25,7 @@
|
||||
package de.bluecolored.bluemap.common.rendermanager;
|
||||
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import de.bluecolored.bluemap.core.map.BmMap;
|
||||
import de.bluecolored.bluemap.core.world.Grid;
|
||||
import de.bluecolored.bluemap.core.world.World;
|
||||
@ -34,6 +35,7 @@
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@DebugDump
|
||||
public class MapUpdateTask extends CombinedRenderTask<WorldRegionRenderTask> {
|
||||
|
||||
private final BmMap map;
|
||||
|
@ -24,6 +24,7 @@
|
||||
*/
|
||||
package de.bluecolored.bluemap.common.rendermanager;
|
||||
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
|
||||
import java.util.*;
|
||||
@ -34,17 +35,17 @@
|
||||
public class RenderManager {
|
||||
private static final AtomicInteger nextRenderManagerIndex = new AtomicInteger(0);
|
||||
|
||||
private final int id;
|
||||
private volatile boolean running;
|
||||
@DebugDump private final int id;
|
||||
@DebugDump private volatile boolean running;
|
||||
|
||||
private final AtomicInteger nextWorkerThreadIndex;
|
||||
private final Collection<WorkerThread> workerThreads;
|
||||
@DebugDump private final Collection<WorkerThread> workerThreads;
|
||||
private final AtomicInteger busyCount;
|
||||
|
||||
private ProgressTracker progressTracker;
|
||||
private volatile boolean newTask;
|
||||
|
||||
private final LinkedList<RenderTask> renderTasks;
|
||||
@DebugDump private final LinkedList<RenderTask> renderTasks;
|
||||
|
||||
public RenderManager() {
|
||||
this.id = nextRenderManagerIndex.getAndIncrement();
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
import com.flowpowered.math.vector.Vector2l;
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import de.bluecolored.bluemap.core.map.BmMap;
|
||||
import de.bluecolored.bluemap.core.world.Grid;
|
||||
import de.bluecolored.bluemap.core.world.Region;
|
||||
@ -35,16 +36,16 @@
|
||||
|
||||
public class WorldRegionRenderTask implements RenderTask {
|
||||
|
||||
private final BmMap map;
|
||||
private final Vector2i worldRegion;
|
||||
private final boolean force;
|
||||
@DebugDump private final BmMap map;
|
||||
@DebugDump private final Vector2i worldRegion;
|
||||
@DebugDump private final boolean force;
|
||||
|
||||
private Deque<Vector2i> tiles;
|
||||
private int tileCount;
|
||||
private long startTime;
|
||||
@DebugDump private int tileCount;
|
||||
@DebugDump private long startTime;
|
||||
|
||||
private volatile int atWork;
|
||||
private volatile boolean cancelled;
|
||||
@DebugDump private volatile int atWork;
|
||||
@DebugDump private volatile boolean cancelled;
|
||||
|
||||
public WorldRegionRenderTask(BmMap map, Vector2i worldRegion) {
|
||||
this(map, worldRegion, false);
|
||||
|
@ -16,13 +16,16 @@ test {
|
||||
}
|
||||
|
||||
processResources {
|
||||
def git = versionDetails()
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
include 'de/bluecolored/bluemap/version.json'
|
||||
duplicatesStrategy = DuplicatesStrategy.WARN
|
||||
|
||||
|
||||
expand (
|
||||
version: project.version
|
||||
)
|
||||
version: project.version,
|
||||
gitHash: git.gitHashFull,
|
||||
gitClean: git.isCleanTag
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
package de.bluecolored.bluemap.core;
|
||||
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.gson.GsonConfigurationLoader;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -32,18 +33,29 @@
|
||||
|
||||
public class BlueMap {
|
||||
|
||||
public static final String VERSION;
|
||||
public static final String VERSION, GIT_HASH, GIT_CLEAN;
|
||||
static {
|
||||
String version = "DEV";
|
||||
String version = "DEV", gitHash = "DEV", gitClean = "DEV";
|
||||
try {
|
||||
version = GsonConfigurationLoader.builder().url(BlueMap.class.getResource("/de/bluecolored/bluemap/version.json")).build().load().node("version").getString("DEV");
|
||||
ConfigurationNode node = GsonConfigurationLoader.builder()
|
||||
.url(BlueMap.class.getResource("/de/bluecolored/bluemap/version.json"))
|
||||
.build()
|
||||
.load();
|
||||
|
||||
version = node.node("version").getString("DEV");
|
||||
gitHash = node.node("git-hash").getString("DEV");
|
||||
gitClean = node.node("git-clean").getString("DEV");
|
||||
} catch (IOException ex) {
|
||||
Logger.global.logError("Failed to load version.json from resources!", ex);
|
||||
}
|
||||
|
||||
if (version.equals("${version}")) version = "DEV";
|
||||
if (gitHash.equals("${gitHash}")) version = "DEV";
|
||||
if (gitClean.equals("${gitClean}")) version = "DEV";
|
||||
|
||||
VERSION = version;
|
||||
GIT_HASH = gitHash;
|
||||
GIT_CLEAN = gitClean;
|
||||
}
|
||||
|
||||
public static final ForkJoinPool THREAD_POOL = new ForkJoinPool();
|
||||
|
@ -24,6 +24,7 @@
|
||||
*/
|
||||
package de.bluecolored.bluemap.core;
|
||||
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import de.bluecolored.bluemap.core.util.Lazy;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -40,7 +41,10 @@ public class MinecraftVersion implements Comparable<MinecraftVersion> {
|
||||
public static final MinecraftVersion EARLIEST_SUPPORTED = new MinecraftVersion(1, 12, 2);
|
||||
public static final MinecraftVersion THE_FLATTENING = new MinecraftVersion(1, 13);
|
||||
|
||||
@DebugDump
|
||||
private final int major, minor, patch;
|
||||
|
||||
@DebugDump
|
||||
private final Lazy<MinecraftResource> resource;
|
||||
|
||||
public MinecraftVersion(int major, int minor) {
|
||||
@ -148,9 +152,9 @@ public enum MinecraftResource {
|
||||
MC_1_16_2 (new MinecraftVersion(1, 16, 2), "mc1_16", "https://launcher.mojang.com/v1/objects/653e97a2d1d76f87653f02242d243cdee48a5144/client.jar"),
|
||||
MC_1_17 (new MinecraftVersion(1, 17), "mc1_16", "https://launcher.mojang.com/v1/objects/1cf89c77ed5e72401b869f66410934804f3d6f52/client.jar");
|
||||
|
||||
private final MinecraftVersion version;
|
||||
private final String resourcePrefix;
|
||||
private final String clientUrl;
|
||||
@DebugDump private final MinecraftVersion version;
|
||||
@DebugDump private final String resourcePrefix;
|
||||
@DebugDump private final String clientUrl;
|
||||
|
||||
MinecraftResource(MinecraftVersion version, String resourcePrefix, String clientUrl) {
|
||||
this.version = version;
|
||||
|
@ -24,6 +24,7 @@
|
||||
*/
|
||||
package de.bluecolored.bluemap.core.config;
|
||||
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
import java.io.File;
|
||||
@ -31,10 +32,10 @@
|
||||
|
||||
public class CoreConfig {
|
||||
|
||||
private boolean downloadAccepted = false;
|
||||
private int renderThreadCount = 0;
|
||||
private boolean metricsEnabled = false;
|
||||
private File dataFolder = new File("data");
|
||||
@DebugDump private boolean downloadAccepted = false;
|
||||
@DebugDump private int renderThreadCount = 0;
|
||||
@DebugDump private boolean metricsEnabled = false;
|
||||
@DebugDump private File dataFolder = new File("data");
|
||||
|
||||
|
||||
public CoreConfig(ConfigurationNode node) throws IOException {
|
||||
|
@ -26,14 +26,15 @@
|
||||
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
import com.flowpowered.math.vector.Vector3i;
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import de.bluecolored.bluemap.core.map.MapSettings;
|
||||
import de.bluecolored.bluemap.core.map.hires.RenderSettings;
|
||||
import de.bluecolored.bluemap.core.util.ConfigUtils;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@DebugDump
|
||||
public class MapConfig implements MapSettings {
|
||||
private static final Pattern VALID_ID_PATTERN = Pattern.compile("[a-zA-Z0-9_]+");
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
*/
|
||||
package de.bluecolored.bluemap.core.config;
|
||||
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
import java.io.File;
|
||||
@ -31,6 +32,7 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@DebugDump
|
||||
public class RenderConfig {
|
||||
|
||||
private File webRoot = new File("web");
|
||||
|
@ -24,6 +24,7 @@
|
||||
*/
|
||||
package de.bluecolored.bluemap.core.config;
|
||||
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
|
||||
import java.io.File;
|
||||
@ -31,6 +32,7 @@
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
@DebugDump
|
||||
public class WebServerConfig {
|
||||
|
||||
private boolean enabled = true;
|
||||
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package de.bluecolored.bluemap.core.debug;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({
|
||||
ElementType.METHOD,
|
||||
ElementType.FIELD,
|
||||
ElementType.TYPE
|
||||
})
|
||||
public @interface DebugDump {
|
||||
|
||||
String value() default "";
|
||||
|
||||
}
|
@ -0,0 +1,236 @@
|
||||
/*
|
||||
* This file is part of BlueMap, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
|
||||
* Copyright (c) contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package de.bluecolored.bluemap.core.debug;
|
||||
|
||||
import de.bluecolored.bluemap.core.BlueMap;
|
||||
import org.spongepowered.configurate.ConfigurationNode;
|
||||
import org.spongepowered.configurate.ConfigurationOptions;
|
||||
import org.spongepowered.configurate.gson.GsonConfigurationLoader;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.nio.file.Path;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
public class StateDumper {
|
||||
|
||||
private static final StateDumper GLOBAL = new StateDumper();
|
||||
|
||||
private final Set<Object> instances = Collections.newSetFromMap(new WeakHashMap<>());
|
||||
|
||||
public void dump(Path file) throws IOException {
|
||||
GsonConfigurationLoader loader = GsonConfigurationLoader.builder()
|
||||
.path(file)
|
||||
.build();
|
||||
ConfigurationNode node = loader.createNode();
|
||||
|
||||
collectSystemInfo(node.node("system-info"));
|
||||
|
||||
Set<Object> alreadyDumped = Collections.newSetFromMap(new WeakHashMap<>());
|
||||
|
||||
ConfigurationNode dump = node.node("dump");
|
||||
for (Object instance : instances) {
|
||||
Class<?> type = instance.getClass();
|
||||
ConfigurationNode instanceDump = dump.node(type.getName()).appendListNode();
|
||||
dumpInstance(instance, loader.defaultOptions(), instanceDump, alreadyDumped);
|
||||
}
|
||||
|
||||
loader.save(node);
|
||||
|
||||
}
|
||||
|
||||
private void dumpInstance(Object instance, ConfigurationOptions options, ConfigurationNode node, Set<Object> alreadyDumped) throws SerializationException {
|
||||
|
||||
try {
|
||||
if (instance == null){
|
||||
node.raw(null);
|
||||
return;
|
||||
}
|
||||
|
||||
Class<?> type = instance.getClass();
|
||||
|
||||
if (!alreadyDumped.add(instance)) {
|
||||
node.set("<<" + instance.toString() + ">>");
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof Map) {
|
||||
int count = 0;
|
||||
Map<?, ?> map = (Map<?, ?>) instance;
|
||||
|
||||
if (map.isEmpty()){
|
||||
node.set(map.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
for (Map.Entry<?, ?> entry : map.entrySet()) {
|
||||
if (++count > 20) {
|
||||
node.appendListNode().set("<<" + (map.size() - 20) + " more elements>>");
|
||||
break;
|
||||
}
|
||||
|
||||
ConfigurationNode entryNode = node.appendListNode();
|
||||
dumpInstance(entry.getKey(), options, entryNode.node("key"), alreadyDumped);
|
||||
dumpInstance(entry.getValue(), options, entryNode.node("value"), alreadyDumped);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof Collection) {
|
||||
if (((Collection<?>) instance).isEmpty()){
|
||||
node.set(instance.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for (Object entry : (Collection<?>) instance) {
|
||||
if (++count > 20) {
|
||||
node.appendListNode().set("<<" + (((Collection<?>) instance).size() - 20) + " more elements>>");
|
||||
break;
|
||||
}
|
||||
|
||||
dumpInstance(entry, options, node.appendListNode(), alreadyDumped);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (instance instanceof Object[]) {
|
||||
if (((Object[]) instance).length == 0){
|
||||
node.set(instance.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
for (Object entry : (Object[]) instance) {
|
||||
if (++count > 20) {
|
||||
node.appendListNode().set("<<" + (((Object[]) instance).length - 20) + " more elements>>");
|
||||
break;
|
||||
}
|
||||
|
||||
dumpInstance(entry, options, node.appendListNode(), alreadyDumped);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
boolean allFields = type.isAnnotationPresent(DebugDump.class);
|
||||
|
||||
boolean foundSomething = false;
|
||||
for (Field field : type.getDeclaredFields()) {
|
||||
DebugDump dd = field.getAnnotation(DebugDump.class);
|
||||
if (dd == null){
|
||||
if (!allFields) continue;
|
||||
if (Modifier.isStatic(field.getModifiers())) continue;
|
||||
if (Modifier.isTransient(field.getModifiers())) continue;
|
||||
}
|
||||
foundSomething = true;
|
||||
|
||||
String key = "";
|
||||
if (dd != null) key = dd.value();
|
||||
if (key.isEmpty()) key = field.getName();
|
||||
|
||||
if (options.acceptsType(field.getType())) {
|
||||
field.setAccessible(true);
|
||||
node.node(key).set(field.get(instance));
|
||||
} else {
|
||||
field.setAccessible(true);
|
||||
dumpInstance(field.get(instance), options, node.node(key), alreadyDumped);
|
||||
}
|
||||
}
|
||||
|
||||
for (Method method : type.getDeclaredMethods()) {
|
||||
DebugDump dd = method.getAnnotation(DebugDump.class);
|
||||
if (dd == null) continue;
|
||||
foundSomething = true;
|
||||
|
||||
String key = dd.value();
|
||||
if (key.isEmpty()) key = method.toGenericString().replace(' ', '_');
|
||||
|
||||
if (options.acceptsType(method.getReturnType())) {
|
||||
method.setAccessible(true);
|
||||
node.node(key).set(method.invoke(instance));
|
||||
} else {
|
||||
method.setAccessible(true);
|
||||
dumpInstance(method.invoke(instance), options, node.node(key), alreadyDumped);
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundSomething) {
|
||||
node.set(instance.toString());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
node.set("Error: " + ex.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private void collectSystemInfo(ConfigurationNode node) throws SerializationException {
|
||||
node.node("bluemap-version").set(BlueMap.VERSION);
|
||||
node.node("git-hash").set(BlueMap.GIT_HASH);
|
||||
node.node("git-clean").set(BlueMap.GIT_CLEAN);
|
||||
|
||||
String[] properties = new String[]{
|
||||
"java.runtime.name",
|
||||
"java.runtime.version",
|
||||
"java.vm.vendor",
|
||||
"java.vm.name",
|
||||
"os.name",
|
||||
"os.version",
|
||||
"user.dir",
|
||||
"java.home",
|
||||
"file.separator",
|
||||
"sun.io.unicode.encoding",
|
||||
"java.class.version"
|
||||
};
|
||||
Map<String, String> propMap = new HashMap<>();
|
||||
for (String key : properties) {
|
||||
propMap.put(key, System.getProperty(key));
|
||||
}
|
||||
node.node("system-properties").set(propMap);
|
||||
|
||||
node.node("cores").set(Runtime.getRuntime().availableProcessors());
|
||||
node.node("max-memory").set(Runtime.getRuntime().maxMemory());
|
||||
node.node("total-memory").set(Runtime.getRuntime().totalMemory());
|
||||
node.node("free-memory").set(Runtime.getRuntime().freeMemory());
|
||||
|
||||
node.node("timestamp").set(System.currentTimeMillis());
|
||||
node.node("time").set(LocalDateTime.now().toString());
|
||||
}
|
||||
|
||||
public static StateDumper global() {
|
||||
return GLOBAL;
|
||||
}
|
||||
|
||||
public synchronized void register(Object instance) {
|
||||
GLOBAL.instances.add(instance);
|
||||
}
|
||||
|
||||
public synchronized void unregister(Object instance) {
|
||||
GLOBAL.instances.remove(instance);
|
||||
}
|
||||
|
||||
}
|
@ -25,7 +25,7 @@
|
||||
package de.bluecolored.bluemap.core.map;
|
||||
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
import de.bluecolored.bluemap.core.BlueMap;
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import de.bluecolored.bluemap.core.map.hires.HiresModel;
|
||||
import de.bluecolored.bluemap.core.map.hires.HiresModelManager;
|
||||
@ -40,6 +40,7 @@
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@DebugDump
|
||||
public class BmMap {
|
||||
|
||||
private final String id;
|
||||
|
@ -25,6 +25,7 @@
|
||||
package de.bluecolored.bluemap.core.map;
|
||||
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import de.bluecolored.bluemap.core.util.AtomicFileHelper;
|
||||
|
||||
import java.io.*;
|
||||
@ -33,6 +34,7 @@
|
||||
import java.util.zip.GZIPInputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
@DebugDump
|
||||
public class MapRenderState {
|
||||
|
||||
private final Map<Vector2i, Long> regionRenderTimes;
|
||||
|
@ -30,6 +30,7 @@
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import de.bluecolored.bluemap.core.BlueMap;
|
||||
import de.bluecolored.bluemap.core.MinecraftVersion;
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import de.bluecolored.bluemap.core.mca.extensions.*;
|
||||
import de.bluecolored.bluemap.core.mca.mapping.BiomeMapper;
|
||||
@ -53,11 +54,11 @@ public class MCAWorld implements World {
|
||||
private static final Grid CHUNK_GRID = new Grid(16);
|
||||
private static final Grid REGION_GRID = new Grid(32).multiply(CHUNK_GRID);
|
||||
|
||||
private final UUID uuid;
|
||||
private final Path worldFolder;
|
||||
@DebugDump private final UUID uuid;
|
||||
@DebugDump private final Path worldFolder;
|
||||
private final MinecraftVersion minecraftVersion;
|
||||
private String name;
|
||||
private Vector3i spawnPoint;
|
||||
@DebugDump private String name;
|
||||
@DebugDump private Vector3i spawnPoint;
|
||||
|
||||
private final LoadingCache<Vector2i, MCARegion> regionCache;
|
||||
private final LoadingCache<Vector2i, MCAChunk> chunkCache;
|
||||
@ -67,8 +68,8 @@ public class MCAWorld implements World {
|
||||
private BiomeMapper biomeMapper;
|
||||
|
||||
private final Map<String, List<BlockStateExtension>> blockStateExtensions;
|
||||
|
||||
private boolean ignoreMissingLightData;
|
||||
|
||||
@DebugDump private boolean ignoreMissingLightData;
|
||||
|
||||
private final Map<Integer, String> forgeBlockMappings;
|
||||
|
||||
|
@ -24,6 +24,11 @@
|
||||
*/
|
||||
package de.bluecolored.bluemap.core.metrics;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import de.bluecolored.bluemap.core.BlueMap;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
@ -32,13 +37,6 @@
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import de.bluecolored.bluemap.core.BlueMap;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
|
||||
public class Metrics {
|
||||
|
||||
private static final String METRICS_REPORT_URL = "https://metrics.bluecolored.de/bluemap/";
|
||||
@ -81,7 +79,7 @@ private static String sendData(String data) throws MalformedURLException, IOExce
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
while ((line = in.readLine()) != null) {
|
||||
builder.append(line + "\n");
|
||||
builder.append(line).append("\n");
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
|
@ -29,6 +29,7 @@
|
||||
import com.flowpowered.math.vector.Vector2i;
|
||||
import com.flowpowered.math.vector.Vector3f;
|
||||
import com.flowpowered.math.vector.Vector3i;
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import de.bluecolored.bluemap.core.util.ConfigUtils;
|
||||
import de.bluecolored.bluemap.core.util.MathUtils;
|
||||
import de.bluecolored.bluemap.core.world.Biome;
|
||||
@ -44,6 +45,7 @@
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Function;
|
||||
|
||||
@DebugDump
|
||||
public class BlockColorCalculator {
|
||||
|
||||
private BufferedImage foliageMap;
|
||||
|
@ -25,6 +25,7 @@
|
||||
package de.bluecolored.bluemap.core.resourcepack;
|
||||
|
||||
import de.bluecolored.bluemap.core.MinecraftVersion;
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import de.bluecolored.bluemap.core.resourcepack.BlockStateResource.Builder;
|
||||
import de.bluecolored.bluemap.core.resourcepack.fileaccess.BluemapAssetOverrideFileAccess;
|
||||
@ -42,6 +43,7 @@
|
||||
/**
|
||||
* Represents all resources (BlockStates / BlockModels and Textures) that are loaded and used to generate map-models.
|
||||
*/
|
||||
@DebugDump
|
||||
public class ResourcePack {
|
||||
|
||||
private static final String[] CONFIG_FILES = {
|
||||
|
@ -24,12 +24,16 @@
|
||||
*/
|
||||
package de.bluecolored.bluemap.core.util;
|
||||
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class Lazy<T> {
|
||||
|
||||
private Supplier<T> loader;
|
||||
|
||||
@DebugDump
|
||||
private T value;
|
||||
|
||||
public Lazy(Supplier<T> loader) {
|
||||
|
@ -24,6 +24,7 @@
|
||||
*/
|
||||
package de.bluecolored.bluemap.core.webserver;
|
||||
|
||||
import de.bluecolored.bluemap.core.debug.DebugDump;
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -33,6 +34,7 @@
|
||||
import java.net.SocketException;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
@DebugDump
|
||||
public class WebServer extends Thread {
|
||||
|
||||
private final int port;
|
||||
|
@ -1,3 +1,5 @@
|
||||
{
|
||||
"version": "${version}"
|
||||
"version": "${version}",
|
||||
"git-hash": "${gitHash}",
|
||||
"git-clean": "${gitClean}"
|
||||
}
|
@ -3,6 +3,7 @@ plugins {
|
||||
id 'java-library'
|
||||
id 'com.github.johnrengelman.shadow' version '6.1.0'
|
||||
id 'com.github.hierynomus.license' version '0.16.1'
|
||||
id 'com.palantir.git-version' version '0.12.3'
|
||||
}
|
||||
|
||||
allprojects {
|
||||
|
Loading…
Reference in New Issue
Block a user