From 1aea2172807b3cf36352bdb5514d4ee6d86e539a Mon Sep 17 00:00:00 2001 From: Biquaternions Date: Fri, 7 Aug 2026 22:46:37 -0500 Subject: [PATCH] Update upstream --- build.gradle | 1 + settings.gradle | 18 ++++---- .../spark/common/command/CommandManager.java | 14 ++++--- .../command/CommandResponseHandler.java | 3 +- .../command/modules/ActivityLogModule.java | 3 +- .../command/modules/GcMonitoringModule.java | 11 ++--- .../common/command/modules/HealthModule.java | 33 ++++++++------- .../command/modules/HeapAnalysisModule.java | 22 +++++----- .../common/command/modules/SamplerModule.java | 19 +++++---- .../common/monitor/tick/TickMonitor.java | 9 ++-- .../spark/common/util/StatisticFormatter.java | 41 ++++++++++--------- .../paper/PaperServerConfigProvider.java | 4 ++ 12 files changed, 99 insertions(+), 79 deletions(-) diff --git a/build.gradle b/build.gradle index b5f4b9e129c..f3add9e2117 100644 --- a/build.gradle +++ b/build.gradle @@ -81,6 +81,7 @@ subprojects { } def determinePatchVersion() { + if (true) return 0 def tagInfo = providers.exec { commandLine 'git', 'describe', '--tags' }.standardOutput.asText.get().trim() diff --git a/settings.gradle b/settings.gradle index 44e8ab8ed05..e166fbf7740 100644 --- a/settings.gradle +++ b/settings.gradle @@ -24,15 +24,15 @@ plugins { rootProject.name = 'spark' include ( 'spark-api', - 'spark-bukkit', - 'spark-bungeecord', + // 'spark-bukkit', + // 'spark-bungeecord', 'spark-common', - 'spark-fabric', - 'spark-forge', - 'spark-minecraft', - 'spark-neoforge', + // 'spark-fabric', + // 'spark-forge', + // 'spark-minecraft', + // 'spark-neoforge', 'spark-paper', - 'spark-sponge', - 'spark-standalone-agent', - 'spark-velocity', + // 'spark-sponge', + // 'spark-standalone-agent', + // 'spark-velocity', ) diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/CommandManager.java b/spark-common/src/main/java/me/lucko/spark/common/command/CommandManager.java index 5e85e90d317..87c3341dc68 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/CommandManager.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/CommandManager.java @@ -60,6 +60,7 @@ import static net.kyori.adventure.text.format.TextDecoration.BOLD; public class CommandManager implements AutoCloseable { + private static final net.kyori.adventure.text.format.TextColor COLOR_TITLE = net.kyori.adventure.text.format.TextColor.color(255, 170, 230); private final SparkPlatform platform; private final boolean disableResponseBroadcast; @@ -159,7 +160,8 @@ public CompletableFuture executeCommand(CommandSender sender, String[] arg // schedule a task to detect timeouts plugin.executeAsync(() -> { timeoutThread.set(Thread.currentThread()); - int warningIntervalSeconds = 5; + int warningIntervalSeconds = 10; + int warningIntervalSecondsIterable = 10; try { if (completed.get()) { @@ -168,7 +170,7 @@ public CompletableFuture executeCommand(CommandSender sender, String[] arg for (int i = 1; i <= 3; i++) { try { - Thread.sleep(warningIntervalSeconds * 1000); + Thread.sleep(warningIntervalSecondsIterable * 1000); } catch (InterruptedException e) { // ignore } @@ -180,7 +182,7 @@ public CompletableFuture executeCommand(CommandSender sender, String[] arg Thread executor = executorThread.get(); if (executor == null) { plugin.log(Level.WARNING, "A command execution has not completed after " + - (i * warningIntervalSeconds) + " seconds but there is no executor present. Perhaps the executor shutdown?"); + (warningIntervalSeconds + ((i - 1) * warningIntervalSecondsIterable)) + " seconds but there is no executor present. Perhaps the executor shutdown?"); plugin.log(Level.WARNING, "If the command subsequently completes without any errors, this warning should be ignored. :)"); } else { @@ -189,7 +191,7 @@ public CompletableFuture executeCommand(CommandSender sender, String[] arg .collect(Collectors.joining("\n")); plugin.log(Level.WARNING, "A command execution has not completed after " + - (i * warningIntervalSeconds) + " seconds, it *might* be stuck. Trace: \n" + stackTrace); + (warningIntervalSeconds + ((i - 1) * warningIntervalSecondsIterable)) + " seconds, it *might* be stuck. Trace: \n" + stackTrace); plugin.log(Level.WARNING, "If the command subsequently completes without any errors, this warning should be ignored. :)"); } } @@ -298,7 +300,7 @@ private void sendUsage(List commands, CommandResponseHandler sender) { String subCommandUsage = usage + " " + subCommand; sender.reply(text() - .append(text(">", GOLD, BOLD)) + .append(text(">", COLOR_TITLE, BOLD)) .append(space()) .append(text().content(subCommandUsage).color(GRAY).clickEvent(ClickEvent.suggestCommand(subCommandUsage)).build()) .build() @@ -313,7 +315,7 @@ private void sendUsage(List commands, CommandResponseHandler sender) { }); } else { sender.reply(text() - .append(text(">", GOLD, BOLD)) + .append(text(">", COLOR_TITLE, BOLD)) .append(space()) .append(text().content(usage).color(GRAY).clickEvent(ClickEvent.suggestCommand(usage)).build()) .build() diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/CommandResponseHandler.java b/spark-common/src/main/java/me/lucko/spark/common/command/CommandResponseHandler.java index 51d5b58506c..a3c74c69fed 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/CommandResponseHandler.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/CommandResponseHandler.java @@ -40,11 +40,12 @@ public class CommandResponseHandler { + private static final net.kyori.adventure.text.format.TextColor PREFIX_COLOR = net.kyori.adventure.text.format.TextColor.color(180, 140, 255); /** The prefix used in all messages "&8[&e&l⚡&8] &7" */ private static final TextComponent PREFIX = text() .color(GRAY) .append(text("[", DARK_GRAY)) - .append(text("⚡", YELLOW, BOLD)) + .append(text("\uD83C\uDF00", PREFIX_COLOR, BOLD)) .append(text("]", DARK_GRAY)) .append(text(" ")) .build(); diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/ActivityLogModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/ActivityLogModule.java index c72038bb852..0b87cf7e803 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/ActivityLogModule.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/ActivityLogModule.java @@ -47,6 +47,7 @@ import static net.kyori.adventure.text.format.TextDecoration.BOLD; public class ActivityLogModule implements CommandModule, RowRenderer { + private static final net.kyori.adventure.text.format.TextColor COLOR_TITLE = net.kyori.adventure.text.format.TextColor.color(255, 170, 230); private final Pagination.Builder pagination = Pagination.builder() .width(45) @@ -115,7 +116,7 @@ public void registerCommands(Consumer consumer) { int page = Math.max(1, arguments.intFlag("page")); Pagination activityPagination = this.pagination.build( - text("Recent spark activity", GOLD), + text("Recent spark activity", COLOR_TITLE), this, value -> "/" + platform.getPlugin().getCommandName() + " activity --page " + value ); diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/GcMonitoringModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/GcMonitoringModule.java index 1d0c226c463..fdea0a317ac 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/GcMonitoringModule.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/GcMonitoringModule.java @@ -49,6 +49,7 @@ public class GcMonitoringModule implements CommandModule { private static final DecimalFormat DF = new DecimalFormat("#.##"); + private static final net.kyori.adventure.text.format.TextColor COLOR_TITLE = net.kyori.adventure.text.format.TextColor.color(255, 170, 230); /** The gc monitoring instance currently running, if any */ private ReportingGcMonitor activeGcMonitor = null; @@ -73,7 +74,7 @@ public void registerCommands(Consumer consumer) { report.add(text() .append(text(">", DARK_GRAY, BOLD)) .append(space()) - .append(text("Garbage Collector statistics", GOLD)) + .append(text("Garbage Collector statistics", COLOR_TITLE)) .build() ); @@ -112,7 +113,7 @@ public void registerCommands(Consumer consumer) { ); report.add(text() .content(" ") - .append(text(DF.format(averageCollectionTime), GOLD)) + .append(text(DF.format(averageCollectionTime), COLOR_TITLE)) .append(text(" ms avg", GRAY)) .append(text(", ", DARK_GRAY)) .append(text(collectionCount, WHITE)) @@ -177,7 +178,7 @@ public void onGc(GarbageCollectionNotificationInfo data) { .append(text(gcType + " ")) .append(text("GC", RED)) .append(text(" lasting ")) - .append(text(DF.format(data.getGcInfo().getDuration()), GOLD)) + .append(text(DF.format(data.getGcInfo().getDuration()), COLOR_TITLE)) .append(text(" ms." + gcCause)) .build() )); @@ -199,7 +200,7 @@ public void onGc(GarbageCollectionNotificationInfo data) { if (diff > 0) { report.add(text() .content(" ") - .append(text(FormatUtil.formatBytes(diff), GOLD)) + .append(text(FormatUtil.formatBytes(diff), COLOR_TITLE)) .append(text(" freed from ", DARK_GRAY)) .append(text(type, GRAY)) .build() @@ -218,7 +219,7 @@ public void onGc(GarbageCollectionNotificationInfo data) { } else { report.add(text() .content(" ") - .append(text(FormatUtil.formatBytes(-diff), GOLD)) + .append(text(FormatUtil.formatBytes(-diff), COLOR_TITLE)) .append(text(" moved to ", DARK_GRAY)) .append(text(type, GRAY)) .build() diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/HealthModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/HealthModule.java index 9298e9d6e8d..5c1aaf3c2e5 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/HealthModule.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/HealthModule.java @@ -71,6 +71,9 @@ import static net.kyori.adventure.text.format.TextDecoration.BOLD; public class HealthModule implements CommandModule { + private static final net.kyori.adventure.text.format.TextColor COLOR_HEALTH_GOOD = net.kyori.adventure.text.format.TextColor.color(155, 255, 255); + private static final net.kyori.adventure.text.format.TextColor COLOR_HEALTH_BAD = net.kyori.adventure.text.format.TextColor.color(255, 20, 20); + private static final net.kyori.adventure.text.format.TextColor COLOR_TITLE = net.kyori.adventure.text.format.TextColor.color(255, 170, 230); @Override public void registerCommands(Consumer consumer) { @@ -239,7 +242,7 @@ private static void uploadHealthReport(SparkPlatform platform, CommandSender sen String key = platform.getBytebinClient().postContent(data.build(), MediaTypes.SPARK_HEALTH_MEDIA_TYPE).key(); String url = platform.getViewerUrl() + key; - resp.broadcastPrefixed(text("Health report:", GOLD)); + resp.broadcastPrefixed(text("Health report:", COLOR_TITLE)); resp.broadcast(text() .content(url) .color(GRAY) @@ -249,7 +252,7 @@ private static void uploadHealthReport(SparkPlatform platform, CommandSender sen platform.getActivityLog().addToLog(Activity.urlActivity(resp.senderData(), System.currentTimeMillis(), "Health report", url)); } catch (Exception e) { - resp.broadcastPrefixed(text("An error occurred whilst uploading the data.", RED)); + resp.broadcastPrefixed(text("An error occurred whilst uploading the data.", COLOR_HEALTH_BAD)); platform.getPlugin().log(Level.SEVERE, "An error occurred whilst uploading data", e); } } @@ -258,7 +261,7 @@ private static void addTickStats(List report, TickStatistics tickStat report.add(text() .append(text(">", DARK_GRAY, BOLD)) .append(space()) - .append(text("TPS from last 5s, 10s, 1m, 5m, 15m:", GOLD)) + .append(text("TPS from last 5s, 10s, 1m, 5m, 15m:", COLOR_TITLE)) .build() ); report.add(text() @@ -276,7 +279,7 @@ private static void addTickStats(List report, TickStatistics tickStat report.add(text() .append(text(">", DARK_GRAY, BOLD)) .append(space()) - .append(text("Tick durations (min/med/95%ile/max ms) from last 10s, 1m:", GOLD)) + .append(text("Tick durations (min/med/95%ile/max ms) from last 10s, 1m:", COLOR_TITLE)) .build() ); report.add(text() @@ -293,7 +296,7 @@ private static void addCpuStats(List report) { report.add(text() .append(text(">", DARK_GRAY, BOLD)) .append(space()) - .append(text("CPU usage from last 10s, 1m, 15m:", GOLD)) + .append(text("CPU usage from last 10s, 1m, 15m:", COLOR_TITLE)) .build() ); report.add(text() @@ -320,7 +323,7 @@ private static void addBasicMemoryStats(List report, MemoryMXBean mem report.add(text() .append(text(">", DARK_GRAY, BOLD)) .append(space()) - .append(text("Memory usage:", GOLD)) + .append(text("Memory usage:", COLOR_TITLE)) .build() ); report.add(text() @@ -332,7 +335,7 @@ private static void addBasicMemoryStats(List report, MemoryMXBean mem .append(text(FormatUtil.formatBytes(heapUsage.getMax()), WHITE)) .append(text(" ")) .append(text("(", GRAY)) - .append(text(FormatUtil.percent(heapUsage.getUsed(), heapUsage.getMax()), GREEN)) + .append(text(FormatUtil.percent(heapUsage.getUsed(), heapUsage.getMax()), COLOR_HEALTH_GOOD)) .append(text(")", GRAY)) .build() ); @@ -345,7 +348,7 @@ private static void addDetailedMemoryStats(List report, MemoryMXBean report.add(text() .append(text(">", DARK_GRAY, BOLD)) .append(space()) - .append(text("Non-heap memory usage:", GOLD)) + .append(text("Non-heap memory usage:", COLOR_TITLE)) .build() ); report.add(text() @@ -371,7 +374,7 @@ private static void addDetailedMemoryStats(List report, MemoryMXBean report.add(text() .append(text(">", DARK_GRAY, BOLD)) .append(space()) - .append(text(memoryPool.getName() + " pool usage:", GOLD)) + .append(text(memoryPool.getName() + " pool usage:", COLOR_TITLE)) .build() ); report.add(text() @@ -383,7 +386,7 @@ private static void addDetailedMemoryStats(List report, MemoryMXBean .append(text(FormatUtil.formatBytes(usage.getMax()), WHITE)) .append(text(" ")) .append(text("(", GRAY)) - .append(text(FormatUtil.percent(usage.getUsed(), usage.getMax()), GREEN)) + .append(text(FormatUtil.percent(usage.getUsed(), usage.getMax()), COLOR_HEALTH_GOOD)) .append(text(")", GRAY)) .build() ); @@ -392,7 +395,7 @@ private static void addDetailedMemoryStats(List report, MemoryMXBean if (collectionUsage != null) { report.add(text() .content(" ") - .append(text("-", RED)) + .append(text("-", COLOR_HEALTH_BAD)) .append(space()) .append(text("Usage at last GC:", GRAY)) .append(space()) @@ -419,7 +422,7 @@ private static void addNetworkStats(List report, boolean detailed) { averagesReport.add(text() .color(GRAY) .content(" ") - .append(FormatUtil.formatBytes(bytesPerSec, GREEN, "/s")) + .append(FormatUtil.formatBytes(bytesPerSec, COLOR_HEALTH_GOOD, "/s")) .append(text(" / ")) .append(text(String.format(Locale.ENGLISH, "%,d", packetsPerSec), WHITE)) .append(text(" pps ")) @@ -438,7 +441,7 @@ private static void addNetworkStats(List report, boolean detailed) { report.add(text() .append(text(">", DARK_GRAY, BOLD)) .append(space()) - .append(text("Network usage: (system, last 15m)", GOLD)) + .append(text("Network usage: (system, last 15m)", COLOR_TITLE)) .build() ); report.addAll(averagesReport); @@ -457,7 +460,7 @@ private static void addDiskStats(List report) { report.add(text() .append(text(">", DARK_GRAY, BOLD)) .append(space()) - .append(text("Disk usage:", GOLD)) + .append(text("Disk usage:", COLOR_TITLE)) .build() ); report.add(text() @@ -469,7 +472,7 @@ private static void addDiskStats(List report) { .append(text(FormatUtil.formatBytes(total), WHITE)) .append(text(" ")) .append(text("(", GRAY)) - .append(text(FormatUtil.percent(used, total), GREEN)) + .append(text(FormatUtil.percent(used, total), COLOR_HEALTH_GOOD)) .append(text(")", GRAY)) .build() ); diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/HeapAnalysisModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/HeapAnalysisModule.java index 9a97ca7edb6..ab80767fec1 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/HeapAnalysisModule.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/HeapAnalysisModule.java @@ -53,6 +53,8 @@ import static net.kyori.adventure.text.format.NamedTextColor.RED; public class HeapAnalysisModule implements CommandModule { + private static final net.kyori.adventure.text.format.TextColor COLOR_TITLE = net.kyori.adventure.text.format.TextColor.color(255, 170, 230); + private static final net.kyori.adventure.text.format.TextColor COLOR_DATA = net.kyori.adventure.text.format.TextColor.color(155, 255, 255); @Override public void registerCommands(Consumer consumer) { @@ -100,7 +102,7 @@ private static void heapSummary(SparkPlatform platform, CommandSender sender, Co String key = platform.getBytebinClient().postContent(output, MediaTypes.SPARK_HEAP_MEDIA_TYPE).key(); String url = platform.getViewerUrl() + key; - resp.broadcastPrefixed(text("Heap dump summmary output:", GOLD)); + resp.broadcastPrefixed(text("Heap dump summmary output:", COLOR_TITLE)); resp.broadcast(text() .content(url) .color(GRAY) @@ -123,7 +125,7 @@ private static void heapSummary(SparkPlatform platform, CommandSender sender, Co resp.broadcastPrefixed(text() .content("Heap dump summary written to: ") - .color(GOLD) + .color(COLOR_TITLE) .append(text(file.toString(), GRAY)) .build() ); @@ -160,7 +162,7 @@ private static void heapDump(SparkPlatform platform, CommandSender sender, Comma resp.broadcastPrefixed(text() .content("Heap dump written to: ") - .color(GOLD) + .color(COLOR_TITLE) .append(text(file.toString(), GRAY)) .build() ); @@ -201,11 +203,11 @@ private static void heapDumpCompress(SparkPlatform platform, CommandResponseHand resp.broadcastPrefixed(text() .color(GRAY) .append(text("Compressed ")) - .append(text(FormatUtil.formatBytes(progress), GOLD)) + .append(text(FormatUtil.formatBytes(progress), COLOR_TITLE)) .append(text(" / ")) - .append(text(FormatUtil.formatBytes(size), GOLD)) + .append(text(FormatUtil.formatBytes(size), COLOR_TITLE)) .append(text(" so far... (")) - .append(text(FormatUtil.percent(progress, size), GREEN)) + .append(text(FormatUtil.percent(progress, size), COLOR_DATA)) .append(text(")")) .build() ); @@ -219,18 +221,18 @@ private static void heapDumpCompress(SparkPlatform platform, CommandResponseHand resp.broadcastPrefixed(text() .color(GRAY) .append(text("Compression complete: ")) - .append(text(FormatUtil.formatBytes(size), GOLD)) + .append(text(FormatUtil.formatBytes(size), COLOR_TITLE)) .append(text(" --> ")) - .append(text(FormatUtil.formatBytes(compressedSize), GOLD)) + .append(text(FormatUtil.formatBytes(compressedSize), COLOR_TITLE)) .append(text(" (")) - .append(text(FormatUtil.percent(compressedSize, size), GREEN)) + .append(text(FormatUtil.percent(compressedSize, size), COLOR_DATA)) .append(text(")")) .build() ); resp.broadcastPrefixed(text() .content("Compressed heap dump written to: ") - .color(GOLD) + .color(COLOR_TITLE) .append(text(compressedFile.toString(), GRAY)) .build() ); diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java index d82ec63c27c..69d2b326180 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/SamplerModule.java @@ -71,6 +71,7 @@ import static net.kyori.adventure.text.format.NamedTextColor.WHITE; public class SamplerModule implements CommandModule { + private static final net.kyori.adventure.text.format.TextColor COLOR_TITLE = net.kyori.adventure.text.format.TextColor.color(255, 170, 230); @Override public void registerCommands(Consumer consumer) { @@ -159,7 +160,7 @@ private void profilerStart(SparkPlatform platform, CommandSender sender, Command if (previousSampler != null) { if (previousSampler.isRunningInBackground()) { // there is a background profiler running - stop that first - resp.replyPrefixed(text("Stopping the background profiler before starting... please wait")); + resp.replyPrefixed(text("Stopping the background profiler before starting...")); previousSampler.stop(true); platform.getSamplerContainer().unsetActiveSampler(previousSampler); } else { @@ -255,7 +256,7 @@ private void profilerStart(SparkPlatform platform, CommandSender sender, Command platform.getSamplerContainer().setActiveSampler(sampler); resp.broadcastPrefixed(text() - .append(text((mode == SamplerMode.ALLOCATION ? "Allocation Profiler" : "Profiler") + " is now running!", GOLD)) + .append(text((mode == SamplerMode.ALLOCATION ? "Allocation Profiler" : "Profiler") + " is now running!", COLOR_TITLE)) .append(space()) .append(text("(" + (sampler instanceof AsyncSampler ? "async" : "built-in java") + ")", DARK_GRAY)) .build() @@ -302,7 +303,7 @@ private void profilerInfo(SparkPlatform platform, CommandResponseHandler resp) { resp.replyPrefixed(text("To start a new one, run:")); resp.replyPrefixed(cmdPrompt("/" + platform.getPlugin().getCommandName() + " profiler start")); } else { - resp.replyPrefixed(text("Profiler is already running!", GOLD)); + resp.replyPrefixed(text("Profiler is already running!", COLOR_TITLE)); long runningTime = (System.currentTimeMillis() - sampler.getStartTime()) / 1000L; @@ -382,7 +383,7 @@ private void profilerCancel(SparkPlatform platform, CommandResponseHandler resp) resp.replyPrefixed(text("There isn't an active profiler running.")); } else { platform.getSamplerContainer().stopActiveSampler(true); - resp.broadcastPrefixed(text("Profiler has been cancelled.", GOLD)); + resp.broadcastPrefixed(text("Profiler has been cancelled.", COLOR_TITLE)); } } @@ -427,10 +428,10 @@ private void handleUpload(SparkPlatform platform, CommandResponseHandler resp, S String key = platform.getBytebinClient().postContent(output, MediaTypes.SPARK_SAMPLER_MEDIA_TYPE).key(); String url = platform.getViewerUrl() + key; - resp.broadcastPrefixed(text("Profiler stopped & upload complete!", GOLD)); - resp.broadcast(text() + resp.broadcastPrefixed(text("Profiler stopped & upload complete!", COLOR_TITLE)); + resp.broadcastPrefixed(text() .content(url) - .color(GRAY) + .color(WHITE) .clickEvent(ClickEvent.openUrl(url)) .build() ); @@ -448,7 +449,7 @@ private void handleUpload(SparkPlatform platform, CommandResponseHandler resp, S try { Files.write(file, output.toByteArray()); - resp.broadcastPrefixed(text("Profiler stopped & save complete!", GOLD)); + resp.broadcastPrefixed(text("Profiler stopped & save complete!", COLOR_TITLE)); resp.broadcastPrefixed(text("Data has been written to: " + file)); resp.broadcastPrefixed(text("You can view the profile file using the web app @ " + platform.getViewerUrl(), GRAY)); @@ -471,7 +472,7 @@ private void handleOpen(SparkPlatform platform, BytesocksClient bytesocksClient, String key = platform.getBytebinClient().postContent(data, MediaTypes.SPARK_SAMPLER_MEDIA_TYPE, "live").key(); String url = platform.getViewerUrl() + key; - resp.broadcastPrefixed(text("Profiler live viewer:", GOLD)); + resp.broadcastPrefixed(text("Profiler live viewer:", COLOR_TITLE)); resp.broadcast(text() .content(url) .color(GRAY) diff --git a/spark-common/src/main/java/me/lucko/spark/common/monitor/tick/TickMonitor.java b/spark-common/src/main/java/me/lucko/spark/common/monitor/tick/TickMonitor.java index f9b41f319fe..10954645380 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/monitor/tick/TickMonitor.java +++ b/spark-common/src/main/java/me/lucko/spark/common/monitor/tick/TickMonitor.java @@ -42,6 +42,7 @@ */ public abstract class TickMonitor implements TickHook.Callback, GarbageCollectionMonitor.Listener, AutoCloseable { private static final DecimalFormat DF = new DecimalFormat("#.##"); + private static final net.kyori.adventure.text.format.TextColor COLOR_TITLE = net.kyori.adventure.text.format.TextColor.color(255, 170, 230); /** The spark platform */ private final SparkPlatform platform; @@ -135,7 +136,7 @@ public void onTick(int currentTick) { // move onto the next state if (this.averageTickTimeCalc.getCount() >= 120) { this.platform.getPlugin().executeAsync(() -> { - sendMessage(text("Analysis is now complete.", GOLD)); + sendMessage(text("Analysis is now complete.", COLOR_TITLE)); sendMessage(text() .color(GRAY) .append(text(">", WHITE)) @@ -181,10 +182,10 @@ public void onTick(int currentTick) { .append(text("Tick ")) .append(text("#" + getCurrentTick(), DARK_GRAY)) .append(text(" lasted ")) - .append(text(DF.format(tickDuration), GOLD)) + .append(text(DF.format(tickDuration), COLOR_TITLE)) .append(text(" ms. ")) .append(text("(")) - .append(text(DF.format(percentageChange) + "%", GOLD)) + .append(text(DF.format(percentageChange) + "%", COLOR_TITLE)) .append(text(" increase from avg)")) .build() ); @@ -209,7 +210,7 @@ public void onGc(GarbageCollectionNotificationInfo data) { .append(text(" included ")) .append(text("GC", RED)) .append(text(" lasting ")) - .append(text(DF.format(data.getGcInfo().getDuration()), GOLD)) + .append(text(DF.format(data.getGcInfo().getDuration()), COLOR_TITLE)) .append(text(" ms. (type = " + GarbageCollectionMonitor.getGcType(data) + ")")) .build() ); diff --git a/spark-common/src/main/java/me/lucko/spark/common/util/StatisticFormatter.java b/spark-common/src/main/java/me/lucko/spark/common/util/StatisticFormatter.java index 03bd68490f0..414a4e8ab40 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/util/StatisticFormatter.java +++ b/spark-common/src/main/java/me/lucko/spark/common/util/StatisticFormatter.java @@ -41,16 +41,19 @@ public enum StatisticFormatter { private static final String BAR_TRUE_CHARACTER = "┃"; private static final String BAR_FALSE_CHARACTER = "╻"; + private static final TextColor COLOR_HEALTH_GOOD = TextColor.color(155, 255, 255); + private static final TextColor COLOR_HEALTH_MEDIUM = TextColor.color(255, 190, 0); + private static final TextColor COLOR_HEALTH_BAD = TextColor.color(255, 20, 20); public static TextComponent formatTps(double tps, int gameTargetTps) { TextColor color; if (tps > (gameTargetTps * 0.9d)) { - color = GREEN; + color = COLOR_HEALTH_GOOD; } else if (tps > (gameTargetTps * 0.8d)) { - color = YELLOW; + color = COLOR_HEALTH_MEDIUM; } else { - color = RED; + color = COLOR_HEALTH_BAD; } return text((tps > gameTargetTps ? "*" : "") + Math.min(Math.round(tps * 100.0) / 100.0, gameTargetTps), color); @@ -71,11 +74,11 @@ public static TextComponent formatTickDurations(DoubleAverageInfo average, int g public static TextComponent formatTickDuration(double duration, int gameMaxIdealDuration) { TextColor color; if (duration >= gameMaxIdealDuration) { - color = RED; + color = COLOR_HEALTH_BAD; } else if (duration >= (gameMaxIdealDuration * 0.8d)) { - color = YELLOW; + color = COLOR_HEALTH_MEDIUM; } else { - color = GREEN; + color = COLOR_HEALTH_GOOD; } return text(String.format(Locale.ENGLISH, "%.1f", duration), color); @@ -84,11 +87,11 @@ public static TextComponent formatTickDuration(double duration, int gameMaxIdeal public static TextComponent formatCpuUsage(double usage) { TextColor color; if (usage > 0.9) { - color = RED; + color = COLOR_HEALTH_BAD; } else if (usage > 0.65) { - color = YELLOW; + color = COLOR_HEALTH_MEDIUM; } else { - color = GREEN; + color = COLOR_HEALTH_GOOD; } return text(FormatUtil.percent(usage, 1d), color); @@ -109,11 +112,11 @@ public static TextComponent formatPingRtts(double min, double median, double per public static TextComponent formatPingRtt(double ping) { TextColor color; if (ping >= 200) { - color = RED; + color = COLOR_HEALTH_BAD; } else if (ping >= 100) { - color = YELLOW; + color = COLOR_HEALTH_MEDIUM; } else { - color = GREEN; + color = COLOR_HEALTH_GOOD; } return text((int) Math.ceil(ping), color); @@ -127,10 +130,10 @@ public static TextComponent generateMemoryUsageDiagram(MemoryUsage usage, int le int usedChars = (int) ((used * length) / max); int committedChars = (int) ((committed * length) / max); - TextComponent.Builder line = text().content(Strings.repeat(BAR_TRUE_CHARACTER, usedChars)).color(YELLOW); + TextComponent.Builder line = text().content(Strings.repeat(BAR_TRUE_CHARACTER, usedChars)).color(COLOR_HEALTH_MEDIUM); if (committedChars > usedChars) { line.append(text(Strings.repeat(BAR_FALSE_CHARACTER, (committedChars - usedChars) - 1), GRAY)); - line.append(Component.text(BAR_FALSE_CHARACTER, RED)); + line.append(Component.text(BAR_FALSE_CHARACTER, COLOR_HEALTH_BAD)); } if (length > committedChars) { line.append(text(Strings.repeat(BAR_FALSE_CHARACTER, (length - committedChars)), GRAY)); @@ -156,15 +159,15 @@ public static TextComponent generateMemoryPoolDiagram(MemoryUsage usage, MemoryU int collectionUsedChars = (int) ((collectionUsed * length) / max); int committedChars = (int) ((committed * length) / max); - TextComponent.Builder line = text().content(Strings.repeat(BAR_TRUE_CHARACTER, collectionUsedChars)).color(YELLOW); + TextComponent.Builder line = text().content(Strings.repeat(BAR_TRUE_CHARACTER, collectionUsedChars)).color(COLOR_HEALTH_MEDIUM); if (usedChars > collectionUsedChars) { - line.append(Component.text(BAR_TRUE_CHARACTER, RED)); - line.append(text(Strings.repeat(BAR_TRUE_CHARACTER, (usedChars - collectionUsedChars) - 1), YELLOW)); + line.append(Component.text(BAR_TRUE_CHARACTER, COLOR_HEALTH_BAD)); + line.append(text(Strings.repeat(BAR_TRUE_CHARACTER, (usedChars - collectionUsedChars) - 1), COLOR_HEALTH_MEDIUM)); } if (committedChars > usedChars) { line.append(text(Strings.repeat(BAR_FALSE_CHARACTER, (committedChars - usedChars) - 1), GRAY)); - line.append(Component.text(BAR_FALSE_CHARACTER, YELLOW)); + line.append(Component.text(BAR_FALSE_CHARACTER, COLOR_HEALTH_MEDIUM)); } if (length > committedChars) { line.append(text(Strings.repeat(BAR_FALSE_CHARACTER, (length - committedChars)), GRAY)); @@ -182,7 +185,7 @@ public static TextComponent generateDiskUsageDiagram(double used, double max, in int freeChars = length - usedChars; return text() .append(text("[", DARK_GRAY)) - .append(text(Strings.repeat(BAR_TRUE_CHARACTER, usedChars), YELLOW)) + .append(text(Strings.repeat(BAR_TRUE_CHARACTER, usedChars), COLOR_HEALTH_MEDIUM)) .append(text(Strings.repeat(BAR_FALSE_CHARACTER, freeChars), GRAY)) .append(text("]", DARK_GRAY)) .build(); diff --git a/spark-paper/src/main/java/me/lucko/spark/paper/PaperServerConfigProvider.java b/spark-paper/src/main/java/me/lucko/spark/paper/PaperServerConfigProvider.java index d48e46f92d9..0780cf8b7fa 100644 --- a/spark-paper/src/main/java/me/lucko/spark/paper/PaperServerConfigProvider.java +++ b/spark-paper/src/main/java/me/lucko/spark/paper/PaperServerConfigProvider.java @@ -129,6 +129,8 @@ private static Map getNestedFiles(Path configDir, String prefix) { .put("paper.yml", YamlConfigParser.INSTANCE) .put("paper/", SplitYamlConfigParser.INSTANCE) .put("purpur.yml", YamlConfigParser.INSTANCE) + .put("jellyfish.yml", YamlConfigParser.INSTANCE) + .put("aurora.yml", YamlConfigParser.INSTANCE) .put("pufferfish.yml", YamlConfigParser.INSTANCE); for (String config : getSystemPropertyList("spark.serverconfigs.extra")) { @@ -143,6 +145,8 @@ private static Map getNestedFiles(Path configDir, String prefix) { .add("proxies.velocity.secret") .add("world-settings.*.feature-seeds") .add("world-settings.*.seed-*") + .add("web-services.token") + .add("sentry-dsn") .add("feature-seeds") .add("seed-*") .addAll(getSystemPropertyList("spark.serverconfigs.hiddenpaths"));