Skip to content

Commit

Permalink
show a message stating the removal of mojang profiler when running pe…
Browse files Browse the repository at this point in the history
…rf comamnd, closes #1591
  • Loading branch information
granny committed Oct 7, 2024
1 parent 4565f41 commit 4671e1e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
8 changes: 5 additions & 3 deletions patches/api/0037-Remove-Timings.patch
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ index e81d0bc309de877ed2b5da6122f55c162e9b5f10..3d663104c8e3089abdb9dc4d7309f873

private static void warnAboutDeprecationOnEnable() {
diff --git a/src/main/java/co/aikar/timings/TimingsCommand.java b/src/main/java/co/aikar/timings/TimingsCommand.java
index 95d87c9dbf2b237787294dfbe7fed87a36e6dedf..b831a23999c94cb1bdf7f5d2cd719d0b846242ad 100644
index 95d87c9dbf2b237787294dfbe7fed87a36e6dedf..9e165525c4c4c07c783ae2899e07c37ae49ec2de 100644
--- a/src/main/java/co/aikar/timings/TimingsCommand.java
+++ b/src/main/java/co/aikar/timings/TimingsCommand.java
@@ -47,7 +47,7 @@ public class TimingsCommand extends BukkitCommand {
Expand All @@ -111,22 +111,24 @@ index 95d87c9dbf2b237787294dfbe7fed87a36e6dedf..b831a23999c94cb1bdf7f5d2cd719d0b
this.setPermission("bukkit.command.timings");
}

@@ -56,8 +56,12 @@ public class TimingsCommand extends BukkitCommand {
@@ -56,8 +56,14 @@ public class TimingsCommand extends BukkitCommand {
if (!testPermission(sender)) {
return true;
}
- if (false) {
- sender.sendMessage(Timings.deprecationMessage());
+ // Purpur start
+ if (true) {
+ net.kyori.adventure.text.minimessage.MiniMessage mm = net.kyori.adventure.text.minimessage.MiniMessage.miniMessage();
+ sender.sendMessage(mm.deserialize("<gold>Purpur has removed timings to save your performance. Please use <click:suggest_command:'/spark'><grey>/spark</grey></click> instead"));
+ sender.sendMessage(mm.deserialize("<gold>For more information, view its documentation at"));
+ sender.sendMessage(mm.deserialize("<gold><click:open_url:'https://spark.lucko.me/docs/Command-Usage'>https://spark.lucko.me/docs/Command-Usage</click>"));
+ return true;
+ // Purpur end
}
if (args.length < 1) {
sender.sendMessage(text("Usage: " + this.usageMessage, NamedTextColor.RED));
@@ -117,7 +121,7 @@ public class TimingsCommand extends BukkitCommand {
@@ -117,7 +123,7 @@ public class TimingsCommand extends BukkitCommand {
Preconditions.checkNotNull(args, "Arguments cannot be null");
Preconditions.checkNotNull(alias, "Alias cannot be null");

Expand Down
39 changes: 39 additions & 0 deletions patches/server/0253-Remove-Mojang-Profiler.patch
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,45 @@ index 9cd4f7c6910727c849ac7f5d675dc6105c4bbba2..4e4b7f2a6d7ed92a2ce06e566186027c
}

}
diff --git a/src/main/java/net/minecraft/server/commands/PerfCommand.java b/src/main/java/net/minecraft/server/commands/PerfCommand.java
index 8c587f829c5e8c6b6df3150024c4ae704988c47b..8ac4d5dbe7f8febf4226f26a6b035282dcdf1b0f 100644
--- a/src/main/java/net/minecraft/server/commands/PerfCommand.java
+++ b/src/main/java/net/minecraft/server/commands/PerfCommand.java
@@ -42,6 +42,7 @@ public class PerfCommand {
}

private static int startProfilingDedicatedServer(CommandSourceStack source) throws CommandSyntaxException {
+ if (true) return removedMessage(source); // Purpur
MinecraftServer minecraftServer = source.getServer();
if (minecraftServer.isRecordingMetrics()) {
throw ERROR_ALREADY_RUNNING.create();
@@ -55,6 +56,7 @@ public class PerfCommand {
}

private static int stopProfilingDedicatedServer(CommandSourceStack source) throws CommandSyntaxException {
+ if (true) return removedMessage(source); // Purpur
MinecraftServer minecraftServer = source.getServer();
if (!minecraftServer.isRecordingMetrics()) {
throw ERROR_NOT_RUNNING.create();
@@ -64,6 +66,18 @@ public class PerfCommand {
}
}

+ // Purpur start
+ private static int removedMessage(CommandSourceStack source) {
+ if (true) {
+ net.kyori.adventure.text.minimessage.MiniMessage mm = net.kyori.adventure.text.minimessage.MiniMessage.miniMessage();
+ source.getSender().sendMessage(mm.deserialize("<gold>Purpur has removed Mojang's Profiler to save your performance. Please use <click:suggest_command:'/spark'><grey>/spark</grey></click> instead"));
+ source.getSender().sendMessage(mm.deserialize("<gold>For more information, view its documentation at"));
+ source.getSender().sendMessage(mm.deserialize("<gold><click:open_url:'https://spark.lucko.me/docs/Command-Usage'>https://spark.lucko.me/docs/Command-Usage</click>"));
+ }
+ return 0;
+ }
+ // Purpur end
+
private static void saveResults(CommandSourceStack source, Path tempProfilingDirectory, MinecraftServer server) {
String string = String.format(
Locale.ROOT, "%s-%s-%s", Util.getFilenameFormattedDateTime(), server.getWorldData().getLevelName(), SharedConstants.getCurrentVersion().getId()
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
index 4b2a66b68e96b85e78c12a12c410ffab3c14ab71..1883abec14e05f8eb2e865446b4d81091b1aa5e0 100644
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
Expand Down

0 comments on commit 4671e1e

Please sign in to comment.