diff options
author | Luck <git@lucko.me> | 2019-05-04 23:22:09 +0100 |
---|---|---|
committer | Luck <git@lucko.me> | 2019-05-04 23:22:32 +0100 |
commit | 23a1e13543966e311c5c613c1f434d93efe2a544 (patch) | |
tree | 28194498c2eea4bb5dbd9e0fe0b696e65995c417 /spark-common/src/main | |
parent | c3ae37e88f967a21522af7d0cb79a571326cd7e9 (diff) | |
download | spark-23a1e13543966e311c5c613c1f434d93efe2a544.tar.gz spark-23a1e13543966e311c5c613c1f434d93efe2a544.tar.bz2 spark-23a1e13543966e311c5c613c1f434d93efe2a544.zip |
Update to text 3.0.0
Diffstat (limited to 'spark-common/src/main')
6 files changed, 40 insertions, 42 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java b/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java index d05d9e8..1bc6b57 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java +++ b/spark-common/src/main/java/me/lucko/spark/common/SparkPlatform.java @@ -34,7 +34,6 @@ import me.lucko.spark.common.command.tabcomplete.TabCompleter; import me.lucko.spark.common.monitor.tick.TpsCalculator; import me.lucko.spark.common.sampler.TickCounter; import me.lucko.spark.common.util.BytebinClient; -import net.kyori.text.Component; import net.kyori.text.TextComponent; import net.kyori.text.event.ClickEvent; import net.kyori.text.format.TextColor; @@ -123,7 +122,7 @@ public class SparkPlatform { if (args.length == 0) { resp.replyPrefixed(TextComponent.builder("") .append(TextComponent.of("spark", TextColor.WHITE)) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of("v" + getPlugin().getVersion(), TextColor.GRAY)) .build() ); @@ -132,7 +131,7 @@ public class SparkPlatform { .append(TextComponent.builder("/" + getPlugin().getLabel() + " help") .color(TextColor.WHITE) .decoration(TextDecoration.UNDERLINED, true) - .clickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, getPlugin().getLabel() + " help")) + .clickEvent(ClickEvent.runCommand("/" + getPlugin().getLabel() + " help")) .build() ) .append(TextComponent.of(" to view usage information.")) @@ -186,17 +185,17 @@ public class SparkPlatform { private void sendUsage(CommandResponseHandler sender) { sender.replyPrefixed(TextComponent.builder("") .append(TextComponent.of("spark", TextColor.WHITE)) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of("v" + getPlugin().getVersion(), TextColor.GRAY)) .build() ); for (Command command : this.commands) { - String usage = getPlugin().getLabel() + " " + command.aliases().get(0); - ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, usage); + String usage = "/" + getPlugin().getLabel() + " " + command.aliases().get(0); + ClickEvent clickEvent = ClickEvent.suggestCommand(usage); sender.reply(TextComponent.builder("") .append(TextComponent.builder(">").color(TextColor.GOLD).decoration(TextDecoration.BOLD, true).build()) - .append(Component.space()) - .append(TextComponent.builder("/" + usage).color(TextColor.GRAY).clickEvent(clickEvent).build()) + .append(TextComponent.space()) + .append(TextComponent.builder(usage).color(TextColor.GRAY).clickEvent(clickEvent).build()) .build() ); for (Command.ArgumentInfo arg : command.arguments()) { @@ -204,7 +203,7 @@ public class SparkPlatform { sender.reply(TextComponent.builder(" ") .append(TextComponent.of("[", TextColor.DARK_GRAY)) .append(TextComponent.of("--" + arg.argumentName(), TextColor.GRAY)) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of("<" + arg.parameterDescription() + ">", TextColor.DARK_GRAY)) .append(TextComponent.of("]", TextColor.DARK_GRAY)) .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 ad6b3e8..36ba47c 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 @@ -23,7 +23,6 @@ package me.lucko.spark.common.command.modules; import me.lucko.spark.common.ActivityLog; import me.lucko.spark.common.command.Command; import me.lucko.spark.common.command.CommandModule; -import net.kyori.text.Component; import net.kyori.text.TextComponent; import net.kyori.text.event.ClickEvent; import net.kyori.text.format.TextColor; @@ -55,7 +54,7 @@ public class ActivityLogModule implements CommandModule { resp.replyPrefixed(TextComponent.builder("") .append(TextComponent.builder(">").color(TextColor.DARK_GRAY).decoration(TextDecoration.BOLD, true).build()) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of("#" + count, TextColor.WHITE)) .append(TextComponent.of(" - ", TextColor.DARK_GRAY)) .append(TextComponent.of(activity.getType(), TextColor.YELLOW)) @@ -73,12 +72,12 @@ public class ActivityLogModule implements CommandModule { .append(TextComponent.builder(activity.getUrl()) .color(TextColor.WHITE) .decoration(TextDecoration.UNDERLINED, true) - .clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, activity.getUrl())) + .clickEvent(ClickEvent.openUrl(activity.getUrl())) .build() ) .build() ); - resp.reply(Component.space()); + resp.reply(TextComponent.space()); } }) .tabCompleter(Command.TabCompleter.empty()) 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 83f9006..f2ae6fc 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 @@ -70,33 +70,33 @@ public class HealthModule implements CommandModule { resp.replyPrefixed(TextComponent.of("Generating server health report...")); platform.getPlugin().runAsync(() -> { List<Component> report = new ArrayList<>(15); - report.add(Component.empty()); + report.add(TextComponent.empty()); TpsCalculator tpsCalculator = platform.getTpsCalculator(); if (tpsCalculator != null) { report.add(TextComponent.builder("") .append(TextComponent.builder(">").color(TextColor.DARK_GRAY).decoration(TextDecoration.BOLD, true).build()) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of("TPS from last 5s, 10s, 1m, 5m, 15m:", TextColor.GOLD)) .build() ); report.add(TextComponent.builder(" ").append(tpsCalculator.toFormattedComponent()).build()); - report.add(Component.empty()); + report.add(TextComponent.empty()); } MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean(); MemoryUsage heapUsage = memoryMXBean.getHeapMemoryUsage(); report.add(TextComponent.builder("") .append(TextComponent.builder(">").color(TextColor.DARK_GRAY).decoration(TextDecoration.BOLD, true).build()) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of("Memory usage:", TextColor.GOLD)) .build() ); report.add(TextComponent.builder(" ") .append(TextComponent.of(formatBytes(heapUsage.getUsed()), TextColor.WHITE)) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of("/", TextColor.GRAY)) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of(formatBytes(heapUsage.getMax()), TextColor.WHITE)) .append(TextComponent.of(" ")) .append(TextComponent.of("(", TextColor.GRAY)) @@ -105,13 +105,13 @@ public class HealthModule implements CommandModule { .build() ); report.add(TextComponent.builder(" ").append(generateMemoryUsageDiagram(heapUsage, 40)).build()); - report.add(Component.empty()); + report.add(TextComponent.empty()); if (arguments.boolFlag("memory")) { MemoryUsage nonHeapUsage = memoryMXBean.getNonHeapMemoryUsage(); report.add(TextComponent.builder("") .append(TextComponent.builder(">").color(TextColor.DARK_GRAY).decoration(TextDecoration.BOLD, true).build()) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of("Non-heap memory usage:", TextColor.GOLD)) .build() ); @@ -119,7 +119,7 @@ public class HealthModule implements CommandModule { .append(TextComponent.of(formatBytes(nonHeapUsage.getUsed()), TextColor.WHITE)) .build() ); - report.add(Component.empty()); + report.add(TextComponent.empty()); List<MemoryPoolMXBean> memoryPoolMXBeans = ManagementFactory.getMemoryPoolMXBeans(); for (MemoryPoolMXBean memoryPool : memoryPoolMXBeans) { @@ -136,15 +136,15 @@ public class HealthModule implements CommandModule { report.add(TextComponent.builder("") .append(TextComponent.builder(">").color(TextColor.DARK_GRAY).decoration(TextDecoration.BOLD, true).build()) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of(memoryPool.getName() + " pool usage:", TextColor.GOLD)) .build() ); report.add(TextComponent.builder(" ") .append(TextComponent.of(formatBytes(usage.getUsed()), TextColor.WHITE)) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of("/", TextColor.GRAY)) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of(formatBytes(usage.getMax()), TextColor.WHITE)) .append(TextComponent.of(" ")) .append(TextComponent.of("(", TextColor.GRAY)) @@ -157,14 +157,14 @@ public class HealthModule implements CommandModule { if (collectionUsage != null) { report.add(TextComponent.builder(" ") .append(TextComponent.of("-", TextColor.RED)) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of("Usage at last GC:", TextColor.GRAY)) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of(formatBytes(collectionUsage.getUsed()), TextColor.WHITE)) .build() ); } - report.add(Component.empty()); + report.add(TextComponent.empty()); } } @@ -174,7 +174,7 @@ public class HealthModule implements CommandModule { if (systemCpuLoad >= 0 || processCpuLoad >= 0) { report.add(TextComponent.builder("") .append(TextComponent.builder(">").color(TextColor.DARK_GRAY).decoration(TextDecoration.BOLD, true).build()) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of("CPU usage:", TextColor.GOLD)) .build() ); @@ -186,7 +186,7 @@ public class HealthModule implements CommandModule { .build() ); report.add(TextComponent.builder(" ").append(generateCpuUsageDiagram(systemCpuLoad, 40)).build()); - report.add(Component.empty()); + report.add(TextComponent.empty()); } if (processCpuLoad >= 0) { report.add(TextComponent.builder(" ") @@ -195,7 +195,7 @@ public class HealthModule implements CommandModule { .build() ); report.add(TextComponent.builder(" ").append(generateCpuUsageDiagram(processCpuLoad, 40)).build()); - report.add(Component.empty()); + report.add(TextComponent.empty()); } } @@ -205,15 +205,15 @@ public class HealthModule implements CommandModule { long usedSpace = totalSpace - fileStore.getUsableSpace(); report.add(TextComponent.builder("") .append(TextComponent.builder(">").color(TextColor.DARK_GRAY).decoration(TextDecoration.BOLD, true).build()) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of("Disk usage:", TextColor.GOLD)) .build() ); report.add(TextComponent.builder(" ") .append(TextComponent.of(formatBytes(usedSpace), TextColor.WHITE)) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of("/", TextColor.GRAY)) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of(formatBytes(totalSpace), TextColor.WHITE)) .append(TextComponent.of(" ")) .append(TextComponent.of("(", TextColor.GRAY)) @@ -222,13 +222,13 @@ public class HealthModule implements CommandModule { .build() ); report.add(TextComponent.builder(" ").append(generateDiskUsageDiagram(usedSpace, totalSpace, 40)).build()); - report.add(Component.empty()); + report.add(TextComponent.empty()); } catch (IOException e) { e.printStackTrace(); } TextComponent.Builder builder = TextComponent.builder(""); - report.forEach(line -> builder.append(line).append(Component.newline())); + report.forEach(line -> builder.append(line).append(TextComponent.newline())); resp.reply(builder.build()); }); }) diff --git a/spark-common/src/main/java/me/lucko/spark/common/command/modules/MemoryModule.java b/spark-common/src/main/java/me/lucko/spark/common/command/modules/MemoryModule.java index b65db78..e3f1cdb 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/command/modules/MemoryModule.java +++ b/spark-common/src/main/java/me/lucko/spark/common/command/modules/MemoryModule.java @@ -73,7 +73,7 @@ public class MemoryModule implements CommandModule { resp.broadcastPrefixed(TextComponent.of("Heap dump summmary output:", TextColor.GOLD)); resp.broadcast(TextComponent.builder(url) .color(TextColor.GRAY) - .clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url)) + .clickEvent(ClickEvent.openUrl(url)) .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 fb1bc72..c4f88cb 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 @@ -196,7 +196,7 @@ public class SamplerModule implements CommandModule { resp.broadcastPrefixed(TextComponent.of("Profiler now active!", TextColor.GOLD)); if (timeoutSeconds == -1) { - resp.broadcastPrefixed(TextComponent.of("Use '/" + platform.getPlugin().getLabel() + " stop' to stop profiling and upload the results.")); + resp.broadcastPrefixed(TextComponent.of("Use '/" + platform.getPlugin().getLabel() + " sampler --stop' to stop profiling and upload the results.")); } else { resp.broadcastPrefixed(TextComponent.of("The results will be automatically returned after the profiler has been running for " + timeoutSeconds + " seconds.")); } @@ -257,7 +257,7 @@ public class SamplerModule implements CommandModule { resp.broadcastPrefixed(TextComponent.of("Sampling results:", TextColor.GOLD)); resp.broadcast(TextComponent.builder(url) .color(TextColor.GRAY) - .clickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url)) + .clickEvent(ClickEvent.openUrl(url)) .build() ); 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 5e1ec54..e16ce49 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 @@ -96,7 +96,7 @@ public abstract class TickMonitor implements TickCounter.TickTask, GarbageCollec sendMessage(TextComponent.of("Analysis is now complete.", TextColor.GOLD)); sendMessage(TextComponent.builder("").color(TextColor.GRAY) .append(TextComponent.of(">", TextColor.WHITE)) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of("Max: ")) .append(TextComponent.of(df.format(this.averageTickTime.getMax()))) .append(TextComponent.of("ms")) @@ -104,7 +104,7 @@ public abstract class TickMonitor implements TickCounter.TickTask, GarbageCollec ); sendMessage(TextComponent.builder("").color(TextColor.GRAY) .append(TextComponent.of(">", TextColor.WHITE)) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of("Min: ")) .append(TextComponent.of(df.format(this.averageTickTime.getMin()))) .append(TextComponent.of("ms")) @@ -112,7 +112,7 @@ public abstract class TickMonitor implements TickCounter.TickTask, GarbageCollec ); sendMessage(TextComponent.builder("").color(TextColor.GRAY) .append(TextComponent.of(">", TextColor.WHITE)) - .append(Component.space()) + .append(TextComponent.space()) .append(TextComponent.of("Avg: ")) .append(TextComponent.of(df.format(this.averageTickTime.getAverage()))) .append(TextComponent.of("ms")) |