From 93d8876b20baee08afd678a2064abd3be8c899c6 Mon Sep 17 00:00:00 2001 From: "Lukas Rieger (Blue)" Date: Wed, 15 May 2024 23:47:25 +0200 Subject: [PATCH] Rework StateDumper --- BlueMapAPI | 2 +- BlueMapCommon/build.gradle.kts | 1 + .../bluemap/common/BlueMapService.java | 4 +- .../common/config/BlueMapConfigManager.java | 2 - .../bluemap/common/config/CoreConfig.java | 3 - .../bluemap/common/config/MapConfig.java | 2 - .../bluemap/common/config/PluginConfig.java | 2 - .../bluemap/common/config/WebappConfig.java | 2 - .../common/config/WebserverConfig.java | 3 - .../common/config/storage/FileConfig.java | 2 - .../common/config/storage/SQLConfig.java | 17 +- .../common/config/storage/StorageConfig.java | 2 - .../bluemap/common/debug/DebugDump.java | 44 +++ .../bluemap/common/debug/StateDumper.java | 328 ++++++++++++++++++ .../bluemap/common/plugin/Plugin.java | 4 +- .../common/plugin/RegionFileWatchService.java | 2 - .../common/plugin/commands/Commands.java | 4 +- .../plugin/skins/PlayerSkinUpdater.java | 2 - .../rendermanager/CombinedRenderTask.java | 3 - .../common/rendermanager/MapPurgeTask.java | 2 +- .../common/rendermanager/MapUpdateTask.java | 2 - .../common/rendermanager/RenderManager.java | 11 +- .../rendermanager/StorageDeleteTask.java | 2 +- .../rendermanager/WorldRegionRenderTask.java | 3 +- .../common/serverinterface/Server.java | 2 +- .../common/serverinterface/ServerWorld.java | 2 +- .../common/web/BlueMapResponseModifier.java | 2 - .../common/web/FileRequestHandler.java | 2 - .../common/web/LoggingRequestHandler.java | 2 - .../common/web/MapStorageRequestHandler.java | 2 - .../common/web/RoutingRequestHandler.java | 3 - .../bluemap/common/web/http/HttpServer.java | 2 - .../bluemap/core/debug/StateDumper.java | 277 --------------- .../bluecolored/bluemap/core/map/BmMap.java | 2 - .../bluemap/core/map/TextureGallery.java | 2 - .../core/map/renderstate/CellStorage.java | 2 - .../core/map/renderstate/MapChunkState.java | 2 - .../core/map/renderstate/MapTileState.java | 2 - .../BlockColorCalculatorFactory.java | 2 - .../core/resources/BlockPropertiesConfig.java | 2 - .../core/resources/BlockStateMapping.java | 2 - .../core/resources/MinecraftVersion.java | 2 - .../bluemap/core/resources/ResourcePath.java | 2 - .../datapack/dimension/DimensionTypeData.java | 2 - .../pack/resourcepack/ResourcePack.java | 2 - .../resourcepack/blockmodel/BlockModel.java | 2 - .../pack/resourcepack/blockmodel/Element.java | 2 - .../pack/resourcepack/blockmodel/Face.java | 2 - .../resourcepack/blockmodel/Rotation.java | 2 - .../blockmodel/TextureVariable.java | 2 - .../resourcepack/blockstate/BlockState.java | 2 - .../blockstate/BlockStateCondition.java | 6 - .../resourcepack/blockstate/Multipart.java | 2 - .../pack/resourcepack/blockstate/Variant.java | 2 - .../resourcepack/blockstate/VariantSet.java | 2 - .../resourcepack/blockstate/Variants.java | 2 - .../pack/resourcepack/texture/Texture.java | 2 - .../de/bluecolored/bluemap/core/util/Key.java | 3 - .../bluecolored/bluemap/core/util/Lazy.java | 3 - .../bluemap/core/util/math/Color.java | 3 - .../bluemap/core/world/BlockProperties.java | 2 - .../bluemap/core/world/BlockState.java | 2 - .../bluemap/core/world/biome/Biome.java | 2 - .../bluemap/core/world/mca/MCAWorld.java | 2 - .../core/world/mca/data/LevelData.java | 5 - 65 files changed, 398 insertions(+), 419 deletions(-) create mode 100644 BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/debug/DebugDump.java create mode 100644 BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/debug/StateDumper.java delete mode 100644 BlueMapCore/src/main/java/de/bluecolored/bluemap/core/debug/StateDumper.java diff --git a/BlueMapAPI b/BlueMapAPI index 6c84500d..8b179fb5 160000 --- a/BlueMapAPI +++ b/BlueMapAPI @@ -1 +1 @@ -Subproject commit 6c84500dfc560ec9588c89f71cc4a2d7edef2b2d +Subproject commit 8b179fb5e011ef8ac7e550e2e9aa6c64b644eaee diff --git a/BlueMapCommon/build.gradle.kts b/BlueMapCommon/build.gradle.kts index f092b0c2..883f31f1 100644 --- a/BlueMapCommon/build.gradle.kts +++ b/BlueMapCommon/build.gradle.kts @@ -27,6 +27,7 @@ repositories { dependencies { api ("com.mojang:brigadier:1.0.17") + api ("de.bluecolored.bluemap:BlueMapCore") compileOnly ("org.jetbrains:annotations:16.0.2") diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/BlueMapService.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/BlueMapService.java index 0ab90b72..ae00c429 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/BlueMapService.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/BlueMapService.java @@ -29,14 +29,13 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonParseException; import com.google.gson.reflect.TypeToken; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.api.gson.MarkerGson; import de.bluecolored.bluemap.api.markers.MarkerSet; import de.bluecolored.bluemap.common.config.ConfigurationException; import de.bluecolored.bluemap.common.config.MapConfig; import de.bluecolored.bluemap.common.config.storage.StorageConfig; import de.bluecolored.bluemap.common.plugin.Plugin; -import de.bluecolored.bluemap.core.debug.StateDumper; +import de.bluecolored.bluemap.common.debug.StateDumper; import de.bluecolored.bluemap.core.logger.Logger; import de.bluecolored.bluemap.core.map.BmMap; import de.bluecolored.bluemap.core.resources.MinecraftVersion; @@ -69,7 +68,6 @@ /** * 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 implements Closeable { private final BlueMapConfiguration config; diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/BlueMapConfigManager.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/BlueMapConfigManager.java index aec0deb7..a005b10b 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/BlueMapConfigManager.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/BlueMapConfigManager.java @@ -24,7 +24,6 @@ */ package de.bluecolored.bluemap.common.config; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.common.BlueMapConfiguration; import de.bluecolored.bluemap.common.config.storage.StorageConfig; import de.bluecolored.bluemap.common.serverinterface.ServerWorld; @@ -44,7 +43,6 @@ import java.util.*; import java.util.stream.Stream; -@DebugDump @Getter public class BlueMapConfigManager implements BlueMapConfiguration { diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/CoreConfig.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/CoreConfig.java index 810e27e4..c83d0863 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/CoreConfig.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/CoreConfig.java @@ -24,13 +24,11 @@ */ package de.bluecolored.bluemap.common.config; -import de.bluecolored.bluemap.api.debug.DebugDump; import org.spongepowered.configurate.objectmapping.ConfigSerializable; import java.nio.file.Path; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) -@DebugDump @ConfigSerializable public class CoreConfig { @@ -75,7 +73,6 @@ public LogConfig getLog() { return log; } - @DebugDump @ConfigSerializable public static class LogConfig { diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/MapConfig.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/MapConfig.java index d986bc61..4463d4b2 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/MapConfig.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/MapConfig.java @@ -26,7 +26,6 @@ import com.flowpowered.math.vector.Vector2i; import com.flowpowered.math.vector.Vector3i; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.map.MapSettings; import de.bluecolored.bluemap.core.util.Key; import lombok.AccessLevel; @@ -38,7 +37,6 @@ import java.nio.file.Path; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) -@DebugDump @ConfigSerializable @Getter public class MapConfig implements MapSettings { diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/PluginConfig.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/PluginConfig.java index 328b25fd..f7cfd0b6 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/PluginConfig.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/PluginConfig.java @@ -24,14 +24,12 @@ */ package de.bluecolored.bluemap.common.config; -import de.bluecolored.bluemap.api.debug.DebugDump; import org.spongepowered.configurate.objectmapping.ConfigSerializable; import java.util.ArrayList; import java.util.List; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) -@DebugDump @ConfigSerializable public class PluginConfig { diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/WebappConfig.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/WebappConfig.java index e366da11..adde07d3 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/WebappConfig.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/WebappConfig.java @@ -24,7 +24,6 @@ */ package de.bluecolored.bluemap.common.config; -import de.bluecolored.bluemap.api.debug.DebugDump; import org.spongepowered.configurate.objectmapping.ConfigSerializable; import java.nio.file.Path; @@ -33,7 +32,6 @@ import java.util.Set; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) -@DebugDump @ConfigSerializable public class WebappConfig { diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/WebserverConfig.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/WebserverConfig.java index 63a43d20..533f6951 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/WebserverConfig.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/WebserverConfig.java @@ -24,7 +24,6 @@ */ package de.bluecolored.bluemap.common.config; -import de.bluecolored.bluemap.api.debug.DebugDump; import org.spongepowered.configurate.objectmapping.ConfigSerializable; import java.net.InetAddress; @@ -33,7 +32,6 @@ import java.nio.file.Path; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) -@DebugDump @ConfigSerializable public class WebserverConfig { @@ -75,7 +73,6 @@ public LogConfig getLog() { return log; } - @DebugDump @ConfigSerializable public static class LogConfig { diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/FileConfig.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/FileConfig.java index 5065504f..b4714f97 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/FileConfig.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/FileConfig.java @@ -24,7 +24,6 @@ */ package de.bluecolored.bluemap.common.config.storage; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.common.config.ConfigurationException; import de.bluecolored.bluemap.core.storage.compression.Compression; import de.bluecolored.bluemap.core.storage.file.FileStorage; @@ -34,7 +33,6 @@ import java.nio.file.Path; @SuppressWarnings("FieldMayBeFinal") -@DebugDump @ConfigSerializable @Getter public class FileConfig extends StorageConfig { diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/SQLConfig.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/SQLConfig.java index 68de7b2d..2a10f917 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/SQLConfig.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/SQLConfig.java @@ -24,8 +24,8 @@ */ package de.bluecolored.bluemap.common.config.storage; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.common.config.ConfigurationException; +import de.bluecolored.bluemap.common.debug.DebugDump; import de.bluecolored.bluemap.core.storage.compression.Compression; import de.bluecolored.bluemap.core.storage.sql.Database; import de.bluecolored.bluemap.core.storage.sql.SQLStorage; @@ -51,17 +51,20 @@ @Getter public class SQLConfig extends StorageConfig { + @DebugDump(exclude = true) private String connectionUrl = "jdbc:mysql://localhost/bluemap?permitMysqlScheme"; + + @DebugDump(exclude = true) private Map connectionProperties = new HashMap<>(); - @DebugDump private String dialect = null; - @DebugDump private String driverJar = null; - @DebugDump private String driverClass = null; - @DebugDump private int maxConnections = -1; + private String dialect = null; - @DebugDump private String compression = Compression.GZIP.getKey().getFormatted(); + private String driverJar = null; + private String driverClass = null; + private int maxConnections = -1; + + private String compression = Compression.GZIP.getKey().getFormatted(); - @DebugDump @Getter(AccessLevel.NONE) private transient URL driverJarURL = null; diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/StorageConfig.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/StorageConfig.java index 4c2705c2..0cb74b49 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/StorageConfig.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/config/storage/StorageConfig.java @@ -24,7 +24,6 @@ */ package de.bluecolored.bluemap.common.config.storage; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.common.config.ConfigurationException; import de.bluecolored.bluemap.core.storage.Storage; import de.bluecolored.bluemap.core.util.Key; @@ -35,7 +34,6 @@ import java.util.Locale; @SuppressWarnings("FieldMayBeFinal") -@DebugDump @ConfigSerializable public abstract class StorageConfig { diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/debug/DebugDump.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/debug/DebugDump.java new file mode 100644 index 00000000..07f61005 --- /dev/null +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/debug/DebugDump.java @@ -0,0 +1,44 @@ +/* + * This file is part of BlueMap, licensed under the MIT License (MIT). + * + * Copyright (c) Blue (Lukas Rieger) + * 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.common.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 ""; + + boolean exclude() default false; + +} \ No newline at end of file diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/debug/StateDumper.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/debug/StateDumper.java new file mode 100644 index 00000000..1fc1b780 --- /dev/null +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/debug/StateDumper.java @@ -0,0 +1,328 @@ +/* + * This file is part of BlueMap, licensed under the MIT License (MIT). + * + * Copyright (c) Blue (Lukas Rieger) + * 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.common.debug; + +import com.google.gson.stream.JsonWriter; +import de.bluecolored.bluemap.core.BlueMap; +import de.bluecolored.bluemap.core.util.Key; + +import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; +import java.time.LocalDateTime; +import java.util.*; + +public class StateDumper { + + private static final StateDumper GLOBAL = new StateDumper(); + + private final Set instances = Collections.newSetFromMap(new WeakHashMap<>()); + + public void dump(Path file) throws IOException { + JsonWriter writer = new JsonWriter(Files.newBufferedWriter( + file, + StandardCharsets.UTF_8, + StandardOpenOption.CREATE, + StandardOpenOption.TRUNCATE_EXISTING + )); + writer.setIndent(" "); + + writer.beginObject(); + + writer.name("system-info"); + collectSystemInfo(writer); + + Set alreadyDumped = Collections.newSetFromMap(new IdentityHashMap<>()); + + writer.name("threads").beginArray(); + for (Thread thread : Thread.getAllStackTraces().keySet()) { + dumpInstance(thread, writer, alreadyDumped); + } + writer.endArray(); + + writer.name("dump").beginObject(); + for (Object instance : instances) { + Class type = instance.getClass(); + writer.name(type.getName()); + dumpInstance(instance, writer, alreadyDumped); + } + writer.endObject(); + + writer.endObject(); + + writer.flush(); + writer.close(); + } + + private void dumpInstance(Object instance, JsonWriter writer, Set alreadyDumped) throws IOException { + + if (instance == null) { + writer.nullValue(); + return; + } + + if (instance instanceof String || + instance instanceof Path || + instance instanceof UUID || + instance instanceof Key + ) { + writer.value(instance.toString()); + return; + } + + if (instance instanceof Number val) { + writer.value(val); + return; + } + + if (instance instanceof Boolean val) { + writer.value(val); + return; + } + + if (!alreadyDumped.add(instance)) { + writer.value("<<" + Objects.toIdentityString(instance) + ">>"); + return; + } + + writer.beginObject(); + try { + String identityString = Objects.toIdentityString(instance); + writer.name("#identity").value(identityString); + + if (instance instanceof Map map) { + writer.name("entries").beginArray(); + + int count = 0; + for (Map.Entry entry : map.entrySet()) { + if (++count > 30) { + writer.value("<<" + (map.size() - 30) + " more elements>>"); + break; + } + + writer.beginObject(); + + writer.name("key"); + dumpInstance(entry.getKey(), writer, alreadyDumped); + + writer.name("value"); + dumpInstance(entry.getValue(), writer, alreadyDumped); + + writer.endObject(); + } + + writer.endArray(); + return; + } + + if (instance instanceof Collection collection) { + writer.name("entries").beginArray(); + + int count = 0; + for (Object entry : collection) { + if (++count > 30) { + writer.value("<<" + (collection.size() - 30) + " more elements>>"); + break; + } + + dumpInstance(entry, writer, alreadyDumped); + } + + writer.endArray(); + return; + } + + if (instance instanceof Object[] array) { + writer.name("entries").beginArray(); + + int count = 0; + for (Object entry : array) { + if (++count > 30) { + writer.value("<<" + (array.length - 30) + " more elements>>"); + break; + } + + dumpInstance(entry, writer, alreadyDumped); + } + + writer.endArray(); + return; + } + + String toString = instance.toString(); + if (!toString.equals(identityString)) + writer.name("#toString").value(instance.toString()); + + if (instance instanceof Thread thread) { + writer.name("name").value(thread.getName()); + writer.name("state").value(thread.getState().toString()); + writer.name("priority").value(thread.getPriority()); + writer.name("alive").value(thread.isAlive()); + writer.name("id").value(thread.getId()); + writer.name("deamon").value(thread.isDaemon()); + writer.name("interrupted").value(thread.isInterrupted()); + + try { + StackTraceElement[] trace = thread.getStackTrace(); + writer.name("stacktrace").beginArray(); + for (StackTraceElement element : trace) { + writer.value(element.toString()); + } + writer.endArray(); + } catch (SecurityException ignore) {} + + return; + } + + dumpAnnotatedInstance(instance.getClass(), instance, writer, alreadyDumped); + + } finally { + writer.endObject(); + } + } + + private void dumpAnnotatedInstance(Class type, Object instance, JsonWriter writer, Set alreadyDumped) throws IOException { + + DebugDump typedd = type.getAnnotation(DebugDump.class); + boolean exclude = typedd != null && typedd.exclude(); + boolean allFields = !exclude && ( + typedd != null || + type.getPackageName().startsWith("de.bluecolored.bluemap") + ); + + for (Field field : type.getDeclaredFields()) { + String key = field.getName(); + Object value; + + try { + DebugDump dd = field.getAnnotation(DebugDump.class); + if (dd == null) { + if (!allFields) continue; + if (Modifier.isStatic(field.getModifiers())) continue; + if (Modifier.isTransient(field.getModifiers())) continue; + } else { + if (dd.exclude()) continue; + } + + if (dd != null) { + key = dd.value(); + if (key.isEmpty()) key = field.getName(); + } + + field.setAccessible(true); + value = field.get(instance); + } catch (Exception ex) { + writer.name("!!" + key).value(ex.toString()); + continue; + } + + writer.name(key); + dumpInstance(value, writer, alreadyDumped); + } + + for (Method method : type.getDeclaredMethods()) { + String key = method.toGenericString(); + Object value; + + try { + DebugDump dd = method.getAnnotation(DebugDump.class); + if (dd == null || dd.exclude()) continue; + + key = dd.value(); + if (key.isEmpty()) key = method.toGenericString(); + + method.setAccessible(true); + value = method.invoke(instance); + } catch (Exception ex) { + writer.name("!!" + key).value(ex.toString()); + continue; + } + + writer.name(key); + dumpInstance(value, writer, alreadyDumped); + } + + for (Class iface : type.getInterfaces()) { + dumpAnnotatedInstance(iface, instance, writer, alreadyDumped); + } + + Class typeSuperclass = type.getSuperclass(); + if (typeSuperclass != null) { + dumpAnnotatedInstance(typeSuperclass, instance, writer, alreadyDumped); + } + + } + + private void collectSystemInfo(JsonWriter writer) throws IOException { + writer.beginObject(); + + writer.name("bluemap-version").value(BlueMap.VERSION); + writer.name("git-hash").value(BlueMap.GIT_HASH); + + 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 propMap = new HashMap<>(); + for (String key : properties) { + propMap.put(key, System.getProperty(key)); + } + writer.name("properties"); + dumpInstance(propMap, writer, new HashSet<>()); + + writer.name("cores").value(Runtime.getRuntime().availableProcessors()); + writer.name("max-memory").value(Runtime.getRuntime().maxMemory()); + writer.name("total-memory").value(Runtime.getRuntime().totalMemory()); + writer.name("free-memory").value(Runtime.getRuntime().freeMemory()); + + writer.name("timestamp").value(System.currentTimeMillis()); + writer.name("time").value(LocalDateTime.now().toString()); + + writer.endObject(); + } + + public static StateDumper global() { + return GLOBAL; + } + + public synchronized void register(Object instance) { + GLOBAL.instances.add(instance); + } + +} diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/Plugin.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/Plugin.java index 822e8944..17c30de2 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/Plugin.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/Plugin.java @@ -24,7 +24,6 @@ */ package de.bluecolored.bluemap.common.plugin; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.common.BlueMapConfiguration; import de.bluecolored.bluemap.common.BlueMapService; import de.bluecolored.bluemap.common.InterruptableReentrantLock; @@ -40,7 +39,7 @@ import de.bluecolored.bluemap.common.serverinterface.ServerWorld; import de.bluecolored.bluemap.common.web.*; import de.bluecolored.bluemap.common.web.http.HttpServer; -import de.bluecolored.bluemap.core.debug.StateDumper; +import de.bluecolored.bluemap.common.debug.StateDumper; import de.bluecolored.bluemap.core.logger.Logger; import de.bluecolored.bluemap.core.map.BmMap; import de.bluecolored.bluemap.core.metrics.Metrics; @@ -71,7 +70,6 @@ import java.util.function.Predicate; import java.util.regex.Pattern; -@DebugDump public class Plugin implements ServerEventListener { public static final String PLUGIN_ID = "bluemap"; diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/RegionFileWatchService.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/RegionFileWatchService.java index 21a7324b..a788bed4 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/RegionFileWatchService.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/RegionFileWatchService.java @@ -25,7 +25,6 @@ package de.bluecolored.bluemap.common.plugin; import com.flowpowered.math.vector.Vector2i; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.common.rendermanager.RenderManager; import de.bluecolored.bluemap.common.rendermanager.WorldRegionRenderTask; import de.bluecolored.bluemap.core.logger.Logger; @@ -52,7 +51,6 @@ public class RegionFileWatchService extends Thread { private Timer delayTimer; - @DebugDump private final Map scheduledUpdates; public RegionFileWatchService(RenderManager renderManager, BmMap map) throws IOException { diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java index 26a16017..5d002fb8 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java @@ -48,7 +48,7 @@ import de.bluecolored.bluemap.common.rendermanager.*; import de.bluecolored.bluemap.common.serverinterface.CommandSource; import de.bluecolored.bluemap.core.BlueMap; -import de.bluecolored.bluemap.core.debug.StateDumper; +import de.bluecolored.bluemap.common.debug.StateDumper; import de.bluecolored.bluemap.core.logger.Logger; import de.bluecolored.bluemap.core.map.BmMap; import de.bluecolored.bluemap.core.map.renderstate.TileInfoRegion; @@ -635,7 +635,7 @@ public int debugDumpCommand(CommandContext context) { final CommandSource source = commandSourceInterface.apply(context.getSource()); try { - Path file = plugin.getBlueMap().getConfig().getCoreConfig().getData().resolve("dump.json"); + Path file = plugin.getBlueMap().getConfig().getCoreConfig().getData().resolve("dump.json.gz"); StateDumper.global().dump(file); source.sendMessage(Text.of(TextColor.GREEN, "Dump created at: " + file)); diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/skins/PlayerSkinUpdater.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/skins/PlayerSkinUpdater.java index 2afe3ee2..3840a5bb 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/skins/PlayerSkinUpdater.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/skins/PlayerSkinUpdater.java @@ -24,7 +24,6 @@ */ package de.bluecolored.bluemap.common.plugin.skins; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.api.plugin.PlayerIconFactory; import de.bluecolored.bluemap.api.plugin.SkinProvider; import de.bluecolored.bluemap.common.plugin.Plugin; @@ -45,7 +44,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; -@DebugDump public class PlayerSkinUpdater implements ServerEventListener { private final Plugin plugin; diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/CombinedRenderTask.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/CombinedRenderTask.java index f239f60f..b164b00e 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/CombinedRenderTask.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/CombinedRenderTask.java @@ -24,11 +24,8 @@ */ package de.bluecolored.bluemap.common.rendermanager; -import de.bluecolored.bluemap.api.debug.DebugDump; - import java.util.*; -@DebugDump public class CombinedRenderTask implements RenderTask { private final String description; diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/MapPurgeTask.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/MapPurgeTask.java index 20f6a691..77d7d98b 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/MapPurgeTask.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/MapPurgeTask.java @@ -24,7 +24,7 @@ */ package de.bluecolored.bluemap.common.rendermanager; -import de.bluecolored.bluemap.api.debug.DebugDump; +import de.bluecolored.bluemap.common.debug.DebugDump; import de.bluecolored.bluemap.core.map.BmMap; import java.util.Objects; diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/MapUpdateTask.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/MapUpdateTask.java index d5224cdd..47a455ec 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/MapUpdateTask.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/MapUpdateTask.java @@ -25,7 +25,6 @@ package de.bluecolored.bluemap.common.rendermanager; import com.flowpowered.math.vector.Vector2i; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.logger.Logger; import de.bluecolored.bluemap.core.map.BmMap; import de.bluecolored.bluemap.core.map.renderstate.MapTileState; @@ -39,7 +38,6 @@ import java.util.function.Predicate; import java.util.stream.Stream; -@DebugDump public class MapUpdateTask extends CombinedRenderTask { private final BmMap map; diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/RenderManager.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/RenderManager.java index d5d6112f..b1b7a696 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/RenderManager.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/RenderManager.java @@ -24,7 +24,6 @@ */ package de.bluecolored.bluemap.common.rendermanager; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.logger.Logger; import java.util.*; @@ -35,19 +34,19 @@ public class RenderManager { private static final AtomicInteger nextRenderManagerIndex = new AtomicInteger(0); - @DebugDump private final int id; - @DebugDump private volatile boolean running; + private final int id; + private volatile boolean running; - @DebugDump private long lastTimeBusy; + private long lastTimeBusy; private final AtomicInteger nextWorkerThreadIndex; - @DebugDump private final Collection workerThreads; + private final Collection workerThreads; private final AtomicInteger busyCount; private ProgressTracker progressTracker; private volatile boolean newTask; - @DebugDump private final LinkedList renderTasks; + private final LinkedList renderTasks; public RenderManager() { this.id = nextRenderManagerIndex.getAndIncrement(); diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/StorageDeleteTask.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/StorageDeleteTask.java index caff33d4..ecdf337e 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/StorageDeleteTask.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/StorageDeleteTask.java @@ -24,7 +24,7 @@ */ package de.bluecolored.bluemap.common.rendermanager; -import de.bluecolored.bluemap.api.debug.DebugDump; +import de.bluecolored.bluemap.common.debug.DebugDump; import de.bluecolored.bluemap.core.storage.MapStorage; import java.util.Objects; diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/WorldRegionRenderTask.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/WorldRegionRenderTask.java index 33f8862a..ab728050 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/WorldRegionRenderTask.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/rendermanager/WorldRegionRenderTask.java @@ -26,7 +26,7 @@ import com.flowpowered.math.vector.Vector2i; import com.flowpowered.math.vector.Vector2l; -import de.bluecolored.bluemap.api.debug.DebugDump; +import de.bluecolored.bluemap.common.debug.DebugDump; import de.bluecolored.bluemap.core.logger.Logger; import de.bluecolored.bluemap.core.map.BmMap; import de.bluecolored.bluemap.core.map.renderstate.TileActionResolver.ActionAndNextState; @@ -47,7 +47,6 @@ import static de.bluecolored.bluemap.core.map.renderstate.TileActionResolver.Action.DELETE; import static de.bluecolored.bluemap.core.map.renderstate.TileActionResolver.Action.RENDER; -@DebugDump public class WorldRegionRenderTask implements RenderTask { @Getter private final BmMap map; diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/serverinterface/Server.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/serverinterface/Server.java index 1b00db5b..2430c39d 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/serverinterface/Server.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/serverinterface/Server.java @@ -24,7 +24,7 @@ */ package de.bluecolored.bluemap.common.serverinterface; -import de.bluecolored.bluemap.api.debug.DebugDump; +import de.bluecolored.bluemap.common.debug.DebugDump; import de.bluecolored.bluemap.core.util.Tristate; import de.bluecolored.bluemap.core.world.World; import de.bluecolored.bluemap.core.world.mca.MCAWorld; diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/serverinterface/ServerWorld.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/serverinterface/ServerWorld.java index 69216b8d..22f1785f 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/serverinterface/ServerWorld.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/serverinterface/ServerWorld.java @@ -24,7 +24,7 @@ */ package de.bluecolored.bluemap.common.serverinterface; -import de.bluecolored.bluemap.api.debug.DebugDump; +import de.bluecolored.bluemap.common.debug.DebugDump; import de.bluecolored.bluemap.core.util.Key; import java.io.IOException; diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/BlueMapResponseModifier.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/BlueMapResponseModifier.java index ce0c362a..c11d07f5 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/BlueMapResponseModifier.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/BlueMapResponseModifier.java @@ -24,14 +24,12 @@ */ package de.bluecolored.bluemap.common.web; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.common.web.http.HttpRequest; import de.bluecolored.bluemap.common.web.http.HttpRequestHandler; import de.bluecolored.bluemap.common.web.http.HttpResponse; import de.bluecolored.bluemap.common.web.http.HttpStatusCode; import de.bluecolored.bluemap.core.BlueMap; -@DebugDump public class BlueMapResponseModifier implements HttpRequestHandler { private final HttpRequestHandler delegate; diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/FileRequestHandler.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/FileRequestHandler.java index af960e77..b3f42725 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/FileRequestHandler.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/FileRequestHandler.java @@ -24,7 +24,6 @@ */ package de.bluecolored.bluemap.common.web; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.common.web.http.*; import org.apache.commons.lang3.time.DateFormatUtils; @@ -39,7 +38,6 @@ import java.util.TimeZone; import java.util.concurrent.TimeUnit; -@DebugDump public class FileRequestHandler implements HttpRequestHandler { private final Path webRoot; diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/LoggingRequestHandler.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/LoggingRequestHandler.java index f5483457..62efe642 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/LoggingRequestHandler.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/LoggingRequestHandler.java @@ -24,12 +24,10 @@ */ package de.bluecolored.bluemap.common.web; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.common.web.http.*; import de.bluecolored.bluemap.core.logger.Logger; import lombok.Getter; -@DebugDump @Getter public class LoggingRequestHandler implements HttpRequestHandler { diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/MapStorageRequestHandler.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/MapStorageRequestHandler.java index 0fdb3853..eaa8043b 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/MapStorageRequestHandler.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/MapStorageRequestHandler.java @@ -25,7 +25,6 @@ package de.bluecolored.bluemap.common.web; import de.bluecolored.bluemap.api.ContentTypeRegistry; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.common.web.http.HttpRequest; import de.bluecolored.bluemap.common.web.http.HttpRequestHandler; import de.bluecolored.bluemap.common.web.http.HttpResponse; @@ -47,7 +46,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -@DebugDump @RequiredArgsConstructor public class MapStorageRequestHandler implements HttpRequestHandler { diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/RoutingRequestHandler.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/RoutingRequestHandler.java index 0f2f8cd4..c68cb4eb 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/RoutingRequestHandler.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/RoutingRequestHandler.java @@ -24,7 +24,6 @@ */ package de.bluecolored.bluemap.common.web; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.common.web.http.HttpRequest; import de.bluecolored.bluemap.common.web.http.HttpRequestHandler; import de.bluecolored.bluemap.common.web.http.HttpResponse; @@ -39,7 +38,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -@DebugDump public class RoutingRequestHandler implements HttpRequestHandler { public final LinkedList routes; @@ -83,7 +81,6 @@ public HttpResponse handle(HttpRequest request) { return new HttpResponse(HttpStatusCode.BAD_REQUEST); } - @DebugDump @AllArgsConstructor @Getter @Setter public static class Route { diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/http/HttpServer.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/http/HttpServer.java index e11e7224..d8e8c354 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/http/HttpServer.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/http/HttpServer.java @@ -24,13 +24,11 @@ */ package de.bluecolored.bluemap.common.web.http; -import de.bluecolored.bluemap.api.debug.DebugDump; import lombok.Getter; import lombok.Setter; import java.io.IOException; -@DebugDump public class HttpServer extends Server { @Getter @Setter diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/debug/StateDumper.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/debug/StateDumper.java deleted file mode 100644 index 7551a021..00000000 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/debug/StateDumper.java +++ /dev/null @@ -1,277 +0,0 @@ -/* - * This file is part of BlueMap, licensed under the MIT License (MIT). - * - * Copyright (c) Blue (Lukas Rieger) - * 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.api.debug.DebugDump; -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.io.PrintWriter; -import java.io.StringWriter; -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 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 alreadyDumped = Collections.newSetFromMap(new WeakHashMap<>()); - - try { - ConfigurationNode threadDump = node.node("threads"); - for (Thread thread : Thread.getAllStackTraces().keySet()) { - dumpInstance(thread, loader.defaultOptions(), threadDump.appendListNode(), alreadyDumped); - } - } catch (SecurityException ex){ - node.node("threads").set(ex.toString()); - } - - 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 alreadyDumped) throws SerializationException { - - try { - if (instance == null){ - node.raw(null); - return; - } - - Class type = instance.getClass(); - - if (!alreadyDumped.add(instance)) { - node.set("<<" + instance + ">>"); - 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 > 100) { - node.appendListNode().set("<<" + (map.size() - 100) + " 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 > 100) { - node.appendListNode().set("<<" + (((Collection) instance).size() - 100) + " 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 > 100) { - node.appendListNode().set("<<" + (((Object[]) instance).length - 100) + " more elements>>"); - break; - } - - dumpInstance(entry, options, node.appendListNode(), alreadyDumped); - } - return; - } - - if (instance instanceof Thread) { - Thread t = (Thread) instance; - node.node("name").set(t.getName()); - node.node("state").set(t.getState().toString()); - node.node("priority").set(t.getPriority()); - node.node("alive").set(t.isAlive()); - node.node("id").set(t.getId()); - node.node("deamon").set(t.isDaemon()); - node.node("interrupted").set(t.isInterrupted()); - - dumpInstance(t.getStackTrace(), options, node.node("stackTrace"), alreadyDumped); - return; - } - - boolean foundSomething = dumpAnnotatedInstance(type, instance, options, node, alreadyDumped); - if (!foundSomething) { - node.set(instance.toString()); - } - - } catch (Exception ex) { - StringWriter stringWriter = new StringWriter(); - ex.printStackTrace(new PrintWriter(stringWriter)); - node.set("Error: " + ex + " >> " + stringWriter); - } - } - - private boolean dumpAnnotatedInstance(Class type, Object instance, ConfigurationOptions options, ConfigurationNode node, Set alreadyDumped) throws Exception { - boolean foundSomething = false; - boolean allFields = type.isAnnotationPresent(DebugDump.class); - - 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(); - - field.setAccessible(true); - if (options.acceptsType(field.getType())) { - node.node(key).set(field.get(instance)); - } else { - 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); - } - } - - for (Class iface : type.getInterfaces()) { - foundSomething |= dumpAnnotatedInstance(iface, instance, options, node, alreadyDumped); - } - - Class typeSuperclass = type.getSuperclass(); - if (typeSuperclass != null) { - foundSomething |= dumpAnnotatedInstance(typeSuperclass, instance, options, node, alreadyDumped); - } - - return foundSomething; - } - - private void collectSystemInfo(ConfigurationNode node) throws SerializationException { - node.node("bluemap-version").set(BlueMap.VERSION); - node.node("git-hash").set(BlueMap.GIT_HASH); - - 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 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); - } - -} diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/BmMap.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/BmMap.java index 01851a38..3b9120ce 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/BmMap.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/BmMap.java @@ -28,7 +28,6 @@ import com.google.gson.FieldNamingPolicy; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.api.gson.MarkerGson; import de.bluecolored.bluemap.api.markers.MarkerSet; import de.bluecolored.bluemap.core.logger.Logger; @@ -55,7 +54,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.function.Predicate; -@DebugDump @Getter public class BmMap { diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/TextureGallery.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/TextureGallery.java index 2a5c8977..47d33bb4 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/TextureGallery.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/TextureGallery.java @@ -29,7 +29,6 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonIOException; import com.google.gson.JsonParseException; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.resources.ResourcePath; import de.bluecolored.bluemap.core.resources.adapter.ResourcesGson; import de.bluecolored.bluemap.core.resources.pack.resourcepack.ResourcePack; @@ -43,7 +42,6 @@ import java.util.HashMap; import java.util.Map; -@DebugDump public class TextureGallery { private static final Gson GSON = ResourcesGson.addAdapter(new GsonBuilder()) diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/renderstate/CellStorage.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/renderstate/CellStorage.java index f133d88b..0d9ee99b 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/renderstate/CellStorage.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/renderstate/CellStorage.java @@ -26,7 +26,6 @@ import com.flowpowered.math.vector.Vector2i; import com.google.gson.reflect.TypeToken; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.logger.Logger; import de.bluecolored.bluemap.core.storage.GridStorage; import de.bluecolored.bluemap.core.storage.compression.CompressedInputStream; @@ -41,7 +40,6 @@ import java.util.LinkedHashMap; import java.util.Map; -@DebugDump abstract class CellStorage { private static final BlueNBT BLUE_NBT = new BlueNBT(); diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/renderstate/MapChunkState.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/renderstate/MapChunkState.java index 945a888c..246146e3 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/renderstate/MapChunkState.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/renderstate/MapChunkState.java @@ -24,10 +24,8 @@ */ package de.bluecolored.bluemap.core.map.renderstate; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.storage.GridStorage; -@DebugDump public class MapChunkState extends CellStorage { static final int SHIFT = 7; diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/renderstate/MapTileState.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/renderstate/MapTileState.java index f3796698..1dbc87a3 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/renderstate/MapTileState.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/map/renderstate/MapTileState.java @@ -24,7 +24,6 @@ */ package de.bluecolored.bluemap.core.map.renderstate; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.logger.Logger; import de.bluecolored.bluemap.core.storage.GridStorage; import de.bluecolored.bluemap.core.util.Grid; @@ -36,7 +35,6 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; -@DebugDump public class MapTileState extends CellStorage { static final int SHIFT = 5; diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/BlockColorCalculatorFactory.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/BlockColorCalculatorFactory.java index 913c08cd..41282d94 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/BlockColorCalculatorFactory.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/BlockColorCalculatorFactory.java @@ -26,7 +26,6 @@ import com.flowpowered.math.GenericMath; import com.google.gson.stream.JsonReader; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.util.math.Color; import de.bluecolored.bluemap.core.world.biome.Biome; import de.bluecolored.bluemap.core.world.block.Block; @@ -40,7 +39,6 @@ import java.util.HashMap; import java.util.Map; -@DebugDump public class BlockColorCalculatorFactory { private static final int BLEND_RADIUS_H = 2; diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/BlockPropertiesConfig.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/BlockPropertiesConfig.java index 59939d04..aa2d73ef 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/BlockPropertiesConfig.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/BlockPropertiesConfig.java @@ -25,7 +25,6 @@ package de.bluecolored.bluemap.core.resources; import com.google.gson.stream.JsonReader; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.world.BlockProperties; import de.bluecolored.bluemap.core.world.BlockState; @@ -39,7 +38,6 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -@DebugDump public class BlockPropertiesConfig { private final Map>> mappings; diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/BlockStateMapping.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/BlockStateMapping.java index 090f9c62..e681d2f4 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/BlockStateMapping.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/BlockStateMapping.java @@ -24,12 +24,10 @@ */ package de.bluecolored.bluemap.core.resources; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.world.BlockState; import java.util.Map.Entry; -@DebugDump class BlockStateMapping { private final BlockState blockState; private final T mapping; diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/MinecraftVersion.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/MinecraftVersion.java index 2b2067ff..5c80eb37 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/MinecraftVersion.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/MinecraftVersion.java @@ -29,7 +29,6 @@ import com.google.gson.JsonObject; import com.google.gson.annotations.JsonAdapter; import com.google.gson.stream.JsonReader; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.logger.Logger; import de.bluecolored.bluemap.core.util.FileHelper; import lombok.AccessLevel; @@ -48,7 +47,6 @@ import java.security.NoSuchAlgorithmException; import java.util.Arrays; -@DebugDump @Getter @RequiredArgsConstructor(access = AccessLevel.PRIVATE) public class MinecraftVersion { diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/ResourcePath.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/ResourcePath.java index ef357ed9..05f7fd15 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/ResourcePath.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/ResourcePath.java @@ -31,7 +31,6 @@ import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.util.Key; import org.jetbrains.annotations.Nullable; @@ -40,7 +39,6 @@ import java.util.Locale; import java.util.function.Function; -@DebugDump @JsonAdapter(ResourcePath.Adapter.class) public class ResourcePath extends Key { diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/datapack/dimension/DimensionTypeData.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/datapack/dimension/DimensionTypeData.java index 4fca54a9..27694b37 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/datapack/dimension/DimensionTypeData.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/datapack/dimension/DimensionTypeData.java @@ -24,14 +24,12 @@ */ package de.bluecolored.bluemap.core.resources.pack.datapack.dimension; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.world.DimensionType; import de.bluecolored.bluenbt.NBTName; import lombok.*; import lombok.experimental.Accessors; @Data -@DebugDump public class DimensionTypeData implements DimensionType { @NBTName("natural") diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/ResourcePack.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/ResourcePack.java index b85d111c..28495ded 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/ResourcePack.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/ResourcePack.java @@ -26,7 +26,6 @@ import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.LoadingCache; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.BlueMap; import de.bluecolored.bluemap.core.logger.Logger; import de.bluecolored.bluemap.core.resources.BlockColorCalculatorFactory; @@ -58,7 +57,6 @@ import java.util.Set; import java.util.concurrent.CompletableFuture; -@DebugDump public class ResourcePack extends Pack { public static final ResourcePath MISSING_BLOCK_STATE = new ResourcePath<>("bluemap", "missing"); public static final ResourcePath MISSING_BLOCK_MODEL = new ResourcePath<>("bluemap", "block/missing"); diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/BlockModel.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/BlockModel.java index 00dbae8d..6c6f63c4 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/BlockModel.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/BlockModel.java @@ -24,7 +24,6 @@ */ package de.bluecolored.bluemap.core.resources.pack.resourcepack.blockmodel; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.resources.ResourcePath; import de.bluecolored.bluemap.core.resources.pack.resourcepack.ResourcePack; import de.bluecolored.bluemap.core.resources.pack.resourcepack.texture.Texture; @@ -34,7 +33,6 @@ import java.util.*; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) -@DebugDump public class BlockModel { private ResourcePath parent; diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/Element.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/Element.java index a022d063..95093935 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/Element.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/Element.java @@ -30,7 +30,6 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.resources.AbstractTypeAdapterFactory; import de.bluecolored.bluemap.core.resources.pack.resourcepack.ResourcePack; import de.bluecolored.bluemap.core.util.Direction; @@ -39,7 +38,6 @@ import java.util.EnumMap; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) -@DebugDump @JsonAdapter(Element.Adapter.class) public class Element { private static final Vector3f FULL_BLOCK_MIN = Vector3f.ZERO; diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/Face.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/Face.java index 5c6ca23a..2b9c42a3 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/Face.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/Face.java @@ -25,14 +25,12 @@ package de.bluecolored.bluemap.core.resources.pack.resourcepack.blockmodel; import com.flowpowered.math.vector.Vector4f; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.resources.pack.resourcepack.ResourcePack; import de.bluecolored.bluemap.core.util.Direction; import java.util.function.Function; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) -@DebugDump public class Face { private static final TextureVariable DEFAULT_TEXTURE = new TextureVariable(ResourcePack.MISSING_TEXTURE); diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/Rotation.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/Rotation.java index 009d9993..47f0af12 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/Rotation.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/Rotation.java @@ -31,7 +31,6 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.resources.AbstractTypeAdapterFactory; import de.bluecolored.bluemap.core.util.math.Axis; import de.bluecolored.bluemap.core.util.math.MatrixM4f; @@ -39,7 +38,6 @@ import java.io.IOException; @SuppressWarnings("FieldMayBeFinal") -@DebugDump @JsonAdapter(Rotation.Adapter.class) public class Rotation { private static final Vector3f DEFAULT_ORIGIN = new Vector3f(8, 8, 8); diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/TextureVariable.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/TextureVariable.java index f29b5996..5d132186 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/TextureVariable.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockmodel/TextureVariable.java @@ -28,7 +28,6 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.resources.ResourcePath; import de.bluecolored.bluemap.core.resources.pack.resourcepack.ResourcePack; import de.bluecolored.bluemap.core.resources.pack.resourcepack.texture.Texture; @@ -38,7 +37,6 @@ import java.util.Objects; import java.util.function.Function; -@DebugDump @JsonAdapter(TextureVariable.Adapter.class) public class TextureVariable { diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/BlockState.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/BlockState.java index 26b01521..c5ade4bc 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/BlockState.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/BlockState.java @@ -24,13 +24,11 @@ */ package de.bluecolored.bluemap.core.resources.pack.resourcepack.blockstate; -import de.bluecolored.bluemap.api.debug.DebugDump; import org.jetbrains.annotations.Nullable; import java.util.function.Consumer; @SuppressWarnings("FieldMayBeFinal") -@DebugDump public class BlockState { private Variants variants = null; diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/BlockStateCondition.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/BlockStateCondition.java index 85890749..4c071066 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/BlockStateCondition.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/BlockStateCondition.java @@ -24,8 +24,6 @@ */ package de.bluecolored.bluemap.core.resources.pack.resourcepack.blockstate; - -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.util.Preconditions; import de.bluecolored.bluemap.core.world.BlockState; @@ -41,7 +39,6 @@ public interface BlockStateCondition { boolean matches(BlockState state); - @DebugDump class Property implements BlockStateCondition { private final String key; @@ -61,7 +58,6 @@ public boolean matches(BlockState state) { } - @DebugDump class PropertySet implements BlockStateCondition { private final String key; @@ -82,7 +78,6 @@ public boolean matches(BlockState state) { } - @DebugDump class And implements BlockStateCondition { final BlockStateCondition[] conditions; @@ -117,7 +112,6 @@ public boolean matches(BlockState state) { } - @DebugDump class Or implements BlockStateCondition { private final BlockStateCondition[] conditions; diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/Multipart.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/Multipart.java index 87223503..ae3f542c 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/Multipart.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/Multipart.java @@ -28,7 +28,6 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.resources.AbstractTypeAdapterFactory; import de.bluecolored.bluemap.core.world.BlockState; import org.apache.commons.lang3.StringUtils; @@ -39,7 +38,6 @@ import java.util.function.Consumer; @SuppressWarnings("FieldMayBeFinal") -@DebugDump @JsonAdapter(Multipart.Adapter.class) public class Multipart { diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/Variant.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/Variant.java index ed491195..aefb0bf8 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/Variant.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/Variant.java @@ -28,7 +28,6 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.resources.AbstractTypeAdapterFactory; import de.bluecolored.bluemap.core.resources.ResourcePath; import de.bluecolored.bluemap.core.resources.pack.resourcepack.blockmodel.BlockModel; @@ -38,7 +37,6 @@ import java.io.IOException; @SuppressWarnings({"FieldMayBeFinal", "FieldCanBeLocal"}) -@DebugDump @JsonAdapter(Variant.Adapter.class) public class Variant { diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/VariantSet.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/VariantSet.java index b1e51482..7cb5740a 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/VariantSet.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/VariantSet.java @@ -28,7 +28,6 @@ import com.google.gson.annotations.JsonAdapter; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonToken; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.resources.AbstractTypeAdapterFactory; import java.io.IOException; @@ -36,7 +35,6 @@ import java.util.function.Consumer; @SuppressWarnings("FieldMayBeFinal") -@DebugDump @JsonAdapter(VariantSet.Adapter.class) public class VariantSet { diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/Variants.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/Variants.java index 0630025b..93edf381 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/Variants.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/blockstate/Variants.java @@ -27,7 +27,6 @@ import com.google.gson.Gson; import com.google.gson.annotations.JsonAdapter; import com.google.gson.stream.JsonReader; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.logger.Logger; import de.bluecolored.bluemap.core.resources.AbstractTypeAdapterFactory; import de.bluecolored.bluemap.core.world.BlockState; @@ -40,7 +39,6 @@ import java.util.function.Consumer; @SuppressWarnings("FieldMayBeFinal") -@DebugDump @JsonAdapter(Variants.Adapter.class) public class Variants { diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/texture/Texture.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/texture/Texture.java index ea7fcb87..b20cdbf6 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/texture/Texture.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/resources/pack/resourcepack/texture/Texture.java @@ -24,7 +24,6 @@ */ package de.bluecolored.bluemap.core.resources.pack.resourcepack.texture; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.resources.ResourcePath; import de.bluecolored.bluemap.core.util.BufferedImageUtil; import de.bluecolored.bluemap.core.util.math.Color; @@ -36,7 +35,6 @@ import java.io.IOException; import java.util.Base64; -@DebugDump public class Texture { public static final Texture MISSING = new Texture( diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/util/Key.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/util/Key.java index 24c377ad..e3f3fa47 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/util/Key.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/util/Key.java @@ -24,11 +24,8 @@ */ package de.bluecolored.bluemap.core.util; -import de.bluecolored.bluemap.api.debug.DebugDump; - import java.util.concurrent.ConcurrentHashMap; -@DebugDump public class Key implements Keyed { private static final ConcurrentHashMap STRING_INTERN_POOL = new ConcurrentHashMap<>(); diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/util/Lazy.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/util/Lazy.java index 8d968ce3..71a0c275 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/util/Lazy.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/util/Lazy.java @@ -24,8 +24,6 @@ */ package de.bluecolored.bluemap.core.util; -import de.bluecolored.bluemap.api.debug.DebugDump; - import java.util.Objects; import java.util.function.Supplier; @@ -33,7 +31,6 @@ public class Lazy { private Supplier loader; - @DebugDump private volatile T value; public Lazy(Supplier loader) { diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/util/math/Color.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/util/math/Color.java index ef8f5ee3..fb666393 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/util/math/Color.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/util/math/Color.java @@ -24,10 +24,7 @@ */ package de.bluecolored.bluemap.core.util.math; -import de.bluecolored.bluemap.api.debug.DebugDump; - @SuppressWarnings("UnusedReturnValue") -@DebugDump public class Color { public float r, g, b, a; diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/BlockProperties.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/BlockProperties.java index f5a31eff..2c51d1ac 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/BlockProperties.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/BlockProperties.java @@ -24,10 +24,8 @@ */ package de.bluecolored.bluemap.core.world; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.util.Tristate; -@DebugDump public class BlockProperties { public static final BlockProperties DEFAULT = new BlockProperties(); diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/BlockState.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/BlockState.java index 51164c8c..fff30e89 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/BlockState.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/BlockState.java @@ -24,7 +24,6 @@ */ package de.bluecolored.bluemap.core.world; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.util.Key; import org.jetbrains.annotations.NotNull; @@ -39,7 +38,6 @@ *
* The implementation of this class has to be thread-save!
*/ -@DebugDump public class BlockState extends Key { private static final Pattern BLOCKSTATE_SERIALIZATION_PATTERN = Pattern.compile("^(.+?)(?:\\[(.*)])?$"); diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/biome/Biome.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/biome/Biome.java index 799028be..681c2605 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/biome/Biome.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/biome/Biome.java @@ -24,13 +24,11 @@ */ package de.bluecolored.bluemap.core.world.biome; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.util.Key; import de.bluecolored.bluemap.core.util.Keyed; import de.bluecolored.bluemap.core.util.math.Color; import lombok.Getter; -@DebugDump public interface Biome extends Keyed { Biome DEFAULT = new Default(); diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/MCAWorld.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/MCAWorld.java index d4a0eb72..0e75dfec 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/MCAWorld.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/MCAWorld.java @@ -29,7 +29,6 @@ import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.LoadingCache; import com.google.gson.reflect.TypeToken; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.BlueMap; import de.bluecolored.bluemap.core.logger.Logger; import de.bluecolored.bluemap.core.resources.pack.datapack.DataPack; @@ -60,7 +59,6 @@ @Getter @ToString -@DebugDump public class MCAWorld implements World { private static final Grid CHUNK_GRID = new Grid(16); diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/data/LevelData.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/data/LevelData.java index 8130731c..8720e584 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/data/LevelData.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/world/mca/data/LevelData.java @@ -24,7 +24,6 @@ */ package de.bluecolored.bluemap.core.world.mca.data; -import de.bluecolored.bluemap.api.debug.DebugDump; import de.bluecolored.bluemap.core.world.DimensionType; import lombok.AllArgsConstructor; import lombok.Getter; @@ -35,13 +34,11 @@ @Getter @SuppressWarnings("FieldMayBeFinal") -@DebugDump public class LevelData { private Data data = new Data(); @Getter - @DebugDump public static class Data { private String levelName = "world"; private int spawnX = 0, spawnY = 0, spawnZ = 0; @@ -49,7 +46,6 @@ public static class Data { } @Getter - @DebugDump public static class WGSettings { private Map dimensions = new HashMap<>(); } @@ -57,7 +53,6 @@ public static class WGSettings { @Getter @NoArgsConstructor @AllArgsConstructor - @DebugDump public static class Dimension { private DimensionType type = DimensionType.OVERWORLD; }