Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ subprojects {
}

def determinePatchVersion() {
if (true) return 0
def tagInfo = providers.exec {
commandLine 'git', 'describe', '--tags'
}.standardOutput.asText.get().trim()
Expand Down
18 changes: 9 additions & 9 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -159,7 +160,8 @@ public CompletableFuture<Void> 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()) {
Expand All @@ -168,7 +170,7 @@ public CompletableFuture<Void> 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
}
Expand All @@ -180,7 +182,7 @@ public CompletableFuture<Void> 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 {
Expand All @@ -189,7 +191,7 @@ public CompletableFuture<Void> 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. :)");
}
}
Expand Down Expand Up @@ -298,7 +300,7 @@ private void sendUsage(List<Command> 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()
Expand All @@ -313,7 +315,7 @@ private void sendUsage(List<Command> 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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import static net.kyori.adventure.text.format.TextDecoration.BOLD;

public class ActivityLogModule implements CommandModule, RowRenderer<Activity> {
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)
Expand Down Expand Up @@ -115,7 +116,7 @@ public void registerCommands(Consumer<Command> consumer) {
int page = Math.max(1, arguments.intFlag("page"));

Pagination<Activity> activityPagination = this.pagination.build(
text("Recent spark activity", GOLD),
text("Recent spark activity", COLOR_TITLE),
this,
value -> "/" + platform.getPlugin().getCommandName() + " activity --page " + value
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -73,7 +74,7 @@ public void registerCommands(Consumer<Command> 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()
);

Expand Down Expand Up @@ -112,7 +113,7 @@ public void registerCommands(Consumer<Command> 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))
Expand Down Expand Up @@ -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()
));
Expand All @@ -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()
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Command> consumer) {
Expand Down Expand Up @@ -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)
Expand All @@ -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);
}
}
Expand All @@ -258,7 +261,7 @@ private static void addTickStats(List<Component> 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()
Expand All @@ -276,7 +279,7 @@ private static void addTickStats(List<Component> 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()
Expand All @@ -293,7 +296,7 @@ private static void addCpuStats(List<Component> 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()
Expand All @@ -320,7 +323,7 @@ private static void addBasicMemoryStats(List<Component> 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()
Expand All @@ -332,7 +335,7 @@ private static void addBasicMemoryStats(List<Component> 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()
);
Expand All @@ -345,7 +348,7 @@ private static void addDetailedMemoryStats(List<Component> 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()
Expand All @@ -371,7 +374,7 @@ private static void addDetailedMemoryStats(List<Component> 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()
Expand All @@ -383,7 +386,7 @@ private static void addDetailedMemoryStats(List<Component> 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()
);
Expand All @@ -392,7 +395,7 @@ private static void addDetailedMemoryStats(List<Component> 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())
Expand All @@ -419,7 +422,7 @@ private static void addNetworkStats(List<Component> 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 "))
Expand All @@ -438,7 +441,7 @@ private static void addNetworkStats(List<Component> 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);
Expand All @@ -457,7 +460,7 @@ private static void addDiskStats(List<Component> 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()
Expand All @@ -469,7 +472,7 @@ private static void addDiskStats(List<Component> 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()
);
Expand Down
Loading
Loading